| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | N | |||
| real(kind=r64), | intent(inout) | :: | A(:,:) | |||
| real(kind=r64), | intent(out) | :: | XSOL(:) | 
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
SUBROUTINE SOLMATS(N, A, XSOL)
          !
          ! SUBROUTINE INFORMATION:
          !       AUTHOR         John L. Wright, University of Waterloo,
          !                      Mechanical Engineering, Advanced Glazing System Laboratory
          !       DATE WRITTEN   Unknown
          !       MODIFIED       na
          !
          !       RE-ENGINEERED  na
          ! PURPOSE OF THIS SUBROUTINE:
          !  Matrix solver.
          !
          ! METHODOLOGY EMPLOYED:
          !  Solves matrix by the elimination method supplemented by a search for the
          !  largest pivotal element at each stage
          !
          ! REFERENCES:
          ! na
          ! USE STATEMENTS:
          ! na
          !
    IMPLICIT NONE   ! Enforce explicit typing of all variables in this routine
          ! SUBROUTINE ARGUMENT DEFINITIONS:
    INTEGER,      INTENT(IN) :: N            ! # of active rows in A
    REAL(r64), INTENT(INOUT) ::  A(:,:)      ! matrix, minimum required dimensions: A( N, N+2)
                                             !   modified in place
    REAL(r64),   INTENT(OUT) ::  XSOL(:)     ! returned: solution vector, min req dimension: XSOL( N)
          !
          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na
          ! INTERFACE BLOCK SPECIFICATIONS
          ! na
          ! DERIVED TYPE DEFINITIONS
          ! na
          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    REAL(r64) :: CMAX, TEMP, C, Y, D
    INTEGER   :: NM1, NP1, NP2, I, J, L, LP, NOS, NI, NJ
    NM1=N-1
    NP1=N+1
    NP2=N+2
    DO I=1,N
        A(I,NP2)=0.0d0
        ! DO 1 J=1,NP1    ! TODO ?
    END DO
    DO I=1,N
        DO J=1,NP1
            A(I,NP2)=A(I,NP2)+A(I,J)
        END DO
    END DO
    DO L=1,N-1
        CMAX=A(L,L)
        LP=L+1
        NOS=L
        DO I=LP,N
            IF (ABS(CMAX).LT.ABS(A(I,L))) THEN
                CMAX=A(I,L)
                NOS=I
            ENDIF
        END DO
        ! Swap rows
        IF (NOS.NE.L) THEN
            DO J=1,NP2
                TEMP=A(L,J)
                A(L,J)=A(NOS,J)
                A(NOS,J)=TEMP
            END DO
        END IF
        DO I=LP,N
            C=0.0d0
            Y=-A(I,L)/A(L,L)
            DO J=L,NP2
                A(I,J)=A(I,J)+Y*A(L,J)
            END DO
            DO J=L,NP1
                C=C+A(I,J)
            END DO
        END DO
    END DO
    ! back-substitute
    XSOL(N)=A(N,NP1)/A(N,N)
    DO I=1,NM1
        NI=N-I
        D=0.0d0
        DO J=1,I
            NJ=N+1-J
            D=D+A(NI,NJ)*XSOL(NJ)
        END DO
        XSOL(NI)=(A(NI,NP1)-D)/A(NI,NI)
    END DO
    RETURN
END SUBROUTINE SOLMATS