Message Passing interface introductory question

Click For Summary

Discussion Overview

The discussion revolves around troubleshooting issues related to compiling a basic MPI (Message Passing Interface) program in Fortran. Participants are exploring problems with file inclusion and linking during the compilation process.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant encounters an error indicating that the compiler cannot find the included file 'mpif.h' and questions whether additional installations are needed.
  • Another participant suggests checking if the folder containing 'mpif.h' is in the include path, as the compiler requires access to this file.
  • A participant provides a command to locate 'mpif.h' and discusses how to include the correct directory in the compiler's search path using the -I flag.
  • Subsequent issues arise when the participant reports an "undefined reference" error for MPI subroutines, suggesting a potential problem with the linker not finding the necessary MPI library code.
  • One participant notes that Fortran typically does not use include files in the same way as C-based languages, indicating that the problem may lie in the absence of the library code for MPI routines.

Areas of Agreement / Disagreement

Participants express varying opinions on the nature of the errors encountered, with some focusing on file inclusion issues while others emphasize linking problems. No consensus is reached regarding the exact cause of the compilation errors.

Contextual Notes

There are unresolved assumptions regarding the specific MPI implementation being used and the environment setup, which may affect the compilation process.

sketos
Messages
55
Reaction score
0
Hello,

I have just started to learn myself parallel programming specifically MPI. I know that this is going to be a silly question. I am trying to run the most basic 'hello world' program :


program example1
implicit none
!--Include the mpi header file
include 'mpif.h'
integer ierr,myid,numprocs
integer irc
!--Initialize MPI
call MPI_INIT( ierr )
!--Who am I? --- get my rank=myid
call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
!--How many processes in the global group?
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
print *, "Process ",myid," of ",numprocs," is alive"
!--Finalize MPI
call MPI_FINALIZE(irc)
stop
end

to compile ( test.f95 in my file's name )
f95 test.95 -o new
But i get the Error: Can't open included file 'mpif.h'

What is going on exactly?? is there something missing that i have to install??

Is there something wrong with the way i am trying to compile it ( if there was no error i should just type mpirun -np 3 new)

Sorry for the silly question!​

 
Technology news on Phys.org
Is the folder containing the file 'mpif.h' in your include path? If the compiler can't find the file named 'mpif.h' then it'll probably throw an error that looks like that.
 
By typing in the command line " whereis mpif.h " i get :

mpif: /usr/bin/mpif90.mpich2 /usr/bin/mpif77.mpich2 /usr/bin/X11/mpif90.mpich2 /usr/bin/X11/mpif77.mpich2

how exactly can i include a path??

*( My expression in the post was wrong ... by folder i meant document's name )
 
Try "locate mpif.h" instead. whereis doesn't really work that way. It looks from your first post that you're using the SunStudio f95 compiler. From Oracle's documentation page, you can use the compiler flag -I ( that's an an uppercase i ) to include directories in your search path. So for example:
Code:
f95 foo.bar -o foo -I /directory-path-containing-mpif.h/
 
Thanks a lot!

Unfortunately the problems keep coming! Now that i try to compile it that way i get: undefined reference to `mpi_init_'

and also the same error for the other MPI subroutines.
 
sketos said:
Thanks a lot!

Unfortunately the problems keep coming! Now that i try to compile it that way i get: undefined reference to `mpi_init_'

and also the same error for the other MPI subroutines.
My guess is that the compiler/linker can't find the lib code for the MPI routines. Fortran doesn't ordinarily use include files (that I'm aware of), but the C-based languages do. The header files contain function declarations (and a few other things), but the code for the functions typically resides in a library, either static (usually *.lib) or dynamic (*.dll in Windows). If the linker is unable to find the lib code, you'll get an error like the one you show.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 54 ·
2
Replies
54
Views
5K