Debian Codegraph @

test/mpi/f77/attr/commattr2f.f

raw
1 C
2 C Copyright (C) by Argonne National Laboratory
3 C See COPYRIGHT in top-level directory
4 C
5
6 C This is a modified version of commattrf.f that uses two of the
7 C default functions
8 C
9 program main
10 implicit none
11 include 'mpif.h'
12 integer errs, ierr
13 include 'attraints.h'
14 integer comm1, comm2
15 integer keyval
16 logical flag
17 C
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.
22 C
23 errs = 0
24 call mtest_init( ierr )
25 call mpi_comm_dup( MPI_COMM_WORLD, comm1, ierr )
26 C
27 extrastate = 1001
28 call mpi_comm_create_keyval( MPI_COMM_DUP_FN,
29 & MPI_COMM_NULL_DELETE_FN, keyval,
30 & extrastate, ierr )
31 flag = .true.
32 call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
33 if (flag) then
34 errs = errs + 1
35 print *, ' get attr returned true when no attr set'
36 endif
37
38 valin = 2003
39 call mpi_comm_set_attr( comm1, keyval, valin, ierr )
40 flag = .false.
41 valout = -1
42 call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
43 if (valout .ne. 2003) then
44 errs = errs + 1
45 print *, 'Unexpected value (should be 2003)', valout,
46 & ' from attr'
47 endif
48
49 valin = 2001
50 call mpi_comm_set_attr( comm1, keyval, valin, ierr )
51 flag = .false.
52 valout = -1
53 call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
54 if (valout .ne. 2001) then
55 errs = errs + 1
56 print *, 'Unexpected value (should be 2001)', valout,
57 & ' from attr'
58 endif
59
60 C
61 C Test the copy function
62 valin = 5001
63 call mpi_comm_set_attr( comm1, keyval, valin, ierr )
64 call mpi_comm_dup( comm1, comm2, ierr )
65 flag = .false.
66 call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
67 if (valout .ne. 5001) then
68 errs = errs + 1
69 print *, 'Unexpected output value in comm ', valout
70 endif
71 flag = .false.
72 call mpi_comm_get_attr( comm2, keyval, valout, flag, ierr )
73 if (valout .ne. 5001) then
74 errs = errs + 1
75 print *, 'Unexpected output value in comm2 ', valout
76 endif
77 C Test the delete function
78 call mpi_comm_free( comm2, ierr )
79 C
80 C Test the attr delete function
81 call mpi_comm_dup( comm1, comm2, ierr )
82 valin = 6001
83 extrastate = 1001
84 call mpi_comm_set_attr( comm2, keyval, valin, ierr )
85 call mpi_comm_delete_attr( comm2, keyval, ierr )
86 flag = .true.
87 call mpi_comm_get_attr( comm2, keyval, valout, flag, ierr )
88 if (flag) then
89 errs = errs + 1
90 print *, ' Delete_attr did not delete attribute'
91 endif
92 call mpi_comm_free( comm2, ierr )
93 C
94 ierr = -1
95 call mpi_comm_free_keyval( keyval, ierr )
96 if (ierr .ne. MPI_SUCCESS) then
97 errs = errs + 1
98 call mtestprinterror( ierr )
99 endif
100 call mpi_comm_free( comm1, ierr )
101
102 call mtest_finalize( errs )
103 end