C PSILU0    SOURCE    GOUNAND   11/07/21    21:15:47     7046
      SUBROUTINE PSILU0(TRANS,N,NNZ,JU,JLU,ALU,Z,R)
      IMPLICIT INTEGER(I-N)
      IMPLICIT REAL*8 (A-H,O-Z)
C***********************************************************************
C NOM         : PSILU0
C DESCRIPTION :
C    PSILU0 solves the linear system Mz = r
C    M is a (preconditionning) matrix written as :
C                 M=(D+L)D-1(D+U)
C    It can be the ILU(0) (i.e. Crout or Choleski)
C    incomplete factorization of a matrix A (computed in meilu0.eso)
C    or any other (preconditionning) matrix.
C
C    WE DO NOT STORE M but WE STORE L, D-1 and U in the same
C    Modified Sparse Row (MSR) matrix.
C    (see reference Sparskit version 2 for a description)
C
C    L and U correspond to the strictly lower and strictly
C    upper part of the factorization.
C
C
C LANGAGE     : FORTRAN 77 + chouilla ESOPE (pour les E/S)
C AUTEUR      : Stéphane GOUNAND (CEA/DRN/DMT/SEMT/TTMF)
C               mél : gounand@semt2.smts.cea.fr
C REFERENCE (bibtex-like) :
C  @BOOK{templates,
C        AUTHOR={R.Barrett, M.Berry, T.F.Chan, J.Demmel, J.Donato,
C                J.Dongarra, V.Eijkhout, R.Pozo, C.Romine,
C                H. Van der Vorst},
C        TITLE={Templates for the Solution of Linear Systems :
C               Building Blocks for Iterative Methods},
C        PUBLISHER={SIAM}, YEAR={1994}, ADDRESS={Philadelphia,PA} }
C  -> URL : http://www.netlib.org/templates/Templates.html
C  Sparskit : a basic tool kit for sparse matrix computations
C  Version 2 (Youcef Saad)
C  -> URL : http://www.cs.umn.edu/Research/arpa/SPARSKIT/sparskit.html
C
C***********************************************************************
C APPELES : -
C APPELE PAR       : CGILU0, BCGSI0, GMRI0
C***********************************************************************
C ENTREES            : N, NNZ, JU, JLU, ALU
C                      R
C ENTREES/SORTIES    : Z
C SORTIES            : -
C CODE RETOUR (IRET) : -
C     N      : nombre de degrés de liberté
C     NNZ    : nombre de valeurs non nulles de la factorisation Morse
C     JU,JLU,ALU : factorisation incomplète au format MSR
C     R      : vecteur second membre du système à résoudre.
C     Z      : vecteur des inconnues du système à résoudre.
C              initialisé dans la subroutine appelante.
C***********************************************************************
C VERSION    :     20/12/99
C HISTORIQUE : v1, 01/04/98, création
C HISTORIQUE :     20/12/99
C Modifications de la montée-descente (factorisations incomplètes
C stockées au format MSR (Modified Sparse Row).
C HISTORIQUE :
C***********************************************************************
C Prière de PRENDRE LE TEMPS de compléter les commentaires
C en cas de modification de ce sous-programme afin de faciliter
C la maintenance !
C***********************************************************************
*
*     .. Scalar Arguments ..
      INTEGER  N,NNZ
      CHARACTER*1        TRANS
      LOGICAL            LSAME
      EXTERNAL           LSAME
*     ..
*     .. Array Arguments ..
*     .. Matrices stockées en Morse
      INTEGER JU(N)
      INTEGER JLU(NNZ+1)
      REAL*8  ALU(NNZ+1)
*     .. Vecteurs
      REAL*8  Z(N),R(N)
*
*
*     .. Variables locales
      INTEGER I,K
*     .. Executable Statements ..
*
      IF (.NOT.LSAME(TRANS,'T')) THEN
*
* Montée
*
         DO 1 I=1,N
            Z(I)=R(I)
            DO 12 K=JLU(I),JU(I)-1
               Z(I)=Z(I)-ALU(K)*Z(JLU(K))
 12         CONTINUE
 1       CONTINUE
*
* Descente
*
         DO 3 I=N,1,-1
            DO 32 K=JU(I),JLU(I+1)-1
               Z(I)=Z(I)-ALU(K)*Z(JLU(K))
 32         CONTINUE
            Z(I)=ALU(I)*Z(I)
 3       CONTINUE
      ELSE
*
* Montée avec U^t
*
         DO 5 I=1,N
            Z(I)=R(I)
 5       CONTINUE
*
         DO 7 I=1,N
            Z(I)=Z(I)*ALU(I)
            DO 72 K=JU(I),JLU(I+1)-1
               Z(JLU(K))=Z(JLU(K))-ALU(K)*Z(I)
 72         CONTINUE
 7       CONTINUE
*
* Descente avec L^t
*
         DO 9 I=N,1,-1
            DO 92 K=JLU(I),JU(I)-1
               Z(JLU(K))=Z(JLU(K))-ALU(K)*Z(I)
 92         CONTINUE
 9       CONTINUE
      ENDIF

*
*     Normal termination (if lucky !)
*
      RETURN
*
*     End of PSILU0.
*
      END





