Skip to content
This repository was archived by the owner on Apr 18, 2018. It is now read-only.

Commit 4803db9

Browse files
authored
Merge pull request #9 from jrscott/manual_edits
edits/restructure to manual, adding placeholders for all chapters
2 parents 3eefbbb + baa44c3 commit 4803db9

File tree

149 files changed

+53954
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+53954
-132
lines changed

doc/auto_diff/auto_diff.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Automatic Differentiation
2+
*************************
3+

doc/contributing.rst renamed to doc/contributing/contributing.rst

Lines changed: 113 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To request a new feature, or guidance on how to implement it yourself, please op
2525
Using Git and Github
2626
========================
2727

28-
To contribute to the source code of the model you will need to fork the repository and place a pull request on GitHub. The two following sections describe this process in different levels of detail. If you are unfamiliar with git, you may wish to skip the quickstart guide and use the detailed instructions. All contributions are expected to conform with the :ref:`sec_code_style_guide`.
28+
To contribute to the source code of the model you will need to fork the repository and place a pull request on GitHub. The two following sections describe this process in different levels of detail. If you are unfamiliar with git, you may wish to skip the quickstart guide and use the detailed instructions. All contributions to the source code are expected to conform with the :ref:`sec_code_style_guide`. Contributions to the manual should follow the same procedure and conform with :numref:`contrib_manual`.
2929

3030

3131
Quickstart Guide
@@ -204,19 +204,15 @@ The MITgcm uses the continuous integration service Travis-CI to test code before
204204

205205
**Detailed instructions or link to be added.**
206206

207+
.. _contrib_manual:
207208

208209
Contributing to the manual
209210
==========================
210211

