OpenMPI Fortran: 'Error reading module mpi' and unexpected but silent termination





Hello,

I'm encountering very strange behaviour with the very basic MPI/Fortran
program listed at the end of the message on a system running KUbuntu and
with the following compilers:
- gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
- GNU-Fortran compiler, 4.3.0 20071002 (experimental)
- OpenMPI 1.1-2.3

It must be noted that the same system was used to run another MPI
program, written in C. This worked without any problem. But we can't get this
simple Fortran program up and running. This is an overview of things
i've been testing, without any result...
Any help on this matter is very welcome!

Kind greetings,

Koen Poppe



== Version 1 ==

Compiling the program with the only "USE MPI" statement uncommented and
compiling with the "mpif90" wrapper resulted in this output:
> mpif90 foo.f90 --showme
gfortran -pthread -I/usr/lib foo.f90 -lmpi_f90 -lmpi -lorte -lopal -ldl
-Wl,--export-dynamic -lnsl -lutil -lm -ldl Fatal Error: Reading module mpi at line 110 column 31: Expected string

The module file is present at "/usr/lib/mpi.mod" but there seems to be a
problem while reading (the following) line 110:
(273 'impi_client_color' 'mpi' 1 ((PARAMETER UNKNOWN-INTENT
UNKNOWN-PROC UNKNOWN) (INTEGER 4 ()) 0 0 () (CONSTANT (INTEGER 4 ()) 0 '11') () 0 ()
())

It's not easy to understand the "*.o" file format for me. Note that this
"mpi.mod" file looks to be generated with the same compiler, as is
indicated by it's first line:
GFORTRAN module created from mpi.f90 on Fri Jan 26 16:06:27 2007

This version was abandoned as we couldn't fine a way to solve this...


== Version 2 ==

The second attempt used the ' include "mpif.h" ' statement. At first,
running the program with the same command didn't work:
> mpif90 foo.f90
Error: Can't open included file 'mpif.h'

... although the required files are could be found in "/usr/include/".
Against al regulations, we've tried copying those required files to the
working directory. That worked, well, almost, the references to the
MPI-implementation was still a problem:
> mpif90 foo.f90 --showme
gfortran -pthread -I/usr/lib foo.f90 -lmpi_f90 -lmpi -lorte -lopal -ldl
-Wl,--export-dynamic -lnsl -lutil -lm -ldl
/tmp/cc0eZ1OR.o: In function `MAIN__':
foo.f90:(.text+0x88): undefined reference to `mpi_init_'
foo.f90:(.text+0x119): undefined reference to `mpi_comm_rank_'
foo.f90:(.text+0x20a): undefined reference to `mpi_finalize_'
collect2: ld returned 1 exit status

As we've inspected the linked libraries ("libmpi.a", "libmpi_f90.a", ...
) we discovered that the double underscore mangling convention was
used. This could be solved by using the compiler flag "-fsecond-underscore".
Strange enough this worked, well, for the compilation part ... Running
the executable didn't. The program terminated without any kind of error
message. It must have failed on the "MPI_INIT" method as can be seen
from the output it generated: only the first print statement is executed,
but 4 times, so one could assume MPI did what it should do...
> mpiexec -np 4 a.out
MPI_INIT
MPI_INIT
MPI_INIT
MPI_INIT
>


== Program listing ==

program foo

! VERSION 1
! use MPI

implicit none

! VERSION 2
! include 'mpif.h'

integer :: rank, nb, ierr

print
*,"MPI_INIT"
call MPI_INIT( ierr )

write(unit=*, fmt="(A)")
"MPI_COMM_RANK"
call MPI_Comm_rank( MPI_COMM_WORLD, rank, ierr )
print *,"Hello
i'm proc ",rank

print *,"MPI_FINALIZE"
call MPI_FINALIZE( ierr )

end
program


.



Relevant Pages