Main integration routine for the rk_class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(rk_class), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | t0 |
initial time |
||
real(kind=wp), | intent(in), | dimension(me%n) | :: | x0 |
initial state |
|
real(kind=wp), | intent(in) | :: | h |
abs(time step) |
||
real(kind=wp), | intent(in) | :: | tf |
final time |
||
real(kind=wp), | intent(out), | dimension(me%n) | :: | xf |
final state |
subroutine integrate(me,t0,x0,h,tf,xf) implicit none class(rk_class),intent(inout) :: me real(wp),intent(in) :: t0 !! initial time real(wp),dimension(me%n),intent(in) :: x0 !! initial state real(wp),intent(in) :: h !! abs(time step) real(wp),intent(in) :: tf !! final time real(wp),dimension(me%n),intent(out) :: xf !! final state real(wp) :: t,dt,t2 real(wp),dimension(me%n) :: x logical :: last,export if (.not. associated(me%f)) error stop 'Error in integrate: f is not associated.' export = associated(me%report) if (export) call me%report(t0,x0) !first point if (h==zero) then xf = x0 else t = t0 x = x0 dt = sign(h,tf-t0) !time step (correct sign) do t2 = t + dt last = ((dt>=zero .and. t2>=tf) .or. & !adjust last time step (dt<zero .and. t2<=tf)) ! if (last) dt = tf-t ! call me%step(t,x,dt,xf) if (last) exit if (export) call me%report(t2,xf) !intermediate point x = xf t = t2 end do end if if (export) call me%report(tf,xf) !last point end subroutine integrate