(j3.2006) (SC22WG5.4934) [ukfortran] WG5 ballot on first draft TS 18508, Additional Parallel Features in Fortran
Van Snyder
Van.Snyder
Thu Mar 14 14:33:43 EDT 2013
On Thu, 2013-03-14 at 16:49 +0100, Tobias Burnus wrote:
> Side remark: the current proposal does not allow error recovery for
> communication using the bracket syntax ("a[i] = 5", "b = c[i]"), but
> only for team formation, sync, allocate etc.
The broad area of recovery from things not done by procedure calls is
the reason for a block-structured exception handler.
The oldest examples come from arithmetic, including divide by zero,
overflow, failure in a math intrinsic function....
In Fortran 90, it was observed that one cannot respond to failure to
elaborate automatic variables.
Ada had exception-handling facilities from its start in 1983. C++ added
a block-structured exception handler to C. It has been repeatedly
proposed for Fortran, and rejected.
If it is ever done in Fortran, it ought to be based upon an extensible
enumeration type, that is a true type, not syntactic sugar for PARAMETER
statements, probably defined in ISO_FORTRAN_ENV, with several
enumerators defined by the standard.
Here's an example of such a type definition. Notice that the type
definition is spelled "ENUMERATION", not "ENUM".
ENUMERATION, PUBLIC, ORDERED :: SYSTEM_EXCEPTIONS
ENUMERATOR :: ALLOC_ERROR ! An error occurred during execution of an
! ALLOCATE statement.
ENUMERATOR :: AUTO_FAIL ! Creation of automatic objects failed.
ENUMERATOR :: DEALLOC_ERROR ! An error occurred during execution of a
! DEALLOCATE statement.
ENUMERATOR :: FLT_OVERFLOW ! Floating-point overflow occurred during
! evaluation of an expression.
ENUMERATOR :: FLT_UNDERFLOW ! Floating-point underflow occurred during
! evaluation of an expression.
ENUMERATOR :: FLT_ZERO_DIV ! Floating-point division by zero occurred
! during evaluation of an expression.
ENUMERATOR :: IEEE_EXCEPTION ! An IEEE exception occurred during evaluation
! of an expression, or during execution of a
! procedure from the intrinsic module
! IEEE_ARITHMETIC.
ENUMERATOR :: INT_OVERFLOW ! integer overflow occurred during
! evaluation of an expression.
ENUMERATOR :: INT_ZERO_DIV ! integer division by zero occurred
! during evaluation of an expression.
ENUMERATOR :: INTRIN_ERROR ! An error occurred during execution of an
! intrinsic procedure other than a
! mathematical intrinsic function.
ENUMERATOR :: IO_END ! An end-of-file occurred during input.
ENUMERATOR :: IO_ERROR ! An input/output error occurred.
ENUMERATOR :: LOCK_ERROR ! Lock variable already locked by locking image.
ENUMERATOR :: MATH_ERROR ! An error occurred during execution of a
! mathematical intrinsic function.
ENUMERATOR :: SYNC_ERROR ! An error occurred during execution of a
! SYNC ALL, SYNC IMAGES or SYNC MEMORY statement.
ENUMERATOR :: UNLOCK_ERROR ! Lock variable not locked by locking image.
ENUMERATOR :: UNSUPPORTED_EXCEPTION ! An exception of type SYSTEM_EXCEPTIONS
! that is specified in a RAISE, ENABLE, or
! DISABLE statement is not supported.
END ENUMERATION SYSTEM_EXCEPTIONS
Processors could add enumerators to the intrinsic type as extensions.
Users could extend the type to add exceptions, such as SINGULAR_MATRIX.
More information about the J3
mailing list