Rk4 Fortran Code
PROGRAM PCMET
OPEN(1,’INPUT.DAT’)
OPEN(2,’OUTPUT.DAT’)
READ(1,*)A,B,N,Y0
CALL PCM(A,B,N,Y0)
END PROGRAM Newbluefx keygen rar.
Runge Kutta Fehlberg Fortran Code
Rk4 Fortran Code Example
The RK2 method is a signicant improvement from Euler‘s method, how- ever, we can get even better data with the 4th order Runge-Kutta technique. RK4 may not always produce more accurate data than RK2, but it is more stable, which becomes important with more complicated systems. The RK4 formulation is as follows. K 1= dtf(t,y) k. You should compile your code for debugging. If you use gfortran, use -g -fbacktrace -fcheck=all -Wall. For ifort use -g -traceback-check -warn. Other compilers have similar options. – Vladimir F Dec 1 '14 at 19:30.
Rk4 Fortran Code Examples
SUBROUTINE PCM(A,B,N,Y0)
F(T,Y)=Y-T*T+1
G(T)=(T+1)**2-0.5*EXP(T)
REAL::T(0:N),W(0:N),K1,K2,K3,K4
WRITE(2,*)’ADAMS 4TH ORDER PC METHOD:’
WRITE(2,10)
10 FORMAT(3X,’T’,9X,’W’,8X,’EXACT’,5X,’ERROR’)
H=(B-A)/N
T(0)=A
W(0)=Y0
WRITE(2,11)T(0),W(0),G(T(0)),ABS(W(0)-G(T(0)))
11 FORMAT(2X,F4.2,2X,F9.6,2X,F9.6,2X,F9.6)
DO I=0,2
K1=H*F(T(I),W(I))
K2=H*F(T(I)+0.5*H,W(I)+0.5*K1)
K3=H*F(T(I)+0.5*H,W(I)+0.5*K2)
K4=H*F(T(I)+H,W(I)+K3)
W(I+1)=W(I)+(K1+2*K2+2*K3+K4)/6
T(I+1)=A+(I+1)*H
WRITE(2,11)T(I+1),W(I+1),G(T(I+1)),ABS(W(I+1)-G(T(I+1)))
END DO
DO I=3,N-1
T(I+1)=A+(I+1)*H
W(I+1)=W(I)+H*(55*F(T(I),W(I))-59*F(T(I-1),W(I-1))+37*F(T(I-2),W(
1I-2))-9*F(T(I-3),W(I-3)))/24
W(I+1)=W(I)+H*(9*F(T(I+1),W(I+1))+19*F(T(I),W(I))-5*F(T(I-1),W(I-1
1))+F(T(I-2),W(I-2)))/24
WRITE(2,11)T(I+1),W(I+1),G(T(I+1)),ABS(W(I+1)-G(T(I+1)))
END DO
END SUBROUTINE