I'm running into a strange problem with openmpi and the pgi compiler (version
9.0-4). I first stumbled across this when using petsc but have reduced it to a
few lines of test code to demonstrate the problem I'm seeing. Essentially it
appears as if a shared library contains a fortran-compiled object file that a)
was built with "-g" and b) contains "use mpi" will produce errors similar to
these when it is linked against:
./libfoo.so: undefined reference to `mpi_sizeof3dch_'
./libfoo.so: undefined reference to `mpi_sizeof4dl_'
./libfoo.so: undefined reference to `mpi_sizeof2dl_'
./libfoo.so: undefined reference to `mpi_sizeof2dch_'
./libfoo.so: undefined reference to `mpi_sizeof0dl_'
./libfoo.so: undefined reference to `mpi_sizeof1dch_'
./libfoo.so: undefined reference to `mpi_sizeof3dl_'
./libfoo.so: undefined reference to `mpi_sizeof1dl_'
./libfoo.so: undefined reference to `mpi_sizeof0dch_'
./libfoo.so: undefined reference to `mpi_sizeof4dch_'
Take the following code-
libfoo.f90:
subroutine printhi()
use mpi
! do some mpi stuff
print *, "Hello"
end
main.f90:
program myprog
call printhi()
end
And to compile (using openmpi built with pgi):
mpif90 -g -c -fPIC libfoo.f90
cc -shared -Wl -o libfoo.so libfoo.o
mpif90 -g main.f90 -lfoo -L. -o main
If I remove the "-g" from the first mpif90 command, then the compile finishes
and there are no errors about undefined references.
This occurs with openmpi-1.4 but ONLY with the pgi fortran compilers. I can't
reproduce this behavior with either gnu gfortran or intel's ifort.
I'm not sure if this is a pgi problem or an openmpi problem or if I'm missing
something.
Any help would be much appreciated!
-Aaron