|
[Sponsors] |
March 6, 2012, 10:42 |
Problem reading floating array
|
#1 |
New Member
Join Date: Sep 2011
Posts: 2
Rep Power: 0 |
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. |
|
March 6, 2012, 11:00 |
|
#2 |
New Member
Join Date: Sep 2011
Posts: 2
Rep Power: 0 |
The problem seems to be solved, changing the type from real to float
|
|
Tags |
array, fscanf, udf |
|
|
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 |