2

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?

Ress
  • 667
  • 1
  • 7
  • 24
  • How are you compiling your application? Are you using the MPI compiler wrappers (`mpifortran`)? – Wesley Bland Nov 05 '14 at 03:18
  • As @WesleyBland asked, are you using the MPI compiler wrappers (`mpicc`, `mpif90`, etc). Also `which` only searches your $PATH. The `mpif.h` file is a header and will be in the include directory (`/home/hamid/edpacks/mpich-install/include` in your case). – Timothy Brown Nov 05 '14 at 18:03
  • thanks; yes i am using mpicc and mipf90 and the setting in include file where i think the problem is, is as follow : (CMACH=PC_GFORTRAN F_COMP=mpif90 F_OPTS=-g -O2 -ffree-line-length-none -fno-whole-file C_COMP=mpicc C_OPTS=-g -O2 LOADER=mpif90 LOADER_OPTS=${F_OPTS} C_LOADER=mpicc LIBS=) and after that ( MPI_PATH=/home/hamid/edpacks/mpich-install PAR_INCS=-I$(MPI_PATH)/include PAR_LIBS=-L$(MPI_PATH)/lib PAR_DEFS=-DRAMS_MPI) – Ress Nov 05 '14 at 19:01
  • @HamidDashti I'm unfamiliar with ED and it's possible Makefile variables, What happens if you set `FFLAGS=$(PAR_INCS)`? As a side note are you able to build a simple `hello_world` MPI test? – Timothy Brown Nov 06 '14 at 18:36
  • actually i am new to parallel computing, so i decided to start from hello world compiling with Mpich2. here is the codes (mpicc helloworld.c -o myhello \ mpirun -nc 2 ./myhello. ) it wokrs. however i noticed by increasing the number of CPUs the wall clock time increased which i expect it to decrease?! – Ress Nov 09 '14 at 00:36
  • @HamidDashti did you ever find a solution to this problem? i am also trying to compile ED but I am running into the same problem. – Herman Toothrot Dec 15 '14 at 19:12
  • Hi No i could not find the solution unfortunately. but im still working on it. hopefully we would find the solution :) – Ress Dec 16 '14 at 19:52

2 Answers2

1

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

gomfy
  • 637
  • 8
  • 16
0

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.