Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] linking with openmpi version 1.6.1
From: Jeff Squyres (jsquyres) (jsquyres_at_[hidden])
Date: 2014-02-24 16:45:23

This is not an issue with Open MPI; it's an issue with how the Fortran compiler works on your Linux system. It's choosing to put suffix it Fortran symbols with "_" (and possibly in some cases, "__"), whereas the C compiler is not. FWIW, this is a fairly common Fortran Linux compiler convention.

If you want to do C/Fortran interop, you'll either need to account for these differences with, perhaps, some clever #define macros in your C code, or do alternate entry points in C, such as:

void my_real_func(...) {
   // real work

void my_real_func_(...) { my_real_func(...); }

Or you can use the new Fortran'08 C interop stuff (BIND(C)), in which you can specify the C symbol name in the Fortran code. Be aware that while this is supported in some Fortran compilers, it is not yet necessarily supported in the version of gfortran that you may be using.

Also, FWIW, OMPI 1.6.1 is ancient. Can you upgrade to the latest 1.6.x version of Open MPI: 1.6.5?

On Feb 24, 2014, at 12:02 PM, ocnoptcs_at_[hidden] wrote:

> Hi…..
> I have a rather large and complex set of FORTRAN and C++ programs for a simulation project.
> I am using a Nvidia Cluster system that hosts Linux along with openmpi version 1.6.1 along with
> FORTRAN 77 and 90 compilers and C++. The linux system uses Bourne shells.
> I have a makefile that compiles and links the object codes
> To produce an executable file.
> In the past I have been successful in compiling, linking, and running the modules using IBM MPI,
> As well as SUN, SGI, and CRAY. However, I cannot seem to get the FORTRAN object files to link
> With the C++ object files with this system. Unfortunately the system I am now using has no manuals
> On openmpi.
> In attempt to link, I am getting the following error messages….
> “undefined reference to ranf_”
> “undefined reference to ranskip_”
> “undefined reference to ranget_”
> I have 3 C++ routines in a module called ranf, ranskip, ranf.
> In the fortran programs, I make calls to the C++ like
> R = RANF
> And have the C++ routine set up as ….
> Real ranf (void)
> It seems that it is referring to the fact that I need an underscore in the C++ routine name,
> Like real ranf_ (void)
> As I said previously, the other systems I used does not require the underscore. I thought
> This one might so I tried to use the underscore but getting the same results.
> I am attaching the makefile (compressed with bzip2) which I hope will be some help.
> I would appreciate any help in this matter. It is best to respond to me via my email
> As it is quite infrequent that I can access the user list.
> Thanks.
> Bill
> ocnoptcs_at_[hidden]
> <Makefile.bz2>_______________________________________________
> users mailing list
> users_at_[hidden]

Jeff Squyres
For corporate legal information go to: