Hello, i’m sorry i’m new to that - trying to compile a simple mpi code
program hello
include ‘mpif.h’
integer ierr, myproc
call mpi_init(ierr)
call mpi_comm_rank(MPI_COMM_WORLD, myproc, ierr)
print *, “Hello world! I’m node”, myproc
call mpi_finalize(ierr)
end
using precompiled mpich2 libraries on windows 32 machine:
PGI$ pgf95 -I “C:\Program Files\MPICH2\include” -L “C:\Program Files\MPICH2\lib” -Mfree hellompi.f -l fmpitch2.lib
It comes with 7 severes about mpifcmb1,has not been explicitly declared(C:\Program Files\MPICH2\include\mpif.h: 494) etc.
What is the right way to compile that?
using precompiled mpich2 libraries on windows 32 machine
Where did get the MPICH2 libraries from? Were they compiled for use the PGI Fortran?
It comes with 7 severes about mpifcmb1,has not been explicitly declared
mpifcmb1 is a common block so I suspect that your MPICH2 library was not compiled for use with PGI and differing name decoration is causing the error. Though, this is just a guess. An example of the error would be helpful.
Since you’re using F90 and MPICH2, try using the mpi module instead of including the header file. (i.e. replace “include ‘mpif.h’” with “use mpi”). Granted, you’ll still have problems if your MPICH2 was compiled for PGI.
Hi akanaev,
I downloaded the MPICH2 package and found that the error was being caused by several misplaced “!DEC$” declarations in “mpif.h”. To fix, I simply moved these declaration below the common blocks. Because the symbols used in the “DEC” declarations hadn’t been declared yet, the compiler complained.
Example:
CHARACTER*1 PADS_A(3), PADS_B(3)
COMMON /MPIFCMB1/ MPI_STATUS_IGNORE
COMMON /MPIFCMB2/ MPI_STATUSES_IGNORE
COMMON /MPIFCMB3/ MPI_BOTTOM
COMMON /MPIFCMB4/ MPI_IN_PLACE
COMMON /MPIFCMB5/ MPI_UNWEIGHTED
COMMON /MPIFCMB6/ MPI_ERRCODES_IGNORE
COMMON /MPIFCMB7/ MPI_ARGVS_NULL, PADS_A
COMMON /MPIFCMB8/ MPI_ARGV_NULL, PADS_B
SAVE /MPIFCMB1/,/MPIFCMB2/
SAVE /MPIFCMB3/,/MPIFCMB4/,/MPIFCMB5/,/MPIFCMB6/
SAVE /MPIFCMB7/,/MPIFCMB8/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB1/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB2/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB3/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB4/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB5/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB7/
!DEC$ ATTRIBUTES DLLIMPORT::/MPIFCMB8/
Because this build of the library was not built with PGI, to link, you need to add the flag “-Miface=cref”. Also, the “-l” flag will add a “lib” before the name of the library, so you need to instead put the fully qualified PATH to fmpich2.lib.
Example:
PGI$ pgf95 -I "C:\Program Files\MPICH2\include" "C:\Program Files\MPICH2\lib\fmpich2.lib" -Mfree hello.f -Miface=cref -o hello.exe
hello.f:
PGI$ hello.exe
Hello world! I'm node 0
Hope this helps,
Mat
Hi,Mat
It works this way, thanks for the help!