New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
README.rst in NEMO/releases/r4.0/r4.0-HEAD/src/OCE/USR – NEMO

source: NEMO/releases/r4.0/r4.0-HEAD/src/OCE/USR/README.rst @ 15814

Last change on this file since 15814 was 14444, checked in by clem, 3 years ago

some corrections on the html user guide

File size: 12.3 KB
Line 
1******************************
2Setting up a new configuration
3******************************
4
5.. todo::
6
7
8
9.. contents::
10   :local:
11
12Starting from an existing configuration
13=======================================
14
15There are three options to build a new configuration from an existing one.
16
17Option 1: Duplicate an existing configuration
18---------------------------------------------
19
20The NEMO so-called Reference Configurations cover a number of major features for NEMO setup
21(global, regional, 1D, using embedded zoom with AGRIF...)
22
23One can create a new configuration by duplicating one of the reference configurations
24(``ORCA2_ICE_PISCES`` in the following example)
25
26.. code-block:: console
27
28   $ ./makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' -m 'my_arch'
29
30Option 2: Duplicate with differences
31------------------------------------
32
33Create and compile a new configuration based on a reference configuration
34(``ORCA2_ICE_PISCES`` in the following example) but with different pre-processor options.
35For this either add ``add_key`` or ``del_key`` keys as required; e.g.
36
37.. code-block:: console
38
39   $ ./makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' -m 'my_arch' del_key 'key_iomput' add_key 'key_diahth'
40
41Option 3: Use the SIREN tools to subset an existing model
42---------------------------------------------------------
43
44Define a regional configuration which is a {sub,super}-set of an existing configuration.
45
46This last option employs the SIREN software tools that are included in the standard distribution.
47The software is written in Fortran 95 and available in the :file:`./tools/SIREN` directory.
48SIREN allows you to create your own regional configuration embedded in a wider one.
49
50SIREN is a set of programs to create all the input files you need to
51run a NEMO regional configuration.
52
53:Demo:     Set of GLORYS files (GLObal ReanalYSis on the ORCA025 grid),
54           as well as examples of namelists are available `here`_.
55:Doc:      :forge:`chrome/site/doc/SIREN/html/index.html`
56:Support:  Any questions or comments regarding the use of SIREN should be posted in
57  :forge:`the corresponding forum <discussion/forum/2>`.
58
59.. _here: https://prodn.idris.fr/thredds/catalog/ipsl_public/rron463/catalog.html
60
61Option 4: Use the nesting tools to create embedded zooms or regional configurations from an existing grid
62---------------------------------------------------------------------------------------------------------
63(see :download:`NESTING README <../../../tools/NESTING/README>`).
64
65
66Creating a completely new configuration
67=======================================
68
69From NEMO version 4.0 there are two ways to build configurations from scratch.
70The appropriate method to use depends largely on the target configuration.
71Method 1 is for more complex/realistic global or regional configurations and
72method 2 is intended for simpler, idealised configurations whose
73domains and characteristics can be described in simple geometries and formulae.
74
75Option 1: Create and use a domain configuration file
76----------------------------------------------------
77
78This method is used by each of the reference configurations,
79so that downloading their input files linked to their description can help.
80Although starting from scratch,
81it is advisable to create the directory structure to house your new configuration by
82duplicating the closest reference configuration to your target application.
83For example, if your application requires both ocean ice and passive tracers,
84then use the ``ORCA2_ICE_PISCES`` as template,
85and execute following command to build your ``MY_NEW_CONFIG`` configuration:
86
87.. code-block:: sh
88
89   $ ./makenemo –n 'MY_NEW_CONFIG' -r 'ORCA2_ICE_PISCES' -m 'my_arch'
90
91where ``MY_NEW_CONFIG`` can be substituted with
92a suitably descriptive name for your new configuration.
93
94The purpose of this step is simply to create and populate the appropriate :file:`WORK`,
95:file:`MY_SRC` and :file:`EXP00` subdirectories for your new configuration.
96Other choices for the base reference configuration might be
97
98:GYRE:  If your target application is ocean-only
99:AMM12: If your target application is regional with open boundaries
100
101All the domain information for your new configuration will be contained within
102a netcdf file called :file:`domain_cfg.nc` which you will need to create and
103place in the :file:`./cfgs/MY_NEW_CONFIG/EXP00` sub-directory.
104Firstly though, ensure that your configuration is set to use such a file by checking that
105
106.. code-block:: fortran
107
108   ln_read_cfg = .true.
109
110in :file:`./cfgs/MY_NEW_CONFIG/EXP00/namelist_cfg`
111
112Create the :file:`domain_cfg.nc` file which must contain the following fields
113
114.. code-block:: c
115
116   /* configuration name, configuration resolution                 */
117   int    ORCA, ORCA_index
118   /* global domain sizes                                          */
119   int    jpiglo, jpjglo, jpkglo
120   /* lateral global domain b.c.                                   */
121   int    jperio
122   /* flags for z-coord, z-coord with partial steps and s-coord    */
123   int    ln_zco, ln_zps, ln_sco
124   /* flag  for ice shelf cavities                                 */
125   int    ln_isfcav
126   /* geographic position                                          */
127   double glamt, glamu, glamv, glamf
128   /* geographic position                                          */
129   double gphit, gphiu, gphiv, gphif
130   /* Coriolis parameter (if not on the sphere)                    */
131   double iff, ff_f, ff_t
132   /* horizontal scale factors                                     */
133   double e1t, e1u, e1v, e1f
134   /* horizontal scale factors                                     */
135   double e2t, e2u, e2v, e2f
136   /* U and V surfaces (if grid size reduction in some straits)    */
137   double ie1e2u_v, e1e2u, e1e2v
138   /* reference vertical scale factors at T and W points           */
139   double e3t_1d, e3w_1d
140   /* vertical scale factors 3D coordinate at T,U,V,F and W points */
141   double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0
142   /* vertical scale factors 3D coordinate at UW and VW points     */
143   double e3uw_0, e3vw_0
144   /* last wet T-points, 1st wet T-points (for ice shelf cavities) */
145   int    bottom_level, top_level
146
147There are two options for creating a :file:`domain_cfg.nc` file:
148
149- Users can use tools of their own choice to build a :file:`domain_cfg.nc` with all mandatory fields.
150- Users can adapt and apply the supplied tool available in :file:`./tools/DOMAINcfg`.
151  This tool is based on code extracted from NEMO version 3.6 and will allow similar choices for
152  the horizontal and vertical grids that were available internally to that version.
153  See :ref:`tools <DOMAINcfg>` for details.
154
155Option 2: Adapt the usr_def configuration module of NEMO for you own purposes
156-----------------------------------------------------------------------------
157
158This method is intended for configuring easily simple/idealised configurations which
159are often used as demonstrators or for process evaluation and comparison.
160This method can be used whenever the domain geometry has a simple mathematical description and
161the ocean initial state and boundary forcing is described analytically.
162As a start, consider the case of starting a completely new ocean-only test case based on
163the ``LOCK_EXCHANGE`` example.
164
165.. note::
166
167   We probably need an even more basic example than this with only one namelist and
168   minimal changes to the usrdef modules
169
170Firstly, construct the directory structure, starting in the :file:`cfgs` directory:
171
172.. code-block:: console
173
174   $ ./makenemo -n 'MY_NEW_TEST' -t 'LOCK_EXCHANGE' -m 'my_arch'
175
176where the ``-t`` option has been used to locate the new configuration in
177the :file:`tests` subdirectory
178(it is recommended practice to keep full configurations and idealised cases clearly distinguishable).
179This command will create (amongst others) the following files and directories::
180
181   ./tests/MY_NEW_TEST:
182   BLD  EXP00  MY_SRC WORK  cpp_MY_NEW_TEST.fcm
183
184   ./tests/MY_NEW_TEST/EXP00:
185   context_nemo.xml  domain_def_nemo.xml  field_def_nemo-oce.xml  file_def_nemo-oce.xml  iodef.xml
186   namelist_cfg      namelist_ref
187
188   ./tests/MY_NEW_TEST/MY_SRC:
189   usrdef_hgr.F90  usrdef_nam.F90  usrdef_zgr.F90  usrdef_istate.F90  usrdef_sbc.F90  zdfini.F90
190
191The key to setting up an idealised configuration lies in
192adapting a small set of short Fortran 90 modules which
193should be dropped into the :file:`MY_SRC` directory.
194Here the ``LOCK_EXCHANGE`` example is using 5 such routines but the full set that is available in
195the :file:`src/OCE/USR` directory is::
196
197   ./src/OCE/USR:
198   usrdef_closea.F90  usrdef_fmask.F90  usrdef_hgr.F90  usrdef_istate.F90
199   usrdef_nam.F90     usrdef_sbc.F90    usrdef_zgr.F90
200
201Before discussing these in more detail it is worth noting the various namelist controls that
202engage the different user-defined aspects.
203These controls are set using two new logical switches or are implied by the settings of existing ones.
204For example, the mandatory requirement for an idealised configuration is to provide routines which
205define the horizontal and vertical domains.
206Templates for these are provided in the :file:`usrdef_hgr.F90` and :file:`usrdef_zgr.F90` modules.
207The application of these modules is activated whenever:
208
209.. code-block:: fortran
210
211   ln_read_cfg = .false.
212
213in any configuration's :file:`namelist_cfg` file.
214This setting also activates the reading of an optional ``&nam_usrdef`` namelist which can be used to
215supply configuration specific settings.
216These need to be declared and read in the :file:`usrdef_nam.F90` module.
217
218Another explicit control is available in the ``&namsbc`` namelist which
219activates the use of analytical forcing.
220With
221
222.. code-block:: fortran
223
224   ln_usr = .true.
225
226Other usrdef modules are activated by less explicit means.
227For example, code in :file:`usrdef_istate.F90` is used to
228define initial temperature and salinity fields if
229
230.. code-block:: fortran
231
232   ln_tsd_init   = .false.
233
234in the ``&namtsd`` namelist.
235The remaining modules, namely :file:`usrdef_closea.F90` :file:`usrdef_fmask.F90` are specific to
236ORCA configurations and set local variations of some specific fields for
237the various resolutions of the global models.
238They do not need to be considered here in the context of idealised cases but
239it is worth noting that all configuration specific code has now been isolated in the usrdef modules.
240In the case of these last two modules, they are activated only if an ORCA configuration is detected.
241Currently,
242this requires a specific integer variable named ``ORCA`` to be set in a :file:`domain_cfg.nc` file.
243
244.. note::
245
246   This would be less confusing if the ``cn_cfg`` string is read directly as
247   a character attribue from the :file:`domain_cfg.nc`.
248
249So, in most cases, the set up of idealised model configurations can be completed by
250copying the template routines from :file:`./src/OCE/USR` into
251your new :file:`./cfgs/MY_NEW_TEST/MY_SRC` directory and
252editing the appropriate modules as needed.
253The default set are those used for the GYRE reference configuration.
254The contents of :file:`MY_SRC` directories from other idealised configurations may provide
255more convenient templates if they share common characteristics with your target application.
256
257Whatever the starting point,
258it should not require too many changes or additional lines of code to produce routines in
259:file:`./src/OCE/USR` that define analytically the domain,
260the initial state and the surface boundary conditions for your new configuration.
261
262To summarize, the base set of modules is:
263
264:usrdef_hgr.F90:    Define horizontal grid
265:usrdef_zgr.F90:    Define vertical grid
266:usrdef_sbc.F90:    Provides at each time-step the surface boundary condition,
267   i.e. the momentum, heat and freshwater fluxes
268:usrdef_istate.F90: Defines initialization of the dynamics and tracers
269:usrdef_nam.F90:    Configuration-specific namelist processing to
270   set any associated run-time parameters
271
272with two specialised ORCA modules
273(not related to idealised configurations but used to isolate configuration specific code that
274is used in ORCA2 reference configurations and established global configurations using
275the ORCA tripolar grid):
276
277:usrdef_fmask.F90:  only used in ORCA configurations for
278   alteration of f-point land/ocean mask in some straits
279:usrdef_closea.F90: only used in ORCA configurations for
280   specific treatments associated with closed seas
281
282From version 4.0, the NEMO release includes a :file:`tests` subdirectory containing available and
283up to date :doc:`test cases <tests>` build by the community.
284These will not be fully supported as are NEMO reference configurations,
285but should provide a source of raw material.
Note: See TracBrowser for help on using the repository browser.