@@ -2,7 +2,7 @@ module time_integration_m
22 implicit none
33
44#ifndef HAVE_TEMPLATE_SUPPORT
5- integer dummy
5+ logical prevent_empty_module
66#else
77
88 requirement unary_op_r(op, T, U)
@@ -38,21 +38,20 @@ function op(x,y) result(z)
3838 end requirement
3939
4040 template runge_kutta_4th_order_t( &
41- R, TFA, TFB, TFC, TFD & ! types
42- ,rmult , rtmult, tplus , rhs & ! functions
41+ TFA, TFB, TFC, TFD & ! types
42+ ,tmult , rtmult, taplus, tcplus , rhs & ! functions
4343 )
44- type, deferred :: R
4544 type, deferred :: TFA
4645 type, deferred :: TFB
4746 type, deferred :: TFC
4847 type, deferred :: TFD
4948
50- require :: binary_op_r(integer , TFC, TFC, tmult)
51- require :: binary_op_r( R, integer , R, rdiv)
52- require :: binary_op_r( R, TFC, TFB, rtmult)
49+ require :: binary_op_r(integer , TFC, TFC, tmult) ! report lfortran bug on intrinsic types
50+ require :: binary_op_r( TFC, R, TFB, rtmult)
5351 require :: binary_op_r( TFA, TFB, TFA, taplus)
5452 require :: binary_op_r( TFC, TFC, TFC, tcplus)
5553 require :: binary_op_r( TFA, TFD, TFC, rhs)
54+ require :: binary_op_r( R, integer , R, rdiv)
5655
5756 interface operator (+ )
5857 module procedure taplus, tcplus
@@ -71,19 +70,17 @@ function op(x,y) result(z)
7170 pure function step (s , v , dt ) result(s_next)
7271 type (TFA), intent (in ) :: s
7372 type (TFD), intent (in ) :: v
74- type (R), intent (in ) :: dt
73+ type (R) , intent (in ) :: dt
7574 type (TFA) s_next
7675
77- associate(k1 = > rhs(s, v))
78- associate(k2 = > rhs(s + (dt/ 2 )* k1, v))
79- associate(k3 = > rhs(s + (dt/ 2 )* k2, v))
80- associate(k4 = > rhs(s + dt* k3, v))
81- s_next = s + (dt/ 6 )* (k1 + 2 * k2 + 2 * k3 + k4)
82- end associate
83- end associate
84- end associate
85- end associate
86- end function
76+ associate(k1 = > rhs(s, v))
77+ associate(k2 = > rhs(s + k1* (dt/ 2 ), v))
78+ associate(k3 = > rhs(s + k2* (dt/ 2 ), v))
79+ associate(k4 = > rhs(s + k3* dt, v))
80+ s_next = s + (k1 + 2 * k2 + 2 * k3 + k4) * (dt/ 6 )
81+ ! s_next = s + k1*(dt/6) + k2*(dt/3) + k3*(dt/3) + k4*(dt/6)
82+ end associate; end associate; end associate; end associate
83+ end function
8784
8885 end template
8986
0 commit comments