CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

non-integer subscript expression: float

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 20, 2013, 06:59
Default non-integer subscript expression: float
  #1
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 4
vExus is on a distinguished road
Hi,
Being a total rookie at programming I am trying to set free steam temperature as a function of flow time. While interpreting UDF i get this error:
Code:
non-integer subscript expression: float
This is how the error line looks like:
Code:
F_PROFILE(f, thread, index) = tab[s];
Whole code:
Code:
#include "udf.h"	
DEFINE_PROFILE (T_ot, thread, index)
{
	real s;
	double tab[8547]={}; //There are 8547 temperature values set in the correct order (as they change with every time step). I had to cut them off to make the code shorter
	face_t f;
	
	s=RP_Get_Real("flow-time");
	
	begin_f_loop(f, thread)
	{
		F_PROFILE(f, thread, index) = tab[s];
	}
	end_f_loop(f, thread);
}
While changing "tab[s]" to "tab[2]" UDF interprets fine so "s" must be the problem.
How else can I specify array index? Does code look ok?

EDIT
I have changed "real s" to "int s" and now fluent do interpret UDF.
Does the rest looks fine?
vExus is offline   Reply With Quote

Old   August 20, 2013, 09:16
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 12
blackmask will become famous soon enough
You might need to change the code if the index of tab corresponds to time step rather than flow time. Also you need to avoid index out of range.

Code:
#include "udf.h"     
DEFINE_PROFILE (T_ot, thread, index)
{
        int s;
        real tval;
        double tab[8547]={}; //There are 8547 temperature values set in the correct order (as they change with every time step). I had to cut them off to make the code shorter
        face_t f;
            
        s = N_TIME;
        tval = s < 8547 ? tab[s] : tab[8546];
            
        begin_f_loop(f, thread)
        {   
                F_PROFILE(f, thread, index) = tval;
        }    
        end_f_loop(f, thread);
}
blackmask is offline   Reply With Quote

Old   August 21, 2013, 18:41
Default
  #3
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 4
vExus is on a distinguished road
Thanks a lot!
vExus is offline   Reply With Quote

Reply

Tags
array, flow, index, time

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 19:44
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 07:25
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
Lift, Drag Vs time chart,calculations Jamesd69climber CFX 8 February 17, 2005 18:23
to correct me an udf program farida hamadi FLUENT 0 December 18, 2004 06:54


All times are GMT -4. The time now is 15:26.