Discussion:
MPI_Barrier generates a segfault
(too old to reply)
xalbert76
2009-01-20 02:31:29 UTC
Permalink
Dear all.

My fortran program gives me a segfault when calling MPI_BARRIER. Could
somebody explain me why this is so and possibly how I can avoid it ?
Below is a simple code that reproduces this error. If I comment out
the lines with "if (my_rank==0) then" and "end if" everything is fine.
Why is that so ? I am using:

MPICH2 Version: 1.0.6
MPICH2 Release date: Unknown, built on Wed Oct 29 20:37:18 MDT 2008
MPICH2 Device: ch3:sock
MPICH2 configure:
MPICH2 CC: gcc -O2
MPICH2 CXX: c++ -O2
MPICH2 F77: g77 -O2
MPICH2 F90: ifort -O2
MPICH2 Patch level: none

Thank you,

Roman

---

program BARRIER

implicit none
include "mpif.h"

integer :: ierr, nproc, my_rank

call MPI_INIT(ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nproc, ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, my_rank, ierr)

if (my_rank==0) then
write(*,'("This is process number ",i2)') my_rank
end if

call MPI_BARRIER(MPI_COMM_WORLD)
call MPI_FINALIZE(ierr)

end program BARRIER
Michael Hofmann
2009-01-20 07:40:18 UTC
Permalink
Post by xalbert76
program BARRIER
implicit none
include "mpif.h"
integer :: ierr, nproc, my_rank
call MPI_INIT(ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, nproc, ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, my_rank, ierr)
if (my_rank==0) then
write(*,'("This is process number ",i2)') my_rank
end if
call MPI_BARRIER(MPI_COMM_WORLD)
^
"ierr" is missing!
Post by xalbert76
call MPI_FINALIZE(ierr)
end program BARRIER
Loading...