INTEGER            WHAT, HOW, INFO_A, INFNAN, II, JJ
    *     ..
    *     .. External Subroutines ..
          EXTERNAL           SGEINFNAN
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          MAX, MIN
    *     ..
    *     .. Executable Statements ..
    *
    *     Check for exceptional entries in A
          WHAT = FLAG_REPORT_INTERNAL( 1 )
          IF (WHAT .GE. 1) THEN
    *        Check input or output for Infs and NaNs
             HOW = FLAG_REPORT_INTERNAL( 2 )
             IF (HOW .GE. 1) THEN
    *           INFO_ARRAY used for reporting, as well as INFO
                INFO_A = INFO_ARRAY(LOC)
                IF (INOUT .EQ. 0 .OR. INOUT .EQ. 2) THEN
    *              Checking A on input
                   IF (INFO_A .NE. 0 .AND. INFO_A .NE. 1) THEN
    *                 A not checked yet, so check
                      CALL SGEINFNAN( M, N, A, LDA, INFNAN, II, JJ )
                      INFO_ARRAY(LOC) = INFNAN
                   ENDIF
    *              Update INFO_INTERNAL to point to A if not already set
                   IF (INFO_INTERNAL(1).EQ.0 .AND. INFO_ARRAY(LOC).EQ.1)
         $            INFO_INTERNAL(1) = -ARGNUM
                ELSEIF (INOUT .EQ. 1) THEN
    *              Checking output-only variable A on output
                   CALL SGEINFNAN( M, N, A, LDA, INFNAN, II, JJ )
                   INFO_ARRAY(LOC) = 2*INFNAN
    *              Update INFO_INTERNAL to point to A if not already set
                   IF (INFO_INTERNAL(1).EQ.0 .AND. INFO_ARRAY(LOC).EQ.2)
         $            INFO_INTERNAL(1) = ERRFLAG
                ELSE
    *              Checking input-output variable A on output
                   CALL SGEINFNAN( M, N, A, LDA, INFNAN, II, JJ )
                   IF (INFNAN .EQ. 1) INFO_ARRAY(LOC) = INFO_ARRAY(LOC)+2
    *              Update INFO_INTERNAL to point to A if not already set
                   IF (INFO_INTERNAL(1).EQ.0 .AND. INFO_ARRAY(LOC).EQ.2)
         $            INFO_INTERNAL(1) = ERRFLAG
                ENDIF
             ELSEIF (INFO_INTERNAL(1) .EQ. 0 .AND. INFO .EQ. 0) THEN
    *           Only INFO used for reporting, not set yet
                CALL SGEINFNAN( M, N, A, LDA, INFNAN, II, JJ )
                IF (INOUT .EQ. 0 .OR. INOUT .EQ. 2) THEN
    *              Checking A on input
                   IF (INFNAN .EQ. 1) INFO_INTERNAL(1) = -ARGNUM
                ELSE
    *              Checking A on output
                   IF (INFNAN .EQ. 1) INFO_INTERNAL(1) = ERRFLAG
                ENDIF
             ENDIF
          ENDIF
    *
          RETURN
    *
    *     End of SGECHECKARG
    *
          END

    *> \brief \b SGEINFNAN
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       SUBROUTINE SGEINFNAN( M, N, A, LDA, INFNAN, I, J )
    *
    *       .. Scalar Arguments ..
    *       INTEGER            LDA, M, N, INFNAN, I, J
    *       ..
    *       .. Array Arguments ..
    *       REAL               A( LDA, * )
    *       ..
    *
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> SGEINFNAN  returns INFNAN = 1 if the matrix A contains an Inf or NaN, and 0 otherwise,
    *>            The location of the Inf or NaN is at A(I,J)
    *> \endverbatim
    *>
    *> \return SGEINFNAN
    *
    *  Arguments:
    *  ==========
    *
    *>
    *> \param[in] M
    *> \verbatim
    *>          M is INTEGER
    *>          The number of rows of the matrix A.  M >= 0.  When M = 0,
    *>          INFNAN is set to 0.
    *> \endverbatim
    *>
    *> \param[in] N
    *> \verbatim
    *>          N is INTEGER
    *>          The number of columns of the matrix A.  N >= 0.  When N = 0,
    *>          INFNAN is set to 0.
    *> \endverbatim
    *>
    *> \param[in] A
    *> \verbatim
    *>          A is REAL array, dimension (LDA,N)
    *>          The M by N matrix A.
    *> \endverbatim
    *>
    *> \param[in] LDA
    *> \verbatim
    *>          LDA is INTEGER
    *>          The leading dimension of the array A.  LDA >= max(M,1).
    *> \endverbatim
    *>
    *> \param[out] INFNAN
    *> \verbatim
    *>          INFNAN is INTEGER
    *>          INFNAN = 1 if A contains an Inf or NaN, and 0 otherwise.
    *> \endverbatim
    *>
    *> \param[out] I
    *> \verbatim
    *>          I is INTEGER
    *>          If A contains an Inf or NaN, one is located at A(I,J),
    *>          otherwise I = 0.
    *> \endverbatim
    *>
    *> \param[out] J
    *> \verbatim
    *>          J is INTEGER
    *>          If A contains an Inf or NaN, one is located at A(I,J),
    *>          otherwise J = 0.
    *
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEauxiliary
    *
    *  =====================================================================
          SUBROUTINE SGEINFNAN( M, N, A, LDA, INFNAN, I, J )
    *
    *  -- LAPACK auxiliary routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
          IMPLICIT NONE
    *     .. Scalar Arguments ..
          INTEGER            LDA, M, N, INFNAN, I, J
    *     ..
    *     .. Array Arguments ..
          REAL               A( LDA, * )
    *     ..
    *
    * =====================================================================
    *
    *     .. Parameters ..
          REAL               ONE
          PARAMETER          ( ONE = 1.0E+0 )
    *     ..
    *     .. Local Scalars ..
          INTEGER            MAXEXP
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          EXPONENT, HUGE
    *     ..
    *     .. Executable Statements ..
    *
          INFNAN = 0
          I = 0
          J = 0
          IF( MIN( M, N ).EQ.0 ) RETURN
    *     MAXEXP is the exponent of an Inf or NaN
          MAXEXP = EXPONENT(HUGE(ONE)) + 1
          DO 20 J = 1, N
             DO 10 I = 1, M
    *           It could be faster to use the function IEEE_IS_FINITE
    *           provided by the intrinsic module IEEE_ARITHMETIC, but
    *           whether this module is provided is processor dependent,
    *           according to the Fortran 2008 standard.
                IF( EXPONENT(A(I,J)) .EQ. MAXEXP ) THEN
    *              A(I,J) is an Inf or NaN
                   INFNAN = 1
                   RETURN
                ENDIF
       10    CONTINUE
       20 CONTINUE
          I = 0
          J = 0
          RETURN
    *
    *     End of SGEINFNAN
    *
          END

    *> \brief \b CHECKCALL
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       SUBROUTINE CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
    *      $                      INFO_CALLARRAY, INFO_ARRAY,
    *      $                      CALL_ID, LOC )
    *
    *       .. Scalar Arguments ..
    *       INTEGER            CALL_ID, LOC
    *       ..
    *       .. Array Arguments ..
    *       INTEGER            FLAG_REPORT_INTERNAL(2), INFO_INTERNAL(2)
    *       INTEGER            INFO_CALLARRAY( * ), INFO_ARRAY( * )
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> CHECKCALL checks whether an internal LAPACK call signaled an
    *> exception and updates reporting variables INFO_INTERNAL and
    *> INFO_ARRAY accordingly.
    *>
    *> \endverbatim
    *
    *  Arguments:
    *  ==========
    *
    *> \param[in] FLAG_REPORT_INTERNAL
    *> \verbatim
    *>          FLAG_REPORT_INTERNAL is INTEGER array, dimension(2)
    *>          FLAG_REPORT_INTERNAL(1) defines what kinds of exceptions
    *>          to report, using INFO and possibly also INFO_ARRAY for
    *>          more details.
    *>          FLAG_REPORT_INTERNAL(1)
    *>           <= -1 turns off all error checking
    *>            =  0 standard error checks only (eg LDA < 0)
    *>            =  1 also check inputs and outputs for Infs and NaN
    *>           >=  2 also check input and output arguments of internal
    *>               LAPACK routines (not performed unless
    *>               FLAG_REPORT_INTERNAL(2) >= 1)
    *>           FLAG_REPORT_INTERNAL(2) determines how errors are
    *>           reported:
    *>           FLAG_REPORT_INTERNAL(2)
    *>           <= 0 only returns INFO
    *>            = 1 also return INFO_ARRAY with more details
    *>            = 2 also calls REPORT_EXCEPTIONS if there are errors
    *>           >= 3 also calls REPORT_EXCEPTIONS in internal LAPACK
    *>                routines
    *> \endverbatim
    *>
    *> \param[out] INFO_INTERNAL
    *> \verbatim
    *>          INFO_INTERNAL is INTEGER array, dimension(2)
    *>          INFO_INTERNAL( 1 ) is not accessed.
    *>          INFO_INTERNAL( 2 ) is used to track potential changes
    *>          to INFO from errors detected by internal subroutine calls.
    *> \endverbatim
    *>
    *> \param[in] INFO_CALLARRAY
    *> \verbatim
    *>          INFO_CALLARRAY is INTEGER array, dimension (*)
    *>          When HOW >= 1, INFO_CALLARRAY is the INFO_ARRAY returned
    *>          by the routine being checked.
    *> \endverbatim
    *>
    *> \param[in,out] INFO_ARRAY
    *> \verbatim
    *>          INFO_ARRAY is INTEGER ARRAY
    *>          INFO_ARRAY can report error checks for each
    *>          floating point input and output, and each
    *>          internal subroutine call.
    *> \endverbatim
    *>
    *> \param[in] CALL_ID
    *> \verbatim
    *>          CALL_ID is INTEGER
    *>          CALL_ID is a unique identifier for each internal
    *>          LAPACK call that may be checked for exceptions.
    *> \endverbatim
    *>
    *> \param[in] LOC
    *> \verbatim
    *>          LOC is INTEGER
    *>          LOC points to the entry of INFO_ARRAY used to report
    *>          on the internal call identified by CALL_ID
    *> \endverbatim
    *>
    *>
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEcomputational
    *
    *  =====================================================================
          SUBROUTINE CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                      INFO_CALLARRAY, INFO_ARRAY,
         $                      CALL_ID, LOC )
    *
    *  -- LAPACK computational routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
    *     .. Scalar Arguments ..
          INTEGER            CALL_ID, LOC
    *     ..
    *     .. Array Arguments ..
          INTEGER            FLAG_REPORT_INTERNAL(2), INFO_INTERNAL(2)
          INTEGER            INFO_CALLARRAY( * ), INFO_ARRAY( * )
    *  =====================================================================
    *
    *     .. Local Scalars ..
          INTEGER            WHAT, HOW
          INTEGER            TMP, TMPINOUT, TMPCALLS, I, NUMARGS, NUMCALLS
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          MAX, MIN
    *     ..
    *     .. Executable Statements ..
    *
          WHAT = FLAG_REPORT_INTERNAL( 1 )
          HOW = FLAG_REPORT_INTERNAL( 2 )
          IF (WHAT .GE. 2 .AND. HOW .GE. 1) THEN
    *     Check inputs, outputs and internal calls of LAPACK call
    *        Update INFO_ARRAY( LOC )
    *        Determine whether called routine had any Inf or NaN
    *        inputs or outputs
             TMP = INFO_ARRAY( LOC )
    *        Determine whether called routine had any Infs or NaNs
    *        reported by its own internal calls
             TMPCALLS = 0
    *        NUMARGS = number of arguments reported in INFO_CALLARRAY
             NUMARGS = INFO_CALLARRAY(5)
    *        NUMCALLS = number of internal subroutine calls reported in
    *        INFO_ALLARRAY
             NUMCALLS = INFO_CALLARRAY(6)
             IF (NUMCALLS .GT. 0) THEN
                DO 10 I = 7+NUMARGS, 6+NUMARGS+NUMCALLS
                   TMPCALLS = MAX( TMPCALLS, INFO_CALLARRAY( I ) )
    10          CONTINUE
             ENDIF
             IF (TMPCALLS .GE. 1) TMP = MAX( TMP, 1 )
    *        Determine whether called routine had any inputs or outputs
    *        containing Infs or NaNs
             TMPINOUT = 0
             IF (NUMARGS .GT. 0) THEN
                DO 20 I = 7, 6+NUMARGS
                   TMPINOUT = MAX( TMPINOUT, INFO_CALLARRAY( I ) )
    20          CONTINUE
             ENDIF
             IF (TMPINOUT .GT. 0) TMP = MAX( TMP, TMPINOUT+1 )
             INFO_ARRAY( LOC ) = TMP
    *        Update INFO_INTERNAL
             IF (INFO_INTERNAL( 2 ) .EQ. 0 .AND. TMP .GT. 0)
         $      INFO_INTERNAL( 2 ) =  CALL_ID
          ENDIF
    *
          RETURN
    *
    *     End of CHECKCALL
    *
          END

    *> \brief \b UPDATE_INFO
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       SUBROUTINE UPDATE_INFO( INFO, INFO_ARRAY, INFO_INTERNAL )
    *
    *       .. Scalar Arguments ..
    *       INTEGER            INFO
    *       ..
    *       .. Array Arguments ..
    *       INTEGER            INFO_ARRAY( * ), INFO_INTERNAL( 2 )
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> UPDATE_INFO updates INFO and INFO_ARRAY before an LAPACK routine
    *> returns.
    *>
    *> \endverbatim
    *
    *  Arguments:
    *  ==========
    *
    *> \param[in,out] INFO
    *> \verbatim
    *>          INFO is INTEGER
    *>          On input, INFO contains the standard value that LAPACK
    *>          would return.
    *>          On output, INFO also reports any exceptional inputs or
    *>          outputs, or exceptions in internal subroutine calls,
    *>          as reported in INFO_INTERNAL
    *> \endverbatim
    *>
    *> \param[in,out] INFO_ARRAY
    *> \verbatim
    *>          INFO_ARRAY(1) is set to the input value of INFO.
    *>          INFO_ARRAY(4) is set to the updated value of INFO.
    *>
    *> \endverbatim
    *>
    *> \param[in] INFO_INTERNAL
    *> \verbatim
    *>          INFO_INTERNAL is INTEGER array, dimension(2)
    *>          INFO_INTERNAL( 1 ) is used to track potential changes
    *>          to INFO from errors detected by checking input and output
    *>          arguments.
    *>          INFO_INTERNAL( 2 ) is used to track potential changes
    *>          to INFO from errors detected by internal subroutine calls.
    *> \endverbatim
    *>
    *>
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEcomputational
    *
    *  =====================================================================
          SUBROUTINE UPDATE_INFO( INFO, INFO_ARRAY, INFO_INTERNAL )
    *
    *  -- LAPACK computational routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
    *     .. Scalar Arguments ..
          INTEGER            INFO
    *     ..
    *     .. Array Arguments ..
          INTEGER            INFO_ARRAY( * ), INFO_INTERNAL( 2 )
    *
    *  =====================================================================
    *
    *     ..
    *     .. Executable Statements ..
    *
          INFO_ARRAY(1) = INFO
          INFO_ARRAY(4) = INFO
          IF (INFO_INTERNAL(1) .GT. 0 .AND. INFO_ARRAY(4) .EQ. 0) THEN
    *         Update INFO and INFO_ARRAY(4) to indicate exceptional
    *         input or output
              INFO_ARRAY(4) = INFO_INTERNAL(1)
              INFO = INFO_INTERNAL(1)
          ENDIF
          IF (INFO_INTERNAL(2) .GT. 0 .AND. INFO_ARRAY(3) .GE. 1 .AND.
         $    INFO_ARRAY(4) .EQ. 0) THEN
    *         Update INFO and INFO_ARRAY(4) to indicate exceptions
    *         in internal LAPACK call
              INFO_ARRAY(4) = INFO_INTERNAL(2)
              INFO = INFO_INTERNAL(2)
          ENDIF
    *
          RETURN
    *
    *     End of UPDATE_INFO
    *
          END

    *> \brief <b> SGESV_EC computes the solution to system of linear equations
    *> A * X = B for GE matrices</b> (simple driver)
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       SUBROUTINE SGESV_EC( N, NRHS, A, LDA, IPIV, B, LDB,
    *      $                     INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *       .. Scalar Arguments ..
    *       INTEGER            INFO, LDA, LDB, N, NRHS
    *       ..
    *       .. Array Arguments ..
    *       INTEGER            IPIV( * )
    *       INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( * )
    *       REAL               A( LDA, * ), B( LDB, * )
    *       ..
    *       .. Pointer Arguments ..
    *       POINTER            CONTEXT ... advice requested
    *
    *
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> SGESV_EC computes the solution to a real system of linear equations
    *>    A * X = B,
    *> where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
    *>
    *> The LU decomposition with partial pivoting and row interchanges is
    *> used to factor A as
    *>    A = P * L * U,
    *> where P is a permutation matrix, L is unit lower triangular, and U
    *> is upper triangular.  The factored form of A is then used to solve
    *> the system of equations A * X = B.
    *>
    *> SGESV_EC also provides new exception handling and
    *> reporting capabilities.
    *>
    *> \endverbatim
    *
    *  Arguments:
    *  ==========
    *
    *> \param[in] N
    *> \verbatim
    *>          N is INTEGER
    *>          The number of linear equations, i.e., the order of the
    *>          matrix A.  N >= 0.
    *> \endverbatim
    *>
    *> \param[in] NRHS
    *> \verbatim
    *>          NRHS is INTEGER
    *>          The number of right hand sides, i.e., the number of columns
    *>          of the matrix B.  NRHS >= 0.
    *> \endverbatim
    *>
    *> \param[in,out] A
    *> \verbatim
    *>          A is REAL array, dimension (LDA,N)
    *>          On entry, the N-by-N coefficient matrix A.
    *>          On exit, the factors L and U from the factorization
    *>          A = P*L*U; the unit diagonal elements of L are not stored.
    *> \endverbatim
    *>
    *> \param[in] LDA
    *> \verbatim
    *>          LDA is INTEGER
    *>          The leading dimension of the array A.  LDA >= max(1,N).
    *> \endverbatim
    *>
    *> \param[out] IPIV
    *> \verbatim
    *>          IPIV is INTEGER array, dimension (N)
    *>          The pivot indices that define the permutation matrix P;
    *>          row i of the matrix was interchanged with row IPIV(i).
    *> \endverbatim
    *>
    *> \param[in,out] B
    *> \verbatim
    *>          B is REAL array, dimension (LDB,NRHS)
    *>          On entry, the N-by-NRHS matrix of right hand side matrix B.
    *>          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
    *> \endverbatim
    *>
    *> \param[in] LDB
    *> \verbatim
    *>          LDB is INTEGER
    *>          The leading dimension of the array B.  LDB >= max(1,N).
    *> \endverbatim
    *>
    *> \param[out] INFO
    *> \verbatim
    *>          INFO is INTEGER
    *>          INFO is defined below depending on FLAG_REPORT
    *> \endverbatim
    *>
    *> \param[in] FLAG_REPORT
    *> \verbatim
    *>          FLAG_REPORT is INTEGER array, dimension(2)
    *>          FLAG_REPORT(1) defines what kinds of exceptions to report,
    *>          using INFO and possibly also INFO_ARRAY for more details.
    *>          FLAG_REPORT(1)
    *>           <= -1 turns off all error checking, so INFO=0 is
    *>                 returned.
    *>            =  0 does standard argument checking:
    *>                 INFO = 0  means successful exit
    *>                 INFO = -i means the i-th (non-floating point)
    *>                           argument had an illegal value
    *>                           (first error found is reported)
    *>                 INFO = i means U(i,i) = 0. The factorization
    *>                          has been completed, but the factor U is
    *>                          exactly singular, and division by zero
    *>                          will occur if it is used to solve a system
    *>                          of equations.
    *>                 Using INFO to report the above errors has priority
    *>                 over reporting any of the errors described below.
    *>                 More generally, an error that would be found with a
    *>                 lower value of FLAG_REPORT(1) has priority to
    *>                 report using INFO than an error that would only
    *>                 be found with a higher value of FLAG_REPORT(1).
    *>            =  1 also checks for Infs and NaNs in inputs and
    *>                 outputs, if INFO not already nonzero:
    *>                 INFO = -3 means A contained an Inf or NaN on
    *>                           input; execution continues.
    *>                 INFO = -6 means B contained an Inf or NaN on
    *>                           input, but not A; execution continues.
    *>                 INFO = N+1 means that A contained an Inf or NaN on
    *>                        output but neither A nor B did on input.
    *>                 INFO = N+2 means that B contained an Inf or NaN on
    *>                        output but neither A nor B did on input nor
    *>                        A on output.
    *>                 A and B will also be checked on input and output if
    *>                 FLAG_REPORT(2) = 1, 2 or 3 and reported in
    *>                 INFO_ARRAY as described below.
    *>            >= 2 also checks for Infs and NaNs as inputs or outputs
    *>                 in all internal LAPACK calls in the call chain, if
    *>                 INFO is not already nonzero, and
    *>                 FLAG_REPORT(2) = 1, 2 or 3. In this case:
    *>                 INFO = N+3 means that either the call to
    *>                        SGETRF_EC had an Inf or NaN as an
    *>                        input or output as above, or a subroutine
    *>                        in its call tree did.
    *>                 INFO = N+4 means that the call to SGETRS_EC
    *>                        had an Inf or NaN as an
    *>                        input or output as above.
    *>                 Each input, output and internal LAPACK call will
    *>                 also be checked if FLAG_REPORT(2) = 1, 2 or 3 and
    *>                 reported in INFO_ARRAY as described below.
    *>
    *>          FLAG_REPORT(2) defines how to report the exceptions
    *>          requested by FLAG_REPORT(1).
    *>            If FLAG_REPORT(1) <= -1, FLAG_REPORT(2) is ignored and
    *>            INFO=0 is returned.
    *>            Otherwise, FLAG_REPORT(2)
    *>             <=  0 only returns the value of INFO described above.
    *>              =  1 also returns INFO_ARRAY, as described below.
    *>              =  2 means that SGESV_EC will also call
    *>                   REPORT_EXCEPTIONS to report INFO_ARRAY, if INFO
    *>                   is nonzero.
    *>              =  3 means that all calls in the call tree will also
    *>                   call REPORT_EXCEPTIONS, if the value of INFO they
    *>                   return is nonzero.
    *>             >=  4 means that SGESV_EC will call
    *>                   GET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   to get values of FLAG_REPORT to use, overriding
    *>                   input values. The user needs to have called
    *>                   SET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   before calling SGESV_EC in order to set
    *>                   FLAG_REPORT, otherwise the default is
    *>                   FLAG_REPORT = [0, 0]. The input array FLAG_REPORT
    *>                   will not be overwritten.
    *> \endverbatim
    *>
    *> \param[out] INFO_ARRAY
    *> \verbatim
    *>          INFO_ARRAY is INTEGER array, dimension( 10 )
    *>          If FLAG_REPORT(1) <= -1 or FLAG_REPORT(2) <= 0,
    *>          INFO_ARRAY is not accessed. Otherwise:
    *>          INFO_ARRAY(1)
    *>              = value of INFO from standard argument checking
    *>                (as defined by FLAG_REPORT(1) = 0)
    *>          INFO_ARRAY(2)
    *>              = value of FLAG_REPORT(1) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(3)
    *>              = value of FLAG_REPORT(2) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(4)
    *>              = value of INFO as specified by FLAG_REPORT(1) above
    *>          INFO_ARRAY(5)
    *>              = 2 = number of input/output arguments reported on
    *>          INFO_ARRAY(6)
    *>              = 2 = number of internal LAPACK calls reported on
    *>          INFO_ARRAY(7), reports exceptions in A, as specified by
    *>            FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and contains no Infs or NaNs
    *>              =  1 if checked and contains an Inf or NaN on input
    *>                   but not output
    *>              =  2 if checked and contains an Inf or NaN on output
    *>                   but not input
    *>              =  3 if checked and contains an Inf or NaN on input
    *>                   and output
    *>          INFO_ARRAY(8), reports exceptions in B, analogously to
    *>            INFO_ARRAY(7)
    *>          INFO_ARRAY(9), reports exceptions in SGETRF_EC, as
    *>            specified by FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and no Infs or NaNs reported
    *>              =  1 if checked and no input or output contains an Inf
    *>                   or NaN, but some LAPACK call deeper in the call
    *>                   chain signaled an Inf or NaN
    *>              =  2 if checked and an input argument contains an Inf
    *>                   or NaN, but not an output
    *>              =  3 if checked and an output argument contains an Inf
    *>                   or NaN, but not an input
    *>              =  4 if checked and an argument contains an Inf or NaN
    *>                   on input and output
    *>          INFO_ARRAY(10), reports exceptions in SGETRS_EC,
    *>            analogously to INFO_ARRAY(9)
    *> \endverbatim
    *>
    *> \param[in] CONTEXT
    *> \verbatim
    *>           CONTEXT is POINTER to an "opaque object"
    *> \endverbatim
    *>
    *
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEsolve
    *
    *  =====================================================================
          SUBROUTINE SGESV_EC( N, NRHS, A, LDA, IPIV, B, LDB,
         $                     INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *  -- LAPACK driver routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
    *     .. Scalar Arguments ..
          INTEGER            INFO, LDA, LDB, N, NRHS
    *     ..
    *     .. Array Arguments ..
          INTEGER            IPIV( * )
          REAL               A( LDA, * ), B( LDB, * )
          INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( * )
    *     ..
    *     .. Pointer Arguments
          POINTER            CONTEXT
    *
    *  =====================================================================
    *
    *     .. Parameters ..
          CHARACTER, DIMENSION(5), PARAMETER ::
         $   ROUTINE_NAME = (/ ’S’,’G’,’E’,’S’,’V’ /)
    *     ..
    *     .. Local Scalars ..
          LOGICAL            CALL_REPORT_EXCEPTIONS
          INTEGER            WHAT, HOW
    *     ..
    *     .. Local Arrays ..
          INTEGER            FLAG_REPORT_INTERNAL(2), FLAG_REPORT_CALL(2)
          INTEGER            INFO_SGETRF_TMP(9), INFO_SGETRS_TMP(9)
          INTEGER            INFO_INTERNAL(2)
    *     ..
    *     .. External Subroutines ..
          EXTERNAL           SGETRF_EC, SGETRS_EC, XERBLA
          EXTERNAL           CHECKINIT1, CHECKINIT2
          EXTERNAL           SGECHECKARG, CHECKCALL
          EXTERNAL           UPDATE_INFO
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          MAX
    *     ..
    *     .. Executable Statements ..
    *
    *     Test the input parameters.
    *
          INFO = 0
    *     Initialize error checking flags
          CALL CHECKINIT1(FLAG_REPORT, FLAG_REPORT_INTERNAL,
         $                FLAG_REPORT_NEXT, CALL_REPORT_EXCEPTIONS,
         $                CONTEXT )
          WHAT = FLAG_REPORT_INTERNAL( 1 )
          HOW = FLAG_REPORT_INTERNAL( 2 )
          IF (WHAT .EQ. -1 ) GOTO 100
    *
    *     Check for standard input errors
          IF( N.LT.0 ) THEN
             INFO = -1
          ELSE IF( NRHS.LT.0 ) THEN
             INFO = -2
          ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
             INFO = -4
          ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
             INFO = -7
          END IF
    *
    *     Initialize error flags
          CALL CHECKINIT2( FLAG_REPORT_INTERNAL, INFO, INFO_INTERNAL,
         $                 INFO_ARRAY, 2, 2)
    *
          IF( INFO.NE.0 ) THEN
             IF (CALL_REPORT_EXCEPTIONS)
         $       CALL REPORT_EXCEPTIONS(CONTEXT,5,ROUTINE_NAME,INFO_ARRAY)
             CALL XERBLA( ’SGESV ’, -INFO )
             RETURN
          END IF
    *
    *     Quick return if possible
    *
          IF( N.EQ.0 ) RETURN
    *
    *     Check for exceptional inputs in A
          CALL SGECHECKARG( FLAG_REPORT_INTERNAL, N, N, A, LDA,
         $                  INFO, INFO_INTERNAL, INFO_ARRAY, 3, 2, 0, 7 )
    *     Check for exceptional inputs in B
          CALL SGECHECKARG( FLAG_REPORT_INTERNAL, N, NRHS, B, LDB,
         $                  INFO, INFO_INTERNAL, INFO_ARRAY, 6, 2, 0, 8 )
    *
    100   CONTINUE
    *
    *     Quick return if possible
    *
          IF( N.EQ.0 ) RETURN
    *
    *     Compute the LU factorization of A.
    *
    *     Indicate if input A already checked for Infs and NaNs
          IF (WHAT .GE. 1 .AND. HOW .GE. 1)
         $    INFO_SGETRF_TMP(7) = INFO_ARRAY(7)
          CALL SGETRF_EC( N, N, A, LDA, IPIV,
         $               INFO, FLAG_REPORT_CALL, INFO_SGETRF_TMP, CONTEXT)
    *
    *     Check inputs, outputs and internal calls of SGETRF_EC
          CALL CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                INFO_SGETRF_TMP, INFO_ARRAY, N+3, 9 )
          IF( INFO.EQ.0 ) THEN
    *
    *        Solve the system A*X = B, overwriting B with X.
    *
    *        Indicate if input B already checked for Infs and NaNs
             IF (WHAT .GE. 1 .AND. HOW .GE. 1)
         $      INFO_SGETRS_TMP(8) = INFO_ARRAY(8)
             CALL SGETRS_EC( ’No transpose’, N, NRHS, A, LDA, IPIV, B,LDB,
         $                  INFO,FLAG_REPORT_CALL,INFO_SGETRS_TMP,CONTEXT)
    *
    *        Check inputs, outputs and internal calls of call to SGETRS_EC
             CALL CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                   INFO_SGETRS_TMP, INFO_ARRAY, N+4, 9 )
          ENDIF
    *
    *     Check for errors before returning
    *
          IF (WHAT.EQ.-1) RETURN
    *     Check for exceptional outputs in A
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, N, N, A, LDA,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 3, 3, N+1, 7)
    *     Check for exceptional outputs in B
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, N, NRHS, B, LDB,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 7, 3, N+2, 8)
    *
    *     Update INFO and INFO_ARRAY
          CALL UPDATE_INFO( INFO, INFO_ARRAY, INFO_INTERNAL )
          IF (CALL_REPORT_EXCEPTIONS .AND. INFO .NE. 0)
         $   CALL REPORT_EXCEPTIONS(CONTEXT, 5, ROUTINE_NAME, INFO_ARRAY)
          RETURN
    *
    *     End of SGESV_EC
    *
          END

    *> \brief \b SGETRF_EC
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       SUBROUTINE SGETRF_EC( M, N, A, LDA, IPIV,
    *      $                   INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *       .. Scalar Arguments ..
    *       INTEGER            INFO, LDA, M, N
    *       ..
    *       .. Array Arguments ..
    *       INTEGER            IPIV( * )
    *       INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( * )
    *       REAL               A( LDA, * )
    *       ..
    *       .. Pointer Arguments ..
    *       POINTER            CONTEXT ... advice requested
    *
    *
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> SGETRF_EC computes an LU factorization of a general M-by-N matrix A
    *> using partial pivoting with row interchanges.
    *>
    *> The factorization has the form
    *>    A = P * L * U
    *> where P is a permutation matrix, L is lower triangular with unit
    *> diagonal elements (lower trapezoidal if m > n), and U is upper
    *> triangular (upper trapezoidal if m < n).
    *>
    *> This is the right-looking Level 3 BLAS version of the algorithm.
    *>
    *> SGETRF_EC also provides new exception handling and
    *> reporting capabilities.
    *>
    *> \endverbatim
    *
    *  Arguments:
    *  ==========
    *
    *> \param[in] M
    *> \verbatim
    *>          M is INTEGER
    *>          The number of rows of the matrix A.  M >= 0.
    *> \endverbatim
    *>
    *> \param[in] N
    *> \verbatim
    *>          N is INTEGER
    *>          The number of columns of the matrix A.  N >= 0.
    *> \endverbatim
    *>
    *> \param[in,out] A
    *> \verbatim
    *>          A is REAL array, dimension (LDA,N)
    *>          On entry, the M-by-N matrix to be factored.
    *>          On exit, the factors L and U from the factorization
    *>          A = P*L*U; the unit diagonal elements of L are not stored.
    *> \endverbatim
    *>
    *> \param[in] LDA
    *> \verbatim
    *>          LDA is INTEGER
    *>          The leading dimension of the array A.  LDA >= max(1,M).
    *> \endverbatim
    *>
    *> \param[out] IPIV
    *> \verbatim
    *>          IPIV is INTEGER array, dimension (min(M,N))
    *>          The pivot indices; for 1 <= i <= min(M,N), row i of the
    *>          matrix was interchanged with row IPIV(i).
    *> \endverbatim
    *>
    *> \param[out] INFO
    *> \verbatim
    *>          INFO is INTEGER
    *>          INFO is defined below depending on FLAG_REPORT
    *> \endverbatim
    *>
    *> \param[in] FLAG_REPORT
    *> \verbatim
    *>          FLAG_REPORT is INTEGER array, dimension(2)
    *>          FLAG_REPORT(1) defines what kinds of exceptions to report,
    *>          using INFO and possibly also INFO_ARRAY for more details.
    *>          FLAG_REPORT(1)
    *>           <= -1 turns off all error checking, so INFO=0 is
    *>                 returned.
    *>            =  0 does standard argument checking:
    *>                 INFO = 0  means successful exit
    *>                 INFO = -i means the i-th (non-floating point)
    *>                           argument had an illegal value
    *>                           (first error found is reported)
    *>                 INFO = i means U(i,i) = 0. The factorization
    *>                          has been completed, but the factor U is
    *>                          exactly singular, and division by zero
    *>                          will occur if it is used to solve a system
    *>                          of equations.
    *>                 Using INFO to report the above errors has priority
    *>                 over reporting any of the errors described below.
    *>                 More generally, an error that would be found with a
    *>                 lower value of FLAG_REPORT(1) has priority to
    *>                 report using INFO than an error that would only
    *>                 be found with a higher value of FLAG_REPORT(1).
    *>            =  1 also checks for Infs and NaNs in inputs and
    *>                 outputs, if INFO not already nonzero:
    *>                 INFO = -3 means A contained an Inf or NaN on
    *>                           input; execution continues.
    *>                 INFO = N+1 means that A contained an Inf or NaN on
    *>                        output but not input.
    *>                 A will also be checked on input and output if
    *>                 FLAG_REPORT(2) = 1, 2 or 3 and reported in
    *>                 INFO_ARRAY as described below.
    *>            >= 2 also checks for Infs and NaNs as inputs or outputs
    *>                 in all internal LAPACK calls in the call chain, if
    *>                 INFO is not already nonzero, and
    *>                 FLAG_REPORT(2) = 1, 2 or 3. In this case:
    *>                 INFO = N+2 means that either the first call
    *>                        to SGETRF2_EC had an Inf or NaN as an
    *>                        input or output as above, or a subroutine
    *>                        in its call tree did.
    *>                 INFO = N+3 means that either the second call
    *>                        to SGETRF2_EC had an Inf or NaN as an
    *>                        input or output as above, or a subroutine
    *>                        in its call tree did.
    *>                 Each input, output and internal LAPACK call will
    *>                 also be checked if FLAG_REPORT(2) = 1, 2 or 3 and
    *>                 reported in INFO_ARRAY as described below.
    *>
    *>          FLAG_REPORT(2) defines how to report the exceptions
    *>          requested by FLAG_REPORT(1).
    *>            If FLAG_REPORT(1) <= -1, FLAG_REPORT(2) is ignored and
    *>            INFO=0 is returned.
    *>            Otherwise, FLAG_REPORT(2)
    *>             <=  0 only returns the value of INFO described above.
    *>              =  1 also returns INFO_ARRAY, as described below.
    *>              =  2 means that SGETRF_EC will also call
    *>                   REPORT_EXCEPTIONS to report INFO_ARRAY, if INFO
    *>                   is nonzero.
    *>              =  3 means that all calls in the call tree will also
    *>                   call REPORT_EXCEPTIONS, if the value of INFO they
    *>                   return is nonzero.
    *>             >=  4 means that SGETRF_EC will call
    *>                   GET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   to get values of FLAG_REPORT to use, overriding
    *>                   input values. The user needs to have called
    *>                   SET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   before calling SGETRF_EC in order to set
    *>                   FLAG_REPORT, otherwise the default is
    *>                   FLAG_REPORT = [0, 0]. The input array FLAG_REPORT
    *>                   will not be overwritten.
    *> \endverbatim
    *>
    *> \param[out] INFO_ARRAY
    *> \verbatim
    *>          INFO_ARRAY is INTEGER array, dimension( 9 )
    *>          If FLAG_REPORT(1) <= -1 or FLAG_REPORT(2) <= 0,
    *>          INFO_ARRAY is not accessed. Otherwise:
    *>          INFO_ARRAY(1)
    *>              = value of INFO from standard argument checking
    *>                (as defined by FLAG_REPORT(1) = 0)
    *>          INFO_ARRAY(2)
    *>              = value of FLAG_REPORT(1) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(3)
    *>              = value of FLAG_REPORT(2) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_SGETRF(4)
    *>              = value of INFO as specified by FLAG_REPORT(1) above
    *>          INFO_ARRAY(5)
    *>              = 1 = number of input/output arguments reported on
    *>          INFO_ARRAY(6)
    *>              = 2 = number of internal LAPACK calls reported on
    *>          INFO_ARRAY(7) reports exceptions in A, as specified by
    *>            FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and contains no Infs or NaNs
    *>              =  1 if checked and contains an Inf or NaN on input
    *>                   but not output
    *>              =  2 if checked and contains an Inf or NaN on output
    *>                   but not input
    *>              =  3 if checked and contains an Inf or NaN on input
    *>                   and output
    *>            If INFO_ARRAY(7) = 0 or 1 on input, then A will not
    *>            be checked again. Input values < -1 or > 1 will be
    *>            treated the same as -1, i.e. not checked.
    *>          INFO_ARRAY(8) reports exceptions in the first
    *>            call to SGETRF2_EC, as specified by FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and no Infs or NaNs reported
    *>              =  1 if checked and no input or output contains an Inf
    *>                   or NaN, but some LAPACK call deeper in the call
    *>                   chain signaled an Inf or NaN
    *>              =  2 if checked and an input argument contains an Inf
    *>                   or NaN, but not an output
    *>              =  3 if checked and an output argument contains an Inf
    *>                   or NaN, but not an input
    *>              =  4 if checked and an argument contains an Inf or NaN
    *>                   on input and output
    *>          INFO_ARRAY(9) reports exceptions in the second
    *>            call to SGETRF2_EC, analogously to INFO_ARRAY(8),
    *>            reporting the maximum over all calls.
    *> \endverbatim
    *>
    *> \param[in] CONTEXT
    *> \verbatim
    *>           CONTEXT is POINTER to an "opaque object"
    *> \endverbatim
    *>
    *
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEcomputational
    *
    *  =====================================================================
          SUBROUTINE SGETRF_EC( M, N, A, LDA, IPIV,
         $                      INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *  -- LAPACK computational routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
    *     .. Scalar Arguments ..
          INTEGER            INFO, LDA, M, N
    *     ..
    *     .. Array Arguments ..
          INTEGER            IPIV( * )
          REAL               A( LDA, * )
          INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( * )
    *     ..
    *     .. Pointer Arguments
          POINTER            CONTEXT
    *
    *  =====================================================================
    *
    *     .. Parameters ..
          REAL               ONE
          PARAMETER          ( ONE = 1.0E+0 )
          CHARACTER, DIMENSION(6), PARAMETER ::
         $   ROUTINE_NAME = (/ ’S’,’G’,’E’,’T’,’R’,’F’ /)
    *     ..
    *     .. Local Scalars ..
          LOGICAL            CALL_REPORT_EXCEPTIONS
          INTEGER            I, IINFO, J, JB, NB
          INTEGER            WHAT, HOW
    *     ..
    *     .. Local Arrays ..
          INTEGER            FLAG_REPORT_INTERNAL(2), FLAG_REPORT_CALL(2)
          INTEGER            INFO_SGETRF2_TMP1(9), INFO_SGETRF2_TMP2(9)
          INTEGER            INFO_INTERNAL(2)
    *     ..
    *     .. External Subroutines ..
          EXTERNAL           SGEMM, SGETRF2_EC, SLASWP, STRSM, XERBLA
          EXTERNAL           CHECKINIT1, CHECKINIT2
          EXTERNAL           SGECHECKARG, CHECKCALL
          EXTERNAL           UPDATE_INFO
    *     ..
    *     .. External Functions ..
          INTEGER            ILAENV
          EXTERNAL           ILAENV
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          MAX, MIN
    *     ..
    *     .. Executable Statements ..
    *
    *     Test the input parameters.
    *
          INFO = 0
    *     Initialize error checking flags
          CALL CHECKINIT1(FLAG_REPORT, FLAG_REPORT_INTERNAL,
         $                FLAG_REPORT_CALL, CALL_REPORT_EXCEPTIONS,
         $                CONTEXT )
          WHAT = FLAG_REPORT_INTERNAL( 1 )
          HOW = FLAG_REPORT_INTERNAL( 2 )
          IF (WHAT .EQ. -1 ) GOTO 100
    *
    *     Check for standard input errors
          IF( M.LT.0 ) THEN
             INFO = -1
          ELSE IF( N.LT.0 ) THEN
             INFO = -2
          ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
             INFO = -4
          END IF
    *
    *     Initialize error flags
          CALL CHECKINIT2( FLAG_REPORT_INTERNAL, INFO, INFO_INTERNAL,
         $                 INFO_ARRAY, 1, 2)
    *
          IF( INFO.NE.0 ) THEN
             IF (CALL_REPORT_EXCEPTIONS)
         $     CALL REPORT_EXCEPTIONS(CONTEXT,6,ROUTINE_NAME,INFO_ARRAY)
             CALL XERBLA( ’SGETRF’, -INFO )
             RETURN
          END IF
    *
    *     Quick return if possible
    *
          IF( M.EQ.0 .OR. N.EQ.0 )
         $   RETURN
    *
    *     Check for exceptional inputs in A
          CALL SGECHECKARG( FLAG_REPORT_INTERNAL, M, N, A, LDA,
         $                  INFO, INFO_INTERNAL, INFO_ARRAY, 3, 2, 0, 7 )
    100   CONTINUE
    *
    *     Quick return if possible
    *
          IF( M.EQ.0 .OR. N.EQ.0 )
         $   RETURN
    *
    *     Determine the block size for this environment.
    *
          NB = ILAENV( 1, ’SGETRF’, ’ ’, M, N, -1, -1 )
          IF( NB.LE.1 .OR. NB.GE.MIN( M, N ) ) THEN
    *
    *        Use unblocked code.
    *
    *        Indicate if input already checked for Infs and NaNs
             IF (WHAT .GE. 1 .AND. HOW .GE. 1) THEN
                INFO_SGETRF2_TMP1(7) = -1
                IF (INFO_ARRAY(7) .NE. 0)
         $          INFO_SGETRF2_TMP1(7) = INFO_ARRAY(7)
             ENDIF
    *
             CALL SGETRF2_EC( M, N, A, LDA, IPIV,
         $             INFO, FLAG_REPORT_CALL, INFO_SGETRF2_TMP1, CONTEXT)
    *
    *        Check inputs, outputs and internal calls of
    *        first call to SGETRF2_EC
             CALL CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                   INFO_SGETRF2_TMP1, INFO_ARRAY, N+2, 8 )
          ELSE
    *
    *        Use blocked code.
    *
             DO 20 J = 1, MIN( M, N ), NB
                JB = MIN( MIN( M, N )-J+1, NB )
    *
    *           Factor diagonal and subdiagonal blocks and test for exact
    *           singularity.
    *
    *           Indicate that input not already checked
                IF (WHAT .GE. 1 .AND. HOW .GE. 1)
         $         INFO_SGETRF2_TMP2(7) = -1
    *
                CALL SGETRF2_EC( M-J+1, JB, A(J,J), LDA, IPIV(J),
         $            IINFO, FLAG_REPORT_CALL, INFO_SGETRF2_TMP2, CONTEXT)
    *
    *           Check inputs, outputs and internal calls of
    *           second call to SGETRF2_EC
                CALL CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                      INFO_SGETRF2_TMP2, INFO_ARRAY, N+3, 9 )
    *
    *           Adjust INFO and the pivot indices.
    *
                IF( INFO.EQ.0 .AND. IINFO.GT.0 )
         $         INFO = IINFO + J - 1
                DO 10 I = J, MIN( M, J+JB-1 )
                   IPIV( I ) = J - 1 + IPIV( I )
       10       CONTINUE
    *
    *           Apply interchanges to columns 1:J-1.
    *
                CALL SLASWP( J-1, A, LDA, J, J+JB-1, IPIV, 1 )
    *
                IF( J+JB.LE.N ) THEN
    *
    *              Apply interchanges to columns J+JB:N.
    *
                   CALL SLASWP( N-J-JB+1, A( 1, J+JB ), LDA, J, J+JB-1,
         $                      IPIV, 1 )
    *
    *              Compute block row of U.
    *
                   CALL STRSM( ’Left’, ’Lower’, ’No transpose’, ’Unit’,JB,
         $                     N-J-JB+1, ONE, A( J, J ), LDA, A(J, J+JB),
         $                     LDA )
                   IF( J+JB.LE.M ) THEN
    *
    *                 Update trailing submatrix.
    *
                      CALL SGEMM( ’No transpose’,’No transpose’, M-J-JB+1,
         $                        N-J-JB+1, JB, -ONE, A( J+JB, J ), LDA,
         $                        A( J, J+JB ), LDA, ONE, A( J+JB, J+JB ),
         $                        LDA )
                   END IF
                END IF
       20    CONTINUE
          END IF
    *
    *     Check for errors before returning
    *
          IF (WHAT.EQ.-1) RETURN
    *     Check for exceptional outputs in A
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, M, N, A, LDA,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 3, 3, N+1, 7)
    *
    *     Update INFO and INFO_ARRAY
          CALL UPDATE_INFO( INFO, INFO_ARRAY, INFO_INTERNAL )
          IF (CALL_REPORT_EXCEPTIONS .AND. INFO .NE. 0)
         $   CALL REPORT_EXCEPTIONS(CONTEXT, 6, ROUTINE_NAME, INFO_ARRAY)
          RETURN
    *
    *     End of SGETRF_EC
    *
          END

    *> \brief \b SGETRF2_EC
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       RECURSIVE SUBROUTINE SGETRF2_EC( M, N, A, LDA, IPIV,
    *      $                     INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *       .. Scalar Arguments ..
    *       INTEGER            INFO, LDA, M, N
    *       ..
    *       .. Array Arguments ..
    *       INTEGER            IPIV( * )
    *       INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( 10 )
    *       REAL               A( LDA, * )
    *       ..
    *       .. Pointer Arguments ..
    *       POINTER            CONTEXT ... advice requested
    *
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> SGETRF2_EC computes an LU factorization of a general M-by-N matrix
    *> A using partial pivoting with row interchanges.
    *>
    *> The factorization has the form
    *>    A = P * L * U
    *> where P is a permutation matrix, L is lower triangular with unit
    *> diagonal elements (lower trapezoidal if m > n), and U is upper
    *> triangular (upper trapezoidal if m < n).
    *>
    *> This is the recursive version of the algorithm. It divides
    *> the matrix into four submatrices:
    *>
    *>        [  A11 | A12  ]  where A11 is n1 by n1 and A22 is n2 by n2
    *>    A = [ -----|----- ]  with n1 = min(m,n)/2
    *>        [  A21 | A22  ]       n2 = n-n1
    *>
    *>                                       [ A11 ]
    *> The subroutine calls itself to factor [ --- ],
    *>                                       [ A12 ]
    *>                 [ A12 ]
    *> do the swaps on [ --- ], solve A12, update A22,
    *>                 [ A22 ]
    *>
    *> then calls itself to factor A22 and do the swaps on A21.
    *>
    *> SGETRF2_EC also provides new exception handling and
    *> reporting capabilities.
    *>
    *> \endverbatim
    *
    *  Arguments:
    *  ==========
    *
    *> \param[in] M
    *> \verbatim
    *>          M is INTEGER
    *>          The number of rows of the matrix A.  M >= 0.
    *> \endverbatim
    *>
    *> \param[in] N
    *> \verbatim
    *>          N is INTEGER
    *>          The number of columns of the matrix A.  N >= 0.
    *> \endverbatim
    *>
    *> \param[in,out] A
    *> \verbatim
    *>          A is REAL array, dimension (LDA,N)
    *>          On entry, the M-by-N matrix to be factored.
    *>          On exit, the factors L and U from the factorization
    *>          A = P*L*U; the unit diagonal elements of L are not stored.
    *> \endverbatim
    *>
    *> \param[in] LDA
    *> \verbatim
    *>          LDA is INTEGER
    *>          The leading dimension of the array A.  LDA >= max(1,M).
    *> \endverbatim
    *>
    *> \param[out] IPIV
    *> \verbatim
    *>          IPIV is INTEGER array, dimension (min(M,N))
    *>          The pivot indices; for 1 <= i <= min(M,N), row i of the
    *>          matrix was interchanged with row IPIV(i).
    *> \endverbatim
    *>
    *> \param[out] INFO
    *> \verbatim
    *>          INFO is INTEGER
    *>          INFO is defined below depending on FLAG_REPORT
    *> \endverbatim
    *>
    *> \param[in] FLAG_REPORT
    *> \verbatim
    *>          FLAG_REPORT is INTEGER array, dimension(2)
    *>          FLAG_REPORT(1) defines what kinds of exceptions to report,
    *>          report, using INFO and possibly also INFO_ARRAY for more
    *>          details. FLAG_REPORT(1)
    *>           <= -1 turns off all error checking, so INFO=0 is
    *>                 returned.
    *>            =  0 does standard argument checking:
    *>                 INFO = 0  means successful exit
    *>                 INFO = -i means the i-th (non-floating point)
    *>                           argument had an illegal value
    *>                           (first error found is reported)
    *>                 INFO = i means U(i,i) = 0. The factorization
    *>                          has been completed, but the factor U is
    *>                          exactly singular, and division by zero
    *>                          will occur if it is used to solve a
    *>                          system of equations.
    *>                 Using INFO to report the above errors has priority
    *>                 over reporting any of the errors described below.
    *>                 More generally, an error that would be found with
    *>                 a lower value of FLAG_REPORT(1) has priority to
    *>                 report using INFO than an error that would only
    *>                 be found with a higher value of FLAG_REPORT(1).
    *>            =  1 also checks for Infs and NaNs in inputs and
    *>                 outputs, if INFO not already nonzero:
    *>                 INFO = -3 means A contained an Inf or NaN on
    *>                           input; execution continues.
    *>                 INFO = N+1 means that A contained an Inf or NaN on
    *>                        output but not input.
    *>                 A will also be checked on input and output if
    *>                 FLAG_REPORT(2) = 1, 2 or 3 and reported in
    *>                 INFO_ARRAY as described below.
    *>            >= 2 also checks for Infs and NaNs as inputs or outputs
    *>                 in all internal LAPACK calls in the call chain, if
    *>                 INFO is not already nonzero, and
    *>                 FLAG_REPORT(2) = 1, 2 or 3. In this case:
    *>                 INFO = N+2 means that either the first recursive
    *>                        call to SGETRF2_EC had an Inf or NaN as an
    *>                        input or output as above, or a subroutine
    *>                        in its call tree did.
    *>                 INFO = N+3 means that either the second recursive
    *>                        call to SGETRF2_EC had an Inf or NaN as an
    *>                        input or output as above, or a subroutine
    *>                        in its call tree did.
    *>                 Each input, output and internal LAPACK call will
    *>                 also be checked if FLAG_REPORT(2) = 1, 2 or 3 and
    *>                 reported in INFO_ARRAY as described below.
    *>
    *>          FLAG_REPORT(2) defines how to report the exceptions
    *>          requested by FLAG_REPORT(1).
    *>            If FLAG_REPORT(1) <= -1, FLAG_REPORT(2) is ignored and
    *>            INFO=0 is returned.
    *>            Otherwise, FLAG_REPORT(2)
    *>             <=  0 only returns the value of INFO described above.
    *>              =  1 also returns INFO_ARRAY, as described below.
    *>              =  2 means that SGETRF2_EC will also call
    *>                   REPORT_EXCEPTIONS to report INFO_ARRAY, if INFO
    *>                   is nonzero.
    *>              =  3 means that all calls in the call tree will also
    *>                   call REPORT_EXCEPTIONS, if the value of INFO
    *>                   they return is nonzero.
    *>             >=  4 means that SGETRF2_EC will call
    *>                   GET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   to get values of FLAG_REPORT to use, overriding
    *>                   input values. The user needs to have called
    *>                   SET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   before calling SGETRF2_EC in order to set
    *>                   FLAG_REPORT, otherwise the default is
    *>                   FLAG_REPORT = [0, 0]. The input array
    *>                   FLAG_REPORT will not be overwritten.
    *> \endverbatim
    *>
    *> \param[out] INFO_ARRAY
    *> \verbatim
    *>          INFO_ARRAY is INTEGER array, dimension( 9 )
    *>          If FLAG_REPORT(1) <= -1 or FLAG_REPORT(2) <= 0,
    *>          INFO_ARRAY is not accessed. Otherwise:
    *>          INFO_ARRAY(1)
    *>              = value of INFO from standard argument checking
    *>                (as defined by FLAG_REPORT(1) = 0)
    *>          INFO_ARRAY(2)
    *>              = value of FLAG_REPORT(1) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(3)
    *>              = value of FLAG_REPORT(2) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(4)
    *>              = value of INFO as specified by FLAG_REPORT(1) above
    *>          INFO_ARRAY(5)
    *>              = 1 = number of input/output arguments reported on
    *>          INFO_ARRAY(6)
    *>              = 2 = number of internal LAPACK calls reported on
    *>          INFO_ARRAY(7) reports exceptions in A, as specified by
    *>            FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and contains no Infs or NaNs
    *>              =  1 if checked and contains an Inf or NaN on input
    *>                   but not output
    *>              =  2 if checked and contains an Inf or NaN on output
    *>                   but not input
    *>              =  3 if checked and contains an Inf or NaN on input
    *>                   and output
    *>            If INFO_ARRAY(7) = 0 or 1 on input, then A will not
    *>            be checked again. Input values < -1 or > 1 will be
    *>            treated the same as -1, i.e. not checked.
    *>          INFO_ARRAY(8) reports exceptions in the first recursive
    *>            call to SGETRF2_EC, as specified by FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and no Infs or NaNs reported
    *>              =  1 if checked and no input or output contains an
    *>                   Inf or NaN, but some LAPACK call deeper in the
    *>                   call chain signaled an Inf or NaN
    *>              =  2 if checked and an input argument contains an
    *>                   Inf or NaN, but not an output
    *>              =  3 if checked and an output argument contains an
    *>                   Inf or NaN, but not an input
    *>              =  4 if checked and an argument contains an
    *>                   Inf or NaN on input and output
    *>          INFO_ARRAY(9) reports exceptions in the second recursive
    *>            call to SGETRF2_EC, analogously to INFO_ARRAY(8)
    *> \endverbatim
    *>
    *> \param[in] CONTEXT
    *> \verbatim
    *>           CONTEXT is POINTER to an "opaque object"
    *> \endverbatim
    *>
    *
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEcomputational
    *
    *  =====================================================================
          RECURSIVE SUBROUTINE SGETRF2_EC( M, N, A, LDA, IPIV,
         $                     INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *  -- LAPACK computational routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
    *     .. Scalar Arguments ..
          INTEGER            INFO, LDA, M, N
    *     ..
    *     .. Array Arguments ..
          INTEGER            IPIV( * )
          REAL               A( LDA, * )
          INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( * )
    *     ..
    *     .. Pointer Arguments
          POINTER            CONTEXT
    *
    *  =====================================================================
    *
    *     .. Parameters ..
          REAL               ONE, ZERO
          PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
          CHARACTER, DIMENSION(7), PARAMETER ::
         $   ROUTINE_NAME = (/ ’S’,’G’,’E’,’T’,’R’,’F’,’2’ /)
    *     ..
    *     .. Local Scalars ..
          LOGICAL            CALL_REPORT_EXCEPTIONS
          REAL               SFMIN, TEMP
          INTEGER            I, IINFO, N1, N2
          INTEGER            WHAT, HOW
    *     ..
    *     .. Local Arrays ..
          INTEGER            FLAG_REPORT_INTERNAL(2), FLAG_REPORT_CALL(2)
          INTEGER            INFO_SGETRF2_TMP1(9), INFO_SGETRF2_TMP2(9)
          INTEGER            INFO_INTERNAL(2)
    *     ..
    *     .. External Functions ..
          REAL               SLAMCH
          INTEGER            ISAMAX
          EXTERNAL           SLAMCH, ISAMAX
    *     ..
    *     .. External Subroutines ..
          EXTERNAL           SGEMM, SSCAL, SLASWP, STRSM, XERBLA
          EXTERNAL           CHECKINIT1, CHECKINIT2
          EXTERNAL           SGECHECKARG, CHECKCALL
          EXTERNAL           UPDATE_INFO
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          MAX, MIN
    *     ..
    *     .. Executable Statements ..
    *
    *     Test the input parameters
    *
          INFO = 0
    *     Initialize error checking flags
          CALL CHECKINIT1(FLAG_REPORT, FLAG_REPORT_INTERNAL,
         $                FLAG_REPORT_CALL, CALL_REPORT_EXCEPTIONS,
         $                CONTEXT )
          WHAT = FLAG_REPORT_INTERNAL( 1 )
          HOW = FLAG_REPORT_INTERNAL( 2 )
          IF (WHAT .EQ. -1 ) GOTO 100
    *
    *     Check for standard input errors
          IF( M.LT.0 ) THEN
             INFO = -1
          ELSE IF( N.LT.0 ) THEN
             INFO = -2
          ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
             INFO = -4
          END IF
    *
    *     Initialize error flags
          CALL CHECKINIT2( FLAG_REPORT_INTERNAL, INFO, INFO_INTERNAL,
         $                 INFO_ARRAY, 1, 2)
    *
          IF( INFO.NE.0 ) THEN
             IF (CALL_REPORT_EXCEPTIONS)
         $     CALL REPORT_EXCEPTIONS(CONTEXT,7,ROUTINE_NAME,INFO_ARRAY)
             CALL XERBLA( ’SGETRF2’, -INFO )
             RETURN
          END IF
    *
    *     Quick return if possible
    *
          IF( M.EQ.0 .OR. N.EQ.0 )
         $   RETURN
    *
    *     Check for exceptional inputs in A
          CALL SGECHECKARG( FLAG_REPORT_INTERNAL, M, N, A, LDA,
         $                  INFO, INFO_INTERNAL, INFO_ARRAY, 3, 2, 0, 7 )
    *
    100   CONTINUE
    *
    *     Quick return if possible
    *
          IF( M.EQ.0 .OR. N.EQ.0 )
         $   RETURN
    *
          IF ( M.EQ.1 ) THEN
    *
    *        Use unblocked code for one row case
    *        Just need to handle IPIV and INFO
    *
             IPIV( 1 ) = 1
             IF ( A(1,1).EQ.ZERO )
         $      INFO = 1
    *
          ELSE IF( N.EQ.1 ) THEN
    *
    *        Use unblocked code for one column case
    *
    *
    *        Compute machine safe minimum
    *
             SFMIN = SLAMCH(’S’)
    *
    *        Find pivot and test for singularity
    *
             I = ISAMAX( M, A( 1, 1 ), 1 )
             IPIV( 1 ) = I
             IF( A( I, 1 ).NE.ZERO ) THEN
    *
    *           Apply the interchange
    *
                IF( I.NE.1 ) THEN
                   TEMP = A( 1, 1 )
                   A( 1, 1 ) = A( I, 1 )
                   A( I, 1 ) = TEMP
                END IF
    *
    *           Compute elements 2:M of the column
    *
                IF( ABS(A( 1, 1 )) .GE. SFMIN ) THEN
                   CALL SSCAL( M-1, ONE / A( 1, 1 ), A( 2, 1 ), 1 )
                ELSE
                   DO 10 I = 1, M-1
                      A( 1+I, 1 ) = A( 1+I, 1 ) / A( 1, 1 )
       10          CONTINUE
                END IF
    *
             ELSE
                INFO = 1
             END IF
    *
          ELSE
    *
    *        Use recursive code
    *
             N1 = MIN( M, N ) / 2
             N2 = N-N1
    *
    *               [ A11 ]
    *        Factor [ --- ]
    *               [ A21 ]
    *
    *        Indicate if input already checked, with no Infs and NaNs
             IF (WHAT .GE. 1 .AND. HOW .GE. 1) THEN
                INFO_SGETRF2_TMP1(7) = -1
                IF (INFO_ARRAY(7) .NE. -1)
         $          INFO_SGETRF2_TMP1(7) = INFO_ARRAY(7)
             ENDIF
    *
             CALL SGETRF2_EC( M, N1, A, LDA, IPIV,
         $        IINFO, FLAG_REPORT_CALL, INFO_SGETRF2_TMP1, CONTEXT )
    *
             IF ( INFO.EQ.0 .AND. IINFO.GT.0 ) THEN
                INFO = IINFO
             ENDIF
    *
    *        Check inputs, outputs and internal calls of
    *        first call to SGETRF2_EC
             CALL CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                   INFO_SGETRF2_TMP1, INFO_ARRAY, N+2, 8 )
    *
    *                              [ A12 ]
    *        Apply interchanges to [ --- ]
    *                              [ A22 ]
    *
             CALL SLASWP( N2, A( 1, N1+1 ), LDA, 1, N1, IPIV, 1 )
    *
    *        Solve A12
    *
             CALL STRSM( ’L’, ’L’, ’N’, ’U’, N1, N2, ONE, A, LDA,
         $               A( 1, N1+1 ), LDA )
    *
    *        Update A22
    *
             CALL SGEMM( ’N’, ’N’, M-N1, N2, N1, -ONE, A( N1+1, 1 ), LDA,
         $               A( 1, N1+1 ), LDA, ONE, A( N1+1, N1+1 ), LDA )
    *
    *        Factor A22
    *
    *        Indicate that input not already checked
             IF (WHAT .GE. 1 .AND. HOW .GE. 1) INFO_SGETRF2_TMP2(7) = -1
    *
             CALL SGETRF2_EC( M-N1, N2, A( N1+1, N1+1 ), LDA, IPIV(N1+1),
         $         IINFO, FLAG_REPORT_CALL, INFO_SGETRF2_TMP2, CONTEXT )
    *
    *        Check inputs, outputs and internal calls of
    *        second call to SGETRF2_EC
             CALL CHECKCALL( FLAG_REPORT_INTERNAL, INFO_INTERNAL,
         $                   INFO_SGETRF2_TMP2, INFO_ARRAY, N+3, 9 )
    *
    *        Adjust INFO and the pivot indices
    *
             IF ( INFO.EQ.0 .AND. IINFO.GT.0 )
         $      INFO = IINFO + N1
             DO 20 I = N1+1, MIN( M, N )
                IPIV( I ) = IPIV( I ) + N1
       20    CONTINUE
    *
    *        Apply interchanges to A21
    *
             CALL SLASWP( N1, A( 1, 1 ), LDA, N1+1, MIN( M, N), IPIV, 1 )
    *
          END IF
    *
    *     Check for errors before returning
    *
          IF (WHAT.EQ.-1) RETURN
    *     Check for exceptional outputs in A
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, M, N, A, LDA,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 3, 3, N+1, 7)
    *
    *     Update INFO and INFO_ARRAY
          CALL UPDATE_INFO( INFO, INFO_ARRAY, INFO_INTERNAL )
          IF (CALL_REPORT_EXCEPTIONS .AND. INFO .NE. 0)
         $   CALL REPORT_EXCEPTIONS(CONTEXT, 7, ROUTINE_NAME, INFO_ARRAY)
          RETURN
    *
    *     End of SGETRF2_EC
    *
          END

    *> \brief \b SGETRS_EC
    *
    *  =========== DOCUMENTATION ===========
    *
    * Online html documentation available at
    *            http://www.netlib.org/lapack/explore-html/
    *
    *  Definition:
    *  ===========
    *
    *       SUBROUTINE SGETRS_EC( TRANS, N, NRHS, A, LDA, IPIV, B, LDB,
    *      $                     INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *       .. Scalar Arguments ..
    *       CHARACTER          TRANS
    *       INTEGER            INFO, LDA, LDB, N, NRHS
    *       ..
    *       .. Array Arguments ..
    *       INTEGER            IPIV( * )
    *       INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( 7 )
    *       REAL               A( LDA, * ), B( LDB, * )
    *       ..
    *       .. Pointer Arguments ..
    *       POINTER            CONTEXT ... advice requested
    *
    *
    *> \par Purpose:
    *  =============
    *>
    *> \verbatim
    *>
    *> SGETRS_EC solves a system of linear equations
    *>    A * X = B  or  A**T * X = B
    *> with a general N-by-N matrix A using the LU factorization computed
    *> by SGETRF_EC.
    *>
    *> SGETRS_EC also provides new exception handling and
    *> reporting capabilities.
    *>
    *> \endverbatim
    *
    *  Arguments:
    *  ==========
    *
    *> \param[in] TRANS
    *> \verbatim
    *>          TRANS is CHARACTER*1
    *>          Specifies the form of the system of equations:
    *>          = ’N’:  A * X = B  (No transpose)
    *>          = ’T’:  A**T* X = B  (Transpose)
    *>          = ’C’:  A**T* X = B  (Conjugate transpose = Transpose)
    *> \endverbatim
    *>
    *> \param[in] N
    *> \verbatim
    *>          N is INTEGER
    *>          The order of the matrix A.  N >= 0.
    *> \endverbatim
    *>
    *> \param[in] NRHS
    *> \verbatim
    *>          NRHS is INTEGER
    *>          The number of right hand sides, i.e., the number of columns
    *>          of the matrix B.  NRHS >= 0.
    *> \endverbatim
    *>
    *> \param[in] A
    *> \verbatim
    *>          A is REAL array, dimension (LDA,N)
    *>          The factors L and U from the factorization A = P*L*U
    *>          as computed by SGETRF.
    *> \endverbatim
    *>
    *> \param[in] LDA
    *> \verbatim
    *>          LDA is INTEGER
    *>          The leading dimension of the array A.  LDA >= max(1,N).
    *> \endverbatim
    *>
    *> \param[in] IPIV
    *> \verbatim
    *>          IPIV is INTEGER array, dimension (N)
    *>          The pivot indices from SGETRF; for 1<=i<=N, row i of the
    *>          matrix was interchanged with row IPIV(i).
    *> \endverbatim
    *>
    *> \param[in,out] B
    *> \verbatim
    *>          B is REAL array, dimension (LDB,NRHS)
    *>          On entry, the right hand side matrix B.
    *>          On exit, the solution matrix X.
    *> \endverbatim
    *>
    *> \param[in] LDB
    *> \verbatim
    *>          LDB is INTEGER
    *>          The leading dimension of the array B.  LDB >= max(1,N).
    *> \endverbatim
    *>
    *> \param[out] INFO
    *> \verbatim
    *>          INFO is INTEGER
    *>          INFO is defined below depending on FLAG_REPORT
    *> \endverbatim
    *>
    *> \param[in] FLAG_REPORT
    *> \verbatim
    *>          FLAG_REPORT is INTEGER array, dimension(2)
    *>          FLAG_REPORT(1) defines what kinds of exceptions to report
    *>          using INFO and possibly also INFO_ARRAY for more details.
    *>          FLAG_REPORT(1)
    *>           <= -1 turns off all error checking, so INFO=0 is
    *>                 returned.
    *>            =  0 does standard argument checking:
    *>                 INFO = 0  means successful exit
    *>                 INFO = -i means the i-th (non-floating point)
    *>                           argument had an illegal value
    *>                           (first error found is reported)
    *>                 Using INFO to report the above errors has priority
    *>                 over reporting any of the errors described below.
    *>                 More generally, an error that would be found with
    *>                 a lower value of FLAG_REPORT(1) has priority to
    *>                 report using INFO than an error that would only
    *>                 be found with a higher value of FLAG_REPORT(1).
    *>            =  1 also checks for Infs and NaNs in inputs and
    *>                 outputs, if INFO is not already nonzero:
    *>                 INFO = -4 means A contained an Inf or NaN on
    *>                           input; execution continues.
    *>                 INFO = -7 means B contained an Inf or NaN on
    *>                           input but A did not;
    *>                           execution continues.
    *>                 INFO = 1  means B contained an Inf or NaN on
    *>                           output but neither A nor B did on input.
    *>                 Since A is an input variable, it is not checked
    *>                 on output.
    *>                 Each input and output will also be checked if
    *>                 FLAG_REPORT(2) = 1, 2, or 3 and reported in
    *>                 INFO_ARRAY as described below.
    *>           >=  2 has the same behavior as 1, since there are no
    *>                 internal calls to LAPACK routines with INFO
    *>                 parameters to be checked.
    *>
    *>          FLAG_REPORT(2) defines how to report the exceptions
    *>          requested by FLAG_REPORT(1).
    *>            If FLAG_REPORT(1) <= -1, FLAG_REPORT(2) is ignored and
    *>            INFO=0 is returned.
    *>            Otherwise, FLAG_REPORT(2)
    *>             <=  0 only returns the value of INFO described above.
    *>              =  1 also returns INFO_ARRAY, as described below.
    *>              =  2 means that SGETRS_EC will also call
    *>                   REPORT_EXCEPTIONS to report INFO_ARRAY, if INFO
    *>                   is nonzero.
    *>              =  3 has the same behavior as 2. (If SGETRS called
    *>                   any LAPACK routines with INFO parameters
    *>                   internally then they would call
    *>                   REPORT_EXCEPTIONS too, but there are none.)
    *>             >=  4 means that SGETRS_EC will call
    *>                   GET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   to get values of FLAG_REPORT to use, overriding
    *>                   input values. The user needs to have called
    *>                   SET_FLAGS_TO_REPORT(CONTEXT,FLAG_REPORT)
    *>                   before calling SGETRS_EC in order to set
    *>                   FLAG_REPORT, otherwise the default is
    *>                   FLAG_REPORT = [0, 0]. The input array
    *>                   FLAG_REPORT will not be overwritten.
    *> \endverbatim
    *>
    *> \param[in,out] INFO_ARRAY
    *> \verbatim
    *>          INFO_ARRAY is INTEGER array, dimension( 8 )
    *>          If FLAG_REPORT(1) <= -1 or FLAG_REPORT(2) <= 0,
    *>          INFO_ARRAY is not accessed. Otherwise:
    *>          INFO_ARRAY(1)
    *>              = value of INFO from standard argument checking
    *>                (as defined by FLAG_REPORT(1) = 0)
    *>          INFO_ARRAY(2)
    *>              = value of FLAG_REPORT(1) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(3)
    *>              = value of FLAG_REPORT(2) used to determine the rest
    *>                of INFO_ARRAY
    *>          INFO_ARRAY(4)
    *>              = value of INFO as specified by FLAG_REPORT(1) above
    *>          INFO_ARRAY(5)
    *>              = 2 = number of input/output arguments reported on
    *>          INFO_ARRAY(6)
    *>              = 0 = number of internal LAPACK calls reported on
    *>          INFO_ARRAY(7) reports exceptions in A, as specified by
    *>            FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and contains no Infs or NaNs
    *>              =  1 if checked and contains an Inf or NaN on input
    *>            If INFO_ARRAY(7) = 0 or 1 on input, then A will not
    *>            be checked again on input. Input values < -1 or > 1
    *>            will be treated the same as -1, i.e. not checked.
    *>          INFO_ARRAY(8) reports exceptions in B, as specified by
    *>            FLAG_REPORT
    *>              = -1 if not checked (default)
    *>              =  0 if checked and contains no Infs or NaNs
    *>              =  1 if checked and contains an Inf or NaN on input
    *>                   but not output
    *>              =  2 if checked and contains an Inf or NaN on output
    *>                   but not input
    *>              =  3 if checked and contains an Inf or NaN on input
    *>                   and output
    *>            As above, if INFO_ARRAY(8) = 0 or 1 on input, then B
    *>            will not be checked again on input. Input values < -1
    *>            or > 1 will be treated the same as -1,
    *>            i.e. not checked.
    *> \endverbatim
    *>
    *> \param[in] CONTEXT
    *> \verbatim
    *>           CONTEXT is POINTER to an "opaque object"
    *> \endverbatim
    *
    *  Authors:
    *  ========
    *
    *> \author Univ. of Tennessee
    *> \author Univ. of California Berkeley
    *> \author Univ. of Colorado Denver
    *> \author NAG Ltd.
    *
    *> \ingroup realGEcomputational
    *
    *  =====================================================================
          SUBROUTINE SGETRS_EC( TRANS, N, NRHS, A, LDA, IPIV, B, LDB,
         $                      INFO, FLAG_REPORT, INFO_ARRAY, CONTEXT )
    *
    *  -- LAPACK computational routine --
    *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    *
    *     .. Scalar Arguments ..
          CHARACTER          TRANS
          INTEGER            INFO, LDA, LDB, N, NRHS
    *     ..
    *     .. Array Arguments ..
          INTEGER            IPIV( * )
          REAL               A( LDA, * ), B( LDB, * )
          INTEGER            FLAG_REPORT( 2 ), INFO_ARRAY( * )
    *     ..
    *     .. Pointer Arguments
          POINTER            CONTEXT
    *  =====================================================================
    *
    *     .. Parameters ..
          REAL               ONE
          PARAMETER          ( ONE = 1.0E+0 )
          CHARACTER, DIMENSION(6), PARAMETER ::
         $   ROUTINE_NAME = (/ ’S’,’G’,’E’,’T’,’R’,’S’ /)
    *     ..
    *     .. Local Scalars ..
          LOGICAL            NOTRAN, CALL_REPORT_EXCEPTIONS
          INTEGER            WHAT, HOW
    *     ..
    *     .. Local Arrays ..
          INTEGER            FLAG_REPORT_INTERNAL(2), FLAG_REPORT_CALL(2)
          INTEGER            INFO_INTERNAL( 2 )
    *     ..
    *     .. External Functions ..
          LOGICAL            LSAME
          EXTERNAL           LSAME
    *     ..
    *     .. External Subroutines ..
          EXTERNAL           SLASWP, STRSM, XERBLA
          EXTERNAL           CHECKINIT1, CHECKINIT2
          EXTERNAL           SGECHECKARG
          EXTERNAL           UPDATE_INFO
    *     ..
    *     .. Intrinsic Functions ..
          INTRINSIC          MAX, MIN
    *     ..
    *     .. Executable Statements ..
    *
    *     Test the input parameters.
    *
          INFO = 0
    *     Initialize error checking flags
          CALL CHECKINIT1(FLAG_REPORT, FLAG_REPORT_INTERNAL,
         $                FLAG_REPORT_CALL, CALL_REPORT_EXCEPTIONS,
         $                CONTEXT )
          WHAT = FLAG_REPORT_INTERNAL( 1 )
          HOW = FLAG_REPORT_INTERNAL( 2 )
          IF (WHAT .EQ. -1 ) GOTO 100
    *
    *     Check for standard input errors
          NOTRAN = LSAME( TRANS, ’N’ )
          IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, ’T’ ) .AND. .NOT.
         $    LSAME( TRANS, ’C’ ) ) THEN
             INFO = -1
          ELSE IF( N.LT.0 ) THEN
             INFO = -2
          ELSE IF( NRHS.LT.0 ) THEN
             INFO = -3
          ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
             INFO = -5
          ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
             INFO = -8
          END IF
    *
    *     Initialize error flags
          CALL CHECKINIT2( FLAG_REPORT_INTERNAL, INFO, INFO_INTERNAL,
         $                 INFO_ARRAY, 2, 0)
    *
          IF( INFO.NE.0 ) THEN
             IF (CALL_REPORT_EXCEPTIONS)
         $      CALL REPORT_EXCEPTIONS(CONTEXT,6,ROUTINE_NAME,INFO_ARRAY)
             CALL XERBLA( ’SGETRS’, -INFO )
             RETURN
          END IF
    *
    *     Quick return if possible
    *
          IF( N.EQ.0 .OR. NRHS.EQ.0 )
         $   RETURN
    *
    *     Check for exceptional inputs in A
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, N, N, A, LDA,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 4, 0, 0, 7)
    *     Check for exceptional inputs in B
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, N, NRHS, B, LDB,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 7, 2, 0, 8)
    *
    100   CONTINUE
    *
    *     Quick return if possible
    *
          IF( N.EQ.0 .OR. NRHS.EQ.0 )
         $   RETURN
    *
          IF( NOTRAN ) THEN
    *
    *        Solve A * X = B.
    *
    *        Apply row interchanges to the right hand sides.
    *
             CALL SLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )
    *
    *        Solve L*X = B, overwriting B with X.
    *
             CALL STRSM(’Left’, ’Lower’, ’No transpose’, ’Unit’, N, NRHS,
         $               ONE, A, LDA, B, LDB )
    *
    *        Solve U*X = B, overwriting B with X.
    *
             CALL STRSM( ’Left’, ’Upper’, ’No transpose’, ’Non-unit’, N,
         $               NRHS, ONE, A, LDA, B, LDB )
          ELSE
    *
    *        Solve A**T * X = B.
    *
    *        Solve U**T *X = B, overwriting B with X.
    *
             CALL STRSM( ’Left’, ’Upper’, ’Transpose’, ’Non-unit’, N,
         $               NRHS, ONE, A, LDA, B, LDB )
    *
    *        Solve L**T *X = B, overwriting B with X.
    *
             CALL STRSM( ’Left’, ’Lower’, ’Transpose’, ’Unit’, N, NRHS,
         $               ONE, A, LDA, B, LDB )
    *
    *        Apply row interchanges to the solution vectors.
    *
             CALL SLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )
          END IF
    *
    *     Check for errors before returning
    *
          IF (WHAT .EQ. -1) RETURN
    *     Check for exceptional outputs in B
          CALL SGECHECKARG(FLAG_REPORT_INTERNAL, N, NRHS, B, LDB,
         $                 INFO, INFO_INTERNAL, INFO_ARRAY, 7, 3, 1, 8)
    *
    *     Update INFO and INFO_ARRAY
          CALL UPDATE_INFO( INFO, INFO_ARRAY, INFO_INTERNAL )
          IF (CALL_REPORT_EXCEPTIONS .AND. INFO .NE. 0)
         $   CALL REPORT_EXCEPTIONS(CONTEXT, 6, ROUTINE_NAME, INFO_ARRAY)
          RETURN
    *
    *     End of SGETRS_EC
    *
          END

