Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

gFortran to iFortran static build

Rick_S_1
Beginner
1,519 Views

Background: I maintain a large legacy Fortran77 code with that has, for many years, been successfully compiled and linked under a c-shell with gFortran and g++, now under OS X Yosemite. I am moving the code from gFortran to Intel Fortran in an attempt to address some 32-bit pointer issues that seem to be cropping up as I increase the size of internal arrays. My first attempt to compile the Fortran code with ifort was successful but the link to the c++ binary is problematic as I need to access the static Intel 64-bit fortran libraries like I do under gFortran.

The batch file I use under gFortran is below where screamer is the code name and cprog is the c++ shell that I am using:

gfortran -c -O02 -mcmodel=medium *.f

ar crv screamer64.a *.o

rm *.o

ranlib screamer64.a

g++ -c cprog.cpp

g++ -o screamer64 cprog.o screamer64.a /usr/local/lib/libgfortran.a /usr/local/lib/libquadmath.a /usr/local/lib/gcc/x86_64-apple-darwin14.4.0/5.1.0/libgcc.a

 

Compiling with ifort (V15.0.3) will work (after removing the optimization). But the final g++ link will fail because the ifort specific library calls are not addressed in that command line. The manual is vague about the library calls needed for a static build. Suggestions?

0 Kudos
2 Replies
TimP
Honored Contributor III
1,519 Views

I doubt you can get away with 32-bit pointers in 64-bit gfortran or ifort.

For Fortran calling g++ compile, linking normally is simple, similar to gfortran e.g.

ifort *.o -lstdc++

You might try a small sample Fortran program with ifort -# -static-intel sample.f to see which libraries your ifort uses in which order.

0 Kudos
Rick_S_1
Beginner
1,519 Views

I was not clear. gFortran is using 32-bit pointers even though there should be none due to the -mcmodel=medium. This pointer size constraint limits the code to 2.4 GB as the pointer defines the max array sizes. My use of ifort is an attempt to avoid this longstanding bug in gFortran.

The error messages in the g++ link show that many ifort routines are not found at the time of final linking. The same would be true in gFortran if I did not link to the static gFortran library, libgfortran.a, in the final link stage. It is not clear to me that an fort compile option of =lstdc++ fixes this. I can try.

0 Kudos
Reply