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

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

Functions/Subroutines

subroutine, public init_integrator (force)
 Subroutine to initialize the integrator. More...
 
subroutine tendencies (t, y, res)
 Routine computing the tendencies of the selected model. More...
 
subroutine, public step (y, t, dt, dtn, res, tend)
 Routine to perform a stochastic step of the selected dynamics (Heun algorithm). The incremented time is returned. More...
 

Variables

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 buf_y1
 
real(kind=8), dimension(:), allocatable buf_f0
 
real(kind=8), dimension(:), allocatable buf_f1
 Integration buffers. More...
 
real(kind=8), dimension(:), allocatable anoise
 Additive noise term. More...
 
type(coolist), dimension(:), allocatable int_tensor
 Dummy tensor that will hold the tendencies tensor. More...
 

Detailed Description

Module with the stochastic rk2 integration routines.

Remarks
This module actually contains the Heun algorithm routines. There are four modes for this integrator:
  • full: use the full dynamics
  • ures: use the intrinsic unresolved dynamics
  • qfst: use the quadratic terms of the unresolved tendencies
  • reso: use the resolved dynamics alone

Function/Subroutine Documentation

subroutine, public rk2_stoch_integrator::init_integrator ( character*4, intent(in), optional  force)

Subroutine to initialize the integrator.

Parameters
forceParameter to force the mode of the integrator

Definition at line 48 of file rk2_stoch_integrator.f90.

48  INTEGER :: allocstat
49  CHARACTER*4, INTENT(IN), OPTIONAL :: force
50  CHARACTER*4 :: test
51 
52  ALLOCATE(buf_y1(0:ndim),buf_f0(0:ndim),buf_f1(0:ndim),stat=allocstat)
53  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
54 
55  ALLOCATE(anoise(0:ndim),stat=allocstat)
56  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
57 
58  ALLOCATE(dwar(0:ndim),dwau(0:ndim),dwor(0:ndim),dwou(0:ndim),stat=allocstat)
59  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
60 
61  ALLOCATE(int_tensor(ndim),stat=allocstat)
62  IF (allocstat /= 0) stop "*** Not enough memory ! ***"
63 
64  dwar=0.d0
65  dwor=0.d0
66  dwau=0.d0
67  dwou=0.d0
68 
69  IF (PRESENT(force)) THEN
70  test=force
71  ELSE
72  test=mode
73  ENDIF
74 
75  SELECT CASE (test)
76  CASE('full')
77  CALL copy_coo(aotensor,int_tensor)
78  CASE('ures')
79  CALL copy_coo(ff_tensor,int_tensor)
80  CASE('qfst')
81  CALL copy_coo(byyy,int_tensor)
82  CASE('reso')
83  CALL copy_coo(ss_tensor,int_tensor)
84  CASE DEFAULT
85  stop '*** MODE variable not properly defined ***'
86  END SELECT
87 
integer ndim
Number of variables (dimension of the model)
Definition: params.f90:85
subroutine, public copy_coo(src, dst)
Routine to copy a coolist.
Definition: tensor.f90:72
Statistics accumulators.
Definition: stat.f90:14
type(coolist), dimension(:), allocatable, public aotensor
- Tensor representation of the tendencies.
character(len=4) mode
Stochastic mode parameter.
subroutine, public rk2_stoch_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 a stochastic step of the selected dynamics (Heun algorithm). 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 112 of file rk2_stoch_integrator.f90.

112  REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y
113  REAL(KIND=8), INTENT(INOUT) :: t
114  REAL(KIND=8), INTENT(IN) :: dt,dtn
115  REAL(KIND=8), DIMENSION(0:ndim), INTENT(OUT) :: res,tend
116 
117  CALL stoch_atm_res_vec(dwar)
118  CALL stoch_atm_unres_vec(dwau)
119  CALL stoch_oc_res_vec(dwor)
120  CALL stoch_oc_unres_vec(dwou)
121  anoise=(q_ar*dwar+q_au*dwau+q_or*dwor+q_ou*dwou)*dtn
122  CALL tendencies(t,y,buf_f0)
123  CALL sparse_mul3(int_tensor,y,y,tend)
124  buf_y1 = y+dt*buf_f0+anoise
125  CALL sparse_mul3(int_tensor,buf_y1,buf_y1,buf_f1)
126  tend=0.5*(tend+buf_f1)
127  CALL tendencies(t,buf_y1,buf_f1)
128  res=y+0.5*(buf_f0+buf_f1)*dt+anoise
129  t=t+dt
subroutine rk2_stoch_integrator::tendencies ( real(kind=8), intent(in)  t,
real(kind=8), dimension(0:ndim), intent(in)  y,
real(kind=8), dimension(0:ndim), intent(out)  res 
)
private

Routine computing the tendencies of the selected model.

Parameters
tTime at which the tendencies have to be computed. Actually not needed for autonomous systems.
yPoint at which the tendencies have to be computed.
resvector to store the result.
Remarks
Note that it is NOT safe to pass y as a result buffer, as this operation does multiple passes.

Definition at line 97 of file rk2_stoch_integrator.f90.

97  REAL(KIND=8), INTENT(IN) :: t
98  REAL(KIND=8), DIMENSION(0:ndim), INTENT(IN) :: y
99  REAL(KIND=8), DIMENSION(0:ndim), INTENT(OUT) :: res
100  CALL sparse_mul3(int_tensor, y, y, res)

Variable Documentation

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

Additive noise term.

Definition at line 37 of file rk2_stoch_integrator.f90.

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

Definition at line 35 of file rk2_stoch_integrator.f90.

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

Integration buffers.

Definition at line 35 of file rk2_stoch_integrator.f90.

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

Definition at line 35 of file rk2_stoch_integrator.f90.

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

Definition at line 33 of file rk2_stoch_integrator.f90.

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

Definition at line 33 of file rk2_stoch_integrator.f90.

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

Definition at line 33 of file rk2_stoch_integrator.f90.

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

Standard gaussian noise buffers.

Definition at line 33 of file rk2_stoch_integrator.f90.

type(coolist), dimension(:), allocatable rk2_stoch_integrator::int_tensor
private

Dummy tensor that will hold the tendencies tensor.

Definition at line 39 of file rk2_stoch_integrator.f90.

39  TYPE(coolist), DIMENSION(:), ALLOCATABLE :: int_tensor !< Dummy tensor that will hold the tendencies tensor
Coordinate list. Type used to represent the sparse tensor.
Definition: tensor.f90:38