[10598] | 1 | *********** |
---|
| 2 | Diagnostics |
---|
| 3 | *********** |
---|
[10201] | 4 | |
---|
[11734] | 5 | .. todo:: |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | |
---|
[10201] | 9 | .. contents:: |
---|
[11734] | 10 | :local: |
---|
[10201] | 11 | |
---|
[10562] | 12 | Output of diagnostics in NEMO is usually done using XIOS. |
---|
[11747] | 13 | This is an efficient way of writing diagnostics because |
---|
| 14 | the time averaging, file writing and even some simple arithmetic or regridding is carried out in |
---|
| 15 | parallel to the NEMO model run. |
---|
[10562] | 16 | This page gives a basic introduction to using XIOS with NEMO. |
---|
[11747] | 17 | Much more information is available from the :xios:`XIOS homepage<>` above and from the NEMO manual. |
---|
[10201] | 18 | |
---|
[14239] | 19 | Use of XIOS for diagnostics is activated using the pre-compiler key ``key_xios``. |
---|
[10201] | 20 | |
---|
| 21 | Extracting and installing XIOS |
---|
[11747] | 22 | ============================== |
---|
[10201] | 23 | |
---|
| 24 | 1. Install the NetCDF4 library. |
---|
[11747] | 25 | If you want to use single file output you will need to compile the HDF & NetCDF libraries to |
---|
| 26 | allow parallel IO. |
---|
| 27 | 2. Download the version of XIOS that you wish to use. |
---|
| 28 | The recommended version is now XIOS 2.5: |
---|
[11734] | 29 | |
---|
[11747] | 30 | .. code-block:: console |
---|
[10201] | 31 | |
---|
[11747] | 32 | $ svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 |
---|
[10201] | 33 | |
---|
[11747] | 34 | and follow the instructions in :xios:`XIOS documentation <wiki/documentation>` to compile it. |
---|
| 35 | If you find problems at this stage, support can be found by subscribing to |
---|
| 36 | the :xios:`XIOS mailing list <../mailman/listinfo.cgi/xios-users>` and sending a mail message to it. |
---|
[10201] | 37 | |
---|
[10562] | 38 | XIOS Configuration files |
---|
| 39 | ------------------------ |
---|
[10201] | 40 | |
---|
[11747] | 41 | XIOS is controlled using XML input files that should be copied to |
---|
| 42 | your model run directory before running the model. |
---|
| 43 | Examples of these files can be found in the reference configurations (:file:`./cfgs`). |
---|
| 44 | The XIOS executable expects to find a file called :file:`iodef.xml` in the model run directory. |
---|
| 45 | In NEMO we have made the decision to use include statements in the :file:`iodef.xml` file to include: |
---|
[10201] | 46 | |
---|
[11747] | 47 | - :file:`field_def_nemo-oce.xml` (for physics), |
---|
| 48 | - :file:`field_def_nemo-ice.xml` (for ice), |
---|
| 49 | - :file:`field_def_nemo-pisces.xml` (for biogeochemistry) and |
---|
| 50 | - :file:`domain_def.xml` from the :file:`./cfgs/SHARED` directory. |
---|
| 51 | |
---|
| 52 | Most users will not need to modify :file:`domain_def.xml` or :file:`field_def_nemo-???.xml` unless |
---|
| 53 | they want to add new diagnostics to the NEMO code. |
---|
| 54 | The definition of the output files is organized into separate :file:`file_definition.xml` files which |
---|
| 55 | are included in the :file:`iodef.xml` file. |
---|
| 56 | |
---|
[10201] | 57 | Modes |
---|
[11747] | 58 | ===== |
---|
[10201] | 59 | |
---|
| 60 | Detached Mode |
---|
| 61 | ------------- |
---|
| 62 | |
---|
| 63 | In detached mode the XIOS executable is executed on separate cores from the NEMO model. |
---|
| 64 | This is the recommended method for using XIOS for realistic model runs. |
---|
[11747] | 65 | To use this mode set ``using_server`` to ``true`` at the bottom of the :file:`iodef.xml` file: |
---|
[10201] | 66 | |
---|
| 67 | .. code-block:: xml |
---|
| 68 | |
---|
[11747] | 69 | <variable id="using_server" type="boolean">true</variable> |
---|
[10201] | 70 | |
---|
[11747] | 71 | Make sure there is a copy (or link to) your XIOS executable in the working directory and |
---|
| 72 | in your job submission script allocate processors to XIOS. |
---|
[10201] | 73 | |
---|
| 74 | Attached Mode |
---|
| 75 | ------------- |
---|
| 76 | |
---|
| 77 | In attached mode XIOS runs on each of the cores used by NEMO. |
---|
[11747] | 78 | This method is less efficient than the detached mode but can be more convenient for testing or |
---|
| 79 | with small configurations. |
---|
| 80 | To activate this mode simply set ``using_server`` to false in the :file:`iodef.xml` file |
---|
[10201] | 81 | |
---|
| 82 | .. code-block:: xml |
---|
| 83 | |
---|
[11747] | 84 | <variable id="using_server" type="boolean">false</variable> |
---|
[10201] | 85 | |
---|
| 86 | and don't allocate any cores to XIOS. |
---|
| 87 | |
---|
[11747] | 88 | .. note:: |
---|
| 89 | |
---|
| 90 | Due to the different domain decompositions between XIOS and NEMO, |
---|
| 91 | if the total number of cores is larger than the number of grid points in the ``j`` direction then |
---|
| 92 | the model run will fail. |
---|
| 93 | |
---|
[10279] | 94 | Adding new diagnostics |
---|
[11747] | 95 | ====================== |
---|
[10201] | 96 | |
---|
| 97 | If you want to add a NEMO diagnostic to the NEMO code you will need to do the following: |
---|
| 98 | |
---|
| 99 | 1. Add any necessary code to calculate you new diagnostic in NEMO |
---|
[11747] | 100 | 2. Send the field to XIOS using ``CALL iom_put( 'field_id', variable )`` where |
---|
| 101 | ``field_id`` is a unique id for your new diagnostics and |
---|
| 102 | variable is the fortran variable containing the data. |
---|
| 103 | This should be called at every model timestep regardless of how often you want to output the field. |
---|
| 104 | No time averaging should be done in the model code. |
---|
| 105 | 3. If it is computationally expensive to calculate your new diagnostic |
---|
| 106 | you should also use "iom_use" to determine if it is requested in the current model run. |
---|
| 107 | For example, |
---|
[11734] | 108 | |
---|
[11747] | 109 | .. code-block:: fortran |
---|
[10201] | 110 | |
---|
[11747] | 111 | IF iom_use('field_id') THEN |
---|
| 112 | !Some expensive computation |
---|
| 113 | !... |
---|
| 114 | !... |
---|
| 115 | iom_put('field_id', variable) |
---|
| 116 | ENDIF |
---|
[10201] | 117 | |
---|
[11747] | 118 | 4. Add a variable definition to the :file:`field_def_nemo-???.xml` file. |
---|
| 119 | 5. Add the variable to the :file:`iodef.xml` or :file:`file_definition.xml` file. |
---|