Source code for pycif.plugins.models.chimere_acc.io.inputs.make_auxiliary
from ......utils import path
from .params import make_nml
from ......utils.check.errclass import CifError
[docs]
def make_auxiliary(self, ddi, runsubdir,
onlyinit=False, do_simu=True, mode="fwd",
**kwargs):
"""Set up the CHIMERE-ACC (OpenACC GPU) executable and namelist for one sub-period.
Mirrors ``chimere/io/inputs/make_auxiliary.py``: symlinks the correct
CHIMERE-ACC binary and writes ``chimere.nml`` via :func:`make_nml`.
Returns immediately when ``do_simu=False`` or ``onlyinit=True``.
Args:
self: CHIMERE-ACC model plugin instance with ``workdir`` set.
ddi (datetime): sub-simulation period start.
runsubdir (str): path to the period run directory.
onlyinit (bool): skip if ``True``.
do_simu (bool): skip if ``False``.
mode (str): ``'fwd'``, ``'tl'``, or ``'adj'``.
**kwargs: unused.
"""
sdc = ddi.strftime("%Y%m%d%H")
# If mode is "fwd" or "tl" but onlyinit is True,
# it means that we are initializing an adjoint by running backward
# the adjoint pipeline
if mode in ["tl", "fwd"] and onlyinit:
mode = "adj"
if not do_simu:
return
# Choose the right executable
if mode == "fwd":
source = "fwdchimere.e"
elif mode == "tl":
source = "tlchimere.e"
elif mode == "adj":
source = "achimere.e"
else:
raise CifError(
f"Unknown mode '{mode}' for executable with CHIMERE"
)
path.link(
f"{self.workdir}/model/{source}",
f"{runsubdir}/chimere.e",
)
# Deals with the nml file
make_nml(self, runsubdir, sdc, mode, ddi)