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

Last change on this file was 14446, checked in by clem, 3 years ago

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