Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Trying to compile an MPI programm

  1. Oct 12, 2014 #1
    Hello, I am relatively new user to Linux system (ubuntu 12.04) and I am trying learn myself parallel programming. At the moment I am trying to run a simple MPI "Hello" programm :

    program example1

    !--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
    • I have downloaded from the synaptic packahe the mpich2.
    • the location of mpif.h is /usr/include/mpich2/mpif.h
    My programms name is "test1.f95" and i can't compile it so far. I have looked around the forums but nothing works. I have tryied:

    • f95 test1.f95 -o new -L/usr/include/mpich2/mpif.h
    • I have also included the compiler to look in this directory: export PATH=$PATH:/usr/include/mpich2
    But i keep getting the error: test1.f95:4: Error: Can't open included file 'mpif.h'

    If it helps the directory of my programs document program is "/home/sketos/Desktop/parallel programming "

    Is there something wrong with my compiler cause i have been using fortran quite a lot ...

    Sorry for the silly question but i can't figure out what is wrong
     
  2. jcsd
  3. Oct 12, 2014 #2

    jedishrfu

    Staff: Mentor

    Have you tried the -I option ( that's the capital letter I) and the directory containing the missing header file mpif.h
     
  4. Oct 12, 2014 #3
    yeah i have tried: f95 test1.f95 -o new -L/usr/include/mpich2/mpif.h -I mpif.h as well and i get the same error
     
  5. Oct 12, 2014 #4

    jedishrfu

    Staff: Mentor

    The -I option means you place the directory path of where the mpif.h file is located not the file itself.
     
  6. Oct 12, 2014 #5
    Ooo that's the same with -L , i just tried it and unfortunately the same result pop-up
     
  7. Oct 12, 2014 #6

    Mark44

    Staff: Mentor

    Just a guess here, but I think the -L switch should have the directory that contains the lib files, and the -I switch should have the directory that contains the include files. They shouldn't be in the same directories.

    Also, it seems to me that Fortran programs don't normally use header files (*.h). Include files (.h file extension) are more the norm in C and C++ programs.
     
  8. Oct 12, 2014 #7

    Mark44

    Staff: Mentor

    Also, this is a continuation of the thread you started a little while ago. Instead of starting a new thread, you should have continued posting in the older thread. I responded in that thread, but you didn't reply in it.
     
  9. Oct 12, 2014 #8

    Mark44

    Staff: Mentor

    Have you looked at this page - http://www.mpich.org/documentation/guides/ ?
    The first three links on the page should be helpful - Installer's Guide, User's Guide, README.

    There is also a section with links to tutorials on the page whose link I gave.
     
  10. Oct 12, 2014 #9

    DrClaude

    User Avatar

    Staff: Mentor

    That's a quirk of MPI. It is a Fortran file (hence the "f" in mpif), but they gave it a .h extension anyway.
     
  11. Oct 13, 2014 #10
    i tried to compile it with " mpif90 test1.f95 -o new "

    That way i dont get an error but it's not working as a parallel code ... for instance the result i get on terminal is:

    Process 0 of 1 is alive

    any thoughts on that? Thank a lot!!!!
     
  12. Oct 13, 2014 #11

    Mark44

    Staff: Mentor

    Add some debugging code. Each of the MPI subroutines you call has a parameter named ierr, which I'm guessing gets set with a value after the subroutine returns. You'll need to look at the MPI documentation to see what the values represent, although if everything went fine, ierr is probably set to 0.

    Add code to print the value of ierr after each subroutine call, and see what that tells you.
     
  13. Oct 14, 2014 #12

    DrClaude

    User Avatar

    Staff: Mentor

    What command are you using to launch your program?
     
  14. Oct 15, 2014 #13
    I was trying to lanch it by : ./new

    Now I tryied using : mpiexec -n 4 ./new and it worked!! THANK YOU ALL FOR YOUR HELP during the whole post and for your patience !!!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Trying to compile an MPI programm
  1. MPI in Fortran (Replies: 2)

  2. MPI Bcast (Replies: 3)

Loading...