5 ! Contributed by Damian Rouson
7 module surrogate_module
8 type ,abstract
:: surrogate
12 module strategy_module
19 module integrand_module
24 type ,abstract
, extends(surrogate
) :: integrand
25 class(strategy
), allocatable
:: quadrature
27 end module integrand_module
34 type ,extends(integrand
) :: lorenz
35 real, dimension(:), allocatable
:: state
37 procedure
,public
:: assign => assign_lorenz
40 type(lorenz
) function constructor(initial_state
, this_strategy
)
41 real ,dimension(:) ,intent(in
) :: initial_state
42 class(strategy
) ,intent(in
) :: this_strategy
43 constructor
%state
=initial_state
44 allocate (constructor
%quadrature
, source
=this_strategy
)
47 subroutine assign_lorenz(lhs
,rhs
)
48 class(lorenz
) ,intent(inout
) :: lhs
49 class(integrand
) ,intent(in
) :: rhs
52 allocate (lhs
%quadrature
, source
=rhs
%quadrature
)
56 end module lorenz_module
58 module runge_kutta_2nd_module
59 use surrogate_module
,only
: surrogate
60 use strategy_module
,only
: strategy
61 use integrand_module
,only
: integrand
64 type, extends(strategy
) ,public
:: runge_kutta_2nd
66 procedure
, nopass
:: integrate
69 subroutine integrate(this
)
70 class(surrogate
) ,intent(inout
) :: this
71 class(integrand
) ,allocatable
:: this_half
75 allocate (this_half
, source
=this
)
82 use runge_kutta_2nd_module
,only
: runge_kutta_2nd
, integrate
85 type(runge_kutta_2nd
) :: timed_lorenz_integrator
86 type(lorenz
) :: attractor
88 attractor
= constructor( [1., 1., 1.] , timed_lorenz_integrator
)
89 call integrate(attractor
)