[10604] | 1 | ******************* |
---|
| 2 | Build the framework |
---|
| 3 | ******************* |
---|
[9596] | 4 | |
---|
[11734] | 5 | .. todo:: |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | |
---|
[10279] | 9 | .. contents:: |
---|
[10604] | 10 | :local: |
---|
| 11 | |
---|
[10557] | 12 | Prerequisites |
---|
| 13 | ============= |
---|
[9596] | 14 | |
---|
[10604] | 15 | | The NEMO source code is written in *Fortran 95* and |
---|
[11723] | 16 | some of its prerequisite tools and libraries are already included in the download. |
---|
[10604] | 17 | | It contains the AGRIF_ preprocessing program ``conv``; the FCM_ build system and |
---|
| 18 | the IOIPSL_ library for parts of the output. |
---|
[10596] | 19 | |
---|
[10604] | 20 | System dependencies |
---|
| 21 | ------------------- |
---|
[9596] | 22 | |
---|
[10604] | 23 | In the first place the other requirements should be provided natively by your system or |
---|
| 24 | can be installed from the official repositories of your Unix-like distribution: |
---|
[9596] | 25 | |
---|
[10604] | 26 | - *Perl* interpreter |
---|
| 27 | - *Fortran* compiler (``ifort``, ``gfortran``, ``pgfortran``, ...), |
---|
| 28 | - *Message Passing Interface (MPI)* implementation (e.g. |OpenMPI|_ or |MPICH|_). |
---|
[11708] | 29 | - |NetCDF|_ library with its underlying |HDF|_ |
---|
[9596] | 30 | |
---|
[10604] | 31 | **NEMO, by default, takes advantage of some MPI features introduced into the MPI-3 standard.** |
---|
[10187] | 32 | |
---|
[10604] | 33 | .. hint:: |
---|
[10187] | 34 | |
---|
[10604] | 35 | The MPI implementation is not strictly essential |
---|
| 36 | since it is possible to compile and run NEMO on a single processor. |
---|
| 37 | However most realistic configurations will require the parallel capabilities of NEMO and |
---|
| 38 | these use the MPI standard. |
---|
| 39 | |
---|
| 40 | .. note:: |
---|
| 41 | |
---|
| 42 | On older systems, that do not support MPI-3 features, |
---|
| 43 | the ``key_mpi2`` preprocessor key should be used at compile time. |
---|
| 44 | This will limit MPI features to those defined within the MPI-2 standard |
---|
| 45 | (but will lose some performance benefits). |
---|
| 46 | |
---|
[11723] | 47 | .. |OpenMPI| replace:: *OpenMPI* |
---|
| 48 | .. _OpenMPI: https://www.open-mpi.org |
---|
| 49 | .. |MPICH| replace:: *MPICH* |
---|
| 50 | .. _MPICH: https://www.mpich.org |
---|
| 51 | .. |NetCDF| replace:: *Network Common Data Form (NetCDF)* |
---|
| 52 | .. _NetCDF: https://www.unidata.ucar.edu |
---|
| 53 | .. |HDF| replace:: *Hierarchical Data Form (HDF)* |
---|
| 54 | .. _HDF: https://www.hdfgroup.org |
---|
| 55 | |
---|
[10604] | 56 | Specifics for NetCDF and HDF |
---|
| 57 | ---------------------------- |
---|
| 58 | |
---|
[11723] | 59 | NetCDF and HDF versions from official repositories may have not been compiled with MPI support. |
---|
[10604] | 60 | However access to all the options available with the XIOS IO-server will require |
---|
[11723] | 61 | the parallelism of these libraries. |
---|
[10604] | 62 | |
---|
| 63 | | **To satisfy these requirements, it is common to have to compile from source |
---|
| 64 | in this order HDF (C library) then NetCDF (C and Fortran libraries)** |
---|
| 65 | | It is also necessary to compile these libraries with the same version of the MPI implementation that |
---|
[11723] | 66 | both NEMO and XIOS (see below) have been compiled and linked with. |
---|
[10604] | 67 | |
---|
| 68 | .. hint:: |
---|
| 69 | |
---|
| 70 | | It is difficult to define the options for the compilation as |
---|
| 71 | they differ from one architecture to another according to |
---|
| 72 | the hardware used and the software installed. |
---|
| 73 | | The following is provided without any warranty |
---|
| 74 | |
---|
| 75 | .. code-block:: console |
---|
| 76 | |
---|
| 77 | $ ./configure [--{enable-fortran,disable-shared,enable-parallel}] ... |
---|
| 78 | |
---|
| 79 | It is recommended to build the tests ``--enable-parallel-tests`` and run them with ``make check`` |
---|
| 80 | |
---|
| 81 | Particular versions of these libraries may have their own restrictions. |
---|
| 82 | State the following requirements for netCDF-4 support: |
---|
| 83 | |
---|
| 84 | .. caution:: |
---|
| 85 | |
---|
| 86 | | When building NetCDF-C library versions older than 4.4.1, use only HDF5 1.8.x versions. |
---|
| 87 | | Combining older NetCDF-C versions with newer HDF5 1.10 versions will create superblock 3 files |
---|
| 88 | that are not readable by lots of older software. |
---|
[11708] | 89 | |
---|
[10557] | 90 | Extract and install XIOS |
---|
| 91 | ======================== |
---|
| 92 | |
---|
[10604] | 93 | With the sole exception of running NEMO in mono-processor mode |
---|
| 94 | (in which case output options are limited to those supported by the ``IOIPSL`` library), |
---|
| 95 | diagnostic outputs from NEMO are handled by the third party ``XIOS`` library. |
---|
[11723] | 96 | It can be used in two different modes: |
---|
[10557] | 97 | |
---|
[11723] | 98 | :*attached*: Every NEMO process also acts as a XIOS server |
---|
| 99 | :*detached*: Every NEMO process runs as a XIOS client. |
---|
[10604] | 100 | Output is collected and collated by external, stand-alone XIOS server processors. |
---|
[10557] | 101 | |
---|
[11723] | 102 | Instructions on how to install XIOS can be found on its :xios:`wiki<>`. |
---|
[10557] | 103 | |
---|
[10604] | 104 | .. hint:: |
---|
[9596] | 105 | |
---|
[11723] | 106 | It is recommended to use XIOS 2.5 release. |
---|
[10604] | 107 | This version should be more stable (in terms of future code changes) than the XIOS trunk. |
---|
[11723] | 108 | It is also the one used by the NEMO system team when testing all developments and new releases. |
---|
[11708] | 109 | |
---|
[11723] | 110 | This particular version has its own branch and can be checked out with: |
---|
[10557] | 111 | |
---|
[10604] | 112 | .. code:: console |
---|
| 113 | |
---|
[10991] | 114 | $ svn co https://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 |
---|
[10604] | 115 | |
---|
[11723] | 116 | Download and install the NEMO code |
---|
| 117 | ================================== |
---|
[10557] | 118 | |
---|
[11723] | 119 | Checkout the NEMO sources |
---|
| 120 | ------------------------- |
---|
| 121 | |
---|
[10557] | 122 | .. code:: console |
---|
| 123 | |
---|
[13688] | 124 | $ svn co https://forge.ipsl.jussieu.fr/nemo/svn/NEMO/releases/r4.0/r4.0.4 |
---|
[9596] | 125 | |
---|
[11723] | 126 | Description of 1\ :sup:`st` level tree structure |
---|
| 127 | ------------------------------------------------ |
---|
[9596] | 128 | |
---|
[11734] | 129 | +---------------+----------------------------------------+ |
---|
| 130 | | :file:`arch` | Compilation settings | |
---|
| 131 | +---------------+----------------------------------------+ |
---|
| 132 | | :file:`cfgs` | :doc:`Reference configurations <cfgs>` | |
---|
| 133 | +---------------+----------------------------------------+ |
---|
| 134 | | :file:`doc` | :doc:`Documentation <doc>` | |
---|
| 135 | +---------------+----------------------------------------+ |
---|
| 136 | | :file:`ext` | Dependencies included | |
---|
| 137 | | | (``AGRIF``, ``FCM`` & ``IOIPSL``) | |
---|
| 138 | +---------------+----------------------------------------+ |
---|
| 139 | | :file:`mk` | Compilation scripts | |
---|
| 140 | +---------------+----------------------------------------+ |
---|
| 141 | | :file:`src` | :doc:`Modelling routines <src>` | |
---|
| 142 | +---------------+----------------------------------------+ |
---|
| 143 | | :file:`tests` | :doc:`Test cases <tests>` | |
---|
| 144 | | | (unsupported) | |
---|
| 145 | +---------------+----------------------------------------+ |
---|
| 146 | | :file:`tools` | :doc:`Utilities <tools>` | |
---|
| 147 | | | to {pre,post}process data | |
---|
| 148 | +---------------+----------------------------------------+ |
---|
[9596] | 149 | |
---|
| 150 | Setup your architecture configuration file |
---|
[11723] | 151 | ------------------------------------------ |
---|
[9596] | 152 | |
---|
[11723] | 153 | All compiler options in NEMO are controlled using files in :file:`./arch/arch-'my_arch'.fcm` where |
---|
| 154 | ``my_arch`` is the name of the computing architecture |
---|
| 155 | (generally following the pattern ``HPCC-compiler`` or ``OS-compiler``). |
---|
| 156 | It is recommended to copy and rename an configuration file from an architecture similar to your owns. |
---|
| 157 | You will need to set appropriate values for all of the variables in the file. |
---|
| 158 | In particular the FCM variables: |
---|
| 159 | ``%NCDF_HOME``; ``%HDF5_HOME`` and ``%XIOS_HOME`` should be set to |
---|
| 160 | the installation directories used for XIOS installation |
---|
[9596] | 161 | |
---|
[10557] | 162 | .. code-block:: sh |
---|
[9596] | 163 | |
---|
[11723] | 164 | %NCDF_HOME /usr/local/path/to/netcdf |
---|
| 165 | %HDF5_HOME /usr/local/path/to/hdf5 |
---|
| 166 | %XIOS_HOME /home/$( whoami )/path/to/xios-2.5 |
---|
| 167 | %OASIS_HOME /home/$( whoami )/path/to/oasis |
---|
[10557] | 168 | |
---|
[11723] | 169 | Create and compile a new configuration |
---|
| 170 | ====================================== |
---|
[9596] | 171 | |
---|
[11734] | 172 | The main script to {re}compile and create executable is called :file:`makenemo` located at |
---|
[11723] | 173 | the root of the working copy. |
---|
| 174 | It is used to identify the routines you need from the source code, to build the makefile and run it. |
---|
| 175 | As an example, compile a :file:`MY_GYRE` configuration from GYRE with 'my_arch': |
---|
[9596] | 176 | |
---|
[10187] | 177 | .. code-block:: sh |
---|
[9596] | 178 | |
---|
[11723] | 179 | ./makenemo –m 'my_arch' –r GYRE -n 'MY_GYRE' |
---|
[10187] | 180 | |
---|
[11723] | 181 | Then at the end of the configuration compilation, |
---|
| 182 | :file:`MY_GYRE` directory will have the following structure. |
---|
[9596] | 183 | |
---|
[11723] | 184 | +------------+----------------------------------------------------------------------------+ |
---|
| 185 | | Directory | Purpose | |
---|
| 186 | +============+============================================================================+ |
---|
| 187 | | ``BLD`` | BuiLD folder: target executable, headers, libs, preprocessed routines, ... | |
---|
| 188 | +------------+----------------------------------------------------------------------------+ |
---|
| 189 | | ``EXP00`` | Run folder: link to executable, namelists, ``*.xml`` and IOs | |
---|
| 190 | +------------+----------------------------------------------------------------------------+ |
---|
| 191 | | ``EXPREF`` | Files under version control only for :doc:`official configurations <cfgs>` | |
---|
| 192 | +------------+----------------------------------------------------------------------------+ |
---|
| 193 | | ``MY_SRC`` | New routines or modified copies of NEMO sources | |
---|
| 194 | +------------+----------------------------------------------------------------------------+ |
---|
| 195 | | ``WORK`` | Links to all raw routines from :file:`./src` considered | |
---|
| 196 | +------------+----------------------------------------------------------------------------+ |
---|
[9596] | 197 | |
---|
[11734] | 198 | After successful execution of :file:`makenemo` command, |
---|
[11723] | 199 | the executable called `nemo` is available in the :file:`EXP00` directory |
---|
[9596] | 200 | |
---|
[11734] | 201 | More :file:`makenemo` options |
---|
| 202 | ----------------------------- |
---|
[10557] | 203 | |
---|
[10604] | 204 | ``makenemo`` has several other options that can control which source files are selected and |
---|
| 205 | the operation of the build process itself. |
---|
[9596] | 206 | |
---|
[11723] | 207 | .. literalinclude:: ../../../makenemo |
---|
| 208 | :language: text |
---|
| 209 | :lines: 119-143 |
---|
| 210 | :caption: Output of ``makenemo -h`` |
---|
[9596] | 211 | |
---|
[10604] | 212 | These options can be useful for maintaining several code versions with only minor differences but |
---|
| 213 | they should be used sparingly. |
---|
| 214 | Note however the ``-j`` option which should be used more routinely to speed up the build process. |
---|
| 215 | For example: |
---|
[10558] | 216 | |
---|
| 217 | .. code-block:: sh |
---|
| 218 | |
---|
| 219 | ./makenemo –m 'my_arch' –r GYRE -n 'MY_GYRE' -j 8 |
---|
| 220 | |
---|
[11723] | 221 | will compile up to 8 processes simultaneously. |
---|
[10558] | 222 | |
---|
[9596] | 223 | Default behaviour |
---|
[10187] | 224 | ----------------- |
---|
[9596] | 225 | |
---|
[11723] | 226 | At the first use, |
---|
| 227 | you need the ``-m`` option to specify the architecture configuration file |
---|
| 228 | (compiler and its options, routines and libraries to include), |
---|
| 229 | then for next compilation, it is assumed you will be using the same compiler. |
---|
| 230 | If the ``-n`` option is not specified the last compiled configuration will be used. |
---|
[9596] | 231 | |
---|
| 232 | Tools used during the process |
---|
[10187] | 233 | ----------------------------- |
---|
[9596] | 234 | |
---|
[11734] | 235 | * :file:`functions.sh`: bash functions used by ``makenemo``, for instance to create the WORK directory |
---|
| 236 | * :file:`cfg.txt` : text list of configurations and source directories |
---|
| 237 | * :file:`bld.cfg` : FCM rules for compilation |
---|
[9596] | 238 | |
---|
| 239 | Examples |
---|
[10187] | 240 | -------- |
---|
[9596] | 241 | |
---|
[11723] | 242 | .. literalinclude:: ../../../makenemo |
---|
| 243 | :language: text |
---|
| 244 | :lines: 146-153 |
---|
[10558] | 245 | |
---|
[9596] | 246 | Running the model |
---|
[10279] | 247 | ================= |
---|
[9596] | 248 | |
---|
[11734] | 249 | Once :file:`makenemo` has run successfully, |
---|
| 250 | the ``nemo`` executable is available in :file:`./cfgs/MY_CONFIG/EXP00`. |
---|
| 251 | For the reference configurations, the :file:`EXP00` folder also contains the initial input files |
---|
[11723] | 252 | (namelists, ``*.xml`` files for the IOs, ...). |
---|
| 253 | If the configuration needs other input files, they have to be placed here. |
---|
[9596] | 254 | |
---|
[10558] | 255 | .. code-block:: sh |
---|
[9596] | 256 | |
---|
[11723] | 257 | cd 'MY_CONFIG'/EXP00 |
---|
| 258 | mpirun -n $NPROCS ./nemo # $NPROCS is the number of processes |
---|
| 259 | # mpirun is your MPI wrapper |
---|
[10558] | 260 | |
---|
[9596] | 261 | Viewing and changing list of active CPP keys |
---|
[10279] | 262 | ============================================ |
---|
[9596] | 263 | |
---|
[11723] | 264 | For a given configuration (here called ``MY_CONFIG``), |
---|
| 265 | the list of active CPP keys can be found in :file:`./cfgs/'MYCONFIG'/cpp_MY_CONFIG.fcm` |
---|
[9596] | 266 | |
---|
[11734] | 267 | This text file can be edited by hand or with :file:`makenemo` to change the list of active CPP keys. |
---|
[11723] | 268 | Once changed, one needs to recompile ``nemo`` in order for this change to be taken in account. |
---|
[10558] | 269 | Note that most NEMO configurations will need to specify the following CPP keys: |
---|
[14239] | 270 | ``key_xios`` for IOs. MPI parallelism is activated by default. Use ``key_mpi_off`` to compile without MPI. |
---|