A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
Functions/Subroutines | Variables
rk2_wl_integrator Module Reference

Module with the WL rk2 integration routines. More...

Functions/Subroutines

subroutine, public init_integrator
 Subroutine that initialize the MARs, the memory unit and the integration buffers. More...
 
subroutine compute_m1 (y)
 Routine to compute the \(M_1\) term. More...
 
subroutine compute_m2 (y)
 Routine to compute the \(M_2\) term. More...
 
subroutine, public step (y, t, dt, dtn, res, tend)
 Routine to perform an integration step (Heun algorithm) of the WL system. The incremented time is returned. More...
 
subroutine, public full_step (y, t, dt, dtn, res)
 Routine to perform an integration step (Heun algorithm) of the full stochastic system. The incremented time is returned. More...
 

Variables

real(kind=8), dimension(:), allocatable buf_y1
 
real(kind=8), dimension(:), allocatable buf_f0
 
real(kind=8), dimension(:), allocatable buf_f1
 Integration buffers. More...
 
real(kind=8), dimension(:), allocatable buf_m2
 
real(kind=8), dimension(:), allocatable buf_m1
 
real(kind=8), dimension(:), allocatable buf_m3
 
real(kind=8), dimension(:), allocatable buf_m
 
real(kind=8), dimension(:), allocatable buf_m3s
 Dummy buffers holding the terms /f$M_i. More...
 
real(kind=8), dimension(:), allocatable anoise
 Additive noise term. More...
 
real(kind=8), dimension(:), allocatable dwar
 
real(kind=8), dimension(:), allocatable dwau
 
real(kind=8), dimension(:), allocatable dwor
 
real(kind=8), dimension(:), allocatable dwou
 Standard gaussian noise buffers. More...
 
real(kind=8), dimension(:,:), allocatable x1
 Buffer holding the subsequent states of the first MAR. More...
 
real(kind=8), dimension(:,:), allocatable x2
 Buffer holding the subsequent states of the second MAR. More...
 

Detailed Description

Module with the WL rk2 integration routines.

Remarks
This module actually contains the Heun algorithm routines.

Function/Subroutine Documentation

subroutine rk2_wl_integrator::compute_m1 ( real(kind=8), dimension(0:ndim), intent(in)  y)
private

Routine to compute the \(M_1\) term.

Parameters
yPresent state of the WL system

Definition at line 106 of file rk2_WL_integrator.f90.

106  REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y
107  buf_m1=0.d0
108  IF (m12def) CALL sparse_mul2_k(m12, y, buf_m1)
109  buf_m1=buf_m1+m1tot
subroutine rk2_wl_integrator::compute_m2 ( real(kind=8), dimension(0:ndim), intent(in)  y)
private

Routine to compute the \(M_2\) term.

Parameters
yPresent state of the WL system

Definition at line 115 of file rk2_WL_integrator.f90.

115  REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y
116  buf_m=0.d0
117  buf_m2=0.d0
118  IF (m21def) CALL sparse_mul3(m21, y, x1(0:ndim,1), buf_m)
119  IF (m22def) CALL sparse_mul3(m22, x2(0:ndim,1), x2(0:ndim,1), buf_m2)
120  buf_m2=buf_m2+buf_m
integer ndim
Number of variables (dimension of the model)
Definition: params.f90:85
subroutine, public rk2_wl_integrator::full_step ( real(kind=8), dimension(0:ndim), intent(in)  y,
real(kind=8), intent(inout)  t,
real(kind=8), intent(in)  dt,
real(kind=8), intent(in)  dtn,
real(kind=8), dimension(0:ndim), intent(out)  res 
)

Routine to perform an integration step (Heun algorithm) of the full stochastic system. The incremented time is returned.

Parameters
yInitial point.
tActual integration time
dtIntegration timestep.
dtnStochastoc integration timestep (normally square-root of dt).
resFinal point after the step.

Definition at line 185 of file rk2_WL_integrator.f90.

