Thanks for the input but it still doesn't work for me... Here's the version without MPI_IN_PLACE that does work:
program test use mpi integer :: ierr, myrank, a(2), a_loc(2) = 0 call MPI_Init(ierr) call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr) if (myrank == 0) then a_loc(1) = 1 a_loc(2) = 2 else a_loc(1) = 3 a_loc(2) = 4 endif call MPI_Allreduce(a_loc,a,2,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr) write(*,*) myrank, a(:) call MPI_Finalize(ierr) end program test $ openmpif90 test.f90 $ openmpirun -np 2 a.out 0 4 6 1 4 6 Now I'd be curious to know why your OpenMPI implementation handles MPI_IN_PLACE correctly and not mine! -- Hugo Gagnon On Fri, Sep 6, 2013, at 22:37, Tom Rosmond wrote: > Hello, > > Your syntax defining 'a' is not correct. This code works correctly. > > program test > use mpi > integer :: ierr, myrank, a(2) = 0 > call MPI_Init(ierr) > call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr) > if (myrank == 0) then > a(1) = 1 > a(2) = 2 > else > a(1) = 3 > a(2) = 4 > endif > call > MPI_Allreduce(MPI_IN_PLACE,a,2,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr) > write(*,*) myrank, a(:) > call MPI_Finalize(ierr) > end program test > > mpif90 test.f90 > mpirun -np 2 a.out > 0 4 6 > 1 4 6 > > T. Rosmond > > > > > > On Fri, 2013-09-06 at 21:27 -0400, Hugo Gagnon wrote: > > Hello, > > > > I'm trying to run this bit of code: > > > > program test > > use mpi > > integer :: ierr, myrank, a(2) = 0 > > call MPI_Init(ierr) > > call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr) > > if (myrank == 0) a(1) = 1; a(2) = 2 > > if (myrank == 1) a(1) = 3; a(2) = 4 > > call > > MPI_Allreduce(MPI_IN_PLACE,a,2,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr) > > write(*,*) myrank, a(:) > > call MPI_Finalize(ierr) > > end program test > > > > but the output is not what I'd expect: > > > > $ openmpif90 test.f90 > > $ openmpirun -np 2 a.out > > 0 0 0 > > 1 0 0 > > > > I tried a version without MPI_IN_PLACE and the call to MPI_Allreduce > > works fine in that case. Am I doing something wrong with MPI_IN_PLACE? > > I'm using OpenMPI 1.6.5 compiled with gcc 4.8.1 on Mac OS 10.8. > > > > Thanks, > > > _______________________________________________ > users mailing list > us...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/users