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