1 C -*- Mode: Fortran; -*-
3 C (C) 2003 by Argonne National Laboratory.
4 C See COPYRIGHT in top-level directory.
11 integer comm, win, buf(10)
12 integer curcount, keyval
14 external mycopyfn, mydelfn
15 integer callcount, delcount
16 common /myattr/ callcount, delcount
18 C The only difference between the MPI-2 and MPI-1 attribute caching
19 C routines in Fortran is that the take an address-sized integer
20 C instead of a simple integer. These still are not pointers,
21 C so the values are still just integers.
26 call mtest_init( ierr )
27 call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
28 C Create a new window; use val for an address-sized int
30 call mpi_win_create( buf, val, 1,
31 & MPI_INFO_NULL, comm, win, ierr )
34 call mpi_win_create_keyval( mycopyfn, mydelfn, keyval,
37 call mpi_win_get_attr( win, keyval, valout, flag, ierr )
40 print *, ' get attr returned true when no attr set'
44 call mpi_win_set_attr( win, keyval, valin, ierr )
47 call mpi_win_get_attr( win, keyval, valout, flag, ierr )
48 if (valout .ne. 2003) then
50 print *, 'Unexpected value (should be 2003)', valout,
55 call mpi_win_set_attr( win, keyval, valin, ierr )
58 call mpi_win_get_attr( win, keyval, valout, flag, ierr )
59 if (valout .ne. 2001) then
61 print *, 'Unexpected value (should be 2001)', valout,
65 C Test the attr delete function
67 call mpi_win_delete_attr( win, keyval, ierr )
68 if (delcount .ne. 1) then
70 print *, ' Delete_attr did not call delete function'
73 call mpi_win_get_attr( win, keyval, valout, flag, ierr )
76 print *, ' Delete_attr did not delete attribute'
79 C Test the delete function on window free
81 call mpi_win_set_attr( win, keyval, valin, ierr )
83 call mpi_win_free( win, ierr )
84 if (delcount .ne. curcount + 1) then
86 print *, ' did not get expected value of delcount ',
87 & delcount, curcount + 1
91 call mpi_win_free_keyval( keyval, ierr )
92 if (ierr .ne. MPI_SUCCESS) then
94 call mtestprinterror( ierr )
97 C The MPI standard defines null copy and duplicate functions.
98 C However, are only used when an object is duplicated. Since
99 C MPI_Win objects cannot be duplicated, so under normal circumstances,
100 C these will not be called. Since they are defined, they should behave
101 C as defined. To test them, we simply call them here
106 call MPI_WIN_DUP_FN( win, keyval, extrastate, valin, valout,
110 print *, " Flag was false after MPI_WIN_DUP_FN"
111 else if (valout .ne. 7001) then
113 if (valout .eq. -1 ) then
114 print *, " output attr value was not copied in MPI_WIN_DUP_FN"
116 print *, " value was ", valout, " but expected 7001"
117 else if (ierr .ne. MPI_SUCCESS) then
119 print *, " MPI_WIN_DUP_FN did not return MPI_SUCCESS"
126 call MPI_WIN_NULL_COPY_FN( win, keyval, extrastate, valin, valout
130 print *, " Flag was true after MPI_WIN_NULL_COPY_FN"
131 else if (valout .ne. -1) then
134 $ " output attr value was copied in MPI_WIN_NULL_COPY_FN"
135 else if (ierr .ne. MPI_SUCCESS) then
137 print *, " MPI_WIN_NULL_COPY_FN did not return MPI_SUCCESS"
140 call mpi_comm_free( comm, ierr )
141 call mtest_finalize( errs )
142 call mpi_finalize( ierr )
145 C Note that the copyfn is unused for MPI windows, since there is
146 C (and because of alias rules, can be) no MPI_Win_dup function
147 subroutine mycopyfn( oldwin, keyval, extrastate, valin, valout,
151 integer oldwin, keyval, ierr
152 include 'attraints.h'
154 integer callcount, delcount
155 common /myattr/ callcount, delcount
156 C increment the attribute by 2
158 callcount = callcount + 1
160 C Since we should *never* call this, indicate an error
161 print *, ' Unexpected use of mycopyfn'
166 subroutine mydelfn( win, keyval, val, extrastate, ierr )
169 integer win, keyval, ierr
170 include 'attraints.h'
171 integer callcount, delcount
172 common /myattr/ callcount, delcount
173 delcount = delcount + 1
174 if (extrastate .eq. 1001) then
177 print *, ' Unexpected value of extrastate = ', extrastate