Next: Matrix Storage Schemes
Up: Documentation Design and Program
Previous: Array Arguments
  Contents
  Index
Error Handling
All LAPACK95 driver and computational routines have
a diagnostic output argument INFO. In the
case of the driver
routines, this argument is optional. Three types of exit from a
routine are allowed:
- successful termination:
- The
routine returns to the calling program with
INFO set to 0.
- illegal value of one or more arguments, or error in memory allocation:
-
The routine sets INFO and calls the error routine
ERINFO, which issues an error message
identifying the first invalid argument and stops execution.
- failure in the course of computation:
- The routine sets INFO
and returns to the calling program without issuing any error message.
It is then the
responsibility of the user to test INFO on return to the calling program.
If INFO is not supplied in the call of a driver routine and
an error occurs, then the routine always issues an
error message and stops execution, even when INFO (in which case
the
error message reports the value of INFO). If a user wishes to continue
execution after a failure in computation, then INFO must be
supplied and should be tested on return.
This behavior simplifies calls to LAPACK95 drivers when there is no need to
test INFO on return and makes it less likely that users will forget to
test INFO when necessary.
If an invalid argument is detected, the routines
issue an error message and stop, as in LAPACK. However, in
LAPACK95 there can be different reasons for an argument being invalid:
- illegal value
- : as in LAPACK.
- invalid shape
- (of an assumed-shape array): for example, a two-dimensional
array is not square when it is required to be.
- inconsistent shapes
- (of two or more assumed-shape arrays): for example,
arrays holding the right hand sides and solutions of a system of
linear equations must have the same shape.
- no more core allocation:
- insufficient memory for LAPACK.
The value of INFO is assigned by a call to
the routine ERINFO below:
SUBROUTINE ERINFO( LINFO, SRNAME, INFO, ISTAT )
! .. Scalar Arguments ..
CHARACTER( LEN = * ), INTENT(IN) :: SRNAME
INTEGER, INTENT( IN ) :: LINFO
INTEGER, INTENT( OUT ), OPTIONAL :: INFO
INTEGER, INTENT( IN ), OPTIONAL :: ISTAT
! .. Executable Statements ..
IF( ( LINFO 0 .AND. LINFO -200 ) .OR. &
( LINFO 0 .AND. .NOT. PRESENT( INFO ) ) )THEN
WRITE ( *, * ) 'Program terminated in LAPACK_95 subroutine ', SRNAME
WRITE ( *, * ) 'Error indicator, INFO = ', LINFO
IF( PRESENT(ISTAT) )THEN
IF( ISTAT /= 0 ) THEN
IF( LINFO == -100 )THEN
WRITE ( *, * ) 'The statement ALLOCATE causes STATUS = ', ISTAT
ELSE
WRITE ( *, * ) 'LINFO = ', LINFO, ' not expected'
END IF
END IF
END IF
STOP
ELSE IF( LINFO -200 )THEN
WRITE(*,*) '++++++++++++++++++++++++++++++++++'
WRITE( *, * ) '*** WARNING, INFO = ', LINFO, ' WARNING ***'
IF( LINFO == -200 )THEN
WRITE( *, * ) 'Could not allocate sufficient workspace for the optimum'
WRITE( *, * ) 'blocksize, hence the routine may not have performed as'
WRITE( *, * ) 'efficiently as possible'
ELSE
WRITE( *, * ) 'Unexpected warning'
END IF
WRITE( *, * ) '++++++++++++++++++++++++++++++++++'
END IF
IF( PRESENT( INFO ) ) INFO = LINFO
END SUBROUTINE ERINFO
The use of ERINFO, INFO and LINFO is illustrated in the code in
Section 3.7.
Next: Matrix Storage Schemes
Up: Documentation Design and Program
Previous: Array Arguments
  Contents
  Index
Susan Blackford
2001-08-19