## References

  * [1] Douglas N. Arnold.  The Explosion of the Ariane 5. Some disasters attributable to bad numerical computing, 2000.  23 August 2000, www-users.math.umn.edu/~arnold/disasters/ariane.html.
  * [2] Gregory Slabodkin.  Software glitches leave Navy Smart Ship dead in the water, 1998.  GCN, 13 July 1998, https://gcn.com/Articles/1998/07/13/Software-glitches-leave-Navy-Smart-Ship-dead-in-the-water.aspx. Accessed 28 April 2021.
  * [3] [OT Roborace] Driverless racecar drives straight into a wall, 2020.  https://www.reddit.com/r/formula1/comments/jk9jrg/ot˙roborace˙driverless˙racecar˙drives˙straight/gai295l/.
  * [4] J. Demmel and E. J. Riedy.  A new IEEE 754 standard for floating-point arithmetic in an ever-changing world.  SIAM News, July/August 2021.
  * [5] T. Huckle and T. Neckel.  Bits and Bugs: A Scientific and Historical Review of Software Failures in Computational Science.  SIAM, 2019.
  * [6] http://www.netlib.org/blas/.
  * [7] http://www.netlib.org/lapack/.
  * [8] 754-2019 IEEE Standard for Floating Point Arithmetic, 2019.
  * [9] D. G. Hough.  The IEEE Standard 754: One for the History Books.  Computer, 52(12):109–112, December 2019.  DOI: 10.1109/MC.2019.2926614.
  * [10] P. Ahrens, J. Demmel, and H. D. Nguyen.  Efficient Reproducible Floating Point Summation and BLAS.  ACM Trans. Math. Software, 46(3), 2020.
  * [11] https://en.wikipedia.org/wiki/bfloat16_floating-point_format, 2017.
  * [12] Intel Corporation.  BFLOAT16 – Hardware Numerics Definition.  Intel Corporation, Santa Clara, USA, 2018.
  * [13] Ahmad Abdelfattah, Hartwig Anzt, Erik G Boman, Erin Carson, Terry Cojean, Jack Dongarra, Alyson Fox, Mark Gates, Nicholas J Higham, Xiaoye S Li, Jennifer Loe, Piotr Luszczek, Srikara Pranesh, Siva Rajamanickam, Tobias Ribizel, Barry F Smith, Kasia Swirydowicz, Stephen Thomas, Stanimire Tomov, Yaohung M Tsai, and Ulrike Meier Yang.  A survey of numerical linear algebra methods utilizing mixed-precision arithmetic.  The International Journal of High Performance Computing Applications, 2021.  DOI: 10.1177/10943420211003313.
  * [14] grouper.ieee.org/groups/msc/ANSI˙IEEE-Std-754-2019/background/minNum˙maxNum˙Removal˙Demotion˙v3.pdf, 2019\.
  * [15] American National Standards Institute.  ANSI/ISO/IEC 9899-1999: Programming Languages — C.  American National Standards Institute, 1430 Broadway, New York, NY 10018, USA, 1999.
  * [16] https://grouper.ieee.org/groups/1788/email/pdfmPSi1DgZZf.pdf.
  * [17] J. Hauser.  Handling floating point exceptions in numeric programs.  ACM Trans. Programming Languages and Systems, 18(2), March 1996\.  https://people.eecs.berkeley.edu/~fateman/264/papers/hauser.pdf.
  * [18] 2008 Fortran Standard, 2008.  https://wg5-fortran.org/f2008.html.
  * [19] D. Priest.  Efficient scaling for complex division.  ACM Trans. Math. Software, 30(4), December 2004.
  * [20] M. Baudin and R. Smith.  A robust complex division in SciLab, October 2012.  https://arxiv.org/abs/1210.4539.
  * [21] C11 standard, 2011.  https://en.wikipedia.org/wiki/C11˙(C˙standard˙revision).
  * [22] Programming languages – C, 2011.  International Standard.
  * [23] Programming languages – C, ISO/IEC 9899:202x (E), February 5 2011.  N2478 working draft.
  * [24] https://github.com/advanpix/mpreal.
  * [25] Working draft, standard for programming language C++, November 27 2019.  Document number: N4842.
  * [26] D. S. Scott.  Out of core dense solvers on Intel parallel supercomputer, 1992.
  * [27] A. Abdelfattah, T. Costa, J. Dongarra, M. Gates, A. Haidar, S. Hammarling, N. Higham, J. Kurzak, P. Luszczek, S. Tomov, and M. Zounon.  A Set of Batched Basic Linear Algebra Subprograms and LAPACK Routines.  ACM Trans. Math. Software, 47(3), September 2021.
  * [28] E. Anderson.  Algorithm 978: Safe scaling in the Level 1 BLAS.  ACM TOMS, 44(1), 2017.
  * [29] D. Bindel, J. Demmel, W. Kahan, and O. Marques.  On computing Givens rotations reliably and efficiently.  ACM Trans. Math. Soft., 28(2), June 2002.  LAPACK Working Note 148.
  * [30] Aydın Buluç, Timothy Mattson, Scott McMillan, José Moreira, and Carl Yang.  The GraphBLAS C API specification, September 25, 2019.  Version 1.3.0, http://people.eecs.berkeley.edu/~aydin/GraphBLAS˙API˙C˙v13.pdf.
  * [31] James L. Blue.  A Portable Fortran Program to Find the Euclidean Norm of a Vector.  ACM Trans. Math. Software, 4(1):15–23, 1978.
  * [32] V. Strassen.  Gaussian elimination is not optimal.  Numerische Mathematik, 13(4):354–356, 1969.
  * [33] O. Marques, E. J. Riedy, and C. Vömel.  Benefits of IEEE-754 features in modern symmetric tridiagonal eigensolvers, September 2005.  LAPACK Working Note 172.
  * [34] J. Demmel and X. Li.  Faster numerical algorithms via exception handling.  IEEE Trans. Comput., 43(8), August 1994.
  * [35] J. Demmel and V. Volkov.  Using GPUs to accelerate the bisection algorithm for finding eigenvalues of symmetric tridiagonal matrices.  Technical Report UCB/EECS-2007-179, UC Berkeley, December 2007.
  * [36] https://en.wikipedia.org/wiki/Fuzzing, July 2021.