Skip to content
Snippets Groups Projects
Commit 480068ca authored by Tomas Lovato's avatar Tomas Lovato
Browse files

move Coupling an external BGC model from misc to model_setup

parent f8b9a29b
No related branches found
No related tags found
No related merge requests found
......@@ -116,5 +116,93 @@ Two options for tracer concentrations in iceberg and ice shelf can be set with t
The depth until which Fe from melting iceberg is delivered can be set with the namelist parameter \textit{rn\_icbdep}. The value of 120 m is the average underwater depth of the different iceberg size classes modeled by the NEMO iceberg module, which was used to produce the freshwater flux climatology of icebergs.
\section{Coupling an external BGC model using NEMO framework}
The coupling with an external BGC model through the NEMO compilation framework can be achieved in different ways according to the degree of coding complexity of the Biogeochemical model, like e.g., the whole code is made only by one file or it has multiple modules and interfaces spread across several subfolders.\\ \\
Beside the 6 core files of MY\_TRC module, see (see \label{Mytrc}, let's assume an external BGC model named \textit{"MYBGC"} and constituted by a rather essential coding structure, likely few Fortran files. The new coupled configuration name is NEMO\_MYBGC. \\ \\
The best solution is to have all files (the modified MY\_TRC routines and the BGC model ones) placed in a unique folder with root \path{<MYBGCPATH>} and to use the \textit{makenemo} external readdressing of MY\_SRC folder. \\ \\
Before compiling the code it is necessary to create the new configuration folder
\begin{minted}{bash}
$[nemo-code-root]> mkdir cfgs/NEMO_MYBGC
\end{minted}
and add in it the configuration file cpp\_MYBGC.fcm whose content will be
\begin{minted}{bash}
bld::tool::fppkeys key_xios key_top
\end{minted}
The compilation with \textit{makenemo} will be executed through the following syntax, by including OCE and TOP components
\begin{minted}{bash}
$[nemo-code-root]> ./makenemo -r GYRE_PISCES -n NEMO_MYBGC -d "OCE TOP" -m <arch_my_machine> -j 8 -e <MYBGCPATH>
\end{minted}
The makenemo feature \textit{-e} was introduced to readdress at compilation time the standard MY\_SRC folder (usually found in NEMO configurations) with a user defined external one.
After the compilation, the coupled configuration will be listed in \textbf{work\_cfg.txt} and it will look like
\begin{minted}{bash}
NEMO_MYBGC OCE TOP
\end{minted}
The compilation of more articulated BGC model code \& infrastructure, like in the case of BFM \citep{bfm_nemo_coupling}, requires some additional features. \\
As before, let's assume a coupled configuration name NEMO\_MYBGC, but in this case MYBGC model root becomes <MYBGCPATH> that contains 4 different subfolders for biogeochemistry, named initialization, pelagic, and benthic, and a separate one named nemo\_coupling including the modified MY\_SRC routines. The latter folder containing the modified NEMO coupling interface will be still linked using the makenemo \textit{-e} option. \\
In order to include the BGC model subfolders in the compilation of NEMO code, it will be necessary to extend the configuration \textit{cpp\_NEMO\_MYBGC.fcm} file to include the specific paths of MYBGC folders, as in the following example
\begin{minted}{bash}
bld::tool::fppkeys key_xios key_top
src::MYBGC::initialization <MYBGCPATH>/initialization
src::MYBGC::pelagic <MYBGCPATH>/pelagic
src::MYBGC::benthic <MYBGCPATH>/benthic
bld::pp::MYBGC 1
bld::tool::fppflags::MYBGC \%FPPFLAGS
bld::tool::fppkeys \%bld::tool::fppkeys MYBGC_MACROS
\end{minted}
where MYBGC\_MACROS is the space delimited list of macros used in MYBGC model for selecting/excluding specific parts of the code. The BGC model code will be preprocessed in the configuration BLD folder as for NEMO, but with an independent path, like NEMO\_MYBGC/BLD/MYBGC/<subfolders>.\\
The compilation of more articulated BGC model code \& infrastructure, like in the case of BFM \citep{bfm_nemo_coupling}, requires some additional features. \\
As before, let's assume a coupled configuration name NEMO\_MYBGC, but in this case MYBGC model root becomes <MYBGCPATH> that contains 4 different subfolders for biogeochemistry, named initialization, pelagic, and benthic, and a separate one named nemo\_coupling including the modified MY\_SRC routines. The latter folder containing the modified NEMO coupling interface will be still linked using the makenemo \textit{-e} option. \\
In order to include the BGC model subfolders in the compilation of NEMO code, it will be necessary to extend the configuration \textit{cpp\_NEMO\_MYBGC.fcm} file to include the specific paths of MYBGC folders, as in the following example
\begin{minted}{bash}
bld::tool::fppkeys key_xios key_top
src::MYBGC::initialization <MYBGCPATH>/initialization
src::MYBGC::pelagic <MYBGCPATH>/pelagic
src::MYBGC::benthic <MYBGCPATH>/benthic
bld::pp::MYBGC 1
bld::tool::fppflags::MYBGC \%FPPFLAGS
bld::tool::fppkeys \%bld::tool::fppkeys MYBGC_MACROS
\end{minted}
where MYBGC\_MACROS is the space delimited list of macros used in MYBGC model for selecting/excluding specific parts of the code. The BGC model code will be preprocessed in the configuration BLD folder as for NEMO, but with an independent path, like NEMO\_MYBGC/BLD/MYBGC/<subfolders>.\\
The compilation will be performed similarly to in the previous case with the following
\begin{minted}{bash}
makenemo -r NEMO_MYBGC -m <arch_my_machine> -j 8 -e <MYBGCPATH>/nemo_coupling
\end{minted}
Note that, the additional lines specific for the BGC model source and build paths, can be written into a separate file, e.g. named MYBGC.fcm, and then simply included in the cpp\_NEMO\_MYBGC.fcm as follow:
\begin{minted}{bash}
bld::tool::fppkeys key_zdftke key_dynspg_ts key_xios key_top
inc <MYBGCPATH>/MYBGC.fcm
\end{minted}
This will enable a more portable compilation structure for all MYBGC related configurations.
Important: the coupling interface contained in nemo\_coupling cannot be added using the FCM syntax, as the same files already exists in NEMO and they are overridden only with the readdressing of MY\_SRC contents to avoid compilation conflicts due to duplicate routines.
All modifications illustrated above, can be easily implemented using shell or python scripting to edit the NEMO configuration cpp.fcm file and to create the BGC model specific FCM compilation file with code paths.
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment