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/trunk/src/OCE/USR – NEMO

source: NEMO/trunk/src/OCE/USR/README.rst @ 14433

Last change on this file since 14433 was 14433, checked in by smasson, 3 years ago

trunk: merge dev_r14312_MPI_Interface into the trunk, #2598

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