1 C -*- Mode: Fortran; -*-
3 C (C) 2003 by Argonne National Laboratory.
4 C See COPYRIGHT in top-level directory.
11 integer left, right, rank, size
13 parameter (nrows=25,ncols=10)
14 integer buf(1:nrows,0:ncols+1)
15 integer comm, group, group2, ans
16 integer nneighbors, nbrs(2), i, j
17 logical mtestGetIntraComm
19 C Include addsize defines asize as an address-sized integer
23 call mtest_init( ierr )
25 call mpi_type_size( MPI_INTEGER, intsize, ierr )
26 do while( mtestGetIntraComm( comm, 2, .false. ) )
27 asize = nrows * (ncols + 2) * intsize
28 call mpi_win_create( buf, asize, intsize * nrows,
29 & MPI_INFO_NULL, comm, win, ierr )
31 C Create the group for the neighbors
32 call mpi_comm_size( comm, size, ierr )
33 call mpi_comm_rank( comm, rank, ierr )
39 nneighbors = nneighbors + 1
40 nbrs(nneighbors) = left
43 if (right .ge. size) then
46 nneighbors = nneighbors + 1
47 nbrs(nneighbors) = right
49 call mpi_comm_group( comm, group, ierr )
50 call mpi_group_incl( group, nneighbors, nbrs, group2, ierr )
51 call mpi_group_free( group, ierr )
53 C Initialize the buffer
60 buf(i,j) = rank * (ncols * nrows) + i + (j-1) * nrows
63 call mpi_win_post( group2, 0, win, ierr )
64 call mpi_win_start( group2, 0, win, ierr )
67 call mpi_put( buf(1,1), nrows, MPI_INTEGER, left, asize,
68 & nrows, MPI_INTEGER, win, ierr )
70 call mpi_put( buf(1,ncols), nrows, MPI_INTEGER, right, asize,
71 & nrows, MPI_INTEGER, win, ierr )
73 call mpi_win_complete( win, ierr )
76 call mpi_win_test( win, flag, ierr )
80 if (left .ne. MPI_PROC_NULL) then
82 ans = rank * (ncols * nrows) - nrows + i
83 if (buf(i,0) .ne. ans) then
85 if (errs .le. 10) then
86 print *, ' buf(',i,',0) = ', buf(i,0),
92 if (right .ne. MPI_PROC_NULL) then
94 ans = (rank+1) * (ncols * nrows) + i
95 if (buf(i,ncols+1) .ne. ans) then
97 if (errs .le. 10) then
98 print *, ' buf(',i,',',ncols+1,') = ',
99 & buf(i,ncols+1), ' expected ', ans
104 call mpi_group_free( group2, ierr )
105 call mpi_win_free( win, ierr )
106 call mtestFreeComm( comm )
109 call mtest_finalize( errs )
110 call mpi_finalize( ierr )