module linalg INTERFACE ! Interfaces are declared using assumed-size arrays, e.g. A( LDA, * ), ! to ensure f77 calling semantics from f95. ! lapack QR-based least squares solver SUBROUTINE DGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK, INFO ) CHARACTER TRANS INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS DOUBLE PRECISION A( LDA, * ), B( LDB, * ), WORK( * ) !call DGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK, INFO ) END SUBROUTINE ! lapack SVD-based least squares solver SUBROUTINE DGELSS( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, WORK, LWORK, INFO ) INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANK DOUBLE PRECISION RCOND DOUBLE PRECISION A( LDA, * ), B( LDB, * ), S( * ), WORK( * ) END SUBROUTINE ! lapack SVD-based least squares solver ! divide-and-conquer method SUBROUTINE DGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, WORK, LWORK, IWORK, INFO ) INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANK DOUBLE PRECISION RCOND INTEGER IWORK( * ) DOUBLE PRECISION A( LDA, * ), B( LDB, * ), S( * ), WORK( * ) END SUBROUTINE ! level-3 BLAS general matrix multiply SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC) !C := alpha*op( A )*op( B ) + beta*C DOUBLE PRECISION ALPHA,BETA INTEGER K,LDA,LDB,LDC,M,N CHARACTER TRANSA,TRANSB DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*) !call DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC) END SUBROUTINE ! lapack GLM driver SUBROUTINE DGGGLM( N, M, P, A, LDA, B, LDB, D, X, Y, WORK, LWORK, INFO ) INTEGER INFO, LDA, LDB, LWORK, M, N, P DOUBLE PRECISION A( LDA, * ), B( LDB, * ), D( * ), WORK( * ), X( * ), Y( * ) !call DGGGLM( N, M, P, A, LDA, B, LDB, D, X, Y, WORK, LWORK, INFO ) END SUBROUTINE END INTERFACE end module