185  REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y
186  REAL(KIND=8), INTENT(INOUT) :: t
187  REAL(KIND=8), INTENT(IN) :: dt,dtn
188  REAL(KIND=8), DIMENSION(0:ndim), INTENT(OUT) :: res
189  CALL stoch_atm_res_vec(dwar)
190  CALL stoch_atm_unres_vec(dwau)
191  CALL stoch_oc_res_vec(dwor)
192  CALL stoch_oc_unres_vec(dwou)
193  anoise=(q_ar*dwar+q_au*dwau+q_or*dwor+q_ou*dwou)*dtn
194  CALL sparse_mul3(aotensor,y,y,buf_f0)
195  buf_y1 = y+dt*buf_f0+anoise
196  CALL sparse_mul3(aotensor,buf_y1,buf_y1,buf_f1)
197  res=y+0.5*(buf_f0+buf_f1)*dt+anoise
198  t=t+dt
type(coolist), dimension(:), allocatable, public aotensor
- Tensor representation of the tendencies.
subroutine, public rk2_wl_integrator::init_integrator ( )

Subroutine that initialize the MARs, the memory unit and the integration buffers.

Definition at line 44 of file rk2_WL_integrator.f90.

44  INTEGER :: allocstat,i
45 
46  CALL init_ss_integrator
47 
48  print*, 'Initializing the integrator ...'
49 
50  IF (mode.ne.'ures') THEN
51  print*, '*** Mode set to ',mode,' in stoch_params.nml ***'
52  print*, '*** WL configuration only support unresolved mode ***'
53  stop "*** Please change to 'ures' and perform the configuration again ! ***"
54  ENDIF
55 
56  ALLOCATE(buf_y1(0:ndim),buf_f0(0:ndim),buf_f1(0:ndim),stat=allocstat)
57  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
58 
59  ALLOCATE(buf_m1(0:ndim), buf_m2(0:ndim), buf_m3(0:ndim), buf_m(0:ndim), buf_m3s(0:ndim), stat=allocstat)
60  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
61 
62  ALLOCATE(dwar(0:ndim),dwau(0:ndim),dwor(0:ndim),dwou(0:ndim),stat=allocstat)
63  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
64 
65  ALLOCATE(anoise(0:ndim), stat=allocstat)
66  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
67 
68  buf_y1=0.d0
69  buf_f1=0.d0
70  buf_f0=0.d0
71 
72  dwar=0.d0
73  dwor=0.d0
74  dwau=0.d0
75  dwou=0.d0
76 
77  buf_m1=0.d0
78  buf_m2=0.d0
79  buf_m3=0.d0
80  buf_m3s=0.d0
81  buf_m=0.d0
82 
83  print*, 'Initializing the MARs ...'
84 
85  CALL init_mar
86 
87  ALLOCATE(x1(0:ndim,ms), x2(0:ndim,ms), stat=allocstat)
88 
89  x1=0.d0
90  DO i=1,50000
91  CALL mar_step(x1)
92  ENDDO
93 
94  x2=0.d0
95  DO i=1,50000
96  CALL mar_step(x2)
97  ENDDO
98 
99  CALL init_memory
100 
integer ndim
Number of variables (dimension of the model)
Definition: params.f90:85
Statistics accumulators.
Definition: stat.f90:14
character(len=4) mode
Stochastic mode parameter.
subroutine, public rk2_wl_integrator::step ( real(kind=8), dimension(0:ndim), intent(in)  y,
real(kind=8), intent(inout)  t,
real(kind=8), intent(in)  dt,
real(kind=8), intent(in)  dtn,
real(kind=8), dimension(0:ndim), intent(out)  res,
real(kind=8), dimension(0:ndim), intent(out)  tend 
)

Routine to perform an integration step (Heun algorithm) of the WL system. The incremented time is returned.

Parameters
yInitial point.
tActual integration time
dtIntegration timestep.
dtnStochastic integration timestep (normally square-root of dt).
resFinal point after the step.
tendPartial or full tendencies used to perform the step (used for debugging).

Definition at line 132 of file rk2_WL_integrator.f90.

