CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   Parse error in UDF (

taha March 9, 2013 12:14

Parse error in UDF
hey guys,

i am trying to write a code for trapping particles in a cross flow over a cylinder. but i get parse error in line 17 and it doesn't matter what is in line 17! even it may be an "Enter" or other routine loops. my code is as follow:

//#include "udf.h"
#include "dpm.h"

real normal[2];
real ds=0.01;

#if RP_2D

if (rp_axi)

real dp=P_DIAM(p);
real x=P_POS(p)[0];
real y=P_POS(p)[1];




}//end of define

it is noticeable that when i activate the #include "udf.h" header, i get "P_POS: undeclared variable" error!
my code is also where my case and data files are. and also the folder doesn't contain "space" in it.

thanks in advance.

vasava March 13, 2013 06:29

Did compiling or did you interpret the code?

I tried compiling your code and nothing seems to be wrong with it. The fluent manual suggest that UDF with DEFINE_DPM_BC works only after compiling.

taha March 14, 2013 03:53

hey vasava
i tried to interpret the code, but i repeatedly get the parse error
could you please give me some tips about compiling the code
tanx in advance

vasava March 14, 2013 04:16

What is the exact error? Can you copy the text here.

Also try to compile some other code and verify that there is no problem with the compiler.

I am no expert myself but lets try to fix it.

taha March 14, 2013 04:22

this the exact error:
cpp -I"C:\Fluent.Inc\fluent6.3.26/src" -I"C:\Fluent.Inc\fluent6.3.26/cortex/src" -I"C:\Fluent.Inc\fluent6.3.26/client/src" -I"C:\Fluent.Inc\fluent6.3.26/multiport/src" -I. -DUDFCONFIG_H="<udfconfig.h>" "C:\Users\Taha\Desktop\trap.c"
Error: C:\Fluent.Inc\fluent6.3.26/src/dpm.h: line 17: parse error.

vasava March 14, 2013 04:58

1. Put UDF in the same folder as the case. It seems that your udf is on your desktop.
2. Remove the comment on line-1. I think you will need udf.h file.
3. The macros you are using will give you real numbers so you dont have to declare them as real
4. You can try ‘double R=sqrt(x*x+y*y);’ instead of just ‘R=sqrt(x*x+y*y);’
5. To me ‘R=sqrt(x*x+y*y);’ does not make sense. You are not using R for anything. You can try after removing that line.

That’s the only help I can do now.

flotus1 March 14, 2013 05:05

Edit: should have read the answers too...

Apparently, the macros you are using only work in compiled mode

taha March 14, 2013 05:18

well thank you vasava
i declared R variable as Double, and moved my .C file into the case folder, but still getting the same parse error!
and about udf.h, when i remove comment from udf.h, i get the "line 16: P_POS: undeclared variable" error.

vasava March 14, 2013 06:10

I am no expert with DPM but may be studying this ( would/might help you.

All the best.

All times are GMT -4. The time now is 09:55.