Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29310 Discussions

Linking Visual Fortran binaries to other compiler binaries

r-david-cantwell
Beginner
860 Views
Hello All,

I am new to FORTRAN, and I am investigating if it is possible to link to binaries generated with Visual Fortran (Composer XE 2011) when using the gfortran compiler to generate the final executable. For example, when I tried to use *.mod files compiled with VF I got the error message:

Fatal Error: File 'module_gpops.mod' opened at (1) is not a GFORTRAN module file

So I tried to create libraries with VF and link against them with the command

gfortran -ffree-form -ffree-line-length-none -fimplicit-none -fno-range-check -Wall -g \\
-L/home/dcantwell/launch -lgpopsf -lsnopts \\
C:/home/GPOPS/launch/modules/*.f90 C:/home/GPOPS/launch/src/*.f90 \\
-o launch.exe

but got the error

Fatal Error: Can't open module file 'module_gpops.mod' for reading at (1): No such file or directory

I confirmed that the modules were contained in the libraries (libgpopsf.a, libsnopts.a) I made with VF. Is it just not possible to link with binaries not made with gfortran, or am I doing something wrong that can be corrected? Thnx for any help.
0 Kudos
4 Replies
mecej4
Honored Contributor III
860 Views
It appears that you are confusing the *.mod files produced by compiling Fortran 9X modules with 'modules' in the old IBM 360 sense. The Fortran module files are used by the compiler and not the linker. The linker uses .o and .a and .so files, and knows nothing about .mod files. Therefore, libraries (.a and .so) do not contain Fortran module files.

It is the .mod files that are not compatible across compilers. The incompatibilities of the .o files are much less, if any. If you organize your sources such that none of the modules compiled by one compiler are USEd in sources delegated to the other compiler, and the two compilers use compatible ABIs, you may get things to work.
0 Kudos
Steven_L_Intel1
Employee
860 Views
In general, objects from different Fortran compilers are not compatible. You must use a single Fortran compiler to compile all your Fortran sources. But indeed .mod files are specific to the compiler that produced them.
0 Kudos
r-david-cantwell
Beginner
860 Views
Thnx mecej4, this cleared some things up for me.
0 Kudos
r-david-cantwell
Beginner
860 Views
Thnx for the reply Steve; the responses have been helpful.
0 Kudos
Reply