Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill trailing whitespaces in teshsuite/smpi/{isp,mpich3-test}.
[simgrid.git] / teshsuite / smpi / mpich3-test / f77 / attr / commattr2f.f
1 C -*- Mode: Fortran; -*-
2 C
3 C  (C) 2003 by Argonne National Laboratory.
4 C      See COPYRIGHT in top-level directory.
5 C  This is a modified version of commattrf.f that uses two of the
6 C  default functions
7 C
8       program main
9       implicit none
10       include 'mpif.h'
11       integer errs, ierr
12       include 'attraints.h'
13       integer comm1, comm2
14       integer keyval
15       logical flag
16 C
17 C The only difference between the MPI-2 and MPI-1 attribute caching
18 C routines in Fortran is that the take an address-sized integer
19 C instead of a simple integer.  These still are not pointers,
20 C so the values are still just integers.
21 C
22       errs      = 0
23       call mtest_init( ierr )
24       call mpi_comm_dup( MPI_COMM_WORLD, comm1, ierr )
25 C
26       extrastate = 1001
27       call mpi_comm_create_keyval( MPI_COMM_DUP_FN,
28      &                             MPI_COMM_NULL_DELETE_FN, keyval,
29      &                             extrastate, ierr )
30       flag = .true.
31       call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
32       if (flag) then
33          errs = errs + 1
34          print *, ' get attr returned true when no attr set'
35       endif
36
37       valin = 2003
38       call mpi_comm_set_attr( comm1, keyval, valin, ierr )
39       flag = .false.
40       valout = -1
41       call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
42       if (valout .ne. 2003) then
43          errs = errs + 1
44          print *, 'Unexpected value (should be 2003)', valout,
45      &            ' from attr'
46       endif
47
48       valin = 2001
49       call mpi_comm_set_attr( comm1, keyval, valin, ierr )
50       flag = .false.
51       valout = -1
52       call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
53       if (valout .ne. 2001) then
54          errs = errs + 1
55          print *, 'Unexpected value (should be 2001)', valout,
56      &            ' from attr'
57       endif
58
59 C
60 C Test the copy function
61       valin = 5001
62       call mpi_comm_set_attr( comm1, keyval, valin, ierr )
63       call mpi_comm_dup( comm1, comm2, ierr )
64       flag = .false.
65       call mpi_comm_get_attr( comm1, keyval, valout, flag, ierr )
66       if (valout .ne. 5001) then
67          errs = errs + 1
68          print *, 'Unexpected output value in comm ', valout
69       endif
70       flag = .false.
71       call mpi_comm_get_attr( comm2, keyval, valout, flag, ierr )
72       if (valout .ne. 5001) then
73          errs = errs + 1
74          print *, 'Unexpected output value in comm2 ', valout
75       endif
76 C Test the delete function
77       call mpi_comm_free( comm2, ierr )
78 C
79 C Test the attr delete function
80       call mpi_comm_dup( comm1, comm2, ierr )
81       valin      = 6001
82       extrastate = 1001
83       call mpi_comm_set_attr( comm2, keyval, valin, ierr )
84       call mpi_comm_delete_attr( comm2, keyval, ierr )
85       flag = .true.
86       call mpi_comm_get_attr( comm2, keyval, valout, flag, ierr )
87       if (flag) then
88          errs = errs + 1
89          print *, ' Delete_attr did not delete attribute'
90       endif
91       call mpi_comm_free( comm2, ierr )
92 C
93       ierr = -1
94       call mpi_comm_free_keyval( keyval, ierr )
95       if (ierr .ne. MPI_SUCCESS) then
96          errs = errs + 1
97          call mtestprinterror( ierr )
98       endif
99       call mpi_comm_free( comm1, ierr )
100
101       call mtest_finalize( errs )
102       call mpi_finalize( ierr )
103       end