A Modular Arbitrary-Order Ocean-Atmosphere Model -- Stochastic implementation
doc/gen_doc.md
Go to the documentation of this file.
1 # Modular arbitrary-order ocean-atmosphere model: MAOOAM -- Stochastic Fortran implementation #
2 
3 ## About ##
4 
5 (c) 2013-2017 Lesley De Cruz and Jonathan Demaeyer
6 
7 See [LICENSE.txt](../../LICENSE.txt) for license information.
8 
9 This software is provided as supplementary material with:
10 
11 * De Cruz, L., Demaeyer, J. and Vannitsem, S.: The Modular Arbitrary-Order
12 Ocean-Atmosphere Model: MAOOAM v1.0, Geosci. Model Dev., 9, 2793-2808,
13 [doi:10.5194/gmd-9-2793-2016](http://dx.doi.org/10.5194/gmd-9-2793-2016), 2016.
14 
15 for the MAOOAM original code, and with
16 
17 *
18 
19 for the stochastic part.
20 
21 **Please cite both articles if you use (a part of) this software for a
22 publication.**
23 
24 The authors would appreciate it if you could also send a reprint of
25 your paper to <lesley.decruz@meteo.be>, <jonathan.demaeyer@meteo.be> and
26 <svn@meteo.be>.
27 
28 Consult the MAOOAM [code repository](http://www.github.com/Climdyn/MAOOAM)
29 for updates, and [our website](http://climdyn.meteo.be) for additional
30 resources.
31 
32 A pdf version of this manual is available [here](../latex/Reference_manual.pdf).
33 
34 ------------------------------------------------------------------------
35 
36 ## Installation ##
37 
38 The program can be installed with Makefile. We provide configuration files for
39 two compilers : gfortran and ifort.
40 
41 By default, gfortran is selected. To select one or the other, simply modify the
42 Makefile accordingly. If gfortran is selected, the code should be compiled
43 with gfortran 4.7+ (allows for allocatable arrays in namelists).
44 If ifort is selected, the code has been tested with the version 14.0.2 and we
45 do not guarantee compatibility with older compiler version.
46 
47 To install, unpack the archive in a folder, and run:
48  make
49 
50  Remark: The command "make clean" removes the compiled files.
51 
52 ------------------------------------------------------------------------
53 
54 ## Description of the files ##
55 
56 The model tendencies are represented through a tensor called aotensor which
57 includes all the coefficients. This tensor is computed once at the program
58 initialization.
59 
60 The following files are part of the MAOOAM model alone:
61 
62 * maooam.f90 : Main program.
63 * aotensor_def.f90 : Tensor aotensor computation module.
64 * IC_def.f90 : A module which loads the user specified initial condition.
65 * inprod_analytic.f90 : Inner products computation module.
66 * rk2_integrator.f90 : A module which contains the Heun integrator for the model equations.
67 * rk4_integrator.f90 : A module which contains the RK4 integrator for the model equations.
68 * Makefile : The Makefile.
69 * gfortran.mk : Gfortran compiler options file.
70 * ifort.mk : Ifort compiler options file.
71 * params.f90 : The model parameters module.
72 * tl_ad_tensor.f90 : Tangent Linear (TL) and Adjoint (AD) model tensors definition module
73 * rk2_tl_ad_integrator.f90 : Heun Tangent Linear (TL) and Adjoint (AD) model integrators module
74 * rk4_tl_ad_integrator.f90 : RK4 Tangent Linear (TL) and Adjoint (AD) model integrators module
75 * test_tl_ad.f90 : Tests for the Tangent Linear (TL) and Adjoint (AD) model versions
76 * README.md : A read me file.
77 * LICENSE.txt : The license text of the program.
78 * util.f90 : A module with various useful functions.
79 * tensor.f90 : Tensor utility module.
80 * stat.f90 : A module for statistic accumulation.
81 * params.nml : A namelist to specify the model parameters.
82 * int_params.nml : A namelist to specify the integration parameters.
83 * modeselection.nml : A namelist to specify which spectral decomposition will be used.
84 
85 with the addition of the files:
86 
87 * maooam_stoch.f90 : Stochastic implementation of MAOOAM.
88 * maooam_MTV.f90 : Main program - MTV implementation for MAOOAM.
89 * maooam_WL.f90 : Main program - WL implementation for MAOOAM.
90 * corrmod.f90 : Unresolved variables correlation matrix initialization module.
91 * corr_tensor.f90 : Correlations and derivatives for the memory term of the WL parameterization.
92 * dec_tensor.f90 : Tensor resolved-unresolved components decomposition module.
93 * int_comp.f90 : Utility module containing the routines to perform the integration of functions.
94 * int_corr.f90 : Module to compute or load the integrals of the correlation matrices.
95 * MAR.f90 : Multidimensional AutoRegressive (MAR) module to generate the correlation for the WL parameterization.
96 * memory.f90 : WL parameterization memory term \f$M_3\f$ computation module.
97 * MTV_int_tensor.f90 : MTV tensors computation module.
98 * MTV_sigma_tensor.f90 : MTV noise sigma matrices computation module.
99 * WL_tensor.f90 : WL tensors computation module.
100 * rk2_stoch_integrator.f90 : Stochastic RK2 integration routines module.
101 * rk2_ss_integrator.f90 : Stochastic uncoupled resolved nonlinear and tangent linear RK2 dynamics integration module.
102 * rk2_MTV_integrator.f90 : MTV RK2 integration routines module.
103 * rk2_WL_integrator.f90 : WL RK2 integration routines module.
104 * sf_def.f90 : Module to select the resolved-unresolved components.
105 * SF.nml : A namelist to select the resolved-unresolved components.
106 * sqrt_mod.f90 : Utility module with various routine to compute matrix square root.
107 * stoch_mod.f90 : Utility module containing the stochastic related routines.
108 * stoch_params.f90 : Stochastic models parameters module.
109 * stoch_params.nml : A namelist to specify the stochastic models parameters.
110 
111 which belong specifically to the stochastic implementation.
112 
113 
114 ------------------------------------------------------------------------
115 
116 ## MAOOAM Usage ##
117 
118 The user first has to fill the params.nml and int_params.nml namelist files according to their needs.
119 Indeed, model and integration parameters can be specified respectively in the params.nml and int_params.nml namelist files. Some examples related to already published article are available in the params folder.
120 
121 The modeselection.nml namelist can then be filled :
122 * NBOC and NBATM specify the number of blocks that will be used in respectively the ocean and
123  the atmosphere. Each block corresponds to a given x and y wavenumber.
124 * The OMS and AMS arrays are integer arrays which specify which wavenumbers of
125  the spectral decomposition will be used in respectively the ocean and the
126  atmosphere. Their shapes are OMS(NBOC,2) and AMS(NBATM,2).
127 * The first dimension specifies the number attributed by the user to the block and the second
128  dimension specifies the x and the y wavenumbers.
129 * The VDDG model, described in Vannitsem et al. (2015) is given as an example
130  in the archive.
131 * Note that the variables of the model are numbered according to the chosen
132  order of the blocks.
133 
134 
135 Finally, the IC.nml file specifying the initial condition should be defined. To
136 obtain an example of this configuration file corresponding to the model you
137 have previously defined, simply delete the current IC.nml file (if it exists)
138 and run the program :
139 
140  ./maooam
141 
142 It will generate a new one and start with the 0 initial condition. If you want another
143 initial condition, stop the program, fill the newly generated file and restart :
144 
145  ./maooam
146 
147 It will generate two files :
148  * evol_field.dat : the recorded time evolution of the variables.
149  * mean_field.dat : the mean field (the climatology)
150 
151 The tangent linear and adjoint models of MAOOAM are provided in the
152 tl_ad_tensor, rk2_tl_ad_integrator and rk4_tl_ad_integrator modules. It is
153 documented [here](./md_tl_ad_doc.html).
154 
155 ------------------------------------------------------------------------
156 
157 ## Stochastic code usage ##
158 
159 The user first has to fill the MAOOAM model namelist files according to their needs (see the previous section).
160 Additional namelist files for the fine tuning of the parameterization must then be filled,
161 and some "definition" files (with the extension .def) must be provided. An example is provided with the code.
162 
163 Full details over the parameterization options and definition files are available [here](md_sto_doc.html).
164 
165 The program "maooam_stoch" will generate the evolution of the full stochastic dynamics with the command:
166 
167  ./maooam_stoch
168 
169 or any other dynamics if specified as an argument (see the header of [maooam_stoch.f90](./maooam_stoch.f90)).
170 It will generate two files :
171  * evol_field.dat : the recorded time evolution of the variables.
172  * mean_field.dat : the mean field (the climatology)
173 
174 The program "maooam_MTV" will generate the evolution of the MTV parameterization evolution, with the command:
175 
176  ./maooam_MTV
177 
178 It will generate three files :
179  * evol_MTV.dat : the recorded time evolution of the variables.
180  * ptend_MTV.dat : the recorded time evolution of the tendencies (used for debugging).
181  * mean_field_MTV.dat : the mean field (the climatology)
182 
183 The program "maooam_WL" will generate the evolution of the MTV parameterization evolution, with the command:
184 
185  ./maooam_WL
186 
187 It will generate three files :
188  * evol_WL.dat : the recorded time evolution of the variables.
189  * ptend_WL.dat : the recorded time evolution of the tendencies (used for debugging).
190  * mean_field_WL.dat : the mean field (the climatology)
191 
192 ------------------------------------------------------------------------
193 
194 ## MAOOAM Implementation notes ##
195 
196 As the system of differential equations is at most bilinear in \f$z_j\f$ (\f$j=1..n\f$),
197 \f$\boldsymbol{z}\f$ being the array of variables, it can be expressed as a tensor
198  contraction :
199 
200 \f[ \frac{d z_i}{dt} = \sum_{j,k=0}^{ndim} \, \mathcal{T}_{i,j,k} \, z_k \; z_j \f]
201 
202 with \f$z_0 = 1\f$.
203 
204 
205 The tensor aotensor_def::aotensor is the tensor \f$\mathcal{T}\f$ that encodes the differential equations is composed so that:
206 
207 * \f$\mathcal{T}_{i,j,k}\f$ contains the contribution of \f$dz_i/dt\f$ proportional to \f$ z_j \, z_k\f$.
208 * Furthermore, \f$z_0\f$ is always equal to 1, so that \f$\mathcal{T}_{i,0,0}\f$ is the constant
209 contribution to \f$dz_i/dt\f$
210 * \f$\mathcal{T}_{i,j,0} + \mathcal{T}_{i,0,j}\f$ is the contribution to \f$dz_i/dt\f$ which is linear in
211 \f$z_j\f$.
212 
213 Ideally, the tensor aotensor_def::aotensor is composed as an upper triangular matrix
214 (in the last two coordinates).
215 
216 The tensor for this model is composed in the aotensor_def module and uses the
217 inner products defined in the inprod_analytic module.
218 
219 ------------------------------------------------------------------------
220 
221 ## Stochastic code implementation notes ##
222 
223 A stochastic version of MAOOAM and two stochastic parameterization methods
224 (MTV and WL) are provided with this code.
225 
226 The stochastic version of MAOOAM is given by
227 
228 \f[ \frac{d \boldsymbol{z}}{dt} = f(\boldsymbol{z})+ \boldsymbol{q} \cdot \boldsymbol{dW} (t)\f]
229 
230 where \f$\boldsymbol{dW}\f$ is a vector of standard Gaussian White noise and where several choice for \f$f(\boldsymbol{z})\f$ are available.
231 For instance, the default choice is to use the full dynamics:
232 \f[ f(\boldsymbol{z}) = \sum_{j,k=0}^{ndim} \, \mathcal{T}_{i,j,k} \, z_k \; z_j . \f]
233 The implementation uses the tensorial framework described above and add some noise to it.
234 This stochastic version is further detailed [here](md_sto_doc.html).
235 
236 The MTV parameterization for MAOOAM is given by
237 
238 \f[ \frac{d\boldsymbol{x}}{dt} = F_x(\boldsymbol{x}) + \frac{1}{\delta} R(\boldsymbol{x}) + G(\boldsymbol{x}) + \sqrt{2} \,\, \boldsymbol{\sigma}(\boldsymbol{x}) \cdot \boldsymbol{dW} \f]
239 
240 where \f$\boldsymbol{x}\f$ is the set of resolved variables and \f$\boldsymbol{dW}\f$ is a vector of standard Gaussian White noise.
241 \f$F_x\f$ is the set of tendencies of resolved system alone and \f$\delta\f$ is the timescale separation parameter.
242 
243 The WL parameterizations for MAOOAM is given by
244 
245 \f[\frac{d\boldsymbol{x}}{dt} = F_x(\boldsymbol{x}) + \varepsilon \, M_1(\boldsymbol{x}) + \varepsilon^2 \, M_2(\boldsymbol{x},t) + \varepsilon^2 \, M_3 (\boldsymbol{x},t)\f]
246 
247 where \f$\varepsilon\f$ is the resolved-unresolved components coupling strenght and where the different terms \f$M_i\f$ account for different effect.
248 
249 The implementation for these two approaches uses the tensorial framework described above, with the addition of new tensors to account for the
250 terms \f$R,G,\sigma,M_1,M_2,M_3\f$. They are detailed more completely [here](md_sto_doc.html).
251 
252 
253 
254 ------------------------------------------------------------------------
255 
256 ## Final Remarks ##
257 
258 The authors would like to thank Kris for help with the lua2fortran project. It
259 has greatly reduced the amount of (error-prone) work.
260 
261  No animals were harmed during the coding process.