user3478040
user3478040

Reputation: 11

Error in Fortran: attempt to call a routine with argument number four as a real (kind=1) when a procedure was required

I have never done programming in my life and this is my very first code for a uni assignment, I get no errors in the compiling stage but myh program does not run saying that I have the error in the title, guess the problem is when I call the subroutine. Can anyone help me? It is my first code and it is really frustrating. Thank you.

!NUMERICAL COMPUTATION OF INCOMPRESSIBLE COUETTE FLOW USING FINITE DIFFERENCE METHOD

!IMPLICIT APPROACH

!MODEL EQUATION
!PARTIAL(U)/PARTIAL(T)=1/RE*(PARTIAL(U) SQUARE/PARTIAL(Y) SQUARE)

!DEFINE VARIABLES

    IMPLICIT NONE

!VELOCITY U AT TIME T, VELOCITY UNEW AT TIME T+1, TIME T
!MAXIMUM 1000 POINTS

    REAL V(1000)
    REAL VNEW(1000)
    REAL T

!GRID SPACING DY, GRID POINTS N+1
    REAL DY
    INTEGER N

!TIME STEP

    REAL DT

!FLOW REYNOLDS NUMBER IN THE MODEL EQUATION

    REAL ALPHA

!TOTAL SIMULATION TIME - LOOP NUMBER

    INTEGER REP, I, J

!COEFFICIENTS IN LINEAR EQUATION MATRIX, SOURCE TERM K, DIAGONAL B, NON-DIAGONAL A

    REAL S(1000), B, A

!INITIALIZATION OF DATA

    DATA ALPHA/5000.0/
    DATA N/100/
    DATA REP/3000/

!CALCULATION OF GRID SPACING

    DY=1.0/N

!CALCULATION OF TIME STEP DELTA T, CAN BE LARGER THAN THAT IN AN EXPLICIT METHOD 

        DT=0.5*RE*DY*DY
    DT=ALPHA*DY*DY

!INITIAL CONDITIONS OF VELOCITY PROFILE
!BOTTOM AND INNER POINTS

    DO I=1,N
    V(I)=0.0
    ENDDO

!POINT AT MOVING PLATE

    V(N+1)=1.0

!BOUNDARY CONDITIONS AT LOWER AND UPPER POINTS ON PLATE 

    V(1)=0.0
    V(N+1)=1.0

!CALCULATION OF DIAGONAL B AND NON-DIAGONAL A IN LINEAR EQUATION MATRIX

    B=1.0+DT/DY/DY/ALPHA
    A=-(DT)/2.0/DY/DY/ALPHA

!INITIAL COMPUTATION TIME 

    T=0.0

!ENTER MAIN LOOP TO MARCH IN TIME DIRECTION

    DO I=1,REP
!SIMULATION TIME INCREASE BY DELTA T EACH STEP

    T=T+DT

!USE IMPLICIT METHOD TO UPDATE GRID POINT VALUES FOR ALL INTERNAL GRIDS ONLY
!TWO BOUNDARY GRID POINTS VALUES ARE CONSTANT WITHIN THE WHOLE SIMULATION       

!CALCULATION OF SOURCE TERM IN LINEAR EQUATION

    DO J=2,N
    S(J)=(1.0-DT/DY/DY/ALPHA)*V(J)+DT/2.0/DY/DY/ALPHA*V(J+1)+V(J-1)
    ENDDO

!INCLUDE BOUNDARY CONDITIONS FOR TWO POINTS NEAR BOUDNARY

    S(2)=S(2)-A*V(1)
    S(N)=S(N)-A*V(N+1)

!USE SOURCE TERM K, DIAGONAL B, NON-DIAGONAL A, ORDER OF MATRIX N, TO SOLVE LINEAR EQUATION TO GET UPDATED VELOCITY
!CHECK ON INTERNET HOW TO SOLVE THIS BECUASE THIS COMPILER
!DOES NOT SOLVE IT, SOLVE LINEAR EQUATIONS BY A LINEAR SOLVER, FIND AND DOWNLOAD THE MATH LIBRARY FOR THIS COMPILER

    CALL SR1(A,B,N,S,VNEW)

!REPLACE OLD VELOCITY VALUES WITH NEW VALUES. 
!SINCE UNEW IS FROM UNEW(1), UNEW(2)......., UNEW(N-1), WE SHOULD RE-ARRANGE NUMBERS AS FOLLOWS

    DO J=1,N-1
    V(J+1)=VNEW(J)
    ENDDO

