Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove f77 attr tests
[simgrid.git] / teshsuite / smpi / mpich3-test / f77 / attr / typeattrf.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
6       program main
7       implicit none
8       include 'mpif.h'
9       integer errs, ierr
10       include 'attraints.h'
11       integer comm
12       integer type1, type2
13       integer curcount, keyval
14       logical flag
15       external mycopyfn, mydelfn
16       integer callcount, delcount
17       common /myattr/ callcount, delcount
18 C
19 C The only difference between the MPI-2 and MPI-1 attribute caching
20 C routines in Fortran is that the take an address-sized integer
21 C instead of a simple integer.  These still are not pointers,
22 C so the values are still just integers. 
23 C
24       errs      = 0
25       callcount = 0
26       delcount  = 0
27       call mtest_init( ierr )
28
29 C Attach an attribute to a predefined object
30       type1 = MPI_INTEGER
31       extrastate = 1001
32       call mpi_type_create_keyval( mycopyfn, mydelfn, keyval, 
33      &                             extrastate, ierr )
34       flag = .true.
35       call mpi_type_get_attr( type1, keyval, valout, flag, ierr )
36       if (flag) then
37          errs = errs + 1
38          print *, ' get attr returned true when no attr set'
39       endif
40
41       valin = 2003
42       call mpi_type_set_attr( type1, keyval, valin, ierr )
43       flag = .false.
44       valout = -1
45       call mpi_type_get_attr( type1, keyval, valout, flag, ierr )
46       if (valout .ne. 2003) then
47          errs = errs + 1
48          print *, 'Unexpected value (should be 2003)', valout, 
49      &            ' from attr'
50       endif
51       
52       valin = 2001
53       call mpi_type_set_attr( type1, keyval, valin, ierr )
54       flag = .false.
55       valout = -1
56       call mpi_type_get_attr( type1, keyval, valout, flag, ierr )
57       if (valout .ne. 2001) then
58          errs = errs + 1
59          print *, 'Unexpected value (should be 2001)', valout, 
60      &            ' from attr'
61       endif
62       
63 C
64 C Test the copy function
65       valin = 5001
66       call mpi_type_set_attr( type1, keyval, valin, ierr )
67       call mpi_type_dup( type1, type2, ierr )
68       flag = .false.
69       call mpi_type_get_attr( type1, keyval, valout, flag, ierr )
70       if (valout .ne. 5001) then
71          errs = errs + 1
72          print *, 'Unexpected output value in type ', valout
73       endif
74       flag = .false.
75       call mpi_type_get_attr( type2, keyval, valout, flag, ierr )
76       if (valout .ne. 5003) then
77          errs = errs + 1
78          print *, 'Unexpected output value in type2 ', valout
79       endif
80 C Test the delete function      
81       curcount = delcount
82       call mpi_type_free( type2, ierr )
83       if (delcount .ne. curcount + 1) then
84          errs = errs + 1
85          print *, ' did not get expected value of delcount ', 
86      &          delcount, curcount + 1
87       endif
88 C
89 C Test the attr delete function
90       call mpi_type_dup( type1, type2, ierr )
91       valin      = 6001
92       extrastate = 1001
93       call mpi_type_set_attr( type2, keyval, valin, ierr )
94       delcount   = 0
95       call mpi_type_delete_attr( type2, keyval, ierr )
96       if (delcount .ne. 1) then
97          errs = errs + 1
98          print *, ' Delete_attr did not call delete function'
99       endif
100       flag = .true.
101       call mpi_type_get_attr( type2, keyval, valout, flag, ierr )
102       if (flag) then
103          errs = errs + 1
104          print *, ' Delete_attr did not delete attribute'
105       endif
106       call mpi_type_free( type2, ierr )
107
108       ierr = -1
109       call mpi_type_free_keyval( keyval, ierr )
110       if (ierr .ne. MPI_SUCCESS) then
111          errs = errs + 1
112          call mtestprinterror( ierr )
113       endif
114
115       call mtest_finalize( errs )
116       call mpi_finalize( ierr )
117       end
118 C
119       subroutine mycopyfn( oldtype, keyval, extrastate, valin, valout,
120      &                     flag, ierr )
121       implicit none
122       include 'mpif.h'
123       integer oldtype, keyval, ierr
124       include 'attraints.h'
125       logical flag
126       integer callcount, delcount
127       common /myattr/ callcount, delcount
128 C increment the attribute by 2
129       valout = valin + 2
130       callcount = callcount + 1
131       if (extrastate .eq. 1001) then
132          flag = .true.
133          ierr = MPI_SUCCESS
134       else
135          print *, ' Unexpected value of extrastate = ', extrastate
136          flag = .false.
137          ierr = MPI_ERR_OTHER
138       endif
139       end
140 C
141       subroutine mydelfn( type, keyval, val, extrastate, ierr )
142       implicit none
143       include 'mpif.h'
144       integer type, keyval, ierr
145       include 'attraints.h'
146       integer callcount, delcount
147       common /myattr/ callcount, delcount
148       delcount = delcount + 1
149       if (extrastate .eq. 1001) then
150          ierr = MPI_SUCCESS
151       else
152          print *, ' Unexpected value of extrastate = ', extrastate
153          ierr = MPI_ERR_OTHER
154       endif
155       end