CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   I/O of a real value by "DEFINE_RW_FILE" (UDF) (http://www.cfd-online.com/Forums/fluent/32343-i-o-real-value-define_rw_file-udf.html)

Pietro Asinari October 18, 2003 05:05

I/O of a real value by "DEFINE_RW_FILE" (UDF)
 
Hi all,

I'm trying to add a real value to DATA file by "DEFINE_RW_FILE" macro (UDF). In the following, find the code. The first sub writes the correct value (I have verified the DATA file) while the second one fails. The same code works well if you consider an integer value (%d), like reported in the UDF manual. I have tried unsuccessfully other file formats (%e,%f,%1.6e,...).

What's the matter ?

Thanks a lot,

Pietro

------------------------------------------------------

#include "udf.h"

real XREAL;

DEFINE_RW_FILE(writer, fp) {

XREAL = 23.678;

printf("Writing UDF data to data file...\n");

fprintf(fp, "%g\n",XREAL); /* write to data file */

printf("\n XREAL = %g \n",XREAL); }

------------------------------------------------------

DEFINE_RW_FILE(reader, fp) {

printf("Reading UDF data from data file...\n");

fscanf(fp, "%g\n",&XREAL); /* read from data file */

printf("\n XREAL = %g\n",XREAL); }

------------------------------------------------------

Writing UDF data to data file... XREAL = 23.678 Done.

Reading UDF data from data file... XREAL = 5.44921e-315 Done.



All times are GMT -4. The time now is 05:31.