|
Packit Service |
c5cf8c |
! This file created from f77/comm/commerrf.f with f77tof90
|
|
Packit Service |
c5cf8c |
! -*- Mode: Fortran; -*-
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
! See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
program main
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
integer errs, ierr, code(2), newerrclass, eclass
|
|
Packit Service |
c5cf8c |
character*(MPI_MAX_ERROR_STRING) errstring
|
|
Packit Service |
c5cf8c |
integer comm, rlen
|
|
Packit Service |
c5cf8c |
! external myerrhanfunc
|
|
Packit Service |
c5cf8c |
INTERFACE
|
|
Packit Service |
c5cf8c |
SUBROUTINE myerrhanfunc(vv0,vv1)
|
|
Packit Service |
c5cf8c |
INTEGER vv0,vv1
|
|
Packit Service |
c5cf8c |
END SUBROUTINE
|
|
Packit Service |
c5cf8c |
END INTERFACE
|
|
Packit Service |
c5cf8c |
integer myerrhan, qerr
|
|
Packit Service |
c5cf8c |
integer callcount, codesSeen(3)
|
|
Packit Service |
c5cf8c |
common /myerrhan/ callcount, codesSeen
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
errs = 0
|
|
Packit Service |
c5cf8c |
callcount = 0
|
|
Packit Service |
c5cf8c |
call mtest_init( ierr )
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! Setup some new codes and classes
|
|
Packit Service |
c5cf8c |
call mpi_add_error_class( newerrclass, ierr )
|
|
Packit Service |
c5cf8c |
call mpi_add_error_code( newerrclass, code(1), ierr )
|
|
Packit Service |
c5cf8c |
call mpi_add_error_code( newerrclass, code(2), ierr )
|
|
Packit Service |
c5cf8c |
call mpi_add_error_string( newerrclass, "New Class", ierr )
|
|
Packit Service |
c5cf8c |
call mpi_add_error_string( code(1), "First new code", ierr )
|
|
Packit Service |
c5cf8c |
call mpi_add_error_string( code(2), "Second new code", ierr )
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
call mpi_comm_create_errhandler( myerrhanfunc, myerrhan, ierr )
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! Create a new communicator so that we can leave the default errors-abort
|
|
Packit Service |
c5cf8c |
! on MPI_COMM_WORLD
|
|
Packit Service |
c5cf8c |
call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
call mpi_comm_set_errhandler( comm, myerrhan, ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mpi_comm_get_errhandler( comm, qerr, ierr )
|
|
Packit Service |
c5cf8c |
if (qerr .ne. myerrhan) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Did not get expected error handler'
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
call mpi_errhandler_free( qerr, ierr )
|
|
Packit Service |
c5cf8c |
! We can free our error handler now
|
|
Packit Service |
c5cf8c |
call mpi_errhandler_free( myerrhan, ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mpi_comm_call_errhandler( comm, newerrclass, ierr )
|
|
Packit Service |
c5cf8c |
call mpi_comm_call_errhandler( comm, code(1), ierr )
|
|
Packit Service |
c5cf8c |
call mpi_comm_call_errhandler( comm, code(2), ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (callcount .ne. 3) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Expected 3 calls to error handler, found ', &
|
|
Packit Service |
c5cf8c |
& callcount
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
if (codesSeen(1) .ne. newerrclass) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, 'Expected class ', newerrclass, ' got ', &
|
|
Packit Service |
c5cf8c |
& codesSeen(1)
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
if (codesSeen(2) .ne. code(1)) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, 'Expected code ', code(1), ' got ', &
|
|
Packit Service |
c5cf8c |
& codesSeen(2)
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
if (codesSeen(3) .ne. code(2)) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, 'Expected code ', code(2), ' got ', &
|
|
Packit Service |
c5cf8c |
& codesSeen(3)
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mpi_comm_free( comm, ierr )
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! Check error strings while here...
|
|
Packit Service |
c5cf8c |
call mpi_error_string( newerrclass, errstring, rlen, ierr )
|
|
Packit Service |
c5cf8c |
if (errstring(1:rlen) .ne. "New Class") then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Wrong string for error class: ', errstring(1:rlen)
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
call mpi_error_class( code(1), eclass, ierr )
|
|
Packit Service |
c5cf8c |
if (eclass .ne. newerrclass) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Class for new code is not correct'
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
call mpi_error_string( code(1), errstring, rlen, ierr )
|
|
Packit Service |
c5cf8c |
if (errstring(1:rlen) .ne. "First new code") then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Wrong string for error code: ', errstring(1:rlen)
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
call mpi_error_class( code(2), eclass, ierr )
|
|
Packit Service |
c5cf8c |
if (eclass .ne. newerrclass) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Class for new code is not correct'
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
call mpi_error_string( code(2), errstring, rlen, ierr )
|
|
Packit Service |
c5cf8c |
if (errstring(1:rlen) .ne. "Second new code") then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, ' Wrong string for error code: ', errstring(1:rlen)
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mtest_finalize( errs )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
end
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
subroutine myerrhanfunc( comm, errcode )
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
integer comm, errcode
|
|
Packit Service |
c5cf8c |
integer rlen, ierr
|
|
Packit Service |
c5cf8c |
integer callcount, codesSeen(3)
|
|
Packit Service |
c5cf8c |
character*(MPI_MAX_ERROR_STRING) errstring
|
|
Packit Service |
c5cf8c |
common /myerrhan/ callcount, codesSeen
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
callcount = callcount + 1
|
|
Packit Service |
c5cf8c |
! Remember the code we've seen
|
|
Packit Service |
c5cf8c |
if (callcount .le. 3) then
|
|
Packit Service |
c5cf8c |
codesSeen(callcount) = errcode
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
call mpi_error_string( errcode, errstring, rlen, ierr )
|
|
Packit Service |
c5cf8c |
if (ierr .ne. MPI_SUCCESS) then
|
|
Packit Service |
c5cf8c |
print *, ' Panic! could not get error string'
|
|
Packit Service |
c5cf8c |
call mpi_abort( MPI_COMM_WORLD, 1, ierr )
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
end
|