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/)
-   -   Problem writing data file (http://www.cfd-online.com/Forums/fluent-udf/106382-problem-writing-data-file.html)

fevi84 August 27, 2012 14:35

Problem writing data file
 
Hello all,

I'm trying write the values of a variable through of an UDF. I'm run the case on a Cluster with linux platform. My UDF is:

real Utb;
real Xs;

FILE *fp;

DEFINE_EXECUTE_AT_END(velocity_integral)
{
Domain *domain;

Thread *thread;

real sum_vel=0.;
real vol_gas=0.;
real vol_tot=0.;
real vel_u, axis;
real Xinit = 0.05;
real X[ND_ND];
real flow_time = CURRENT_TIME;

cell_t cell;
fp = fopen("vol_gas.txt","w");
domain = Get_Domain(1);


if (N_TIME<=1.)
Xs = Xinit;
else
Xs = Xinit + Utb*flow_time;


thread_loop_c(thread,domain)
{
begin_c_loop(cell,thread)
{
vel_u = C_U(cell,thread);
vol_tot += C_VOLUME(cell,thread);
C_CENTROID(X,cell,thread);

if(X[0]>=Xs && vel_u>=0.)
{
axis=X[0];
sum_vel += C_UDSI(cell,thread,0)*C_U(cell,thread)*C_UDSI(cell ,thread,3);
vol_gas += C_UDSI(cell,thread,0)*C_UDSI(cell,thread,3);
}

fprintf(fp,"vg: %g X: %g um: %g\n", vol_gas, axis, sum_vel);
}
end_c_loop(cell,thread_l)
fclose(fp);
}

Utb = sum_vel/vol_gas;
printf("Volume total: %g\n", vol_tot);
printf("Volume gas: %g\n", vol_gas);
printf("volume integral: %g\n", sum_vel);
printf("Velocity of the Taylor bubble: %g\n", Utb);
printf("Distance step: %g\n", Xs);
}

When I load the UDF compiled, the message is:

The UDF library is not compiled for parallel use on the current platform (lnam64).

I think that the error is in the printf, fprintf, fopen and fclose commands, due to when I compile and then load the UDF without this commands, it works well.
Moreover, when I run the case with this UDF on the Windows 64 bit platform, also works well.

Anyone know what could be the problem?, when I run the case on Linux platform (cluster).

Thanks!!!

antonk67 August 29, 2012 03:55

As it is clearly specified in UDF manual you should write to file only from host. You will face the same problem running this code on Windows cluster (or even simply in parallel).

fevi84 August 29, 2012 13:47

Thank you very much for your reply.

Quote:

Originally Posted by antonk67 (Post 379231)
As it is clearly specified in UDF manual you should write to file only from host. You will face the same problem running this code on Windows cluster (or even simply in parallel).



All times are GMT -4. The time now is 22:58.