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

Problem reading floating array

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 6, 2012, 10:42
Default Problem reading floating array
  #1
New Member
 
Join Date: Sep 2011
Posts: 2
Rep Power: 0
maki78 is on a distinguished road
Hello Everybody, I'm working with parallel Fluent 14 under Centos Linux (double precision, UDF is compiled). The problem is the following. I need to read TAB separated array from a file and use the values later for processing in the same UDF function. I used this before in Fluent 12 and it was OK. However currently I can not read the floating values correctly: I receive only zeroes. The cleaned code is below:

#include "udf.h"
DEFINE_ON_DEMAND (test_io)
{
#if !RP_HOST /* either serial or compute node process is involved */
FILE *fin,*fout;
int i,m;
real testa[8];

fout=fopen("fout.txt","w");
fin=fopen("test.txt", "r");

for (m = 0; fscanf(fin, "%f%f" , &testa[m*2], &testa[m*2+1]) != EOF ; ++m) {;}
fclose (fin);
fprintf(fout,"We have %i points data... \n",m);

for( i=0; i<m; ++i )
fprintf(fout, "%f %f\n", testa[i*2], testa[i*2+1]);
fclose(fout);

#endif
#if RP_HOST
printf("host\n");
#endif
}

the input file test.txt is as follows:
5e-5 25.35
7 21
9.36 36
10 15

It is strange but everything works fine with integer values (I've changed the UDF and file accordingly). Thanks in advance.
maki78 is offline   Reply With Quote

Old   March 6, 2012, 11:00
Default
  #2
New Member
 
Join Date: Sep 2011
Posts: 2
Rep Power: 0
maki78 is on a distinguished road
The problem seems to be solved, changing the type from real to float
maki78 is offline   Reply With Quote

Reply

Tags
array, fscanf, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with reading case file gmwsy FLUENT 5 November 23, 2016 13:19
[Commercial meshers] Converting a mesh with splitted cells using fluentMeshToFoam jlpelerin OpenFOAM Meshing & Mesh Conversion 4 April 25, 2011 17:56
Segmentation Fault in fluent3DMeshToFoam cwang5 OpenFOAM Bugs 23 April 13, 2011 16:37
Defining "cyclic" B.C. problem maysmech OpenFOAM 20 March 14, 2011 11:28
problem with reading the .dat file,error object:#f Paulina FLUENT 6 November 7, 2006 16:49


All times are GMT -4. The time now is 18:20.