Source code for pycif.plugins.transforms.system.run_model.forward
[docs]
def forward(
transform,
datastore,
controlvect,
obsvect,
mapper,
di,
df,
mode,
runsubdir,
workdir,
do_simu=True,
onlyinit=False,
approx_transf=False,
overlap=False,
ref_fwd_dir="",
**kwargs
):
"""Execute the transport model for one sub-simulation period.
Calls ``model.make_auxiliary`` to generate auxiliary input files
(e.g. meteorology, boundary conditions) and then ``model.run`` to
execute the model executable.
After a successful run, ``transform.model.adj_refdir`` is updated to
point to the run sub-directory so that subsequent adjoint runs can
locate the corresponding forward outputs.
Args:
transform (Plugin): run_model instance (carries the ``model``
sub-plugin).
datastore (dict): mutable datastore passed to ``model.run``.
controlvect: unused.
obsvect: unused.
mapper (dict): transform mapper (unused directly; passed to
``model.make_auxiliary``).
di (datetime): sub-simulation start date.
df (datetime): sub-simulation end date.
mode (str): ``'fwd'`` or ``'tl'``.
runsubdir (str): sub-simulation run directory.
workdir (str): root working directory.
do_simu (bool): if ``False``, skip the actual model execution
(dry-run; auxiliary files are still prepared).
onlyinit (bool): if ``True``, prepare auxiliary files only and
do not run the model.
approx_transf (bool): passed to ``model.run`` for the approximate
operator (parallel mode).
overlap (bool): passed to ``model.run`` for overlap handling.
ref_fwd_dir (str): path to a reference forward run; passed to
``model.run``.
**kwargs: forwarded to ``model.make_auxiliary`` and ``model.run``.
"""
ddi = min(di, df)
# First produce auxiliary data
transform.model.make_auxiliary(
ddi, runsubdir,
onlyinit=onlyinit, do_simu=do_simu, mode=mode,
**kwargs
)
# Now run the model itself
transform.model.run(runsubdir, mode, workdir, min(di, df),
do_simu=do_simu and not onlyinit, approx_transf=approx_transf,
overlap=overlap,
ref_fwd_dir=ref_fwd_dir, datastore = datastore, **kwargs)
if not onlyinit:
# Update model adj_refdir
transform.model.adj_refdir = f"{runsubdir}/../"