program testFence ! this code should NOT complete since the wrong fences are called use mpi implicit none integer, parameter:: arraySize=10, maxFence=12 integer:: array1(1:arraySize), array2(1:arraySize), temp1, temp2, temp3 integer(kind=MPI_ADDRESS_KIND):: winSize, targetDisp integer:: i,j, myRank, mpierror, win_1, win_2, bytes, numPEs integer:: out call MPI_INIT(MPIerror) call mpi_comm_size(mpi_comm_world, numPEs, MPIerror) call MPI_COMM_RANK(MPI_COMM_WORLD, myRank, MPIerror) ! set where to write output to out = 6 ! create windows call mpi_type_size(mpi_integer, bytes, mpierror) winSize = size(array1) * bytes call mpi_win_create(array1, winSize, bytes, mpi_info_null, mpi_comm_world, win_1, mpierror) call mpi_win_create(array2, winSize, bytes, mpi_info_null, mpi_comm_world, win_2, mpierror) call mpi_win_fence(0, win_1, mpierror) call mpi_win_fence(0, win_2, mpierror) targetDisp = 0 if (myRank.EQ.0) then call mpi_get(temp1, 1, mpi_integer, 1, targetDisp, 1, mpi_integer, win_1, mpierror) call mpi_win_fence(0, win_1, mpierror) call mpi_get(temp2, 1, mpi_integer, 1, targetDisp, 1, mpi_integer, win_2, mpierror) call mpi_win_fence(0, win_2, mpierror) call mpi_get(temp3, 1, mpi_integer, 1, targetDisp, 1, mpi_integer, win_1, mpierror) call mpi_win_fence(0, win_1, mpierror) elseif (myRank.EQ.1) then call mpi_get(temp1, 1, mpi_integer, 0, targetDisp, 1, mpi_integer, win_1, mpierror) call mpi_win_fence(0, win_1, mpierror) call mpi_get(temp2, 1, mpi_integer, 0, targetDisp, 1, mpi_integer, win_2, mpierror) call mpi_win_fence(0, win_2, mpierror) call mpi_get(temp3, 1, mpi_integer, 0, targetDisp, 1, mpi_integer, win_2, mpierror) call mpi_win_fence(0, win_2, mpierror) end if ! free windows call mpi_win_free(win_1, mpierror) call mpi_win_free(win_2, mpierror) call mpi_finalize(mpierror) end program testFence