I have the following code, where I call a function from a subroutine, all of them in the same module:
module mymodule
implicit none
contains
subroutine mycode
real :: y0(3), a = 0.0, b = 1.0
integer :: i, N = 10
real, allocatable :: y(:,:)
y0(:) = [1.0, 1.0, 1.0]
y = AB2(od, a, b, N, y0)
do i = 1, N
print *, y(:,i)
end do
end subroutine mycode
function AB2(f, a, b, N, y0)
real, allocatable :: AB2(:,:)
interface
function f(x, y)
real, allocatable :: f(:)
real, intent(in) :: x, y(:)
end function
end interface
real, intent(in) :: a, b
integer, intent(in) :: N
real, intent(in) :: y0(:)
real :: xn0, xn1, step
real, allocatable :: yn0(:), yn1(:)
integer :: i
allocate(AB2(size(y0),N))
step = (b-a)/(N-1)
AB2(:,1) = y0
AB2(:,2) = y0 + step*f(a, y0)
do i = 3, N
xn0 = a+(i-2)*step
xn1 = a+(i-1)*step
yn0 = AB2(:,i-2)
yn1 = AB2(:,i-1)
AB2(:,i) = AB2(:,i-1) + step*(3.0/2.0*f(xn1,yn1)
& -0.5*f(xn0,yn0))
end do
end function
function od(x, y)
real, allocatable :: od(:)
real, intent(in) :: x, y(:)
allocate(od(3))
od(1) = x + y(1)
od(2) = -y(3) - y(2) - x
od(3) = x - y(1) + y(3)
end function
end module mymodule
If I want to give another parameter to the function od, say c, I have to include it on this line
real, intent(in) :: x, c, y(:)
and also
function od(x,c,y)
However, where do I provide the value for this argument? There is no option in the call
y = AB2(od, a, b, N, y0)