Debian Codegraph @

test/mpi/f77/rma/winaccf.f

raw
1 C
2 C Copyright (C) by Argonne National Laboratory
3 C See COPYRIGHT in top-level directory
4 C
5
6 program main
7 implicit none
8 include 'mpif.h'
9 integer ierr, errs
10 integer win, intsize
11 integer left, right, rank, size
12 integer nrows, ncols
13 parameter (nrows=25,ncols=10)
14 integer buf(1:nrows,0:ncols+1)
15 integer comm, ans
16 integer i, j
17 logical mtestGetIntraComm
18 C Include addsize defines asize as an address-sized integer
19 include 'addsize.h'
20
21 errs = 0
22 call mtest_init( ierr )
23
24 call mpi_type_size( MPI_INTEGER, intsize, ierr )
25 do while( mtestGetIntraComm( comm, 2, .false. ) )
26 asize = nrows * (ncols + 2) * intsize
27 call mpi_win_create( buf, asize, intsize * nrows,
28 & MPI_INFO_NULL, comm, win, ierr )
29
30 call mpi_comm_size( comm, size, ierr )
31 call mpi_comm_rank( comm, rank, ierr )
32 left = rank - 1
33 if (left .lt. 0) then
34 left = MPI_PROC_NULL
35 endif
36 right = rank + 1
37 if (right .ge. size) then
38 right = MPI_PROC_NULL
39 endif
40 C
41 C Initialize the buffer
42 do i=1,nrows
43 buf(i,0) = -1
44 buf(i,ncols+1) = -1
45 enddo
46 do j=1,ncols
47 do i=1,nrows
48 buf(i,j) = rank * (ncols * nrows) + i + (j-1) * nrows
49 enddo
50 enddo
51 call mpi_win_fence( MPI_MODE_NOPRECEDE, win, ierr )
52 C
53 asize = ncols + 1
54 call mpi_accumulate( buf(1,1), nrows, MPI_INTEGER,
55 & left, asize,
56 & nrows, MPI_INTEGER, MPI_SUM, win, ierr )
57 asize = 0
58 call mpi_accumulate( buf(1,ncols), nrows, MPI_INTEGER, right,
59 & asize, nrows, MPI_INTEGER, MPI_SUM, win, ierr )
60 C
61 call mpi_win_fence( MPI_MODE_NOSTORE + MPI_MODE_NOPUT +
62 & MPI_MODE_NOSUCCEED, win, ierr )
63 C
64 C Check the results
65 if (left .ne. MPI_PROC_NULL) then
66 do i=1, nrows
67 ans = rank * (ncols * nrows) - nrows + i - 1
68 if (buf(i,0) .ne. ans) then
69 errs = errs + 1
70 if (errs .le. 10) then
71 print *, ' buf(',i,',0) = ', buf(i,0)
72 endif
73 endif
74 enddo
75 endif
76 if (right .ne. MPI_PROC_NULL) then
77 do i=1, nrows
78 ans = (rank + 1) * (ncols * nrows) + i - 1
79 if (buf(i,ncols+1) .ne. ans) then
80 errs = errs + 1
81 if (errs .le. 10) then
82 print *, ' buf(',i,',',ncols+1,') = ',
83 & buf(i,ncols+1)
84 endif
85 endif
86 enddo
87 endif
88 call mpi_win_free( win, ierr )
89 call mtestFreeComm( comm )
90 enddo
91
92 call mtest_finalize( errs )
93 end