Debian Codegraph @

test/mpi/f77/attr/commattr4f.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 C
8 include 'mpif.h'
9
10 integer ierr
11 integer errs
12 logical found
13 integer comm2
14 integer key
15 include 'attraints.h'
16
17 errs = 0
18 C
19 C initialize the mpi environment
20 C
21 call mtest_init(ierr)
22
23 call mpi_comm_create_keyval(MPI_COMM_DUP_FN,
24 $ MPI_NULL_DELETE_FN,
25 $ key,
26 $ extrastate,
27 $ ierr)
28 C
29 C set a value for the attribute
30 C
31 valin = huge(valin)
32 C
33 C set attr in comm_world
34 C
35 call mpi_comm_set_attr(MPI_COMM_WORLD,
36 $ key,
37 $ valin,
38 $ ierr)
39 call mpi_comm_get_attr(MPI_COMM_WORLD,
40 $ key,
41 $ valout,
42 $ found,
43 $ ierr)
44 if (found .neqv. .true.) then
45 print *, "mpi_comm_set_attr reported key, but not found on ",
46 $ "mpi_comm_world"
47 errs = errs + 1
48 else if (valout .ne. valin) then
49 print *, "key found, but valin does not match valout"
50 print *, valout, " != ", valin
51 errs = errs + 1
52 end if
53 C
54 C dup the communicator, attribute should follow
55 C
56 call mpi_comm_dup(MPI_COMM_WORLD,
57 $ comm2,
58 $ ierr)
59 C
60 C get the value for the attribute
61 C
62 call mpi_comm_get_attr(comm2,
63 $ key,
64 $ valout,
65 $ found,
66 $ ierr)
67 if (found .neqv. .true.) then
68 print *, "mpi_comm_set_attr reported key, but not found on ",
69 $ "duped comm"
70 errs = errs + 1
71 else if (valout .ne. valin) then
72 print *, "key found, but value does not match that on ",
73 $ "mpi_comm_world"
74 print *, valout, " != ", valin
75 errs = errs + 1
76 end if
77 C
78 C free the duped communicator
79 C
80 call mpi_comm_free(comm2, ierr)
81 C
82 C free keyval
83 C
84 call mpi_comm_delete_attr(MPI_COMM_WORLD,
85 $ key, ierr)
86 call mpi_comm_free_keyval(key,
87 $ ierr)
88
89 call mtest_finalize( errs )
90
91 end