CFD Online Logo CFD Online URL
Home > Forums > Fluent UDF and Scheme Programming

Problem reading floating array

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

LinkBack Thread Tools Display Modes
Old   March 6, 2012, 10:42
Default Problem reading floating array
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"
#if !RP_HOST /* either serial or compute node process is involved */
FILE *fin,*fout;
int i,m;
real testa[8];

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]);


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
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


array, fscanf, udf

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
problem with reading case file gmwsy FLUENT 5 November 23, 2016 13:19
Converting a mesh with splitted cells using fluentMeshToFoam jlpelerin OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 4 April 25, 2011 16:56
Segmentation Fault in fluent3DMeshToFoam cwang5 OpenFOAM Bugs 23 April 13, 2011 15: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 09:45.