Skip to content

Commit

Permalink
Update CDEPS (#50)
Browse files Browse the repository at this point in the history
Update NOAA-EMC/CDEPS to include changes from ESCOMP/CDEPS.
  • Loading branch information
uturuncoglu authored Oct 27, 2022
1 parent edaef5b commit 530c262
Show file tree
Hide file tree
Showing 23 changed files with 664 additions and 128 deletions.
7 changes: 5 additions & 2 deletions datm/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ module cdeps_datm_comp
character(CL) :: factorFn_data = 'null' ! file containing correction factors data
logical :: flds_presaero = .false. ! true => send valid prescribed aero fields to mediator
logical :: flds_presndep = .false. ! true => send valid prescribed ndep fields to mediator
logical :: flds_preso3 = .false. ! true => send valid prescribed ozone fields to mediator
logical :: flds_co2 = .false. ! true => send prescribed co2 to mediator
logical :: flds_wiso = .false. ! true => send water isotopes to mediator
character(CL) :: bias_correct = nullstr ! send bias correction fields to coupler
Expand Down Expand Up @@ -236,7 +237,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
model_meshfile, model_maskfile, &
nx_global, ny_global, restfilm, iradsw, factorFn_data, factorFn_mesh, &
flds_presaero, flds_co2, flds_wiso, bias_correct, anomaly_forcing, &
skip_restart_read, flds_presndep
skip_restart_read, flds_presndep, flds_preso3

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -276,6 +277,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(restfilm , mpicom, 'restfilm')
call shr_mpi_bcast(flds_presaero , mpicom, 'flds_presaero')
call shr_mpi_bcast(flds_presndep , mpicom, 'flds_presndep')
call shr_mpi_bcast(flds_preso3 , mpicom, 'flds_preso3')
call shr_mpi_bcast(flds_co2 , mpicom, 'flds_co2')
call shr_mpi_bcast(flds_wiso , mpicom, 'flds_wiso')
call shr_mpi_bcast(skip_restart_read , mpicom, 'skip_restart_read')
Expand All @@ -294,6 +296,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
write(logunit,F00)' factorFn_mesh = ',trim(factorFn_mesh)
write(logunit,F02)' flds_presaero = ',flds_presaero
write(logunit,F02)' flds_presndep = ',flds_presndep
write(logunit,F02)' flds_preso3 = ',flds_preso3
write(logunit,F02)' flds_co2 = ',flds_co2
write(logunit,F02)' flds_wiso = ',flds_wiso
write(logunit,F02)' skip_restart_read = ',skip_restart_read
Expand Down Expand Up @@ -326,7 +329,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case ('CLMNCEP')
call datm_datamode_clmncep_advertise(exportState, fldsExport, flds_scalar_name, &
flds_co2, flds_wiso, flds_presaero, flds_presndep, rc)
flds_co2, flds_wiso, flds_presaero, flds_presndep, flds_preso3, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case ('CPLHIST')
call datm_datamode_cplhist_advertise(exportState, fldsExport, flds_scalar_name, &
Expand Down
37 changes: 35 additions & 2 deletions datm/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _get_neon_data_availability(case, neonsite):
oldestdate = datetime.strptime(neonatm[-10:],"%Y-%m.nc")
neonatm = f'cdeps/{version}/{neonsite}/'+neonatm
datavaliddate.append(neonatm)
if newestdate:
if newestdate:
logger.info("Found tower data version {} for {} through {}".format(version, oldestdate, newestdate))
datavaliddate.sort()
return datavaliddate
Expand Down Expand Up @@ -105,6 +105,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
datm_topo = case.get_value("DATM_TOPO")
datm_presaero = case.get_value("DATM_PRESAERO")
datm_presndep = case.get_value("DATM_PRESNDEP")
datm_preso3 = case.get_value("DATM_PRESO3")
datm_co2_tseries = case.get_value("DATM_CO2_TSERIES")
atm_grid = case.get_value("ATM_GRID")
model_grid = case.get_value("GRID")
Expand All @@ -116,6 +117,8 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
"A DATM_MODE for CLM is incompatible with DATM_PRESAERO=none.")
expect(datm_presndep != "none",
"A DATM_MODE for CLM is incompatible with DATM_PRESNDEP=none.")
expect(datm_preso3 != "none",
"A DATM_MODE for CLM is incompatible with DATM_PRESO3=none.")
expect(datm_topo != "none",
"A DATM_MODE for CLM is incompatible with DATM_TOPO=none.")

Expand All @@ -124,6 +127,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
logger.debug("DATM grid is {}".format(atm_grid))
logger.debug("DATM presaero mode is {}".format(datm_presaero))
logger.debug("DATM presndep mode is {}".format(datm_presndep))
logger.debug("DATM preso3 mode is {}".format(datm_preso3))
logger.debug("DATM topo mode is {}".format(datm_topo))

# Initialize namelist defaults
Expand All @@ -143,6 +147,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
config['datm_co2_tseries'] = datm_co2_tseries
config['datm_presaero'] = datm_presaero
config['datm_presndep'] = datm_presndep
config['datm_preso3'] = datm_preso3

if case.get_value('PTS_LON'):
scol_lon = float(case.get_value('PTS_LON'))
Expand Down Expand Up @@ -173,10 +178,13 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
streamlist.append("presaero.{}".format(datm_presaero))
if datm_presndep != "none":
streamlist.append("presndep.{}".format(datm_presndep))
if datm_preso3 != "none":
streamlist.append("preso3.{}".format(datm_preso3))
if datm_topo != "none":
streamlist.append("topo.{}".format(datm_topo))
if datm_co2_tseries != "none":
streamlist.append("co2tseries.{}".format(datm_co2_tseries))

bias_correct = nmlgen.get_value("bias_correct")
if bias_correct is not None:
streamlist.append(bias_correct)
Expand All @@ -189,10 +197,33 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
schema_file = os.path.join(_CDEPS_CONFIG,"stream_definition_v2.0.xsd")
stream_file = os.path.join(_CDEPS_CONFIG,os.pardir, "datm","cime_config","stream_definition_datm.xml")
streams = StreamCDEPS(stream_file, schema_file)
streams.create_stream_xml(streamlist, case, outfile, data_list_path,
streams.create_stream_xml(streamlist, case, outfile, data_list_path,
os.path.join(caseroot,'user_nl_datm_streams'+inst_string),
available_neon_data=available_neon_data)


####################################################################################
def _create_drv_flds_in(case, confdir):
####################################################################################
datm_preso3 = case.get_value("DATM_PRESO3")

# for now we are hard-coding this file name and values because we only need it for ozone
if datm_preso3 != "none":

# Generate drv_flds_in file
outfile = os.path.join(confdir, "drv_flds_in")
ozone_nl_name = "&ozone_coupling_nl"
ozone_freq_par = "atm_ozone_frequency"
ozone_freq_val = "'multiday_average'"
nl_fin = "/"

with open(outfile, "w") as drv_fl:
drv_fl.write("{}\n".format(ozone_nl_name))
drv_fl.write(" {} = {}\n".format(ozone_freq_par, ozone_freq_val))
drv_fl.write("{}\n".format(nl_fin))



###############################################################################
def buildnml(case, caseroot, compname):
###############################################################################
Expand Down Expand Up @@ -267,6 +298,8 @@ def buildnml(case, caseroot, compname):
# create namelist and stream file(s) data component
_create_namelists(case, confdir, inst_string, namelist_infile, nmlgen, data_list_path)

_create_drv_flds_in(case, confdir)

# copy namelist files and stream text files, to rundir
copy_inputs_to_rundir(caseroot, compname, confdir, rundir, inst_string)

Expand Down
24 changes: 23 additions & 1 deletion datm/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

<entry id="DATM_PRESNDEP">
<type>char</type>
<valid_values>none,clim_1850,clim_2000,clim_2010,hist,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP5-3.4,SSP5-8.5</valid_values>
<valid_values>none,clim_1850,clim_2000,clim_2010,hist,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP5-3.4,SSP5-8.5,cplhist</valid_values>
<default_value>clim_2000</default_value>
<values match="last">
<value compset="^1850_" >clim_1850</value>
Expand All @@ -112,6 +112,28 @@
<desc>DATM prescribed nitrogen deposition forcing</desc>
</entry>

<entry id="DATM_PRESO3">
<type>char</type>
<valid_values>none,clim_1850,clim_2000,clim_2010,hist,SSP2-4.5,SSP3-7.0,SSP5-8.5</valid_values>
<default_value>clim_2000</default_value>
<values match="last">
<value compset="^1850_" >clim_1850</value>
<value compset="^2000_" >clim_2000</value>
<value compset="^2010_" >clim_2010</value>
<value compset="^SSP245_" >SSP2-4.5</value>
<value compset="^SSP370_" >SSP3-7.0</value>
<value compset="^SSP585_" >SSP5-8.5</value>
<value compset="^HIST_" >hist</value>
<value compset="^20TR_" >hist</value>
<!-- Only needed for compsets with active land; only in DATM CLMNCEP mode -->
<value compset="_SLND">none</value>
<value compset="_DLND">none</value>
</values>
<group>run_component_datm</group>
<file>env_run.xml</file>
<desc>DATM prescribed ozone forcing</desc>
</entry>

<entry id="DATM_TOPO">
<type>char</type>
<valid_values>none,observed,cplhist</valid_values>
Expand Down
13 changes: 13 additions & 0 deletions datm/cime_config/namelist_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,19 @@
</values>
</entry>

<entry id="flds_preso3">
<type>logical</type>
<category>datm</category>
<group>datm_nml</group>
<desc>
If true, prescribed o3 is sent from datm (must be true for running with CLM).
</desc>
<values>
<value>.true.</value>
<value datm_preso3="none">.false.</value>
</values>
</entry>

<entry id="flds_co2">
<type>logical</type>
<category>datm</category>
Expand Down
Loading

0 comments on commit 530c262

Please sign in to comment.