CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Call FORTRAN files as UDF in a Linux system (https://www.cfd-online.com/Forums/fluent-udf/236504-call-fortran-files-udf-linux-system.html)

azores June 2, 2021 05:58

Call FORTRAN files as UDF in a Linux system
 
I'm sorry my vocabulary, but I'm new at this topics.
I have some FORTRAN files and I like to use them as source UDF files in FLUENT. The FORTRAN files calculate source terms for some equations in FLUENT and need to receive some variables from the simulation.
I am following the procedure of "ANSYS Fluent UDF Manual", section 5.4. Link Precompiled Object Files From Non-ANSYS Fluent Sources. First I tried to do a similar case of the given example (section 5.4.3), and for the "make "FLUENT_ARCH=lnamd64"" some error messages appeared, like:

"makefile: No such file or directory";
"*** No rule to make target 'makefile'";
"Failed to remake makefile 'makefile'";
"*** No targets specified and no makefile found"


If you have any idea of what might be causing this error or if you have any special documents please share with me.

Thank you,
Beatriz

pakk June 2, 2021 09:29

No answer, but if the Fortran file are not too big, it might be easier to just rewrite it in c.

AlexanderZ June 2, 2021 21:17

looks like you don't have file called makefile in your directory

also you can try to add environment variable

Code:

make FLUENT_INC=/apps/ansys_inc/v192/fluent FLUENT_ARCH=lnamd64 -f makefile
FLUENT_INC contains the path to fluent src folder
makefile is the name of makefile (which contains the list of directives for compiler)

the file to be executed with make command looks something like this (depends on fluent version):
Code:

##
## Copyright 1987-2018 ANSYS, Inc. All Rights Reserved.
## All Rights Reserved 
##

#----------------------------------------------------------------------#
# Makefile to call user's makfile for user defined functions. 
# Do not modify this Makefile.
#
# Usage: make "FLUENT_ARCH=arch"
# were arch is ultra, hp700, irix6r8, etc.
#
# sccs id: %W% %G%
#----------------------------------------------------------------------#
SHELL= /bin/sh
FLUENT_ARCH= unknown_arch
DIR= $(FLUENT_ARCH)/[23]*
SRC= ../../src/*.{c,h,cpp,hpp} ../../src/makefile ../../src/user.udf

all:
        for d in $(DIR); do \
          ( \
            cd $$d; \
                rm -rf *.{c,h,cpp,hpp}; \
            for f in $(SRC); do \
              if [ -f $$f -a ! -f `basename $$f` ]; then \
                echo "# linking to" $$f "in" $$d; \
                ln -s $$f .; \
              fi; \
            done; \
            echo ""; \
            echo "# building library in" $$d; \
            if [ "$(USE_GCC64)" = "1" ]; then \
                echo "# using gcc64"; \
                make ARCHC=gcc64 -k>makelog 2>&1; \
            else \
                if [ "$(USE_GCC)" = "1" ]; then \
                        echo "# using gcc"; \
                        make ARCHC=gcc -k>makelog 2>&1; \
                else \
                        make -k>makelog 2>&1; \
                fi; \
            fi;\
            cat makelog; \
          ) \
        done

clean:
        for d in $(DIR); do \
          ( \
            if [ -f "$$d/makefile" ]; then \
              cd $$d; \
              make clean; \
            fi;\
          ) \
        done


azores June 3, 2021 07:25

ld: i386 architecture of input file is incompatible with i386:x86-64 output
 
Thanks for your replies Pakk and AlexanderZ!

The makefile in the source directory (/libudf/src) needs to be written with low case ("makefile" and no "Makefile"). It was a stupid mistake.

But now, when I execute the command "make "FLUENT_ARCH=lnamd64"", in the libudf directory created, another error message appears. The message is the following:

"
# Linking libudf.so because of makefile user.udf udf_names.c udf_names.o test_use.o
ld -shared -lm udf_names.o test_use.o test.o -o libudf.so
ld: i386 architecture of input file `test.o' is incompatible with i386:x86-64 output
make[3]: *** [makefile:123: libudf.so] Error 1
make[3]: Leaving directory '/home/zirtaeb/Code/Coupling_Code_Fluent/test_mass_source_2D_simple/test_mass_source_2D_simple_files/dp0/FFF/Fluent/libudf/lnamd64/2ddp_node'
make[2]: *** [makefile:194: lnamd64] Error 2
make[2]: Leaving directory '/home/zirtaeb/Code/Coupling_Code_Fluent/test_mass_source_2D_simple/test_mass_source_2D_simple_files/dp0/FFF/Fluent/libudf/lnamd64/2ddp_node'
make[1]: *** [makefile:119: default] Error 2
make[1]: Leaving directory '/home/zirtaeb/Code/Coupling_Code_Fluent/test_mass_source_2D_simple/test_mass_source_2D_simple_files/dp0/FFF/Fluent/libudf/lnamd64/2ddp_node'

"

Any advice or help is greatly appreciated!
Thank you,
Beatriz

AlexanderZ June 3, 2021 22:40

is test.o your FORTRAN precompiled file?
lokks like it was compiled in other system, may be with x32 operation system, but fluent compiler uses x64 or vice versa

don't have other ideas

azores June 4, 2021 03:51

Hello again Alexander,

Yes, my fortran compiled object is test.o. I compiled the fortran code in the same machine, but using, for example, the flag "-m32". I tried to remove this flag and now no error messages appear while executing the Makefile on the libudf directory.
Thanks for your reply!


All times are GMT -4. The time now is 14:51.