1 | ****************************** |
---|
2 | Setting up a new configuration |
---|
3 | ****************************** |
---|
4 | |
---|
5 | .. todo:: |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | .. contents:: |
---|
10 | :local: |
---|
11 | |
---|
12 | Starting from an existing configuration |
---|
13 | ======================================= |
---|
14 | |
---|
15 | There are three options to build a new configuration from an existing one. |
---|
16 | |
---|
17 | Option 1: Duplicate an existing configuration |
---|
18 | --------------------------------------------- |
---|
19 | |
---|
20 | The NEMO so-called Reference Configurations cover a number of major features for NEMO setup |
---|
21 | (global, regional, 1D, using embedded zoom with AGRIF...) |
---|
22 | |
---|
23 | One 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 | |
---|
30 | Option 2: Duplicate with differences |
---|
31 | ------------------------------------ |
---|
32 | |
---|
33 | Create and compile a new configuration based on a reference configuration |
---|
34 | (``ORCA2_ICE_PISCES`` in the following example) but with different pre-processor options. |
---|
35 | For 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 | |
---|
41 | Option 3: Use the SIREN tools to subset an existing model |
---|
42 | --------------------------------------------------------- |
---|
43 | |
---|
44 | Define a regional configuration which is a {sub,super}-set of an existing configuration. |
---|
45 | |
---|
46 | This last option employs the SIREN software tools that are included in the standard distribution. |
---|
47 | The software is written in Fortran 95 and available in the :file:`./tools/SIREN` directory. |
---|
48 | SIREN allows you to create your own regional configuration embedded in a wider one. |
---|
49 | |
---|
50 | SIREN is a set of programs to create all the input files you need to |
---|
51 | run 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 | |
---|
61 | Option 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 | |
---|
66 | Creating a completely new configuration |
---|
67 | ======================================= |
---|
68 | |
---|
69 | From NEMO version 4.0 there are two ways to build configurations from scratch. |
---|
70 | The appropriate method to use depends largely on the target configuration. |
---|
71 | Method 1 is for more complex/realistic global or regional configurations and |
---|
72 | method 2 is intended for simpler, idealised configurations whose |
---|
73 | domains and characteristics can be described in simple geometries and formulae. |
---|
74 | |
---|
75 | Option 1: Create and use a domain configuration file |
---|
76 | ---------------------------------------------------- |
---|
77 | |
---|
78 | This method is used by each of the reference configurations, |
---|
79 | so that downloading their input files linked to their description can help. |
---|
80 | Although starting from scratch, |
---|
81 | it is advisable to create the directory structure to house your new configuration by |
---|
82 | duplicating the closest reference configuration to your target application. |
---|
83 | For example, if your application requires both ocean ice and passive tracers, |
---|
84 | then use the ``ORCA2_ICE_PISCES`` as template, |
---|
85 | and 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 | |
---|
91 | where ``MY_NEW_CONFIG`` can be substituted with |
---|
92 | a suitably descriptive name for your new configuration. |
---|
93 | |
---|
94 | The 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. |
---|
96 | Other 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 | |
---|
101 | All the domain information for your new configuration will be contained within |
---|
102 | a netcdf file called :file:`domain_cfg.nc` which you will need to create and |
---|
103 | place in the :file:`./cfgs/MY_NEW_CONFIG/EXP00` sub-directory. |
---|
104 | Firstly 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 | |
---|
110 | in :file:`./cfgs/MY_NEW_CONFIG/EXP00/namelist_cfg` |
---|
111 | |
---|
112 | Create 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 | |
---|
145 | There 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 | |
---|
153 | Option 2: Adapt the usr_def configuration module of NEMO for you own purposes |
---|
154 | ----------------------------------------------------------------------------- |
---|
155 | |
---|
156 | This method is intended for configuring easily simple/idealised configurations which |
---|
157 | are often used as demonstrators or for process evaluation and comparison. |
---|
158 | This method can be used whenever the domain geometry has a simple mathematical description and |
---|
159 | the ocean initial state and boundary forcing is described analytically. |
---|
160 | As a start, consider the case of starting a completely new ocean-only test case based on |
---|
161 | the ``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 | |
---|
168 | Firstly, 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 | |
---|
174 | where the ``-t`` option has been used to locate the new configuration in |
---|
175 | the :file:`tests` subdirectory |
---|
176 | (it is recommended practice to keep full configurations and idealised cases clearly distinguishable). |
---|
177 | This 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 | |
---|
189 | The key to setting up an idealised configuration lies in |
---|
190 | adapting a small set of short Fortran 90 modules which |
---|
191 | should be dropped into the :file:`MY_SRC` directory. |
---|
192 | Here the ``LOCK_EXCHANGE`` example is using 5 such routines but the full set that is available in |
---|
193 | the :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 | |
---|
199 | Before discussing these in more detail it is worth noting the various namelist controls that |
---|
200 | engage the different user-defined aspects. |
---|
201 | These controls are set using two new logical switches or are implied by the settings of existing ones. |
---|
202 | For example, the mandatory requirement for an idealised configuration is to provide routines which |
---|
203 | define the horizontal and vertical domains. |
---|
204 | Templates for these are provided in the :file:`usrdef_hgr.F90` and :file:`usrdef_zgr.F90` modules. |
---|
205 | The application of these modules is activated whenever: |
---|
206 | |
---|
207 | .. code-block:: fortran |
---|
208 | |
---|
209 | ln_read_cfg = .false. |
---|
210 | |
---|
211 | in any configuration's :file:`namelist_cfg` file. |
---|
212 | This setting also activates the reading of an optional ``&nam_usrdef`` namelist which can be used to |
---|
213 | supply configuration specific settings. |
---|
214 | These need to be declared and read in the :file:`usrdef_nam.F90` module. |
---|
215 | |
---|
216 | Another explicit control is available in the ``&namsbc`` namelist which |
---|
217 | activates the use of analytical forcing. |
---|
218 | With |
---|
219 | |
---|
220 | .. code-block:: fortran |
---|
221 | |
---|
222 | ln_usr = .true. |
---|
223 | |
---|
224 | Other usrdef modules are activated by less explicit means. |
---|
225 | For example, code in :file:`usrdef_istate.F90` is used to |
---|
226 | define initial temperature and salinity fields if |
---|
227 | |
---|
228 | .. code-block:: fortran |
---|
229 | |
---|
230 | ln_tsd_init = .false. |
---|
231 | |
---|
232 | in the ``&namtsd`` namelist. |
---|
233 | The remaining modules, namely :file:`usrdef_closea.F90` :file:`usrdef_fmask.F90` are specific to |
---|
234 | ORCA configurations and set local variations of some specific fields for |
---|
235 | the various resolutions of the global models. |
---|
236 | They do not need to be considered here in the context of idealised cases but |
---|
237 | it is worth noting that all configuration specific code has now been isolated in the usrdef modules. |
---|
238 | In the case of these last two modules, they are activated only if an ORCA configuration is detected. |
---|
239 | Currently, |
---|
240 | this 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 | |
---|
247 | So, in most cases, the set up of idealised model configurations can be completed by |
---|
248 | copying the template routines from :file:`./src/OCE/USR` into |
---|
249 | your new :file:`./cfgs/MY_NEW_TEST/MY_SRC` directory and |
---|
250 | editing the appropriate modules as needed. |
---|
251 | The default set are those used for the GYRE reference configuration. |
---|
252 | The contents of :file:`MY_SRC` directories from other idealised configurations may provide |
---|
253 | more convenient templates if they share common characteristics with your target application. |
---|
254 | |
---|
255 | Whatever the starting point, |
---|
256 | it 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, |
---|
258 | the initial state and the surface boundary conditions for your new configuration. |
---|
259 | |
---|
260 | To 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 | |
---|
270 | with two specialised ORCA modules |
---|
271 | (not related to idealised configurations but used to isolate configuration specific code that |
---|
272 | is used in ORCA2 reference configurations and established global configurations using |
---|
273 | the 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 | |
---|
280 | From version 4.0, the NEMO release includes a :file:`tests` subdirectory containing available and |
---|
281 | up to date :doc:`test cases <tests>` build by the community. |
---|
282 | These will not be fully supported as are NEMO reference configurations, |
---|
283 | but should provide a source of raw material. |
---|