CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   'execute on demand' shut down fluent automatically (http://www.cfd-online.com/Forums/fluent-udf/124054-execute-demand-shut-down-fluent-automatically.html)

czhao86 September 26, 2013 10:14

'execute on demand' shut down fluent automatically
 
Code:

#include "udf.h"

extern float plasma[4];

DEFINE_ON_DEMAND(read_data)
{
int i;
FILE *rfile; /* declare a FILE pointer */

rfile = fopen("try.txt", "r"); /* open file for reading */
Message("file opened\n");

/* loop to read file */
i=0; /* initialize before to loop */
for (i=0;i<4;i++)
{
fscanf (rfile, "%f", &plasma[i]); /* that supposes one value per line */
}

fclose(rfile);
Message("file closed\n");
}

I am trying to import data from a text file named 'try.txt'. After compiling the UDF, and Fluent will close when I click 'execute' under 'execute on demand'. I put try.txt in the same folder as the UDF. Anyone have some idea? Thanks.

czhao86 September 26, 2013 15:43

It turns out that I need to interpret a UDF before do the execute. I don't know why, but it is working now.


All times are GMT -4. The time now is 10:16.