CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Problem About Running Fluent In Linux (http://www.cfd-online.com/Forums/fluent/72896-problem-about-running-fluent-linux.html)

mitra February 21, 2010 01:37

Problem About Running Fluent In Linux
 
Hi,

I ran into a problem which I can't seem to find a resolution for. I've been running FLUENT on the windows console for a while but began running it on the LINUX environment recently. Now the problem that I am getting is that I can't get my UDF running.

It ran on the windows box smoothly but the moment I switched to the LINUX box, it gives me the following error.

Error: (The directory is long so I won't copy it)/s1.cpp: line 2: syntax error
The udf I coded is extremely short and is the following:

#include "udf.h"
DEFINE_PROFILE(velocity_profile,t,i)
{
real x[ND_ND];
real y;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[1];

if (y<=(0.1*0.035))
F_PROFILE(f,t,i)=1435.750179*y;
else
F_PROFILE(f,t,i)=(0.01758793970)/y;
}
end_f_loop(f,t)
}

I ran it for all my other UDFs that worked in the windows environment and still get the same error that I have a syntax error at the beginning of my code while interpreting in linux.

Has anyone experienced it?

Dimo March 24, 2010 12:59

Hello,

Do you have a Compiler in Linux? If you use the same UDF from Windows to Linux, it will not be compatible.

I experienced a similar problem but I copied my UDF, opened it in the Linux Compiler/text editor (in my case it was Emacs) then saved the UDF under the same name as a .c file. After this, I set up the simulation, then when it came to interpreting ther UDF, I had no problems.

Also make sure there's no extra character appearing in the UDF when you paste it into the Linux compiler. If you see text appearing in the top, delete it and make your UDF start with # include udf.h etc...

Hope it helps!

Dimo

isabel March 26, 2010 04:51

Hello,


So far I have succesfully worked in WINDOWS and now I am begining to work in LINUX. I want to interpret this simple code:




#include "udf.h"


DEFINE_PROPERTY(conductivity,c,t)
{
real k;
if (C_T(c,t) > 848.)
k = 90;
else
k = 180;
return k;
}



I opened this UDF with the text editor “Geany” and I saved it under the same name as a .c file, but when I try to interpret it in Fluent, I have the following error in the first line:


cpp -I”/home/isabel/Fluent.Inc/fluent6.3.26/src' -I”home/isabel/Fluent.Inc/fluent6.3.26/cortex/src” -I”home/isabel/Fluent.Inc/fluent6.3.26/client/src” -I”
Error: /home/isabel/Escritorio/conveccion6082linux.c: line 1: syntax error.


Do you think I need to instale other compiler. Which do you recommend me?

Dimo March 26, 2010 06:49

Using another compiler might not necessary solve the problem. It could be that you have a space or some symbol somewhere in line 1 which gives you this error (in my case it was a square that was appearing when I copied the UDF from Windows to Linux, and I did not notice it until spending a few times the UDF!).

Clear all you don't need from the UDF, start with #include 'udf.h' and make sure there's no space or sign or symbol anywhere that should not be there.

It worked for me. I then opened Fluent and immediately interpreted the UDF before setting up the simulation and it worked. I hope it'll be the same for you. Let me know how it goes.

Dimo

isabel March 26, 2010 09:45

I have cleared all I don't need from the UDF. Now my UDF is this:

#include "udf.h"
DEFINE_PROPERTY(conductivity,c,t)
{
real k;
if (C_T(c,t) > 848.)
k = 90;
else
k = 180;
return k;
}



and now OpenFOAM gives error in line 2

cpp -I”/home/isabel/Fluent.Inc/fluent6.3.26/src' -I”home/isabel/Fluent.Inc/fluent6.3.26/cortex/src” -I”home/isabel/Fluent.Inc/fluent6.3.26/client/src” -I”
Error: /home/isabel/Escritorio/conveccion6082linux.c: line 2: syntax error.

DoHander March 26, 2010 14:12

This is a problem with end of line Windows versus Linux. A simple remedy is to use dos2unix command to transform your text, or use some advanced text editor as Editra. Example:

dos2unix your_program.c

Explanation:

On Windows any end of line is made by characters CR CL, on Unix, Linux and new Macs the end of line is composed only by CL.

Hope this will help,

Do

isabel March 31, 2010 13:26

Thank you very much, DoHander. Now I can succesfully interpret my UDF using dos2unix.


Only one more question. Does anybody know what I have to do to compile my UDFs? In Windows I need a Visual C++ compiler, but in LINUX I do not know what compiler to install.

At this moment, If I try to compile a udf, I have the following error:


for d in lnx86/[23]*; do \
( \
cd $d; \
for f in ../../src/*.[ch] ../../src/makefile; do \
if [ ! -f `basename $f` ]; then \
echo "# linking to" $f "in" $d; \
ln -s $f .; \
fi; \
done; \
echo ""; \
echo "# building library in" $d; \
if [ "" = "1" ]; then \
echo "# using gcc64"; \
make ARCHC=gcc64 -k>makelog 2>&1; \
else \
if [ "" = "1" ]; then \
echo "# using gcc"; \
make ARCHC=gcc -k>makelog 2>&1; \
else \
make -k>makelog 2>&1; \
fi; \
fi;\
cat makelog; \
) \
done
# linking to ../../src/conveccion6082propiedadesvariables.c in lnx86/3d
# linking to ../../src/makefile in lnx86/3d

# building library in lnx86/3d
make[1]: se ingresa al directorio `/home/isabel/Escritorio/z/libudf/lnx86/3d'
# Generating udf_names.c because of makefile conveccion6082propiedadesvariables.c
make[2]: se ingresa al directorio `/home/isabel/Escritorio/z/libudf/lnx86/3d'
make libudf.so "CFLAGS=-fpic -shared -ansi -Wall -m32 -O " "LDFLAGS=-shared -lm -m elf_i386"
make[3]: se ingresa al directorio `/home/isabel/Escritorio/z/libudf/lnx86/3d'
# Compiling udf_names.o because of udf_names.c
cc -fpic -shared -ansi -Wall -m32 -O -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/`expr \`pwd\` : '.*/\(.*\)/[23].*'`/`basename \`pwd\`` -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/cortex/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/client/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/tgrid/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/multiport/src -I. -c udf_names.c
# Compiling conveccion6082propiedadesvariables.o because of conveccion6082propiedadesvariables.c
cc -fpic -shared -ansi -Wall -m32 -O -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/`expr \`pwd\` : '.*/\(.*\)/[23].*'`/`basename \`pwd\`` -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/cortex/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/client/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/tgrid/src -I/home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/multiport/src -I. -c conveccion6082propiedadesvariables.c
conveccion6082propiedadesvariables.c:1: error: expected identifier or ‘(’ before ‘/’ token
In file included from /usr/include/stdio.h:75,
from /home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/src/global.h:18,
from /home/isabel/Escritorio/Fluent.Inc/fluent6.3.26/src/udf.h:23,
from conveccion6082propiedadesvariables.c:12:
/usr/include/libio.h:332: error: expected specifier-qualifier-list before ‘size_t’
/usr/include/libio.h:364: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:373: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:493: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_IO_sgetn’

DoHander March 31, 2010 22:55

You need to install gcc on Linux, this is the standard C compiler on Linux. Fluent will pick this by default.

Do

isabel April 30, 2010 08:52

Thank you DoHander. I have instaled gcc with the command:
sudo apt-get install gcc


I have typed dos2unix function.c before compiling but when I try to compile with fluent, I have the following error.




for d in lnx86/[23]*; do \
( \
cd $d; \
for f in ../../src/*.[ch] ../../src/makefile; do \
if [ ! -f `basename $f` ]; then \
echo "# linking to" $f "in" $d; \
ln -s $f .; \
fi; \
done; \
echo ""; \
echo "# building library in" $d; \
if [ "" = "1" ]; then \
echo "# using gcc64"; \
make ARCHC=gcc64 -k>makelog 2>&1; \
else \
if [ "" = "1" ]; then \
echo "# using gcc"; \
make ARCHC=gcc -k>makelog 2>&1; \
else \
make -k>makelog 2>&1; \
fi; \
fi;\
cat makelog; \
) \
done
# linking to ../../src/linux.c in lnx86/2d
# linking to ../../src/makefile in lnx86/2d

# building library in lnx86/2d
make[1]: se ingresa al directorio `/home/isabel/Escritorio/borrar/libudfxx/lnx86/2d'
# Generating udf_names.c because of makefile linux.c
make[2]: se ingresa al directorio `/home/isabel/Escritorio/borrar/libudfxx/lnx86/2d'
make libudf.so "CFLAGS=-fpic -shared -ansi -Wall -m32 -O " "LDFLAGS=-shared -lm -m elf_i386"
make[3]: se ingresa al directorio `/home/isabel/Escritorio/borrar/libudfxx/lnx86/2d'
# Compiling udf_names.o because of udf_names.c
cc -fpic -shared -ansi -Wall -m32 -O -I/home/isabel/Fluent.Inc/fluent6.3.26/`expr \`pwd\` : '.*/\(.*\)/[23].*'`/`basename \`pwd\`` -I/home/isabel/Fluent.Inc/fluent6.3.26/src -I/home/isabel/Fluent.Inc/fluent6.3.26/cortex/src -I/home/isabel/Fluent.Inc/fluent6.3.26/client/src -I/home/isabel/Fluent.Inc/fluent6.3.26/tgrid/src -I/home/isabel/Fluent.Inc/fluent6.3.26/multiport/src -I. -c udf_names.c
# Compiling linux.o because of linux.c
cc -fpic -shared -ansi -Wall -m32 -O -I/home/isabel/Fluent.Inc/fluent6.3.26/`expr \`pwd\` : '.*/\(.*\)/[23].*'`/`basename \`pwd\`` -I/home/isabel/Fluent.Inc/fluent6.3.26/src -I/home/isabel/Fluent.Inc/fluent6.3.26/cortex/src -I/home/isabel/Fluent.Inc/fluent6.3.26/client/src -I/home/isabel/Fluent.Inc/fluent6.3.26/tgrid/src -I/home/isabel/Fluent.Inc/fluent6.3.26/multiport/src -I. -c linux.c
linux.c: En la función ‘moving_arc’:
linux.c:7: error: expected expression before ‘/’ token
linux.c:8: error: expected expression before ‘/’ token
linux.c:9: error: expected expression before ‘/’ token
linux.c:10: error: expected expression before ‘/’ token
linux.c:11: error: expected expression before ‘/’ token
linux.c:16: error: expected expression before ‘/’ token
linux.c:18: error: expected expression before ‘/’ token
linux.c:19: error: expected expression before ‘/’ token
linux.c:32: error: expected expression before ‘/’ token
linux.c:33: error: expected expression before ‘/’ token
linux.c:41: error: expected expression before ‘/’ token
linux.c:42: error: expected expression before ‘/’ token
linux.c:42: error: expected expression before ‘/’ token
linux.c:43: error: expected expression before ‘/’ token
linux.c:57: error: ‘x’ no se declaró aquí (primer uso en esta función)
linux.c:57: error: (Cada identificador no declarado solamente se reporta una vez
linux.c:57: error: para cada funcion en la que aparece.)
linux.c:58: error: expected expression before ‘/’ token
linux.c:58: error: expected expression before ‘/’ token
linux.c:59: error: expected expression before ‘/’ token
linux.c:60: error: expected expression before ‘/’ token
linux.c:60: error: expected expression before ‘/’ token
linux.c:64: error: ‘b’ no se declaró aquí (primer uso en esta función)
linux.c:67: error: ‘w’ no se declaró aquí (primer uso en esta función)
linux.c:67: error: ‘L’ no se declaró aquí (primer uso en esta función)
linux.c:102: error: expected expression before ‘/’ token
linux.c:105: error: ‘tramo’ no se declaró aquí (primer uso en esta función)
linux.c:116: error: expected expression before ‘/’ token
linux.c:21: aviso: variable ‘x0’ sin usar
linux.c:19: aviso: variable ‘theta3’ sin usar
linux.c:18: aviso: variable ‘theta2’ sin usar
make[3]: *** [linux.o] Error 1
make[3]: Debido a los errores, el objetivo `libudf.so' no se reconstruyó.
make[3]: se sale del directorio `/home/isabel/Escritorio/borrar/libudfxx/lnx86/2d'
make[2]: *** [lnx86] Error 2
make[2]: se sale del directorio `/home/isabel/Escritorio/borrar/libudfxx/lnx86/2d'
make[1]: *** [default] Error 2
make[1]: se sale del directorio `/home/isabel/Escritorio/borrar/libudfxx/lnx86/2d'

isabel May 3, 2010 02:55

Hello everybody,

I have succesfully compiled my UDF. I followed the instructions given in the udf manual and it runs Ok. Thank you very much.

calvin March 2, 2011 05:54

i am facing a similar problem
m tryin to run fluent 13 on redhat lnamd64 arch
i am getting this on erroe only
make[3]: *** [udf_names.o] Error 1
can u please help me out
many thanks and best regards

isabel March 2, 2011 06:26

Hello calvin,

Have you read the instructions of the udf manual? It helped me to successfully compile my udf's


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