EDmodel / ED2

Ecosystem Demography Model
78 stars 112 forks source link

Can't find mpif.h and many other header files. #15

Open hamiddashti opened 9 years ago

hamiddashti commented 9 years ago

I am trying to compile the ED with mpich and hdf5 using the GFORTRAN include file. I am new to these types of the model. By the way when i try ./instal.sh the error is compiler can not find the mpif.h and some other include files residing in /ED/src/mpi/ed_empass_init.f90 and /ED/utils/utils_c.c . Do you have any idea what could be the possible reason for that?

Thanks, hamid

rgknox commented 9 years ago

Hi Hamid,

I think the easiest solution to this problem is to use the "mpif90" wrapper function that calls gfortran. A wrapper is kind of like an alias, that makes a compilcated command very simple. For instance, I use openmpi for MPI communications, and it is built with gfortran. If I execute the command "mpif90 -show" in my terminal window, it will show me what it's equivalent command string is, as if it was passed to compile a program:

rgknox@eddi:$ mpif90 -show

gfortran -I/home/rgknox/local/openmpi-1.8.1/include -pthread -I/home/rgknox/local/openmpi-1.8.1/lib -Wl,-rpath -Wl,/home/rgknox/local/openmpi-1.8.1/lib -Wl,--enable-new-dtags -L/home/rgknox/local/openmpi-1.8.1/lib -lmpi_usempi -lmpi_mpifh -lmpi

All that stuff that comes after the gfortran command tell the compiler where to find external libraries and how exactly to compile. So you need to work with your system administrator to find out what type of MPI is available on your system, and once you have identified that you must have the binaries (mpif90) and the libraries that come with it, in your path.

See below I have the F_COMP variable in my include.mk.opt file set to mpif90, and the C_COMP variable set to mpicc.

F_COMP=mpif90 F_OPTS=-g -ffree-line-length-none -fno-whole-file -O2 C_COMP=mpicc C_OPTS=-g -O2 LOADER=mpif90 LOADER_OPTS=${F_OPTS} C_LOADER=mpicc LIBS= MOD_EXT=mod

Note that you will run into a similar issue when the build process tries to incorporate the HDF5 libraries and functionality. In this case you have to make sure that the HDF5_INCS variable and HDF5_LIBS variable are set to the correct path on your machine. See http://www.hdfgroup.org/HDF5/ for more info.

rgknox commented 9 years ago

Another comment:

For some reason, the build process will tell you it can't find mpif.h and some other libraries, but these are just false positives and can be ignored. This is generated during my compile:

./generate_deps.sh ../.. Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: mpif.h Can't find file: stdio.h Can't find file: math.h Can't find file: stdlib.h Can't find file: malloc/malloc.h Can't find file: sys/malloc.h Can't find file: malloc.h Can't find file: stdlib.h Can't find file: errno.h Can't find file: string.h Can't find file: ctype.h Can't find file: dirent.h Can't find file: string.h === Finished dependencies ===

Do you get any specific error messages during compile time?

hamiddashti commented 9 years ago

Thanks for your response. Actually i get the " Can't find file: mpif.h " error when i am trying to compile the ED model downloaded from Moorcroft Lab website. But when i compile the BRAMS version downloaded from GitHub i don't get any more that error. however in BRAMS version the compiling error is something related to "Landuse_input.f90" as follow: . . . cp -f /home/hamid/opt/source/ED2-master/BRAMS/src/mksfc/mem_mksfc.f90 mem_mksfc.f90 mpif90 -c -O3 -ffree-line-length-none -I/home/hamid/opt/source/ED2-master/BRAMS/src/include -I/home/hamid/opt/source/hdf5-1.8.14/build/include -DRAMS_MPI mem_mksfc.f90 rm -f mem_mksfc.f90 cp -f /home/hamid/opt/source/ED2-master/BRAMS/src/mksfc/landuse_input.F90 landuse_input.F90 mpif90 -c -DUSE_INTERF=1 -DUSENC=0 -DPC_GFORTRAN -DUSE_HDF4= -DUSE_HDF5=1 -DUSE_MPIWTIME=1 -DCOUPLED -O3 -ffree-line-length-none -I/home/hamid/opt/source/ED2-master/BRAMS/src/include -I/home/hamid/opt/source/hdf5-1.8.14/build/include -DRAMS_MPI -DUSE_COLLECTIVE_IO=0 landuse_input.F90 landuse_input.F90:1207:0: error: #if with no expression

if USE_HDF4

^ make[1]: * [landuse_input.o] Error 1 make[1]: Leaving directory `/home/hamid/opt/source/ED2-master/BRAMS/build/bin' make: * [all] Error 2

And here is my address to HDF5: HDF5_INCS=-I/home/hamid/opt/source/hdf5-1.8.14/build/include HDF5C_INCS=-I/home/hamid/opt/source/hdf5-1.8.14/build/include HDF5_LIBS=-lz /home/hamid/opt/source/hdf5-1.8.14/build/lib/libhdf5_fortran.a \ /home/hamid/opt/source/hdf5-1.8.14/build/lib/libhdf5.a \ /home/hamid/opt/source/hdf5-1.8.14/build/lib/hdf5_hl.a \ /home/hamid/opt/source/hdf5-1.8.14/build/lib/libhdf5hl_fortran.a

Thanks

DanielNScott commented 9 years ago

This is essentially a wild guess, but it looks like the issue might be the omission of any sort of HDF4 flag I've italicized below...

cp -f /home/hamid/opt/source/ED2-master/BRAMS/src/mksfc/landuse_input.F90 landuse_input.F90 mpif90 -c -DUSE_INTERF=1 -DUSENC=0 -DPCGFORTRAN -DUSEHDF4= -DUSE_HDF5=1 -DUSE_MPIWTIME=1 -DCOUPLED -O3 -ffree-line-length-none -I/home/hamid/opt/source/ED2-master/BRAMS/src/include -I/home/hamid/opt/source/hdf5-1.8.14/build/include -DRAMS_MPI -DUSE_COLLECTIVE_IO=0 landuse_input.F90

Which is to say it looks like the compiler simply doesn't know how to interpret 'USE_HDF4'. Seems reasonable anyway.