I have this feature pictured below. It runs in two vectors with three values ββeach and must skip one vector with three values. I call the function as follows:
Fr = Flux(W(:,i),W(:,i+1))
What I realized while fiddling with the code, trying clean functions and modules and examining the error operator (which I will include below) is that fortran reads my Flux function and thinks that input vectors are an attempt to call a record from an array . This is my best guess about what is happening. I asked around the laboratory, and most people suggested using routines, but that seemed awkward, and I thought there probably should be a more elegant way, but I haven't found it yet. I tried to determine the result by saying:
DOUBLE PRECISION FUNCTION Flux(W1,W2) Result(FluxArray(3))
and then returns fluxarray, but this does not work as fortran cannot understand the syntax
The actual function is as follows:
DOUBLE PRECISION FUNCTION Flux(W1,W2) USE parameters IMPLICIT NONE DOUBLE PRECISION, DIMENSION(3), INTENT(IN)::W1, W2 DOUBLE PRECISION, DIMENSION(3), INTENT(OUT):: Flux DOUBLE PRECISION, DIMENSION(3):: F1, F2 DOUBLE PRECISION::U1,U2,Rh1,Rh2,P1,P2,E1,E2,Rh,P,u,c,Lambda INTEGER:: k U1=W1(2)/W1(1) U2=W2(2)/W2(1) Rh1=W1(1) Rh2=W2(1) P1=(gamma_constant-1.d0)*(W1(3)-.5d0*Rh1*U1**2) P2=(gamma_constant-1.d0)*(W2(3)-.5d0*Rh2*U2**2) E1=W1(3) E2=W2(3) F1=[Rh1*U1,Rh1*U1**2+P1,(E1+P1)*U1] F2=[Rh2*U2,Rh2*U2**2+P2,(E2+P2)*U2] Rh=.5d0*(Rh1+Rh2) P=.5d0*(P1+P2) u=.5d0*(U1+U2) c=sqrt(gamma_constant*P/Rh) Lambda=max(u, u+c, uc) do k=1,3,1 Flux(k)=.5d0*(F1(k)+F2(k))-.5d0*eps*Lambda*(W2(k)-W1(k)) end do RETURN END FUNCTION Flux
Here is the error instruction:
Quasi1DEuler.f90:191.51: DOUBLE PRECISION, DIMENSION(3), INTENT(OUT):: Flux 1 Error: Symbol 'flux' at (1) already has basic type of REAL Quasi1DEuler.f90:217.58: Flux(k)=.5d0*(F1(k)+F2(k))-.5d0*eps*Lambda*(W2(k)-W1(k)) 1 Error: Unexpected STATEMENT FUNCTION statement at (1) Quasi1DEuler.f90:76.18: Fr = Flux(W(:,i),W(:,i+1))
The last error occurs for both Fr and Fl. Thanks for your time and any help or attention you can give!
EDIT / Follow-up :: Thanks for the help, I don't know a better way to introduce this, so I'm going to change the original question.
I did what you suggested and solved this problem, now it says:
Fr = Flux(W(:,i),W(:,i+1)) 1 Error: The reference to function 'flux' at (1) either needs an explicit INTERFACE or the rank is incorrect
I saw a similar problem in SO at this link:
Computing the cross product of two vectors in Fortran 90
where they suggested that he include all his functions in modules. Is there a better / easier way to fix this error?