Source code for pycif.plugins.models.chimere.flushrun

from glob import glob

from ....utils import path


[docs] def flushrun(self, rundir, mode, transform_id, full_flush=True): """Cleaning the simulation directories to limit space usage""" list_subdirs = glob(f"{rundir}/*/") # Removing big files in CHIMERE directories for subdir in list_subdirs: flush_rundir(subdir, mode, final=True, full_flush=full_flush)
[docs] def flush_rundir(runsubdir, mode, final=False, full_flush=True): """Remove large temporary CHIMERE files from one sub-simulation directory. Deletes the bulky input/output NetCDF files that are no longer needed once a sub-simulation period has completed (or once the full run is done). Files always removed: ``AEMISSIONS``, ``BEMISSIONS``, ``BOUN_CONCS``, ``INI_CONCS``, ``METEO``, ``chimere.nml``, deposition, end, output files. Additionally for **adjoint** runs: ``.txt`` files. Additionally when ``final=True``: ``aout``, ``aini``, ``aend`` files. Additionally when ``full_flush=True``: ``end.*.nc`` concentration restart files. Args: runsubdir (str): path to the sub-simulation directory to clean. mode (str): execution mode (``'fwd'``, ``'tl'``, or ``'adj'``). final (bool): if ``True``, also remove ``aout``, ``aini``, ``aend`` files (called at end of full run, not between chained periods). full_flush (bool): if ``True``, also remove ``end.*.nc`` restart files (disables period chaining restart capability). """ path.remove(f"{runsubdir}/AEMISSIONS.*nc") path.remove(f"{runsubdir}/BEMISSIONS.*nc") path.remove(f"{runsubdir}/BOUN_CONCS.*nc") path.remove(f"{runsubdir}/INI_CONCS.0.*nc") path.remove(f"{runsubdir}/METEO.nc") path.remove(f"{runsubdir}/par.nc") path.remove(f"{runsubdir}/dep.nc") path.remove(f"{runsubdir}/end.nc") path.remove(f"{runsubdir}/out.nc") path.remove(f"{runsubdir}/TMPconc*") path.remove(f"{runsubdir}/obs.txt") if mode == "adj": path.remove(f"{runsubdir}/*.txt") if not final: return path.remove(f"{runsubdir}/aout.*.nc") path.remove(f"{runsubdir}/aini.nc") path.remove(f"{runsubdir}/*.txt") path.remove(f"{runsubdir}/aend.*.nc") if mode == "adj" and full_flush: path.remove(f"{runsubdir}/end.*.nc")