CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   Problem with UDF on a Linux machine (Red Hat) (

Iaroslav June 9, 2009 10:55

Problem with UDF on a Linux machine (Red Hat)
Hello everyone,

I have written a simple UDF (DEFINE_TURBULENT_VISCOSITY) to modify the eddy viscosity calculated by the standard k-e model. I have run several simulations in Windows Vista with Fluent interpreting my UDF with no problems at all. However, when I try to run the same simulation on the Linux machine (Red Hat) I am getting an eeror message that informs me of a syntax error on line 2. Here is my UDF:

#include "udf.h"

real mu_t;
real s_11;
real s_12;
real s_22;
real s_g;
real div_vel;
real mach_g;
real l_g;
real alpha;
real c_mu;

real rho = C_R(c,t);
real k = C_K(c,t);
real d = C_D(c,t);
real temper = C_T(c,t);
real dudx = C_DUDX(c,t);
real dvdy = C_DVDY(c,t);
real dudy = C_DUDY(c,t);
real dvdx = C_DVDX(c,t);

s_11 = dudx;
s_22 = dvdy;
s_12 = 0.5*(dudy+dvdx);
div_vel = dudx+dvdy;

s_g = sqrt(2*((SQR(s_11)+2*SQR(s_12)+SQR(s_22))-1/3*SQR(div_vel)));

alpha = sqrt(1.4*287*temper);
l_g = 0.09*pow(k,1.5)/d;
mach_g = s_g*l_g/alpha;
c_mu = 0.07*exp(-0.4*mach_g);

mu_t = c_mu*rho*SQR(k)/d;

return mu_t;

Any help would really be appreciated as my Linux machine is much better at running simulations than my Windows laptop.

Thank you,

gemini June 9, 2009 13:20


dos2unix filename

command in console. it may help to you.

try web search for dos2unix for its description

Iaroslav June 9, 2009 14:07

Thanks for the reply.

Unfortunately this did not solve my problem. First, I get the message "problems converting file mu_t.c" and then I get the same error message "syntax error on line 2". Furthermore, I don't know why this is happening in the first place since its a c course file and the only header I am using is udf.h.


gemini June 9, 2009 14:20

I copied your function and it was was succesfully intepereted by FLUENT on my machine (64 bit OpenSUSE 11.1 on AMDX2-7750 4GBRAM). Maybe you should try another computer.



Iaroslav June 9, 2009 14:38

Thank you for the help Gemini,

I got it working my creating a completely new C file on my Linux system.

Many thanks,

spring May 12, 2010 07:43

same problem
Hi Iaroslave,

I have the same problem. I got a udf file which I wrote in a text file with the ending .c, so that it would become a C file. When interpreting it in fluent in windows XP it is interpreted with no problems. But when I try to interpret it in fluent in linux it always shows me a syntax error in line 1, which by the way is empty.
Here is the code:

/************************************************** ********************
UDF for specifying a steady-state velocity profile boundary condition
************************************************** ********************/

#include "udf.h" /* must be at the beginning of every UDF */

/* constants: */
#define R 8. /* inlet radius [mm] (with actual scaling in Fluent applied!) */
#define VFLOW 15. /* effective volume flow [l/min] */
#define POWER 1./7. /* 1/7 power law defining turbulent profile */

double PI;
real Umax; /* maximal inlet velocity */
real x[ND_ND]; /* this will hold the position vector every single face centroid */
real r;
face_t f;

PI = acos(-1.);
Umax = pow(10.,3.)*VFLOW/PI/pow((R),2.)/49.;

begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */
r = sqrt(pow((1000*x[0]),2.)+pow((1000*x[2]),2.));
F_PROFILE(f,thread,index) = Umax*pow((1.-r/R),POWER);

You said, that you solved this problem by writing a complete new C file in linux. I opend a file and copied my code into this file and then I added the ending .c, but it still doesn't work when I try to interprete it. Did I do something wrong? Can you please tell me in detail how you solved your problem, because I have EXACTLY the same problem you had.

And I also need to work on the linux machine because it is faster in running simulations (although I realy hate hate hate linux!).


BigMc March 7, 2017 14:15

Dam Linux

I know this is an old post, but I have the exact same issue,

and I was hoping someone who may have solved it is still active on this Forum.

I tried dos2unix "myfilepath" but still get the line 1 syntax error.

I also tried nano "myfilepath" through my linux system to check for any irregular characters and there is none.

All times are GMT -4. The time now is 13:40.