next up previous contents
Next: 2.3 PPGP Up: 2.2 LAPACK90 Previous: 2.2 LAPACK90

Example:

The Fortran90 Wrapper DGESV_F90 to LAPACK DGESV is in Table 2.

 

   SUBROUTINE DGESV_f90(A,B,IPIV,INFO)
!     .. Use Statements ..
      USE LA_PRECISION, ONLY: WP => DP
      USE LA_AUX, ONLY: ERINFO
      USE LAPACK77_INTERFACES, ONLY: GESV_F77 => DGESV
!     .. Implicit Statement ..
      IMPLICIT NONE
!     .. Scalar Arguments ..
      INTEGER, INTENT(OUT), OPTIONAL :: INFO
!     .. Array Arguments ..
      INTEGER, INTENT(OUT), OPTIONAL, TARGET :: IPIV(:)
      REAL(WP), INTENT(INOUT) :: A(:,:), B(:,:)
!     .. Parameters ..
      CHARACTER(LEN=7), PARAMETER :: SRNAME = 'LA_GESV'
!     .. Local Scalars ..
      INTEGER :: LD, LINFO, NRHS, N
!     .. Local Pointers ..
      INTEGER, POINTER :: LPIV(:)
!     .. Intrinsic Functions ..
!     INTRINSIC ALLOCATE, DEALLOCATE, MAX, PRESENT, SIZE
      INTRINSIC MAX, PRESENT, SIZE
!
!     .. Executable Statements ..
      LINFO = 0
      N = SIZE(A, 1)
      IF( SIZE( A, 2 ) /= N ) THEN
         LINFO = -1
      ELSE IF( SIZE( B, 1 ) /= N ) THEN
         LINFO = -2
      ELSE
         IF( PRESENT( IPIV ) )THEN
            IF( SIZE( IPIV ) /= N ) LINFO = -3
         END IF
      END IF
!
      IF ( LINFO == 0 ) THEN
         LD = MAX( 1, N )
         NRHS = SIZE(B,2)
         IF( PRESENT( IPIV ) )THEN
            LPIV => IPIV
         ELSE
            ALLOCATE(LPIV(N))
         END IF
         CALL GESV_F77( N, NRHS, A, LD, LPIV, B, LD, LINFO )
         IF(.NOT.PRESENT(IPIV)) DEALLOCATE(LPIV)
      END IF
      CALL ERINFO(LINFO,SRNAME,INFO)
!
   END SUBROUTINE DGESV_F90

 
Table 2: LAPACK90 Subroutine DGESV_F90 -- wrapper for the LAPACK routine to perform a Gaussian Elimination on general full matrix.

The level and amount of documentation for the LAPACK90 is not nearly as extreme as for LAPACK, since clearly the developers rely on the excellent documentation which the LAPACK routines (e.g., DGESV) have to offer. Although the code is cleanly broken up with comments into sections (e.g., module include, local variables, executable statements) there is clearly insufficient documentation if these routines were meant to be a stand-alone library.

In section A.1 we revisit the above code again to show how it would look like using the ProTeX conventions.



Will Sawyer
Fri Mar 6 18:02:18 EST 1998