Unable to open include file: mpif.h


I have met this problem many times. Sometimes I just recompile and the problem is gone for no reason, but of course sometimes it is not.
Using the full path can avoid this, but I do include this when preprocesing like
cpp -traditional -DLinux -P -I/usr/netcdf-3.6.0-p1/include/ -I/usr/local/mvapich/include/ read_inp.F | ./mpc > read_inp.f

Can anybody explain to me what causes this?



Hi Yisen,

Unless a header file is located in a standard location, such as /usr/include, ‘cpp’ doesn’t know where to find the file. The “-I” flag tells cpp to also look for header files in the “” directory. Most compilers use the same “-I” flag but may also add more directories in which to search by default. Also, wrapper scripts, such as mpif90, may include even more search directories.

Hope this helps,