×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Fortran and MPI

Fortran and MPI

Fortran and MPI

(OP)
Hi boys.

I'm trying to call a barrier in a MPI program with Fortran, but I don't know how do it.

I don't have any problem with the main program, but i have a lot of problems with the comunicator when I have tried to do it in a Fortran Routine. I don't know how I can do it. Can you give me an example?

Thanks in advande

RE: Fortran and MPI

The barrier basically stops execution until all the processes call it.

CODE --> barrier.f90

program main
include 'mpif.h'
integer ierr
integer rank, sleepsec
character(10):: now

! Initialize the MPI environment
call MPI_Init(ierr)

! Find the node
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)

sleepsec = 5 * rank
call date_and_time(time=now)
print *, rank, ' sleeping for ', sleepsec, ' from ', now
call SLEEP(sleepsec)
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
call date_and_time(time=now)
print *, rank, ' awake ', now
call MPI_FINALIZE(ierr)
end 

CODE --> build

mpif90 -o barrier barrier.f90 

CODE --> run

mpirun -n 4 barrier 
What you will see is that the different processes sleep for differing numbers of seconds but they all only awake when the longest sleeping process callse MPI_BARRIER.

RE: Fortran and MPI

The example uses gfortran and the open MPI package that comes with Linux. You didn't specify which compiler/operating system you were using with MPI.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close