Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addition nitrogen stream functionality to datm #158

Merged
merged 9 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions datm/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ module cdeps_datm_comp
integer :: iradsw = 0 ! radiation interval (input namelist)
character(CL) :: factorFn_mesh = 'null' ! file containing correction factors mesh
character(CL) :: factorFn_data = 'null' ! file containing correction factors data
logical :: flds_presaero = .false. ! true => send valid prescribe aero fields to mediator
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_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 @@ -229,7 +230,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
skip_restart_read, flds_presndep

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -268,6 +269,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(factorFn_mesh , mpicom, 'factorFn_mesh')
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_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 @@ -285,6 +287,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
write(logunit,F00)' factorFn_data = ',trim(factorFn_data)
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_co2 = ',flds_co2
write(logunit,F02)' flds_wiso = ',flds_wiso
write(logunit,F02)' skip_restart_read = ',skip_restart_read
Expand All @@ -308,19 +311,19 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
select case (trim(datamode))
case ('CORE2_NYF', 'CORE2_IAF')
call datm_datamode_core2_advertise(exportState, fldsExport, flds_scalar_name, &
flds_co2, flds_wiso, flds_presaero, rc)
flds_co2, flds_wiso, flds_presaero, flds_presndep, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case ('CORE_IAF_JRA')
call datm_datamode_jra_advertise(exportState, fldsExport, flds_scalar_name, &
flds_co2, flds_wiso, flds_presaero, rc)
flds_co2, flds_wiso, flds_presaero, flds_presndep, 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, rc)
flds_co2, flds_wiso, flds_presaero, flds_presndep, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case ('CPLHIST')
call datm_datamode_cplhist_advertise(exportState, fldsExport, flds_scalar_name, &
flds_co2, flds_wiso, flds_presaero, rc)
flds_co2, flds_wiso, flds_presaero, flds_presndep, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case ('ERA5')
call datm_datamode_era5_advertise(exportState, fldsExport, flds_scalar_name, rc)
Expand Down Expand Up @@ -491,7 +494,7 @@ subroutine ModelAdvance(gcomp, rc)