211-
Whether you are correcting typos or describing currently undocumented packages, we welcome all contributions to the manual. The following information will help you make sure that your contribution is consistent with the style of the MITgcm documentation. (We know that not all of the current documentation follows these guidelines - we're working on it)
212+
Whether you are simply correcting typos or describing undocumented packages, we welcome all contributions to the manual. The following information will help you make sure that your contribution is consistent with the style of the MITgcm documentation. (We know that not all of the current documentation follows these guidelines - we're working on it)
212213

213-
Once you've made your changes to the manual, you should build it locally to verify that it works as expected. To do this you will need a working python installation with the following modules installed (use :code:`pip install MODULE` in the terminal):
214-
215-
- sphinx
216-
- sphinxcontrib-bibtex
217-
- sphinx_rtd_theme
218-
219-
Then, run :code:`make html` in the :code:`docs` directory.
214+
The manual is written in **rst** format, which is short for ReStructuredText directives. rst offers many wonderful features: it automatically does much of the formatting for you, it is reasonably well documented on the web (e.g. primers available `here <http://www.sphinx-doc.org/en/stable/rest.html>`_ and
215+
`here <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_), it can accept raw latex syntax and track equation labelling for you, in addition to numerous other useful features. On the down side however, it can be very fussy about formatting, requiring exact spacing and indenting, and seemingly innocuous things such as blank spaces at ends of lines can wreak havoc. We suggest looking at the existing rst files in the manual to see exactly how something is formatted, along with the syntax guidelines specified in this section, prior to writing and formatting your own manual text.
220216

221217

222218
Section headings
@@ -231,67 +227,109 @@ Section headings
231227
N.B. all underlinings should be the same length as the heading. If they are too short an error will be produced.
232228

233229

234-
Cross referencing
235-
-----------------
230+
Internal document references
231+
----------------------------
232+
233+
rst allows internal referencing of figures, tables, section headings, and equations, i.e. clickable links that bring the reader to the respective figure etc. in the manual.
234+
To be referenced, a unique label is required. To reference figures, tables, or section headings by number,
235+
the rst (inline) directive is ``:numref:`LABELNAME```. For example, this syntax would write out ``Figure XX`` on a line. and when clicked, would relocate your position
236+
in the manual to figure XX. Section Headings can also be referenced so that the name is written out instead of the section number, instead using this
237+
directive ``:ref:`LABELNAME```.
238+
239+
Equation references have a slightly different inline syntax: ``:eq:`LABELNAME``` will produce a clickable equation number reference, surrounded by parentheses.
236240

237-
Labels go above the section they refer to, with the format ``.. _LABELNAME:``. The leading underscore is important.
241+
For instructions how to assign a label to tables and figures, see below. To label a section heading, labels go above the section they refer to, with the format ``.. _LABELNAME:``.
242+
Note the necessary leading underscore.
238243

239-
To reference sections/figures/tables/equations by number use this format for the reference: ``:numref:`sec_eg_baro```
240244

241-
To reference sections by name use this format: ``:ref:`sec_eg_baro```
245+
External references
246+
--------------------
242247

248+
hyperlinks
249+
filelink
250+
varlink
243251

244-
Maths
245-
-----
252+
Symbolic Notation
253+
-----------------
246254

247-
Inline maths is done with ``:math:`LATEX_HERE```
255+
Inline math is done with ``:math:`LATEX_HERE```
248256

249257
Separate equations, which will be typeset on their own lines, are produced with::
250258

251259
.. math::
252-
:label: eqn_label_here
260+
LATEX_HERE
261+
:label: EQN_LABEL_HERE
253262

254-
LATEX_HERE
255263

264+
Labelled separate equations are assigned an equation number, which may be referenced elsewhere in the document (see :numref:`referencing`). Omitting the ``:label:`` above
265+
will still produce an equation on its own line, except without an equation label.
266+
Note that using using latex formatting ``\begin{aligned}`` ... ``\end{aligned}`` across multiple lines of equations will not work in conjunction with unique equation labels for each separate line.
256267

257-
.. _subsec_manual_style_guide:
258268

269+
Figures and tables
270+
------------------
259271

260-
Units
261-
-----
272+
provide example syntax of each
262273

263-
Units should be typeset in normal text, and exponents added with the ``:sup:`` command.
264274

265-
::
275+
Other text blocks
276+
-----------------
266277

267-
100 N m\ :sup:`--2`
278+
To set several lines apart in an whitespace box, e.g. useful for showing lines in from a terminal session, rst uses ``::`` to set off a ‘literal block’.
279+
For example::
268280

269-
If the exponent is negative use two dashes ``--`` to make the minus sign long enough. The backslash removes the space between the unit and the exponent.
281+
::
270282

283+
% unix_command_foo
284+
% unix_command_fum
271285

272286

273287

274-
Describing subroutine inputs and outputs
275-
----------------------------------------
288+
A splashier way to outline a block, including a box label, is to employ what is termed in rst as an ‘admonition block’.
289+
In the manual these are used to show calling trees and for describing subroutine inputs and outputs. An example of
290+
a subroutine input/output block is as follows:
276291

277-
This information should go in an 'adominition' block. The source code to achieve this is:
278292

279-
::
293+
.. admonition:: This is an admonition block showing subroutine in/out syntax
294+
:class: note
280295

281-
.. admonition:: Subroutine
282-
:class: note
296+
| .. admonition:: :filelink:`SUBROUTINE_NAME </model/src/subroutine_name.F>`
297+
| :class: note
298+
|
299+
| | :math:`var1` : **VAR1** ( :filelink:`WHERE_VAR1_DEFINED.h </model/inc/where_var1_defined.h>`)
300+
| | :math:`var2` : **VAR1** ( :filelink:`WHERE_VAR2_DEFINED.h </model/inc/where_var2_defined.h>` )
301+
| | :math:`var3` : **VAR1** ( :filelink:`WHERE_VAR3_DEFINED.h </model/inc/where_var3_defined.h>` )
283302
284-
S/R GMREDI_CALC_TENSOR (*pkg/gmredi/gmredi_calc_tensor.F*)
285303

286-
:math:`\sigma_x`: **SlopeX** (argument on entry)
287304

288-
:math:`\sigma_y`: **SlopeY** (argument on entry)
305+
An example of a calling tree syntax is :filelink:`here </doc/discrete_algorithm/discret_algorithm.rst>`.
289306

290-
:math:`\sigma_z`: **SlopeY** (argument)
291307

292-
:math:`S_x`: **SlopeX** (argument on exit)
293308

294-
:math:`S_y`: **SlopeY** (argument on exit)
309+
310+
.. _subsec_manual_style_guide:
311+
312+
313+
Other style conventions
314+
-----------------------
315+
316+
double quotes for inline literal computer output, variables, typing etc.
317+
how to break up into smaller files
318+
probably want to add more to this subsection; maybe add another subsection “other useful rst syntax”
319+
320+
321+
Building the manual
322+
-------------------
323+
324+
Once you've made your changes to the manual, you should build it locally to verify that it works as expected. To do this you will need a working python installation with the following modules installed (use :code:`pip install MODULE` in the terminal):
325+
326+
- sphinx
327+
- sphinxcontrib-bibtex
328+
- sphinx_rtd_theme
329+
330+
Then, run :code:`make html` in the :code:`docs` directory.
331+
332+
295333

296334
.. _sec_pullreq:
297335

@@ -332,3 +370,40 @@ and switch to the desired branch
332370
You now have a local copy of the code from the pull request and can run tests locally. If you have write access to the main repository you can push fixes or changes directly to the pull request.
333371

334372
None of these steps, apart from pushing fixes back to the pull request, require write access to either the main repository or the repository of the person proposing the pull request. This means that anyone can review pull requests. However, unless you are one of the core developers you won't be able to directly push changes. You will instead have to make a comment describing any problems you find.
373+
374+
375+
Old Stuff to remove:
376+
377+
Units should be typeset in normal text, and exponents added with the ``:sup:`` command.
378+
379+
::
380+
381+
100 N m\ :sup:`--2`
382+
383+
If the exponent is negative use two dashes ``--`` to make the minus sign long enough. The backslash removes the space between the unit and the exponent.
384+
385+
386+
387+
388+
Describing subroutine inputs and outputs
389+
----------------------------------------
390+
391+
This information should go in an 'adminition' block. The source code to achieve this is:
392+
393+
::
394+
395+
.. admonition:: Subroutine
396+
:class: note
397+
398+
S/R GMREDI_CALC_TENSOR (*pkg/gmredi/gmredi_calc_tensor.F*)
399+
400+
:math:`\sigma_x`: **SlopeX** (argument on entry)
401+
402+
:math:`\sigma_y`: **SlopeY** (argument on entry)
403+
404+
:math:`\sigma_z`: **SlopeY** (argument)
405+
406+
:math:`S_x`: **SlopeX** (argument on exit)
407+
408+
:math:`S_y`: **SlopeY** (argument on exit)
409+
File renamed without changes.
File renamed without changes.
File renamed without changes.

doc/discret_algorithm/c-grid.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
C grid staggering of variables
2+
------------------------------
3+
4+
The basic algorithm employed for stepping forward the momentum equations
5+
is based on retaining non-divergence of the flow at all times. This is
6+
most naturally done if the components of flow are staggered in space in
7+
the form of an Arakawa C grid (Arakawa and Lamb, 1977 :cite:`arakawa:77`).
8+
9+
:numref:`cgrid3d` shows the components of flow
10+
(:math:`u`,\ :math:`v`,\ :math:`w`) staggered in space such that the
11+
zonal component falls on the interface between continuity cells in the
12+
zonal direction. Similarly for the meridional and vertical directions.
13+
The continuity cell is synonymous with tracer cells (they are one and
14+
the same).
15+
16+
.. figure:: figs/cgrid3d.*
17+
:width: 60%
18+
:align: center
19+
:alt: cgrid3d
20+
:name: cgrid3d
21+
22+
Three dimensional staggering of velocity components. This facilitates the natural discretization of the continuity and tracer equations.
23+
24+
Grid initialization and data
25+
----------------------------
26+
27+
Initialization of grid data is controlled by subroutine :filelink:`INI_GRID <model/src/ini_grid.F>`
28+
which in calls :filelink:`INI_VERTICAL_GRID <model/src/ini_vertical_grid.F>` to initialize the vertical grid,
29+
and then either of :filelink:`INI_CARTESIAN_GRID <model/src/ini_cartesian_grid.F>`,
30+
:filelink:`INI_SPHERICAL_POLAR_GRID <model/src/ini_spherical_polar_grid.F>`
31+
or :filelink:`INI_CURVILINEAR_GRID <model/src/ini_curvilinear_grid.F>` to initialize the horizontal grid for
32+
cartesian, spherical-polar or curvilinear coordinates respectively.
33+
34+
The reciprocals of all grid quantities are pre-calculated and this is
35+
done in subroutine :filelink:`INI_MASKS_ETC <model/src/ini_masks_etc.F>` which is called later by subroutine
36+
:filelink:`INITIALISE_FIXED <model/src/initialise_fixed.F>`.
37+
38+
All grid descriptors are global arrays and stored in common blocks in
39+
:filelink:`GRID.h <model/inc/GRID.h>` and a generally declared as ``_RS``.
40+
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
.. _crank-nicolson_baro:
2+
3+
Crank-Nicolson barotropic time stepping
4+
---------------------------------------
5+
6+
The full implicit time stepping described previously is
7+
unconditionally stable but damps the fast gravity waves, resulting in
8+
a loss of potential energy. The modification presented now allows one
9+
to combine an implicit part (:math:`\beta,\gamma`) and an explicit
10+
part (:math:`1-\beta,1-\gamma`) for the surface pressure gradient
11+
(:math:`\beta`) and for the barotropic flow divergence
12+
(:math:`\gamma`). For instance, :math:`\beta=\gamma=1` is the previous fully implicit
13+
scheme; :math:`\beta=\gamma=1/2` is the non damping (energy
14+
conserving), unconditionally stable, Crank-Nicolson scheme;
15+
:math:`(\beta,\gamma)=(1,0)` or :math:`=(0,1)` corresponds to the
16+
forward - backward scheme that conserves energy but is only stable for
17+
small time steps. In the code, :math:`\beta,\gamma` are defined as parameters,
18+
respectively :varlink:`implicSurfPress`, :varlink:`implicDiv2DFlow`. They are read
19+
from the main parameter file ``data`` (namelist ``PARM01``) and are set
20+
by default to 1,1.
21+
22+
Equations :eq:`ustar-backward-free-surface` –
23+
:eq:`vn+1-backward-free-surface` are modified as follows:
24+
25+
.. math::
26+
\frac{ \vec{\bf v}^{n+1} }{ \Delta t }
27+
+ {\bf \nabla}_h b_s [ \beta {\eta}^{n+1} + (1-\beta) {\eta}^{n} ]
28+
+ \epsilon_{nh} {\bf \nabla}_h {\phi'_{nh}}^{n+1}
29+
= \frac{ \vec{\bf v}^{n} }{ \Delta t }
30+
+ \vec{\bf G}_{\vec{\bf v}} ^{(n+1/2)}
31+
+ {\bf \nabla}_h {\phi'_{hyd}}^{(n+1/2)}
32+
33+
.. math::
34+
\epsilon_{fs} \frac{ {\eta}^{n+1} - {\eta}^{n} }{ \Delta t}
35+
+ {\bf \nabla}_h \cdot \int_{R_{fixed}}^{R_o}
36+
[ \gamma \vec{\bf v}^{n+1} + (1-\gamma) \vec{\bf v}^{n}] dr
37+
= \epsilon_{fw} (P-E)
38+
:label: eta-n+1-CrankNick
39+
40+
We set
41+
42+
.. math::
43+
\begin{aligned}
44+
\vec{\bf v}^* & = &
45+
\vec{\bf v} ^{n} + \Delta t \vec{\bf G}_{\vec{\bf v}} ^{(n+1/2)}
46+
+ (\beta-1) \Delta t {\bf \nabla}_h b_s {\eta}^{n}
47+
+ \Delta t {\bf \nabla}_h {\phi'_{hyd}}^{(n+1/2)}
48+
\\
49+
{\eta}^* & = &
50+
\epsilon_{fs} {\eta}^{n} + \epsilon_{fw} \Delta t (P-E)
51+
- \Delta t {\bf \nabla}_h \cdot \int_{R_{fixed}}^{R_o}
52+
[ \gamma \vec{\bf v}^* + (1-\gamma) \vec{\bf v}^{n}] dr\end{aligned}
53+
54+
In the hydrostatic case :math:`\epsilon_{nh}=0`, allowing us to find
55+
:math:`{\eta}^{n+1}`, thus:
56+
57+
.. math::
58+
\epsilon_{fs} {\eta}^{n+1} -
59+
{\bf \nabla}_h \cdot \beta\gamma \Delta t^2 b_s (R_o - R_{fixed})
60+
{\bf \nabla}_h {\eta}^{n+1}
61+
= {\eta}^*
62+
63+
and then to compute (:filelink:`CORRECTION_STEP <model/src/correction_step.F>`):
64+
65+
.. math::
66+
\vec{\bf v}^{n+1} = \vec{\bf v}^{*}
67+
- \beta \Delta t {\bf \nabla}_h b_s {\eta}^{n+1}
68+
69+
Notes:
70+
71+
#. The RHS term of equation :eq:`eta-n+1-CrankNick` corresponds the
72+
contribution of fresh water flux (P-E) to the free-surface variations
73+
(:math:`\epsilon_{fw}=1`, :varlink:`useRealFreshWaterFlux` =.TRUE. in parameter
74+
file ``data``). In order to remain consistent with the tracer equation,
75+
specially in the non-linear free-surface formulation, this term is
76+
also affected by the Crank-Nicolson time stepping. The RHS reads:
77+
:math:`\epsilon_{fw} ( \gamma (P-E)^{n+1/2} + (1-\gamma) (P-E)^{n-1/2} )`
78+
79+
80+
#. The stability criteria with Crank-Nicolson time stepping for the pure
81+
linear gravity wave problem in cartesian coordinates is:
82+
83+
- :math:`\beta + \gamma < 1` : unstable
84+
85+
- :math:`\beta \geq 1/2` and :math:`\gamma \geq 1/2` : stable
86+
87+
- :math:`\beta + \gamma \geq 1` : stable if :math:`c_{max}^2 (\beta - 1/2)(\gamma - 1/2) + 1 \geq 0`
88+
with :math:`c_{max} = 2 \Delta t \sqrt{gH} \sqrt{ \frac{1}{\Delta x^2} + \frac{1}{\Delta y^2} }`
89+
90+
91+
#. A similar mixed forward/backward time-stepping is also available for
92+
the non-hydrostatic algorithm, with a fraction :math:`\beta_{nh}`
93+
(:math:`0 < \beta_{nh} \leq 1`) of the non-hydrostatic pressure
94+
gradient being evaluated at time step :math:`n+1` (backward in time)
95+
and the remaining part (:math:`1 - \beta_{nh}`) being evaluated at
96+
time step :math:`n` (forward in time). The run-time parameter
97+
:varlink:`implicitNHPress` corresponding to the implicit fraction
98+
:math:`\beta_{nh}` of the non-hydrostatic pressure is set by default
99+
to the implicit fraction :math:`\beta` of surface pressure
100+
(:varlink:`implicSurfPress`), but can also be specified independently (in
101+
main parameter file ``data``, namelist ``PARM01``).

0 commit comments

Comments
 (0)