132  REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y
133  REAL(KIND=8), INTENT(INOUT) :: t
134  REAL(KIND=8), INTENT(IN) :: dt,dtn
135  REAL(KIND=8), DIMENSION(0:ndim), INTENT(OUT) :: res,tend
136  INTEGER :: i
137 
138  IF (mod(t,muti)<dt) THEN
139  CALL compute_m3(y,dts,dtsn,.true.,.true.,.true.,muti/2,buf_m3s)
140  buf_m3=buf_m3s
141  DO i=1,1
142  CALL compute_m3(y,dts,dtsn,.false.,.true.,.true.,muti/2,buf_m3s)
143  buf_m3=buf_m3+buf_m3s
144  ENDDO
145  !DO i=1,2
146  ! CALL compute_M3(y,dts,dtsn,.false.,.true.,.true.,muti/2,buf_M3s)
147  ! buf_M3=buf_M3+buf_M3s
148  !ENDDO
149  buf_m3=buf_m3/2
150  ENDIF
151 
152 
153  CALL stoch_atm_res_vec(dwar)
154  CALL stoch_oc_res_vec(dwor)
155  anoise=(q_ar*dwar+q_or*dwor)*dtn
156 
157  CALL tendencies(t,y,buf_f0)
158  CALL mar_step(x1)
159  CALL mar_step(x2)
160  CALL compute_m1(y)
161  CALL compute_m2(y)
162  buf_f0= buf_f0+buf_m1+buf_m2+buf_m3
163  buf_y1 = y+dt*buf_f0+anoise
164 
165  CALL tendencies(t+dt,buf_y1,buf_f1)
166  CALL compute_m1(buf_y1)
167  CALL compute_m2(buf_y1)
168  !IF (mod(t,muti)<dt) CALL compute_M3(buf_y1,dts,dtsn,.false.,.true.,buf_M3)
169 
170  buf_f0=0.5*(buf_f0+buf_f1+buf_m1+buf_m2+buf_m3)
171  res=y+dt*buf_f0+anoise
172 
173  tend=buf_m3
174  t=t+dt
175 

Variable Documentation

real(kind=8), dimension(:), allocatable rk2_wl_integrator::anoise
private

Additive noise term.

Definition at line 33 of file rk2_WL_integrator.f90.

33  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: anoise !< Additive noise term
real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_f0
private

Definition at line 31 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_f1
private

Integration buffers.

Definition at line 31 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_m
private

Definition at line 32 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_m1
private

Definition at line 32 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_m2
private

Definition at line 32 of file rk2_WL_integrator.f90.

32  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: buf_m2,buf_m1,buf_m3,buf_m,buf_m3s !< Dummy buffers holding the terms /f$M_i\f$ of the parameterization
real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_m3
private

Definition at line 32 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_m3s
private

Dummy buffers holding the terms /f$M_i.

Definition at line 32 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::buf_y1
private

Definition at line 31 of file rk2_WL_integrator.f90.

31  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: buf_y1,buf_f0,buf_f1 !< Integration buffers
real(kind=8), dimension(:), allocatable rk2_wl_integrator::dwar
private

Definition at line 34 of file rk2_WL_integrator.f90.

34  REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dwar,dwau,dwor,dwou !< Standard gaussian noise buffers
real(kind=8), dimension(:), allocatable rk2_wl_integrator::dwau
private

Definition at line 34 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::dwor
private

Definition at line 34 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:), allocatable rk2_wl_integrator::dwou
private

Standard gaussian noise buffers.

Definition at line 34 of file rk2_WL_integrator.f90.

real(kind=8), dimension(:,:), allocatable rk2_wl_integrator::x1
private

Buffer holding the subsequent states of the first MAR.

Definition at line 36 of file rk2_WL_integrator.f90.

36  REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: x1 !< Buffer holding the subsequent states of the first MAR
real(kind=8), dimension(:,:), allocatable rk2_wl_integrator::x2
private

Buffer holding the subsequent states of the second MAR.

Definition at line 37 of file rk2_WL_integrator.f90.

37  REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: x2 !< Buffer holding the subsequent states of the second MAR