* PACKAGE LGLU2  !" $B@~7?2r@O(B : LU $BJ,2r$K$h$kO"N)J}Dx<0$N2r(B
*
*"  [HIS] 93/07/10(takepiro) $B!V9TNs7W;;%=%U%H%&%'%"!W;HMQ(B(GLU2)
*
**********************************************************************
      SUBROUTINE LGLU
     M            ( AMAT   , 
     M              BVEC   ,
     O              IERR   , 
     I              MATDIM , OLU   )
*
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)                      !" 
      INCLUDE   (ZLDIM)                      !" $B3J;RE@?t(B, $BGH?t(B
#else
#include        "zcdim.F"                    !" 
#include        "zldim.F"                    !" $B78?t9TNs$NBg$-$5(B
#endif
*
*   [MODIFY] 
      REAL      AMAT  ( MATDMX, MATDMX )     !" $B78?t9TNs(B
      REAL      BVEC  ( MATDMX )             !" $B1&JU%Y%/%H%k(B / $B2r(B
*
*   [OUTPUT] 
      INTEGER   IERR                         !" $B%5%V%k!<%A%s%(%i!<%3!<%I(B
*
*   [INPUT] 
      INTEGER   MATDIM                       !" $B7W;;$9$k<!85(B
      LOGICAL   OLU                          !" LU $BJ,2r$9$k$+H]$+(B
*
*   [INTERNAL WORK] 
      INTEGER   IP    ( MATDMX )             !" $B%T%\%C%H>pJs(B
      REAL      WRK1  ( MATDMX )             !" $B:n6HG[Ns(B
      REAL      WRK2  ( MATDMX )             !" $B:n6HG[Ns(B
      REAL      EPS                          !" $BFC0[@-$NH=Dj4p=`(B
      DATA      EPS  / 3.52D-15 /
*
      INTEGER   IUNIT
      LOGICAL   OFIRST 
      DATA      OFIRST  / .TRUE. /
*
      SAVE      EPS, OFIRST
*
      IF ( OFIRST )THEN
         OFIRST = .FALSE.
         CALL GLPGET( 'MSGUNIT', IUNIT )
         WRITE ( IUNIT, * ) 
     &          ' GAUSSIAN ELIMINATION 2-COL. METHOD : 93/07/10'
      ENDIF
*
      IERR = 0
*
      IF ( OLU ) THEN
         CALL GLU2
c$$$         CALL GLU4
     M          ( AMAT   , 
     I            MATDIM , MATDMX , 
     O            EPS    , 
     W            WRK1   , WRK2   ,
     O            IP     , IERR     )
      ENDIF
*
      IF ( IERR .EQ. 0 ) THEN
         CALL GSLV4
     I          ( AMAT   , 
     I            MATDIM , MATDMX , 
     M            BVEC   , 
     I            IP                )
      ELSE
         CALL MSGDMP
     &         ( 'W', 'LGLU', 'SOL. NOT CALCULATED BECAUSE OF ERRORS' )
      END IF
*
      RETURN
      END
