Source code for pycif.plugins.models.wrfchem.run

import os
import shutil
import logging
import subprocess
from .utilities import utilities

[docs] def run(self, runsubdir, mode, workdir, ddi, do_simu=True, **kwargs): """Run WRF Args: runsubdir (str): working directory for the current run mode (str): forward or backward workdir (str): pycif working directory do_simu (bool): if False, considers that the simulation was already run VERSION HISTORY 2021-08-19 Original code from online doc and from plugins/models/lmdz/run.py """ if not do_simu: # if mode != "adj": # # Keeps the running directory in memory for later adjoint simulations # self.adj_refdir = "{}/../".format(runsubdir) return # Run the model logfile = os.path.join(runsubdir, "wrf.log") with open(logfile, "w") as log: command = self.mpirun + " {}/wrf.exe".format(runsubdir) logging.info("Starting WRF. Command: '{}'".format(command)) logging.info("Commented for debugging") # process = subprocess.Popen( # command.split(), # cwd=runsubdir, # stdout=log, # stderr=subprocess.PIPE # ) # process.wait() # # # Check for errors # retcode = utilities.check_out_err(process) # if retcode != 0: # msg = "WRF returned errors. Check {}".format(runsubdir) # raise RuntimeError(msg) # Now move necessary files to the chain directory if self.domain.max_dom>1: raise NotImplementedError("Can't work with nested domains yet.") ddf = self.tstep_dates[ddi][-1] fn_in = ddf.strftime("wrfrst_d01_%Y-%m-%d_%H:%M:%S") fp_in = os.path.join(runsubdir, fn_in) shutil.move(fp_in, os.path.join(runsubdir, "..", "chain"))