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:
print*, "This program solves a tri-diagonal matrix using the Thomas Algorithm"
Here is the subroutine:
! SUBROUTINE SY SOLVES A TRIDIAGONAL SYSTEM OF !
! EQUATIONS FOLLOWING THE THOMAS ALGORITHM !
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)
!... 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)
!... SOLUTION STORED IN CC
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!
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.