!RETURN TO MAIN LOOP HERE

    ENDDO

    PRINT*,'HERE'


!OUTPUT VELOCITY PROFILES AT THE END OF COMPUTATION
!CREATE OUPUT FILE NAME

    OPEN(15,FILE='PLEASEWORK')
!WRITE GRID POINTS AND VELOCITY VALUES

    DO I=1,N+1
    WRITE(15,10) V(I),(I-1)*DY
10  FORMAT(2F12.3)
    ENDDO
    CLOSE(15)

!DISPLAY INFORMATION ON SCREEN 
!WRITE(*,*) 'THE OUTPUT VELOCITY IS AFTER', ITER, '     TIME STEPS'

!TERMINATION OF COMPUTER PROGRAM

    STOP

    END     

!!!!!!!!
!!!!!!!!!!!!
!!!!!!!!!

    SUBROUTINE SR1(A,B,N,S,VNEW)
    REAL DIAGM(N), DIAGU(N), DIAGL(N)
    REAL SS(N)
    DO J=1,N-1
    SS(J)=S(J+1)
    ENDDO

    DO I=1,N
    DIAGM(i)=B        

!Sets main diagonal as B for every value of i

    IF (I==0) then
    DIAGU(I)=A
    DIAGL(I)=0  

! No lower diagonal coefficient when i = 0

    ELSE IF (I==N) THEN
    DIAGU(I)=0  

! No upper diagonal coefficient when i = Num

    DIAGL(I)=A
    ELSE 
    DIAGU(I)=A 

! For all other points there is an upper diagonal coefficient

    DIAGL(I)=A 

! For all other points there is a lower diagonal coefficient

    ENDIF

    ENDDO

!CALL STANDARD FORTRAN MATH LIBRARY TO SOLVE LINEAR EQUATION AND GET SOLUTION VECTOR X(N-1)

    CALL SR2 (DIAGL,DIAGM,DIAGU,SS,VNEW,N-2)

!RETURN TO MAIN PROGRAM AND X(N-1) IS FEEDED INTO UNEW(N-1)

    RETURN
    END SUBROUTINE

!!!!!!!!!!!!!!!
!!!!!!!!!!!
!!!!!!!!!!!

    SUBROUTINE SR2 (A,B,C,D,Z,N)

!a - sub-diagonal (means it is the diagonal below the main diagonal)
!b - the main diagonal
!c - sup-diagonal (means it is the diagonal above the main diagonal)
!K - right part
!UNEW - the answer
!E - number of equations

    INTEGER N
    REAL A(N), B(N), C(N), D(N)
    REAL CP(N), DP(N), Z(N)
    REAL M
    INTEGER I
    DATA M/1/

!initialize c-prime and d-prime

    CP(1) = C(1)/B(1)
    DP(1) = D(1)/B(1)
!solve for vectors c-prime and d-prime

    DO I=2,N
    M=b(i)-CP(I-1)*(A(I))
    CP(I)=C(I)/M
    DP(I)=(D(I)-DP(I-1)*A(I))/M
    ENDDO

!initialize UNEW

    Z(N)=DP(N)

!solve for x from the vectors c-prime and d-prime

    DO I=N-1, 1, -1
    Z(I)=DP(I)-CP(I)*Z(I+1)
    ENDDO

    END SUBROUTINE

Upvotes: 1

Views: 749

Answers (1)

francescalus
francescalus

Reputation: 32366

As george says in a comment, the problem is with the subroutine SR1. So that this isn't just a CW-stealing-a-comment answer I'll also expand a bit.

The way things are structured SR1 is a different scope from the main program. The IMPLICIT NONE in the main program doesn't apply to the subroutine, so A, B, N, S and VNEW are all implicitly typed. Apart from N,which is an integer, they are (scalar) reals.

The reference to S(J+1), as george says, means that S is not only a scalar real, but also a function. Remember that SR1 is a different scope and no information is passed from the caller to the callee about types, shapes, etc.. Further, that the dummy argument in SR1 called A happens to be same name as the actual argument in the call doesn't mean that the callee "knows" things. Your call to SR2 with the VNEW is also a problem for the same reason.

The question is tagged as "fortran77" so there isn't too much you can do to ensure there is a lot of checking going on, but there may well be compiler options and as you can use IMPLICIT NONE (not Fortran 77) that would detect your problems.

But, the question is also tagged "fortran" and "fortran95" so I'll point out that there are far better ways to detect the issues, using more modern features. Look at interfaces, modules and internal procedures.

Upvotes: 1

Related Questions