can't find mpif.h compiling error?

Ress picture Ress · Nov 5, 2014 · Viewed 10.4k times · Source

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?

Answer

gomfy picture gomfy · Aug 2, 2018

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.)