1 C -*- Mode: Fortran; -*-
3 C (C) 2003 by Argonne National Laboratory.
4 C See COPYRIGHT in top-level directory.
9 integer errs, ierr, code(2), newerrclass, eclass
10 character*(MPI_MAX_ERROR_STRING) errstring
11 integer comm, rlen, intsize
16 CF90 SUBROUTINE myerrhanfunc(vv0,vv1)
20 integer myerrhan, qerr
22 integer callcount, codesSeen(3)
23 common /myerrhan/ callcount, codesSeen
27 call mtest_init( ierr )
29 C Setup some new codes and classes
30 call mpi_add_error_class( newerrclass, ierr )
31 call mpi_add_error_code( newerrclass, code(1), ierr )
32 call mpi_add_error_code( newerrclass, code(2), ierr )
33 call mpi_add_error_string( newerrclass, "New Class", ierr )
34 call mpi_add_error_string( code(1), "First new code", ierr )
35 call mpi_add_error_string( code(2), "Second new code", ierr )
37 call mpi_win_create_errhandler( myerrhanfunc, myerrhan, ierr )
39 C Create a new communicator so that we can leave the default errors-abort
40 C on MPI_COMM_WORLD. Use this comm for win_create, just to leave a little
41 C more separation from comm_world
43 call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
44 call mpi_type_size( MPI_INTEGER, intsize, ierr )
46 call mpi_win_create( buf, asize, intsize, MPI_INFO_NULL,
49 call mpi_win_set_errhandler( win, myerrhan, ierr )
51 call mpi_win_get_errhandler( win, qerr, ierr )
52 if (qerr .ne. myerrhan) then
54 print *, ' Did not get expected error handler'
56 call mpi_errhandler_free( qerr, ierr )
57 C We can free our error handler now
58 call mpi_errhandler_free( myerrhan, ierr )
60 call mpi_win_call_errhandler( win, newerrclass, ierr )
61 call mpi_win_call_errhandler( win, code(1), ierr )
62 call mpi_win_call_errhandler( win, code(2), ierr )
64 if (callcount .ne. 3) then
66 print *, ' Expected 3 calls to error handler, found ',
69 if (codesSeen(1) .ne. newerrclass) then
71 print *, 'Expected class ', newerrclass, ' got ',
74 if (codesSeen(2) .ne. code(1)) then
76 print *, 'Expected code ', code(1), ' got ',
79 if (codesSeen(3) .ne. code(2)) then
81 print *, 'Expected code ', code(2), ' got ',
86 call mpi_win_free( win, ierr )
87 call mpi_comm_free( comm, ierr )
89 C Check error strings while here here...
90 call mpi_error_string( newerrclass, errstring, rlen, ierr )
91 if (errstring(1:rlen) .ne. "New Class") then
93 print *, ' Wrong string for error class: ', errstring(1:rlen)
95 call mpi_error_class( code(1), eclass, ierr )
96 if (eclass .ne. newerrclass) then
98 print *, ' Class for new code is not correct'
100 call mpi_error_string( code(1), errstring, rlen, ierr )
101 if (errstring(1:rlen) .ne. "First new code") then
103 print *, ' Wrong string for error code: ', errstring(1:rlen)
105 call mpi_error_class( code(2), eclass, ierr )
106 if (eclass .ne. newerrclass) then
108 print *, ' Class for new code is not correct'
110 call mpi_error_string( code(2), errstring, rlen, ierr )
111 if (errstring(1:rlen) .ne. "Second new code") then
113 print *, ' Wrong string for error code: ', errstring(1:rlen)
116 call mtest_finalize( errs )
117 call mpi_finalize( ierr )
121 subroutine myerrhanfunc( win, errcode )
126 integer callcount, codesSeen(3)
127 character*(MPI_MAX_ERROR_STRING) errstring
128 common /myerrhan/ callcount, codesSeen
130 callcount = callcount + 1
131 C Remember the code we've seen
132 if (callcount .le. 3) then
133 codesSeen(callcount) = errcode
135 call mpi_error_string( errcode, errstring, rlen, ierr )
136 if (ierr .ne. MPI_SUCCESS) then
137 print *, ' Panic! could not get error string'
138 call mpi_abort( MPI_COMM_WORLD, 1, ierr )