C PROFI1    SOURCE    CB215821  17/11/30    21:16:54     9639           
      SUBROUTINE PROFI1(N,NNN,E2,ADJ,XADJ,
     $     OLDPRO,NEWPRO,
     $     IMPR,IRET)
      IMPLICIT INTEGER(I-N)
      IMPLICIT REAL*8 (A-H,O-Z)
C***********************************************************************
C NOM         : PROFI1
C DESCRIPTION : Compute the profile using original and new node numbers
C
C LANGAGE     : FORTRAN 77 (sauf E/S)
C
C AUTEUR      : Scott Sloan
C
C BIBLIO      : @Article{,
C  author =  {S. W. Sloan},
C  title =   {A Fortran Program for Profile and Wavefront Reduction},
C  journal = {International Journal for Numerical Methods in Engineering},
C  year =    {1989},
C  volume =  {28},
C  pages =   {2651-2679}
C}
C
C***********************************************************************
C APPELE PAR       : LABEL
C***********************************************************************
C ENTREES            :
C     N      - Number of nodes in graph
C     NNN    - List of new node numbers
C            - New number for node I given by NNN(I)
C     E2     - Twice the number of edges in the graph = XADJ(N+1)-1
C     ADJ    - Adjacency list for all nodes in graph
C            - List of length 2E where E is the number of edges in
C              the graph and 2E = XADJ(N+1)-1
C     XADJ   - Index vector for ADJ
C            - Nodes adjacent to node I are found in ADJ(J), where
C              J = XADJ(I),...,XADJ(I+1)-1
C            - Degree of node I given by XADJ(I+1)-XADJ(I)
C ENTREES/SORTIES    : -
C SORTIES            :
C     OLDPRO - Profile with original node numbering
C     NEWPRO - Profile with new node numbering
C
C NOTES              :
C
C     Profiles include diagonal terms
C
C
C CODE RETOUR (IRET) : = 0 si tout s'est bien passé
C***********************************************************************
C VERSION    : v1, 05/11/99, version initiale
C HISTORIQUE : v1, 10/03/89, création
C HISTORIQUE :
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***********************************************************************
-INC PPARAM
-INC CCOPTIO
      INTEGER NEWPRO,I,J,N,JSTRT,JSTOP,OLDPRO,NEWMIN,OLDMIN,E2
      INTEGER NNN(N),XADJ(N+1),ADJ(E2)
      INTEGER IMPR,IRET
*
* Executable statements
*
      IF (IMPR.GT.1) WRITE(IOIMP,*) 'Entrée dans profi1'
*
*     Set profiles and loop over each node in graph
*
      OLDPRO=0
      NEWPRO=0
      DO 20 I=1,N
         JSTRT=XADJ(I)
         JSTOP=XADJ(I+1)-1
         OLDMIN=ADJ(JSTRT)
         NEWMIN=NNN(ADJ(JSTRT))
*
*     Find lowest numbered neighbour of node I
*     (using both old and new node numbers)
*
         DO 10 J=JSTRT+1,JSTOP
            OLDMIN=MIN(OLDMIN,ADJ(J))
            NEWMIN=MIN(NEWMIN,NNN(ADJ(J)))
 10      CONTINUE
*
*     Update profiles
*
         OLDPRO=OLDPRO+DIM(I,OLDMIN)
         NEWPRO=NEWPRO+DIM(NNN(I),NEWMIN)
 20   CONTINUE
*
*     Add diagonal terms to profiles
*
      OLDPRO=OLDPRO+N
      NEWPRO=NEWPRO+N
*
* Normal termination
*
      IRET=0
      RETURN
*
* Format handling
*
*
* Error handling
*
 9999 CONTINUE
      IRET=1
      WRITE(IOIMP,*) 'An error was detected in subroutine profi1'
      RETURN
*
* End of subroutine PROFI1
*
      END



 
