[MPICH] Compiling MPI Fortran program

Kamaraju Kusumanchi kamaraju at gmail.com
Wed Jul 4 13:28:42 CDT 2007


> My main.f95 is just the hello world program:
>
> --------------------------------------------
> PROGRAM hello
> INCLUDE 'C:\Program Files\MPICH2\include\mpif.h'
> INTEGER err
> CALL MPI_INIT(err)
>  PRINT *, "Hello world!"
> CALL MPI_FINALIZE(err)
> END hello
> --------------------------------------------

Even the serial version of this program does not compile (leave alone
mpi). Also, I do not suggest you to use

INCLUDE 'C:\Program Files\MPICH2\include\mpif.h'

instead use

INCLUDE 'mpif.h'

and include the appropriate paths in your compilation commands etc.,
That way your code will be much more portable.


Consider

cat practice1.f90
program hello
  include 'mpif.h'
  integer :: err
  call MPI_INIT(err)
  write(*,*) "hello world!"
  call MPI_FINALIZE(err)
end program hello

$mpif90 practice1.f90

$mpiexec -l -n 4 ./a.out
0:  hello world!
1:  hello world!
2:  hello world!
3:  hello world!

Here I used mpich2 1.0.5p4 libraries compiled with gfortran 4.2.0, gcc
4.2.0 on a CentOS4 linux machine. I am not sure how things work on
windows machines though.



> Thanks for the information. I thought the mpif90, mpf77, mpicc etc. are just
> the script file to invoke the appropriate compilers. Unfortunately, I don't
> have any mpif90, mpif77 etc. as I am using Windows. Where/how can we get
> those scripts/wrappers for the Windows?

I usually compile the mpich2 libraries myself. You get mpif90
executable if you enable the support for fortran 90 during
compilation. I am not sure whether fortran 90 support is enabled by
default.


hth
raju

-- 
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/




More information about the mpich-discuss mailing list