restart_write = dshr_check_restart_alarm(clock, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Run datm
call ESMF_TraceRegionEnter('datm_run')
call datm_comp_run(importstate, exportstate, next_ymd, next_tod, mon, &
Expand Down Expand Up @@ -705,6 +708,7 @@ subroutine datm_init_dfields(rc)

! local variables
integer :: n
character(CS) :: strm_flds2(2)
character(CS) :: strm_flds3(3)
character(CS) :: strm_flds4(4)
integer :: rank
Expand All @@ -731,6 +735,10 @@ subroutine datm_init_dfields(rc)
exportState, logunit, mainproc, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else if (rank == 2) then
! The following maps stream input fields to export fields that have an ungridded dimension
! TODO: in the future it might be better to change the format of the streams file to have two more entries
! that could denote how the stream variables are mapped to export fields that have an ungridded dimension

select case (trim(lfieldnames(n)))
case('Faxa_bcph')
strm_flds3 = (/'Faxa_bcphidry', 'Faxa_bcphodry', 'Faxa_bcphiwet'/)
Expand Down Expand Up @@ -764,6 +772,11 @@ subroutine datm_init_dfields(rc)
strm_flds3 = (/'Faxa_snowl_16O', 'Faxa_snowl_18O', 'Faxa_snowl_HDO'/)
call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('Faxa_ndep')
strm_flds2 = (/'Faxa_ndep_nhx', 'Faxa_ndep_noy'/)
call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds2, exportState, logunit, mainproc, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

end select
end if
end do
Expand Down
7 changes: 7 additions & 0 deletions datm/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
datm_mode = case.get_value("DATM_MODE")
datm_topo = case.get_value("DATM_TOPO")
datm_presaero = case.get_value("DATM_PRESAERO")
datm_presndep = case.get_value("DATM_PRESNDEP")
datm_co2_tseries = case.get_value("DATM_CO2_TSERIES")
atm_grid = case.get_value("ATM_GRID")
model_grid = case.get_value("GRID")
Expand All @@ -113,13 +114,16 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
if "CLM" in datm_mode and comp_lnd == "clm":
expect(datm_presaero != "none",
"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_topo != "none",
"A DATM_MODE for CLM is incompatible with DATM_TOPO=none.")

# Log some settings.
logger.debug("DATM mode is {}".format(datm_mode))
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 topo mode is {}".format(datm_topo))

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

if case.get_value('PTS_LON'):
scol_lon = float(case.get_value('PTS_LON'))
Expand Down Expand Up @@ -166,6 +171,8 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path

if datm_presaero != "none":
streamlist.append("presaero.{}".format(datm_presaero))
if datm_presndep != "none":
streamlist.append("presndep.{}".format(datm_presndep))
if datm_topo != "none":
streamlist.append("topo.{}".format(datm_topo))
if datm_co2_tseries != "none":
Expand Down
30 changes: 26 additions & 4 deletions datm/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<entry id="DATM_PRESAERO">
<type>char</type>
<valid_values>none,clim_1850,clim_2000,clim_2010,trans_1850-2000,SSP1-1.9,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP4-3.4,SSP4-6.0,SSP5-3.4,SSP5-8.5,cplhist</valid_values>
<valid_values>none,clim_1850,clim_2000,clim_2010,hist,SSP1-1.9,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP4-3.4,SSP4-6.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 @@ -80,8 +80,8 @@
<value compset="^SSP460_" >SSP4-6.0</value>
<value compset="^SSP534_" >SSP5-3.4</value>
<value compset="^SSP585_" >SSP5-8.5</value>
<value compset="^HIST_" >trans_1850-2000</value>
<value compset="^20TR_" >trans_1850-2000</value>
<value compset="^HIST_" >hist</value>
<value compset="^20TR_" >hist</value>
<value compset="_DATM%CPLHIST">cplhist</value>
<value compset="_DATM.*_DICE.*_DOCN.*_DROF">none</value>
</values>
Expand All @@ -90,6 +90,28 @@
<desc>DATM prescribed aerosol forcing</desc>
</entry>

<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>
<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="^SSP126_" >SSP1-2.6</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>
<value compset="_DATM%CPLHIST">cplhist</value>
<value compset="_DATM.*_DICE.*_DOCN.*_DROF">none</value>
</values>
<group>run_component_datm</group>
<file>env_run.xml</file>
<desc>DATM prescribed nitrogen deposition forcing</desc>
</entry>

<entry id="DATM_TOPO">
<type>char</type>
<valid_values>none,observed,cplhist</valid_values>
Expand All @@ -107,7 +129,7 @@

<entry id="DATM_CO2_TSERIES">
<type>char</type>
<valid_values>none,20tr,20tr.latbnd,omip,SSP1-1.9,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP4-3.4,SSP4-6.0,SSP5-3.4,SSP5-8.5,SSP1-1.9.latbnd,SSP1-2.6.latbnd,SSP2-4.5.latbnd,SSP3-7.0.latbnd,SSP4-3.4.latbnd,SSP4-6.0.latbnd,SSP5-3.4.latbnd,SSP5-8.5.latbnd</valid_values>
<valid_values>none,20tr,20tr.latbnd,omip.iaf,omip.jra,SSP1-1.9,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP4-3.4,SSP4-6.0,SSP5-3.4,SSP5-8.5,SSP1-1.9.latbnd,SSP1-2.6.latbnd,SSP2-4.5.latbnd,SSP3-7.0.latbnd,SSP4-3.4.latbnd,SSP4-6.0.latbnd,SSP5-3.4.latbnd,SSP5-8.5.latbnd</valid_values>
<default_value>none</default_value>
<values match="last">
<value compset="^SSP119_">SSP1-1.9</value>
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 @@ -266,6 +266,19 @@
</values>
</entry>

<entry id="flds_presndep">
<type>logical</type>
<category>datm</category>
<group>datm_nml</group>
<desc>
If true, prescribed nitrogen deposition fluxes are sent from datm (must be true for running with CLM).
</desc>
<values>
<value>.true.</value>
<value datm_presndep="none">.false.</value>
</values>
</entry>

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