Hello Ivanpribec,
I did manage to find the old code to the Runge Subroutine. I took a stab at converting it myself. there was a “computed GO TO” which I converted to a Select case construct and the DO loops had to modified. Not sure I did that right, but I have to study the math now to see if the program makes sense. If you can spot anything I did wrong intuitively here I would appreciate it.
Old Code:
Subroutine Runge (n,y,f,x,h,m,k)
!
!This routine performs runge-kutta calculations by gills method.
!
Dimension Y(10), F(10), Q(10)
m=m+1
go to (1,4,5,3,7),m
1 do 2 i=1,n
2 q(i)=0
A=.5
go to 9
!
3 a=1.707107
! if you need more accuracy use a=1.7071067811865475244
!
4 x=x+.5*h
5 do 6 i=1,n
y(i)=y(i)+a*(f(i)*h-Q(i))
6 q(i)=2.*a*h*f(i)+(1.-3.*a)*q(i)
a=.2928932
! if you need more accuracy use a=.2928932188134524756
!
go to 9
7 do 8 i=1,n
8 Y(i)=y(i)+h*F(i)/6.-q(i)/3.
m=0
k=2
go to 10
9 k=1
10 return
end
New code:
! Subroutine Runge(n,y,f,x,h,m,k)
! n = Number of differential equations to be solved (set by the programmer.
! y = Array of n dependent variables (with initial values set by the programmer.
! f = Array of the n derivatives of the variables y (the programmer must provide
! an expression in the main program for the calculation of each F(i))
! x = Independent variable (Initialized by the programmer).
! h = step size delta x (set by the programmer)
! m = Index used in the subroutine which must be set equal to zero by the programmer
! before the first call.
! k = Integer from the subroutine which is used as the argument of a
! computed GO TO Statement (Converted to a do while or Select case Construct here)
!
Subroutine Runge (n,y,f,x,h,m,k)
!
!This subroutine performs runge-kutta calculations by gills method.
!
implicit none
real Y(10), F(10), Q(10),x,h,a
integer n,m,k,i
!
m=m+1
!
Select Case (m)
case (1)
do i=1,n
q(i)=0
A=.5
k=1
End do
!
Case (2)
x=x+.5*h
do i=1,n
y(i)=y(i)+a*(f(i)*h-Q(i))
q(i)=2.*a*h*f(i)+(1.-3.*a)*q(i)
a=.2928932
k=1
! if you need more accuracy use a=.2928932188134524756
end do
!
Case (3)
do i=1,n
y(i)=y(i)+a*(f(i)*h-Q(i))
q(i)=2.*a*h*f(i)+(1.-3.*a)*q(i)
a=.2928932
k=1
! if you need more accuracy use a=.2928932188134524756
end do
!
Case(4)
a=1.707107
! if you need more accuracy use a=1.7071067811865475244
x=x+.5*h
do i=1,n
y(i)=y(i)+a*(f(i)*h-Q(i))
q(i)=2.*a*h*f(i)+(1.-3.*a)*q(i)
a=.2928932
k=1
! if you need more accuracy use a=.2928932188134524756
end do
!
Case (5)
do i=1,n
Y(i)=y(i)+h*F(i)/6.-q(i)/3.
m=0
k=2
end do
End select
!
return
end