| 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 |
implicit none |
| 8 |
include 'mpif.h' |
| 9 |
integer errs, ierr, code(2), newerrclass, eclass |
| 10 |
character*(MPI_MAX_ERROR_STRING) errstring |
| 11 |
integer comm, rlen, intsize |
| 12 |
integer buf(10) |
| 13 |
integer win |
| 14 |
external myerrhanfunc |
| 15 |
CF90 INTERFACE |
| 16 |
CF90 SUBROUTINE myerrhanfunc(vv0,vv1) |
| 17 |
CF90 INTEGER vv0,vv1 |
| 18 |
CF90 END SUBROUTINE |
| 19 |
CF90 END INTERFACE |
| 20 |
integer myerrhan, qerr |
| 21 |
include 'addsize.h' |
| 22 |
integer callcount, codesSeen(3) |
| 23 |
common /myerrhan/ callcount, codesSeen |
| 24 |
|
| 25 |
errs = 0 |
| 26 |
callcount = 0 |
| 27 |
call mtest_init( ierr ) |
| 28 |
C |
| 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 ) |
| 36 |
C |
| 37 |
call mpi_win_create_errhandler( myerrhanfunc, myerrhan, ierr ) |
| 38 |
C |
| 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 |
| 42 |
C |
| 43 |
call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr ) |
| 44 |
call mpi_type_size( MPI_INTEGER, intsize, ierr ) |
| 45 |
asize = 10 * intsize |
| 46 |
call mpi_win_create( buf, asize, intsize, MPI_INFO_NULL, |
| 47 |
& comm, win, ierr ) |
| 48 |
C |
| 49 |
call mpi_win_set_errhandler( win, myerrhan, ierr ) |
| 50 |
|
| 51 |
call mpi_win_get_errhandler( win, qerr, ierr ) |
| 52 |
if (qerr .ne. myerrhan) then |
| 53 |
errs = errs + 1 |
| 54 |
print *, ' Did not get expected error handler' |
| 55 |
endif |
| 56 |
call mpi_errhandler_free( qerr, ierr ) |
| 57 |
C We can free our error handler now |
| 58 |
call mpi_errhandler_free( myerrhan, ierr ) |
| 59 |
|
| 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 ) |
| 63 |
|
| 64 |
if (callcount .ne. 3) then |
| 65 |
errs = errs + 1 |
| 66 |
print *, ' Expected 3 calls to error handler, found ', |
| 67 |
& callcount |
| 68 |
else |
| 69 |
if (codesSeen(1) .ne. newerrclass) then |
| 70 |
errs = errs + 1 |
| 71 |
print *, 'Expected class ', newerrclass, ' got ', |
| 72 |
& codesSeen(1) |
| 73 |
endif |
| 74 |
if (codesSeen(2) .ne. code(1)) then |
| 75 |
errs = errs + 1 |
| 76 |
print *, 'Expected code ', code(1), ' got ', |
| 77 |
& codesSeen(2) |
| 78 |
endif |
| 79 |
if (codesSeen(3) .ne. code(2)) then |
| 80 |
errs = errs + 1 |
| 81 |
print *, 'Expected code ', code(2), ' got ', |
| 82 |
& codesSeen(3) |
| 83 |
endif |
| 84 |
endif |
| 85 |
|
| 86 |
call mpi_win_free( win, ierr ) |
| 87 |
call mpi_comm_free( comm, ierr ) |
| 88 |
C |
| 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 |
| 92 |
errs = errs + 1 |
| 93 |
print *, ' Wrong string for error class: ', errstring(1:rlen) |
| 94 |
endif |
| 95 |
call mpi_error_class( code(1), eclass, ierr ) |
| 96 |
if (eclass .ne. newerrclass) then |
| 97 |
errs = errs + 1 |
| 98 |
print *, ' Class for new code is not correct' |
| 99 |
endif |
| 100 |
call mpi_error_string( code(1), errstring, rlen, ierr ) |
| 101 |
if (errstring(1:rlen) .ne. "First new code") then |
| 102 |
errs = errs + 1 |
| 103 |
print *, ' Wrong string for error code: ', errstring(1:rlen) |
| 104 |
endif |
| 105 |
call mpi_error_class( code(2), eclass, ierr ) |
| 106 |
if (eclass .ne. newerrclass) then |
| 107 |
errs = errs + 1 |
| 108 |
print *, ' Class for new code is not correct' |
| 109 |
endif |
| 110 |
call mpi_error_string( code(2), errstring, rlen, ierr ) |
| 111 |
if (errstring(1:rlen) .ne. "Second new code") then |
| 112 |
errs = errs + 1 |
| 113 |
print *, ' Wrong string for error code: ', errstring(1:rlen) |
| 114 |
endif |
| 115 |
|
| 116 |
call mtest_finalize( errs ) |
| 117 |
|
| 118 |
end |
| 119 |
C |
| 120 |
subroutine myerrhanfunc( win, errcode ) |
| 121 |
implicit none |
| 122 |
include 'mpif.h' |
| 123 |
integer win, errcode |
| 124 |
integer rlen, ierr |
| 125 |
integer callcount, codesSeen(3) |
| 126 |
character*(MPI_MAX_ERROR_STRING) errstring |
| 127 |
common /myerrhan/ callcount, codesSeen |
| 128 |
|
| 129 |
callcount = callcount + 1 |
| 130 |
C Remember the code we've seen |
| 131 |
if (callcount .le. 3) then |
| 132 |
codesSeen(callcount) = errcode |
| 133 |
endif |
| 134 |
call mpi_error_string( errcode, errstring, rlen, ierr ) |
| 135 |
if (ierr .ne. MPI_SUCCESS) then |
| 136 |
print *, ' Panic! could not get error string' |
| 137 |
call mpi_abort( MPI_COMM_WORLD, 1, ierr ) |
| 138 |
endif |
| 139 |
end |