I am using Codeblock IDE to write and compile my Fortran program. Right now I want to include MPI to my GNU Fortran Compiler. After following some guides on GNU GCC Compiler, it occurs to me that I need to set up the following for MPICH2 (there are two guides about that):
(1) add mpi.lib to the linker setting (2) add include file to the search directory
However, these setting won’t compile due to error on this line below, and saying that it has an unexpected EoF: use mpi
So, then I tried to use Cygwin include file (with mpi.lib from MPICH2), strangely, it compiles fine, even with the:
call mpi_init (ierr)
call mpi_comm_rank (mpi_comm_world,rank,ierr)
call mpi_finalize (ierr)
However, when I tried to run the program. It won’t perform pass the:
call mpi_init (ierr)
Then I tried to manually compile the program, and it shows:
C:\Users\7931\AppData\Local\Temp\cclYnhYq.o:main.f90:(.text+0x18c): undefined reference to mpi_init_' C:\Users\7931\AppData\Local\Temp\cclYnhYq.o:main.f90:(.text+0x1fd): undefined reference to mpi_comm_rank_’
C:\Users\7931\AppData\Local\Temp\cclYnhYq.o:main.f90:(.text+0x276): undefined reference to `mpi_finalize_’
collect2.exe: error: ld returned 1 exit status
Maybe there is a setting that I have not set up yet for the MPI environment, or I need to get the Cygwin mpi.lib, which I can’t found after installing the complete MPI package from the Cygwin.
After trying many other things, I realized that, why there is no "include" folder on Cygwin64
Maybe what I need is a guide how to set up linker/search directories/path for MPI within Cygwin64 environment?
Anyone can please help me here? Many thanks for your help
Edit: I have performed the solution from last chance. It seems there is an error during linking. Below is the command window response:
C:\Windows\system32>cd C:\Batch
C:\Batch>do_intel test
C:\Batch>rem ifort -c test.f90 /traceback /check:all /Qparallel -I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include\intel
C:\Batch>ifort -c test.f90 /Qparallel /O3 -I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include\intel Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on IA-32, Version 2021.6.0 Build 20220226_000000 Copyright (C) 1985-2022 Intel Corporation. All rights reserved.
C:\Batch>ifort test.obj -o test.exe "C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\msmpi.lib" "C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\msmpifec.lib" Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on IA-32, Version 2021.6.0 Build 20220226_000000 Copyright (C) 1985-2022 Intel Corporation. All rights reserved.
link: unknown option -- s Try 'link --help' for more information.
C:\Batch>runmpi test.exe 2
C:\Batch>set OPT="C:\Program Files\Microsoft MPI\bin"
C:\Batch>"C:\Program Files\Microsoft MPI\bin"\mpiexec -n 2 test.exe
C:\Batch>link --help Usage: link FILE1 FILE2 or: link OPTION Call the link function to create a link named FILE2 to an existing FILE1.
--help display this help and exit --version output version information and exitGNU coreutils online help: https://www.gnu.org/software/coreutils/ Report any translation bugs to https://translationproject.org/team/ Full documentation https://www.gnu.org/software/coreutils/link or available locally via: info '(coreutils) link invocation'
C:\Batch>
Edit2: Below is the response from CMD when I tried to run the batch file manually one by one (the first line has no response):
C:\Batch>rem ifort -c %1.f90 /traceback /check:all /Qparallel -I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include\intel
C:\Batch>ifort -c %1.f90 /Qparallel /O3 -I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include\intel Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on IA-32, Version 2021.6.0 Build 20220226_000000 Copyright (C) 1985-2022 Intel Corporation. All rights reserved.
fortcom: Severe: No such file or directory
... file is '%1.f90' compilation aborted for %1.f90 (code 1)
Note: I also tried changing all 1.f90 to test.f90, still the same result appear
Many thanks for your help~
mpirun? Please follow minimal reproducible example and show us some complete code, the exact commands you execute and the details of what happened (does it hang? some error messages?).mpifort) instead of the Fortran compiler (e.g.gfortran). If you do not use the wrappers, try runningmpifort --showmeto list the directories and libraries you need to manually include.