f90 linking problem

Hi,

I am trying to compile a large mixed F77-F90 code. Note that I am invoking mpif90. I believe the MPI implementation that came with the PGI compilers is MPICH. The underlying compiler should be pgf90 5.2-4

The problem: I can compile each file into an object file, but the linking phase fails in an obscure way

I compile the files using the following:

$ mpif90 -w -Mpreprocess -O3 -tp=piv -c …

and I (try to) link with:

$ mpif90 -O3 -tp=piv -o flowsi-12step mpiSupport.o pdfMonteCarlo.o mpiProfile.o randomMonteCarlo.o boundary.o tauwall.o imbound.o inicom.o inifac.o inigeo.o initial.o iniuvwtu.o contrexe.o flowsi.o evaluate.o eval2.o inout.o printout.o random.o util.o pdfdiscr.o mtvoutput.o sevaluate.o dx.o inflow.o ifdoutput.o merge.o adapt.o cap1155.o cap1252.o ffts.o poissz.o germano.o mmneqn.o timeint.o scalar.o scalar2.o chemistry.o pdfmc.o ntree.o mcchem.o dvode.o cklib1.o ckwyp.o

and I get a bunch of undefined references:

/usr/bin/ld: Warning: alignment 8 of symbol pghpf_type_' in /usr/local/pgi/linux86/5.1/lib/libpgf902.a(const.o) is smaller than 16 in mpiProfile.o tauwall.o(.text+0x14b9): In function twutln_’:
: undefined reference to pghpf_sect1v' tauwall.o(.text+0x1599): In function twutln_’:
: undefined reference to pghpf_sect1v' tauwall.o(.text+0x167a): In function twutln_’:
: undefined reference to pghpf_sect1v' tauwall.o(.text+0x19cf): In function twutln_’:
: undefined reference to pghpf_sect1v' tauwall.o(.text+0x1aaf): In function twutln_’:
: undefined reference to pghpf_sect1v' tauwall.o(.text+0x1b8f): more undefined references to pghpf_sect1v’ follow
pdfmc.o(.text+0xb118): In function pdfpost_': : undefined reference to pghpf_sect2v’
pdfmc.o(.text+0xb17f): In function pdfpost_': : undefined reference to pghpf_sect2v’
ntree.o(.text+0x2bfa): In function treeread_': : undefined reference to pghpf_sect1v’
ntree.o(.text+0x2ca6): In function treeread_': : undefined reference to pghpf_sect1v’
ntree.o(.text+0x2d50): In function treeread_': : undefined reference to pghpf_sect1v’
ntree.o(.text+0x2f10): In function treeread_': : undefined reference to pghpf_sect1v’
ntree.o(.text+0x2fba): In function treeread_': : undefined reference to pghpf_sect1v’
ntree.o(.text+0x3063): more undefined references to pghpf_sect1v' follow mcchem.o(.text+0x6ded): In function mcfltab_’:
: undefined reference to pghpf_sect2v' cklib1.o(.text+0xd333): In function cksave_’:
: undefined reference to pghpf_sect1v' cklib1.o(.text+0xd3d5): In function cksave_’:
: undefined reference to `pghpf_sect1v’
make: *** [flowsi-12step] Error 2


Note that there are two things I don’t understand:

(a) why is there a reference to ‘pghpf_’ when I am using pgf90
(b) I don’t have anything named ‘sect1v’ or ‘sect2v’ in any of the files. So, what undefined reference are we talking about?

Thanks for any help you might give,

Fabrizio

PS: I could successfully compile the code with the Intel F90 compiler, but I now need to use the code on another cluster, on which they installed PGI compilers

Hi Fabrizio,

a) why is there a reference to ‘pghpf_’ when I am using pgf90?

Although pghpf and pgf90 have different front ends, the back end (ie the optimizer and code generator) share much of the same source code.

b) I don’t have anything named ‘sect1v’ or ‘sect2v’ in any of the files. So, what undefined reference are we talking about?

These are internal compiler objects added with the 5.2 release of the compilers. Notice that the warning your seeing is referencing the 5.1 libpgf902.a library. Since these objects are new to the 5.2 version of libpgf90, the 5.1 version of the library wont have any refernences to them.

Some possible things might be happening:

  1. Your compiling with the 5.2-4 version of the compiler but linking with the 5.1 version
  2. Your mpif90 script is explicitly linking in the old library.

What is the output of the following commands?

which mpif90
mpif90 -dryrun x.f90

Thanks,
Mat

Mat,

thanks for your help. I issued the commands and got the following:

a) $ which mpif90
/usr/local/mpich/bin/mpif90

b) $ mpif90 -dryrun x.f90
Reading rcfile /usr/local/pgi/linux86/5.2/bin/.pgf90rc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/nativerc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/fnativerc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/x86rc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/x8632rc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/lin86rc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/lin8632rc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/iparc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/pgf90rc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/pgftnrc
Reading rcfile /usr/local/pgi/linux86/5.2/bin/localrc
Skipping .mypgf90rc (not found)

/usr/local/pgi/linux86/5.2/bin/pgf901 x.f90 -opt 1 -terse 1 -inform warn -nohpf -nostatic -x 119 0x100000 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -x 57 0x10000 -x 58 0x8031040 -x 48 3328 -stdinc /usr/local/pgi/linux86/5.2/include:/usr/local/include:/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include:/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def inline= -def i386 -def __i386 -def i386 -def __NO_MATH_INLINES -def linux86 -def __THROW= -vect 48 -output /tmp/pgf90aaaaaxzfaD.ilm

/usr/local/pgi/linux86/5.2/bin/pgf902 /tmp/pgf90aaaaaxzfaD.ilm -fn x.f90 -opt 1 -terse 1 -inform warn -x 51 0x20 -x 119 0xa10000 -x 119 0x100000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 119 0x40000000 -x 80 0x300 -y 80 0x1000 -x 80 0x40000000 -x 124 0x1400 -y 15 2 -x 80 0x300 -y 80 0x1000 -x 80 0x40000000 -x 57 0x10000 -x 58 0x8000000 -astype 0 -stdinc /usr/local/pgi/linux86/5.2/include:/usr/local/include:/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include:/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def inline= -def i386 -def __i386 -def i386 -def __NO_MATH_INLINES -def linux86 -def __THROW= -x 124 1 -asm /tmp/pgf90baaaaxzfaD.s

/usr/bin/as /tmp/pgf90baaaaxzfaD.s -o /tmp/pgf90caaaaxzfaD.o

/usr/bin/ld /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/crtbegin.o /usr/local/pgi/linux86/5.2/lib/f90main.o -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /tmp/pgf90caaaaxzfaD.o -L/usr/local/pgi/linux86/5.1/lib -L/usr/local/pgi/linux86/5.2/lib -L/usr/lib -L/usr/lib/gcc-lib/i386-redhat-linux/3.2.3 -rpath /usr/local/pgi/linux86/5.2/lib -lmpichf90 -lmpich -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/crtend.o /usr/lib/crtn.o
Unlinking /tmp/pgf90aaaaaxzfaD.ilm
Unlinking /tmp/pgf90aaaaaxzfaD.dwf
Unlinking /tmp/pgf90baaaaxzfaD.s
Unlinking /tmp/pgf90caaaaxzfaD.o

Thanks,
-Fabrizio

If you look at the link line notice that both “-L/usr/local/pgi/linux86/5.1/lib” and “-L/usr/local/pgi/linux86/5.2/lib” are included. My guess is that when your site upgraded to 5.2, the mpif90 was not changed and still has the 5.1 path as part of its prefix variable. To fix, edit the mpif90 “prefix” variable from 5.1 to 5.2.

  • Mat

Problem solved.
Thanks a lot!
-Fabrizio