Reputation: 271
In order to compile MPI code in gfortran I have to use the syntax
include mpif.h
in my code instead of
use mpi
Several websites indicate that this syntax is for Fortran 77 however, I am using gfortran gcc version 4.7.2 (Debian 4.7.2-5) and mpfi90 for MPICH2 version 1.4.1p1.
The command line
mpif90 test1.f90 -o test1.exe
produces the following error
test1.f90:4.8: use mpi 1 Fatal Error: Parse error when checking module version for file 'mpi.mod' opened at (1)
test1.f90 (from Coursera course on HPC)
program test1
use mpi !(fails to compile)
implicit none
include 'mpif.h' !(this works)
integer :: ierr, numprocs, proc_num
call mpi_init(ierr)
call mpi_comm_size(MPI_COMM_WORLD, numprocs, ierr)
call mpi_comm_rank(MPI_COMM_WORLD, proc_num, ierr)
print *, 'Hello from Process number', proc_num, &
' of ', numprocs, ' processes'
call mpi_finalize(ierr)
end program test1
Upvotes: 5
Views: 9745
Reputation: 60008
Another option I often encounter is when the Fortran compiler used to build the MPI library is not compatible with your current Fortran compiler. Then the problem is the incompatibility of the .mod
files. Gfortran is more susceptible to this, than say Intel Fortran, because it changes the module format more often.
Upvotes: 8
Reputation: 37208
Depending on how MPICH2 was compiled, perhaps the F90 interface wasn't built. That tends to happen depressingly often when using packages built by C-heads.
Upvotes: 2