Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Error Message #6638

lotts__william
Beginner
210 Views

Hi, I am new to FORTRAN; I am just trying to learn the basics and so I am trying to implement a simple tridiagonal solver. The tridiagonal solver is a subroutine, and I am just trying to define the input (2 integers, and four 1 dimensional, size 8); this would've worked to do it this way with Python or MATLAB.  I've tried to troubleshoot this; I sure there is something simple I am missing. 

Here is the script that I call it from:

program TriSolver
    print*, "This program solves a tri-diagonal matrix using the Thomas Algorithm"
    IL=1
    IU=8
    CALL  SY(IL,IU,[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],[-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0,-2.0],[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],[-2.0,-2.0,4.0,-2.0,0.0,-5.0,3.0,-2.0])
end

Here is the subroutine:

!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
!                                                         !
!   SUBROUTINE SY SOLVES A TRIDIAGONAL SYSTEM OF          !
!   EQUATIONS FOLLOWING THE THOMAS ALGORITHM              !
!                                                         !
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
    
SUBROUTINE SY(IL,IU,BB,DD,AA,CC)
    IMPLICIT NONE
    INTEGER, INTENT(IN) :: IL, IU
    REAL, DIMENSION(IL:IU), INTENT(IN) :: AA,BB
    REAL, DIMENSION(IL:IU), INTENT(INOUT) :: CC,DD

    
!...
!... IL = SUBSCRIPT OF FIRST EQUATION
!... IU = SUBSCRIPT OF LAST EQUATION
!... BB = COEFFICIENT BEHIND DIAGONAL
!... DD = COEFFICIENT ON DIAGONAL
!... AA = COEFFICIENT AHEAD OF DIAGONAL
!... CC = ELEMENT OF CONSTANT VECTOR
!...
!... ESTABLISH UPPER TRIANGULAR MATRIX
!...
    
    INTEGER :: LP,I,J
    REAL :: R
    
    LP = IL + 1
    
    DO I = LP,IU
        R = BB(I)/DD(I-1)
        DD(I) = DD(I) -R*AA(I-1)
        CC(I) = CC(I) - R*CC(I-1)
    END DO
    
!...
!... BACK SUBSTITUTION
!...
    
    CC(IU) = CC(IU)/DD(IU)
    DO I=LP, IU
        J=IU - I + IL
        CC(J) = (CC(J) - AA(J)*CC(J+1))/DD(J)
    END DO
!...
!... SOLUTION STORED IN CC
!...
    
END SUBROUTINE

Here is the error message:

Severity    Code    Description    Project    File    Line    Suppression State
Error        error #6638: An actual argument is an expression or constant; this is not valid since the associated dummy argument has the explicit INTENT(OUT) or INTENT(INOUT) attribute.        C:\Users\William Lotts\source\repos\Tridiagonal Solver\Tridiagonal Solver\TriDia.f90    11 

 

Thanks for any help!

-Seth  
 

0 Kudos
2 Replies
Steve_Lionel
Black Belt Retired Employee
210 Views

The CC and DD arguments of SY are INTENT(INOUT), which means that SY is allowed to both read and write to the associated actual argument. You passed array constructors for these arguments, which are constants; constants cannot be written to.

A solution is to declare array variables in the main program, assign the array constructor to the variables, and pass the variables.

lotts__william
Beginner
210 Views

Thanks for your help!

Reply