Source code for pycif.plugins.models.chimere.io.inputs.params

[docs] def make_nml(self, runsubdir, sdc, mode, ddi): """Write the Fortran namelist ``chimere.nml`` for one sub-simulation period. Generates the ``&args`` namelist that controls the CHIMERE executable. All domain dimensions, chemical scheme paths, I/O file paths, physics switches, and run mode flags are written from the plugin's attributes. The output file is ``{runsubdir}/chimere.nml``. Mode flags written: ``fwd``, ``tl``, ``ad`` (only one is set to 1). Key physics switches (sourced from plugin attributes): ``usechemistry``, ``usedepos``, ``useemissions``, ``usetransmix``, ``usewetdepos``, ``useabsclipconc``, ``optemisb``. Args: self: CHIMERE model plugin instance with all required domain, chemistry, and configuration attributes set. runsubdir (str): path to the period run directory. sdc (str): period start date formatted as ``'%Y%m%d%H'``. mode (str): ``'fwd'``, ``'tl'``, or ``'adj'``. ddi (datetime): period start datetime (used to look up ``self.chain`` for the adjoint initial-condition flag ``iopainit``). """ # Default values nvegtype = getattr(self, "nvegtype", 16) # Fills in chimere.nml domain = self.domain chemistry = self.chemistry dirchem = chemistry.dirchem_ref schemeid = chemistry.schemeid nho = self.nho # NML string to write with open(f"{runsubdir}/chimere.nml", "w") as f: f.write("&args\n") f.write(f"version = '{mode}'\n") f.write(f"domain = '{domain.domid}'\n") f.write(f"nphour_ref = {self.nphour_ref}\n") f.write(f"ichemstep = {self.ichemstep}\n") f.write(f"nzonal_domain = {domain.nlon}\n") f.write(f"nmerid_domain = {domain.nlat}\n") f.write(f"nvert_raw = {domain.nlev}\n") f.write(f"nlevemis = {self.nlevemis}\n") f.write(f"nspec = {chemistry.nacspecies}\n") f.write(f"nemisa= {chemistry.nemisspec}\n") f.write(f"nemisb= {chemistry.nemisspec_interp}\n") f.write(f"ndep= {chemistry.ndepspecies}\n") f.write(f"nreac= {chemistry.nreacs}\n") f.write(f"nfam = {chemistry.nfamilies}\n") f.write(f"nspresc = {4}\n") f.write(f"nreactamax = {chemistry.nreactamax}\n") f.write(f"ntemps = {chemistry.ntemps}\n") f.write(f"ntabmax = {chemistry.ntabmax}\n") f.write(f"nlevphotmax = {chemistry.nlevphotmax}\n") f.write(f"ntabuzenmax = {chemistry.ntabuzenmax}\n") f.write(f"nphotmax = {chemistry.nphotmax}\n") f.write(f"ivsurf = {domain.emissublayer + 1}\n") f.write(f"ideepconv = {self.ideepconv}\n") f.write(f"idatestart = {sdc}\n") f.write(f"nhourrun = {nho}\n") f.write(f"nzdoms = {self.nzdoms}\n") f.write(f"nmdoms = {self.nmdoms}\n") f.write(f"fninit = '{runsubdir}/INI_CONCS.0.nc'\n") f.write(f"fnoutspec = '{dirchem}/OUTPUT_SPECIES.{schemeid}'\n") f.write(f"fnspec = '{dirchem}/ACTIVE_SPECIES.{schemeid}'\n") f.write(f"fnchem = '{dirchem}/CHEMISTRY.{schemeid}'\n") f.write(f"fnstoi = '{dirchem}/STOICHIOMETRY.{schemeid}'\n") f.write(f"fnrates = '{dirchem}/REACTION_RATES.{schemeid}'\n") f.write(f"fnfamilies = '{dirchem}/FAMILIES.{schemeid}'\n") f.write(f"fnphot = '{dirchem}/PHOTO_PARAMETERS.{schemeid}'\n") f.write(f"fnanthro = '{dirchem}/ANTHROPIC.{schemeid}'\n") f.write(f"fnbiogen = '{dirchem}/BIOGENIC.{schemeid}'\n") f.write(f"fnemisa = '{runsubdir}/AEMISSIONS.nc'\n") f.write(f"fnemisb = '{runsubdir}/BEMISSIONS.nc'\n") f.write(f"fnbounconc = '{runsubdir}/BOUN_CONCS.nc'\n") f.write(f"fnmeteo = '{runsubdir}/METEO.nc'\n") f.write(f"fndepoespe = '{dirchem}/DEPO_SPEC.{schemeid}'\n") f.write(f"fndepopars = '{dirchem}/DEPO_PARS.{schemeid}'\n") f.write(f"fnwetd = '{dirchem}/WETD_SPEC.{schemeid}'\n") f.write(f"fnlanduse = '{domain.repgrid}/LANDUSE/LANDUSE_{domain.domid}'\n") f.write(f"fnout = '{runsubdir}/out.nc'\n") f.write(f"fnothers = '{runsubdir}/par.nc'\n") f.write(f"fnconcs = '{runsubdir}/{'a' if mode == 'adj' else ''}end.nc'\n") f.write(f"fndepos = '{runsubdir}/dep.nc'\n") f.write(f"fniCOOcorn = '{domain.corners}'\n") f.write(f"usechemistry = {self.usechemistry}\n") f.write(f"usedepos = {self.usedepos}\n") f.write(f"useemissions = {self.useemissions}\n") f.write(f"usetransmix = {self.usetransmix}\n") f.write(f"usewetdepos = {self.usewetdepos}\n") f.write(f"useabsclipconc = {self.useabsclipconc}\n") f.write(f"nvegtype = {self.nvegtype}\n") f.write(f"nlduse = {self.nlduse}\n") f.write(f"nparammax = {self.nparammax}\n") f.write(f"clipconc = {self.clipconc}\n") f.write(f"ntyperate = {self.ntyperate}\n") f.write(f"ihoursu = {self.ihoursu}\n") f.write(f"nivout = {self.nivout}\n") f.write(f"nsaveconcs = {self.nsaveconcs}\n") f.write(f"nsavedepos = {self.nsavedepos}\n") f.write(f"optemisb = {1 if self.useemisb else 0}\n") f.write(f"nitgs = {self.nitgs}\n") f.write(f"nitgssu = {self.nitgssu}\n") f.write(f"fnemisaincr = '{runsubdir}/AEMISSIONS.increment.nc'\n") f.write(f"fnemisbincr = '{runsubdir}/BEMISSIONS.increment.nc'\n") f.write(f"fnbounconcincr = '{runsubdir}/BOUN_CONCS.increment.nc'\n") f.write(f"fninitincr = '{runsubdir}/INI_CONCS.0.increment.nc'\n") f.write(f"fnmetincr = '{runsubdir}/METEO.increment.nc'\n") f.write(f"afnout = '{runsubdir}/aout.'\n") ainit = 1 if (mode == "adj" and self.chain[ddi]) else 0 f.write(f"iopainit = {ainit}\n") netcdfoutput = 1 if self.dumpncoutput else 0 f.write(f"NetCDF_output = {netcdfoutput}\n") netcdfpar = 1 if self.dumpncpar else 0 f.write(f"NetCDF_parout = {netcdfpar}\n") netcdf_outtype = 1 if self.dumpnctype == "double" else 0 f.write(f"NetCDF_outtype = {netcdf_outtype}\n") f.write(f"NetCDF_type = {1 if self.nc4type else 0}\n") f.write(f"fwd = {1 if mode == 'fwd' else 0}\n") f.write(f"tl = {1 if mode == 'tl' else 0}\n") f.write(f"ad = {1 if mode == 'adj' else 0}\n") # hpulse for response functions f.write(f"hpulse = {self.hpulse}\n") f.write(f"ignore_chck_dates = {1 if self.ignore_input_dates else 0}\n") f.write(f"useRAMonly = {1 if self.useRAMonly else 0}\n") f.write("/\n")