|
[Sponsors] |
March 12, 2024, 08:56 |
callling fortran subroutine from openfoam
|
#1 |
Member
Divyaprakash
Join Date: Jun 2014
Posts: 74
Rep Power: 12 |
Hi,
I have a set of operations that need to be performed in fortran. I have bundled it in a subroutine and created a shared library. I am trying to call it from openfoam. Initially I am not passing any arguments to the subroutine since I just want to check if it works. Here is my modified options file. Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfiniteVolume \ -lmeshTools \ -L/home/divyaprakash/my_solvers/ofcil/fem2d -lsoftparticles And this where I include the call in the solver Code:
// Declare the external subroutine extern "C" { void generateellipse_(); } int main(int argc, char *argv[]) { argList::addNote ( "Transient solver for incompressible, laminar flow" " of Newtonian fluids." ); #include "postProcess.H" #include "addCheckCaseOptions.H" #include "setRootCaseLists.H" #include "createTime.H" #include "createMesh.H" pisoControl piso(mesh); #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; generateellipse_(); Code:
Making dependency list for source file icoFoam.C g++ -std=c++14 -m64 -pthread -DOPENFOAM=2012 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3 -DNoRepository -ftemplate-depth-100 -I/usr/lib/openfoam/openfoam2012/src/finiteVolume/lnInclude -I/usr/lib/openfoam/openfoam2012/src/meshTools/lnInclude -iquote. -IlnInclude -I/usr/lib/openfoam/openfoam2012/src/OpenFOAM/lnInclude -I/usr/lib/openfoam/openfoam2012/src/OSspecific/POSIX/lnInclude -fPIC -c icoFoam.C -o Make/linux64GccDPInt32Opt/icoFoam.o g++ -std=c++14 -m64 -pthread -DOPENFOAM=2012 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3 -DNoRepository -ftemplate-depth-100 -I/usr/lib/openfoam/openfoam2012/src/finiteVolume/lnInclude -I/usr/lib/openfoam/openfoam2012/src/meshTools/lnInclude -iquote. -IlnInclude -I/usr/lib/openfoam/openfoam2012/src/OpenFOAM/lnInclude -I/usr/lib/openfoam/openfoam2012/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt32Opt/icoFoam.o -L/usr/lib/openfoam/openfoam2012/platforms/linux64GccDPInt32Opt/lib \ -lfiniteVolume -lmeshTools -L/home/divyaprakash/my_solvers/ofcil/fem2d -lsoftparticles -lOpenFOAM -ldl \ -lm -o /home/divyaprakash/OpenFOAM/divyaprakash-v2012/platforms/linux64GccDPInt32Opt/bin/cilFoam /usr/bin/ld: Make/linux64GccDPInt32Opt/icoFoam.o: in function `main': icoFoam.C:(.text.startup+0x3203): undefined reference to `generateellipse_' collect2: error: ld returned 1 exit status make: *** [/usr/lib/openfoam/openfoam2012/wmake/makefiles/general:150: /home/divyaprakash/OpenFOAM/divyaprakash-v2012/platforms/linux64GccDPInt32Opt/bin/cilFoam] Error 1 Note: I have also tried without the underscore in the subroutine name and that also returns the same error. Last edited by Divyaprakash; March 12, 2024 at 08:57. Reason: more information |
|
Tags |
fortran, shared libraries |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 06:40 |
OpenFOAM Training Jan-Apr 2017, Virtual, London, Houston, Berlin | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | September 21, 2016 12:50 |
OpenFOAM Training, London, Chicago, Munich, Houston 2016-2017 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | September 14, 2016 04:19 |
Suggestion for a new sub-forum at OpenFOAM's Forum | wyldckat | Site Help, Feedback & Discussions | 20 | October 28, 2014 10:04 |
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 | wyldckat | OpenFOAM Announcements from Other Sources | 3 | September 8, 2010 07:25 |