I have the following problem:
I have a subroutine on Fortran 77, which must return a one-dimensional array, D_Y. All values which are needed are transferred correctly from the main program, but three elements of the matrix D_Y (D_Y(16-18)) are set to 0.0 and I don't know why.
NDIM=18, P1 and P2 are right, all parameters, which they have in equation are right too, but their sum is always set to 0!
SUBROUTINE DY(Y,T,PARAM,NDIM,D_Y)
IMPLICIT NONE
real(8),intent(in)::Y(*)
real(8),intent(in)::PARAM(*),T
real(8),intent(out)::D_Y(NDIM)
integer::D
integer,intent(in)::NDIM
real(8)::R,R1,R2,P1,P2
open(18,file='kinetic2.txt',status='unknown')
R=((Y(1)-Y(4))**2.D0+(Y(2)-Y(5))**2.D0+(Y(3)-Y(6))**2.D0)**0.5D0
R1=((Y(1)-Y(13))**2.D0+(Y(2)-Y(14))**2.D0+(Y(3)-Y(15))**2.D0)**0.5D0
R2=((Y(4)-Y(13))**2.D0+(Y(5)-Y(14))**2.D0+(Y(6)-Y(15))**2.D0)**0.5D0
DO D=1,6
D_Y(D)=Y(D+6)
END DO
DO D=7,9
D_Y(D)=-(PARAM(1)*PARAM(3))*(Y(D-6)-Y(D-3))/((R)**3.D0)
END DO
DO D=10,12
D_Y(D)=-(PARAM(1)*PARAM(2))*(Y(D-6)-Y(D-9))/((R)**3.D0)
END DO
DO D=13,15
D_Y(D)=Y(D+3)
END DO
DO D=16,18
P1=-(PARAM(1)*PARAM(3))*(Y(D-3)-Y(D-12))/((R2)**3.D0)
P2=-(PARAM(1)*PARAM(2))*(Y(D-3)-Y(D-15))/((R1)**3.D0)
D_Y(D)=P1+P2
write(18,*) P1,P2,D_Y(D)
END DO
RETURN
END
If your compiler is treating your code as fixed form a D
in column 1, such as in the line
D_Y(D)=P1+P2
may be understood to be a comment. Check your compiler documentation and options.