我编写此代码来解决Runge-Kutta,我的编译器没有显示任何错误,但没有提供任何检查正确性的信息。
我不确定代码是否正确,但是,我使用了Debug选项,它什么也没有显示。它只告诉我
The program '[1328] Console2.exe' has exited with code 0 (0x0).
Program Runge-Kutta
INTEGER i, n
PARAMETER (n=101,m=101)
REAL (kind=8) eta(i), psi(i), teta(i)
REAL (kind=8) k1(i), k2(i), k3(i), k4(i), l1(i), l2(i), l3(i), l4(i)
REAL (kind=8) f(i), g(i)
REAL (kind=8) h
-----------------definition of parameters--------------------
PARAMETER (h=0.01)
------------------ initial conditions---------------------
eta(1)= 0.d0
teta(1)= 0.d0
eta(n)= 1
teta(n)= 1
psi(1)= 0.d0
评价员的评价
FUNCTION f(eta(i), psi(i), teta(i))
DO i=1, n
f= psi(i)
ENDDO
ENDFUNCTION
FUNCTION g(eta(i), psi(i), teta(i))
DO i=1, n
g=-(1/2) eta(i) psi(i)
ENDDO
ENDFUNCTION
获得K值
DO i=1, n
k1(i)= h * f
l1(i)= h * g
!k2(n)= h * f(eta(i) + (h/2), psi(i) + (l1(i)/2), teta(i) + (k1(i)/2))
!l2(n)= h * g(eta(i) + (h/2), psi(i) + (l1(i)/2), teta(i) + (k1(i)/2))
!k3(n)= h * f(eta(i) + (h/2), psi(i) + (l2(i)/2), teta(i) + (k2(i)/2))
!l3(n)= h * g(eta(i) + (h/2), psi(i) + (l2(i)/2), teta(i) + (k2(i)/2))
!k4(n)= h * f(eta(i) + h, psi(i) + l3(i), teta(i) + k3(i))
!l4(n)= h * g(eta(i) + h, psi(i) + l3(i), teta(i) + k3(i))
teta(i+1)= teta(i) + (1/6)*(k1(i)) !+ 2 * k2(i)+2* k3(i) +k4(i))
psi(i+1)= psi(i) + (1/6)*(l1(i)) !+ 2* l2(i)+2* l3(i) +l4(i))
ENDDO
If(n==100)then
----------------------------------------- archivos DATOS ------------------------------
OPEN(unit=12,file='datos RK.dat')
WRITE(12,*)'TITLE = "Grid" '
WRITE(12,*)'VARIABLES = "x"'
WRITE(12,*)'"RK"' ! variable
WRITE(12,*)'ZONE T= "Matrix"'
---------------------------------------- ESCRITURA DE LAS VARIABLES ----------------------------------
DO i=1,n
WRITE(12,*) teta(i), psi(i)
END DO
CLOSE(unit=12)
End Program Runge-Kutta