I am a novice in Fortran programming. I have two .f90 files.
fmat.f90
function fmat(t,y)
implicit none
real::t
real::y(2)
real::fmat(2)
fmat(1) = -2*t+y(1)
fmat(2) = y(1)-y(2)
end function fmat
And, main.f90 looks like:
program main
implicit none
real::t
real::y(2)
real::fmat(2)
real::k(2)
t=0.1
y(1)=0.5
y(2)=1.4
k=fmat(t,y)
write(*,*) k
end program main
So, I am expecting 0.3 -0.9. But I keep getting the following error messages:
ifort fmat.f90 main.f90
main.f90(13): error #6351: The number of subscripts is incorrect. [FMAT]
k=fmat(t,y)
--^
compilation aborted for main.f90 (code 1)
Any help is appreciated!
!==== EDIT ====
I thank Mark for his answers. I could actually compile the separate files without any error using a "subroutine" approach.
main.f90
program main
implicit none
real::t
real::y(2)
real::k(2)
t=0.1
y(1)=0.5
y(2)=1.4
call fmat_sub(t,y,k)
write(*,*) k
end program main
fmat_sub.f90
subroutine fmat_sub(t,y,k)
implicit none
real::t
real::y(2),k(2)
k(1) = -2*t+y(1)
k(2) = y(1)-y(2)
end subroutine fmat_sub
mainthe linecall fmat_sub(t,y,k)with the linecall fmat_sub(t,y)and see how things go.