tags:

views:

41

answers:

1

my os is ubuntu

i downloaded mpich by synaptic

then i try to compile a code:

ifort hello.f

i get the error message:

Cannot open include file 'mpif.h'

it seems that it cannot find mpif.h

how to fix it?

+1  A: 

Your compiler cannot find the include file when it reads your source file. I don't have access to my development platform right now but, from memory, the file is in a location such as

MPICH_ROOT/include/ARCH/

You'll have to figure out what MPICH_ROOT and ARCH are on your machinery; note that they are NOT environment variables, they're just placeholders I've chosen to explain matters. If all else fails, find the root of the directory structure in which mpich is installed and execute

find . -name mpif.h

Don't be surprised if there are multiple occurrences of the file for different variations of architecture and compiler (eg ifort 32-bit, gfortran 64-bit, etc).

Once you've located the file modify your compilation command (better yet, write a makefile) to something like

ifort -I/path/to/file/to/include/ hello.f

While you are searching look also for an mpi.mod file. Replacing

include 'mpif.h'

with

use mpi

is probably a good idea.

High Performance Mark