Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does 'use mpi' fail with mpif90

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
like image 847
Ron Avatar asked May 12 '14 04:05

Ron


People also ask

What is MPI in Fortran?

MPI stands for Message Passing Interface. • It is a library of subroutines/functions, not a computer. language. • Programmer writes fortran/C code, insert appropriate MPI.

What is mpif90 in Linux?

Description. This command can be used to compile and link MPI programs written in Fortran. It provides the options and any special libraries that are needed to compile and link MPI programs. It is important to use this command, particularly when linking programs, as it provides the necessary libraries.


2 Answers

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.

like image 142
Vladimir F Героям слава Avatar answered Sep 28 '22 03:09

Vladimir F Героям слава


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.

like image 25
janneb Avatar answered Sep 28 '22 02:09

janneb