program ode
use rksuite_90
implicit none
……
external::f
dimension(2)::f
……
call range_integrate_r1(comm,f,t_want,t_got,y_got,yderiv_got,flag)
stop
end program ode
function f(t,y)
use rksuite_90
implicit none
real(kind=wp)::t
real(kind=wp)::y(2)
real(kind=wp)::f(2) !声名返回值类型
f(1)=y(2)
f(2)=-y(1)
end function
module rksuite_90
……
recursive subroutine range_integrate_r1(comm,f,t_want,t_got,y_got,yderiv_got,flag)
interface
function f(t,y)
use rksuite_90_prec, only:wp
real(kind=wp), intent(in) :: t !indep!
real(kind=wp), dimension(:), intent(in) :: y !dep!
real(kind=wp), dimension(size(y,1)) :: f !dep!
end function f
end interface
……
comm%yp = f(comm%t,comm%y)
……
end module rksuite_90
external::f
dimension(2)::f
捕获.PNG (9.05 KB, 下载次数: 292)
module rksuite_90_prec
implicit none
integer, parameter :: wp=selected_real_kind(P=15)
end module rksuite_90_prec
module rksuite_90
implicit none
contains
recursive subroutine range_integrate_r1(comm,f,t_want,t_got,y_got,yderiv_got,flag)
implicit none
real :: comm, t_want, t_got, y_got, yderiv_got, flag
interface
function f(t,y)
use rksuite_90_prec, only:wp
implicit none
real(kind=wp), intent(in) :: t
real(kind=wp), dimension(:), intent(in) :: y
real(kind=wp), dimension(size(y,1)) :: f
end function f
end interface
!...
end subroutine range_integrate_r1
end module rksuite_90
program ode
use rksuite_90
implicit none
real :: comm, t_want, t_got, y_got, yderiv_got, flag
interface
function f(t,y)
use rksuite_90_prec, only:wp
implicit none
real(kind=wp), intent(in) :: t
real(kind=wp), dimension(:), intent(in) :: y
real(kind=wp), dimension(size(y,1)) :: f
end function f
end interface
call range_integrate_r1(comm,f,t_want,t_got,y_got,yderiv_got,flag)
end program ode
function f(t,y)
use rksuite_90_prec, only:wp
implicit none
real(kind=wp), intent(in) :: t
real(kind=wp), dimension(:), intent(in) :: y
real(kind=wp), dimension(size(y,1)) :: f
f(1) = y(2)
f(2) =-y(1)
end function f
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |