MS-MPI with the MinGW64 gfortran
Hereby I am creating this thread in order to publicly demonstrate the adaptation of the MS-MPI suite for the MinGW64 gfortran.
Tested on 64-bit MS Windows 8.0; MinGW-W64 project 4.9.0.
- Download and unpack the MS-MPI package (this is v4) . Do not install it otherwise you may face error as this one. All necessary files are unpacked from the mpi_x64.Msi archive and are in the corresponding directory !
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>"C:\Program Files (x86)\7-Zip\7z.exe" x mpi_x64.Msi
7-Zip 9.22 beta Copyright (c) 1999-2011 Igor Pavlov 2011-04-18
Processing archive: mpi_x64.Msi
Extracting etl2clog.exe
Extracting etl2otf.exe
Extracting mpi.f90
Extracting mpi.h
Extracting mpicsync.exe
Extracting mpiexec.exe
Extracting mpif.h
Extracting mpio.h
Extracting mpitrace.man
Extracting msmpi.dll
Extracting msmpi.lib
Extracting msmpi64.dll
Extracting msmpi64.lib
Extracting msmpifec.lib
Extracting msmpifec64.lib
Extracting msmpifes.lib
Extracting msmpifmc.lib
Extracting msmpifmc64.lib
Extracting msmpifms.lib
Extracting msmpires.dll
Extracting msmpires64.dll
Extracting note_mpi.txt
Extracting pmidbg.h
Extracting smpd.exe
Everything is Ok
Files: 24
Size: 9720065
Compressed: 3613184
- In the MS-MPI directory, create the libmsmpi64.a library with the MinGW64 tools gendef and dlltool:
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>gendef msmpi64.dll
* [msmpi64.dll] Found PE image
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>dlltool -d msmpi64.def -l libmsmpi64.a -D msmpi64.dll
- In the MS-MPI folder, rename mpi.f90 to mpi.F90 and modify its source code so that the gfortran compiler can accept traditional (C) preprocessor directives (changes are starting from line 344, see also Attachement 1) :
- generate the Fortran90 mpi.mod file - you must use appropriate preprocessor statements and no-range checking (-D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check)
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>gfortran -c -D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check mpi.F90
- compile and run the MPI example.F90 - see also the Attachement 3 - using the modified Fortran90 module mpi:
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>gfortran -o example.exe -D USE_MPI_MODULE example.F90 libmsmpi64.a
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>mpiexec.exe -n 2 example.exe
PASSED
- In the MS-MPI folder, modify the mpif.h include file so that Intel preprocessor directives are replaced by the traditional ones (changes starting from line 341), see the Attachement 2
- now compile and run the MPI example.F90 file - see also the Attachement 3 - by using the modified include file "mpif.h" (use -D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check flags as in the previous case):
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>gfortran -o example.exe -D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check example.F90 libmsmpi64.a
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>mpiexec -n 2 example.exe
PASSED
Note that you have to link the above generated libmsmpi64.a library. If you would link against the ms-mpi provided dynamical library, msmpi64.dll , you would get the error message of Fatal protocol error: check version between Mpiexec.exe, Msmpi.dll, and Smpd.exe.
Likewise I stress that linking against the delivered lib-file msmpi64.lib does not work, you must have your own prepared libmsmpi64.a library, as explained above:
C:\Users\milias\Documents\Dirac\software\autocmake-devel\ms-mpi>gfortran -o example.exe -D USE_MPI_MODULE example.F90 msmpi64.lib
C:\Users\milias\AppData\Local\Temp\ccmTxg9d.o:example.F90:(.text+0x1b): undefined reference to `mpi_init_'
C:\Users\milias\AppData\Local\Temp\ccmTxg9d.o:example.F90:(.text+0x3b): undefined reference to `mpi_comm_rank_'
C:\Users\milias\AppData\Local\Temp\ccmTxg9d.o:example.F90:(.text+0x5b): undefined reference to `mpi_comm_size_'
C:\Users\milias\AppData\Local\Temp\ccmTxg9d.o:example.F90:(.text+0x6a): undefined reference to `mpi_finalize_'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\milias\AppData\Local\Temp\ccmTxg9d.o: bad reloc address 0x0 in section `.pdata'
collect2.exe: error: ld returned 1 exit status
Attachement 1 - (mpi.f90 -> mpi.F90), modified lines

Attachement 2 - mpif.h, modified lines

Attachement 3 - example.F90

MS-MPI with the MinGW64 gfortran
Hereby I am creating this thread in order to publicly demonstrate the adaptation of the MS-MPI suite for the MinGW64 gfortran.
Tested on 64-bit MS Windows 8.0; MinGW-W64 project 4.9.0.
Note that you have to link the above generated libmsmpi64.a library. If you would link against the ms-mpi provided dynamical library, msmpi64.dll , you would get the error message of Fatal protocol error: check version between Mpiexec.exe, Msmpi.dll, and Smpd.exe.
Likewise I stress that linking against the delivered lib-file msmpi64.lib does not work, you must have your own prepared libmsmpi64.a library, as explained above:
Attachement 1 - (mpi.f90 -> mpi.F90), modified lines
Attachement 2 - mpif.h, modified lines
Attachement 3 - example.F90