CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

Add a FORTRAN object to wmake compilation directives

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   April 9, 2014, 13:52
Default Add a FORTRAN object to wmake compilation directives
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 7
vitors is on a distinguished road
Dear all,

I'm having problems to call a simple Fortran function from my solver.

I tested the fortran function from a simple C++ main file and it works. To be able to compile and link this simple example, I simply did:

gfortran -c q.f90
g++ -o main main.cpp q.o
My next step was to try to add these commands to wmake and I'm stucked.

(I've tried this thread, but nothing)

After manually compiling the fortran file, I added to my solver Make/options file this:

And copied to .o file to the $(FOAM_USER_LIBBIN) folder.

When calling wmake I got the linking error below:

/home/vitors/workspace/.../chtMultiRegionSimpleFoam.C:84: undefined reference to `heatflux_'
collect2: ld returned 1 exit status
As long as I know, this is a linking error. The Fortran code is well referenced in my .C file as extern "C" and I have no reason to think the error is here since the syntax is exactly the same I have in the simple example.

So, I'm sure my problem is how to set the wmake files in my project to tell the compiler and linker recognize the q.o object and link it to the solver executable.

(I didn't try to add the fortran code as an external lib. Since it's is simple I would like to have it inside the executable).

My I guess my question is: if it is possible, how to add to wmake both fortran code compilation and then link the object to the solver executable using wmake?

Thank you!
vitors is offline   Reply With Quote

Old   April 9, 2014, 14:25
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 7
vitors is on a distinguished road
Well, I was doing something wrong and after trying again (and a stop for a briefing) I could correctly link the fortran object as described in the thread I mentioned.

After feeling dumb for replying to myself, I think the first part of the question still holds: how to tell to wmake to compile code in Fortran?

I'm checking the scripts in $(WM_PROJECT_DIR)/wmake but nothing yet...

Thank you and sorry for the self-reply.
vitors is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to interface a Fortran thermodynamic tool with OpenFOAM? Cyp OpenFOAM Programming & Development 31 June 9, 2014 14:30
Building solidMechanics in OpenFOAM 1.6-ext on Mac OS X codder OpenFOAM Installation on Windows, Mac and other Unsupported Platforms 4 January 11, 2014 18:34
How to call FORTRAN files as UDF? Ehsan-F Fluent UDF and Scheme Programming 6 September 11, 2012 11:03
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 09:48

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