Fortran Type mismatch in argument n at 1 passed REAL(8) to integer (4)

I'm having a problem with a fortran 77 project (Yes i know it's archaic, but my prof requres us to program in fixed form fortran)

So I'm having a problem with a subroutine, which should read an N dimension Vector, which should be a column. the code for this looks like: (its still an early draft for my homework, just trying to figure out how to call a subroutine the rest of the code will be done if i can compile this problem)

Program gauss
implicit double precision (A-H,O-Z)
!he directly asked for implicit typing 
call Vread(V(N))
end program

Subroutine Vread(V,N)
Implicit double precision (A-H,O-Z)
dimension V(N)
read(*,*) (V(I),I=1,N)

So my problem is: If I try to compile it with gfortran gauss.exe -o gauss.f the compiler returns with error:

Type mismatch argument 'n' at(1); passed REAL(8) to Integer(4)

1 answer

  • answered 2018-03-11 12:56 High Performance Mark

    In your main program you write

    call Vread(V(N))  ! this passes a rank-1 vector with N elements

    but your subroutine is declared

    Subroutine Vread(V,N)  ! this requires 2 arguments

    Change the call to

    call Vread(V,N)

    and let your professor know that the 21st Century arrived a while age. Note too that it is possible to write 21C Fortran in fixed-form. It doesn't make much sense, but might enable you to toe the line while developing in a more modern version of the language.

    !he directly asked for implicit typing

    I trust that you are in a jurisdiction where you do not pay directly for your education. If you are paying fees then demand more, you're being cheated.