Can't Find Mpif. H Compiling Error?

i have download a big ecosystem model (Ecosystem Demography) which must e compiled in linux and it uses MPI and hdf5. i have installed the mpich (on centOS 7) to compile the ED model with Gfortran compiler. but it gives me the famous error

Can't find file: mpif.h

i have looked for the file by "which mpif.h" and it returns nothing so i set the PATH as follow :

PATH=/home/hamid/edpacks/mpich-install/bin:$PATH
export PATH

now which mpif.h returns the path to the file but again when i try to ./install the model it give me the same error. problem is i don't know how to set this path and also path to mpich from inside the model. Do i have to set the path from include file or makefile?

7

2 Answers

If for some bizarre reason the mpif.h file is indeed under

/home/hamid/edpacks/mpich-install/bin

then you need to move it to

/home/hamid/edpacks/mpich-install/include

since this

PAR_INCS=-I$(MPI_PATH)/include 

points to that directory so the compiler will look for header files (e.g. mpif.h) in that directory.

(Btw increasing the number of processors doesn't automatically decrease the speed of your program; it depends on how the program is written. Also, if you're running this on your laptop, which most likely doesn't have more than 4 cores then increasing the processor count beyond that will certainly slow down even a hello-world MPI program.)

You cannot search for .h files using which, that one only looks for executable files ("which - shows the full path of (shell) commands"). You must use other commands like find, locate or just your desktop search.

The file should be in some include directory somewhere. When compiling the Fortran program by the correct MPI compiler wrapper (mpif90, mpifort or similar) the library should be included automatically. If it is not, you can use the -Idirectory_name compiler flag to include it manually.

If your Makefile includes directories in some environmental variable, as George shows, you can just add the directory name to that environment variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest