Skip to content

Commit

Permalink
Merge pull request ESCOMP#50 from jedwards4b/neon_streams
Browse files Browse the repository at this point in the history
### Description of changes
Adds support for NEON tower data in datm.

### Specific notes

Contributors other than yourself, if any:

CMEPS Issues Fixed (include github issue #):

Are there dependencies on other component PRs
 - [X] CIME (list)   Requires branch neon_data_mode (PR ESMCI/cime#3850)
 - [ ] CMEPS (list) 

Are changes expected to change answers?
 - [X] bit for bit
 - [ ] different at roundoff level
 - [ ] more substantial 

Any User Interface Changes (namelist or namelist defaults changes)?
 - [ ] Yes
 - [X] No

Testing performed:
- [X] (required) aux_cdeps
   - machines and compilers: cheyenne intel 
   - details (e.g. failed tests): SMS_Vnuopc_Ld5.TL319_t061.2000_DATM%JRA-1p4-2018_SLND_SICE_SOCN_SROF_SGLC_SWAV_SESP.cheyenne_intel   fails in build with
       Invalid values ['CORE_IAF_JRA_1p4_2018']
- [ ] (optional) CESM prealpha test
   - machines and compilers
   - details (e.g. failed tests):

Hashes used for testing:
- [ ] CIME
  - repository to check out: https://github.com/ESCOMP/CESM.git
  - branch:  master
  - hash:8b48a2e
- [ ] CMEPS
  - repository to check out: https://github.com/ESCOMP/CESM.git
  - branch: master
  - hash: v0.9.0
- [ ] CESM
  - repository to check out: https://github.com/ESCOMP/CESM.git
  - branch: master
  - hash:
  • Loading branch information
jedwards4b authored Apr 23, 2021
2 parents 5be2b5b + 6dc9e76 commit eceb024
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 28 deletions.
28 changes: 15 additions & 13 deletions cime_config/stream_cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</stream_info>
"""

class StreamCDEPS(GenericXML):

def __init__(self, infile, schema):
Expand All @@ -64,8 +64,12 @@ def create_stream_xml(self, stream_names, case, streams_xml_file, data_list_file
stream_file.write('<file id="stream" version="2.0">\n')
# write contents of stream file
for stream_name in stream_names:
if stream_name:
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : stream_name},
if stream_name.startswith("NEON."):
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : "NEON.$NEONSITE"},
err_msg="No stream_entry {} found".format(stream_name))

elif stream_name:
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : stream_name},
err_msg="No stream_entry {} found".format(stream_name))

# determine stream_year_first and stream_year_list
Expand Down Expand Up @@ -99,26 +103,26 @@ def create_stream_xml(self, stream_names, case, streams_xml_file, data_list_file
stream_datafiles = child.xml_element.text
stream_datafiles = self._resolve_values(case, stream_datafiles)
if 'first_year' in child.xml_element.attrib and 'last_year' in child.xml_element.attrib:
value = child.xml_element.get('first_year')
value = child.xml_element.get('first_year')
value = self._resolve_values(case, value)
stream_year_first= int(value)
value = child.xml_element.get('last_year')
value = child.xml_element.get('last_year')
value = self._resolve_values(case, value)
stream_year_last = int(value)
year_first = max(stream_year_first, data_year_first)
year_last = min(stream_year_last, data_year_last)
stream_datafiles = self._sub_paths(stream_datafiles, year_first, year_last)
stream_datafiles = stream_datafiles.strip()
#endif
if stream_vars[node_name]:
if stream_vars[node_name]:
stream_vars[node_name] += "\n " + self._add_xml_delimiter(stream_datafiles.split("\n"), "file")
else:
stream_vars[node_name] = self._add_xml_delimiter(stream_datafiles.split("\n"), "file")

elif ( node_name == 'stream_meshfile'
or node_name == 'stream_mapalgo'
or node_name == 'stream_tintalgo'
or node_name == 'stream_taxmode'
or node_name == 'stream_mapalgo'
or node_name == 'stream_tintalgo'
or node_name == 'stream_taxmode'
or node_name == 'stream_dtlimit'):
attributes['model_grid'] = case.get_value("GRID")
attributes['compset'] = case.get_value("COMPSET")
Expand All @@ -130,7 +134,7 @@ def create_stream_xml(self, stream_names, case, streams_xml_file, data_list_file
elif node_name.strip():
# Get the other dependencies
stream_dict = self._add_value_to_dict(stream_vars, case, node)

# append to stream xml file
stream_file_text = _stream_nuopc_file_template.format(**stream_vars)
with open(streams_xml_file, 'a') as stream_file:
Expand Down Expand Up @@ -193,7 +197,7 @@ def _get_input_file_hash(self, data_list_file):

def _get_value_match(self, node, child_name, attributes=None, exact_match=False):
'''
Get the first best match for multiple tags in child_name based on the
Get the first best match for multiple tags in child_name based on the
attributes input
<values...>
Expand Down Expand Up @@ -396,5 +400,3 @@ def _add_xml_delimiter(list_to_deliminate, delimiter):
#endif
#endfor
return "\n ".join(list_to_deliminate)


10 changes: 8 additions & 2 deletions datm/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,20 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path

# Initialize namelist defaults
config = {}
config['model_grid'] = model_grid
if 'CLM_USRDAT' in model_grid:
config['model_grid'] = 'CLM_USRDAT'
if case.get_value("NEONSITE"):
config['neon'] = "True"
else:
config['model_grid'] = model_grid

config['datm_mode'] = datm_mode
config['datm_co2_tseries'] = datm_co2_tseries
config['datm_presaero'] = datm_presaero

if case.get_value('PTS_LON'):
scol_lon = float(case.get_value('PTS_LON'))
else:
else:
scol_lon = -999.
if case.get_value('PTS_LAT'):
scol_lat = float(case.get_value('PTS_LAT'))
Expand Down
22 changes: 13 additions & 9 deletions datm/cime_config/namelist_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<value datm_mode="1PT" model_grid="1x1_urbanc_alpha">
1PT.urbanc_alpha
</value>
<value datm_mode="1PT" model_grid="CLM_USRDAT" neon="True">
NEON.$NEONSITE
</value>
<value datm_mode="CORE2_NYF" >
CORE2_NYF.GISS,CORE2_NYF.GXGXS,CORE2_NYF.NCEP
</value>
Expand Down Expand Up @@ -65,7 +68,7 @@
<type>char</type>
<category>datm</category>
<group>datm_nml</group>
<valid_values>CLMNCEP,CORE2_NYF,CORE2_IAF,CORE_IAF_JRA,ERA5,CPLHIST</valid_values>
<valid_values>CLMNCEP,CORE2_NYF,CORE2_IAF,CORE_IAF_JRA,ERA5,CPLHIST,1PT</valid_values>
<desc>
general method that operates on the data.
----datamode = "CPLHIST"----
Expand Down Expand Up @@ -99,6 +102,7 @@
active-land-only simulations.
----datamode = "ERA5"----
Fifth generation ECMWF atmospheric reanalysis of the global climate
----datamode = "CPLHIST" ----
</desc>
<values>
<value datm_mode="CLM">
Expand All @@ -107,13 +111,10 @@
<value datm_mode="1PT">
CLMNCEP
</value>
<value datm_mode="CORE2_NYF">
CORE2_NYF
</value>
<value datm_mode="CORE2_IAF">
CORE2_IAF
</value>
<value datm_mode="CORE_IAF_JRA" >
<value datm_mode="CORE_IAF_JRA">
CORE_IAF_JRA
</value>
<value datm_mode="ERA5">
Expand All @@ -122,6 +123,9 @@
<value datm_mode="CPLHIST">
CPLHIST
</value>
<value>
$DATM_MODE
</value>
</values>
</entry>

Expand All @@ -135,7 +139,7 @@
</desc>
<values>
<value>$ATM_DOMAIN_MESH</value>
<value single_column='true'>null</value>
<value single_column='true'>null</value>
</values>
</entry>

Expand All @@ -149,7 +153,7 @@
</desc>
<values>
<value>$ATM_DOMAIN_MESH</value>
<value single_column='true'>null</value>
<value single_column='true'>null</value>
</values>
</entry>

Expand All @@ -162,7 +166,7 @@
</desc>
<values>
<value>$ATM_NX</value>
<value single_column='true'>1</value>
<value single_column='true'>1</value>
</values>
</entry>

Expand All @@ -175,7 +179,7 @@
</desc>
<values>
<value>$ATM_NY</value>
<value single_column='true'>1</value>
<value single_column='true'>1</value>
</values>
</entry>

Expand Down
48 changes: 45 additions & 3 deletions datm/cime_config/stream_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
%ym => year-month from the range yearfirst to yearlast with all 12 months
%ymd => year-month-day from the range yearfirst to yearlast with all 12 months
******
******
NOTE:
any <file></file> entry that has %y, %ym or %ymd MUST have first_year and last_year syntax
******
******
Each mode below, except for presaero, has a set of streams associated with it
The presaero stream, is associated with all modes
Expand Down Expand Up @@ -194,6 +194,48 @@
BC.QIAN.Precip
-->

<!-- =================================== -->
<!-- datm_mode 1PT NEON -->
<!-- =================================== -->

<stream_entry name="NEON.$NEONSITE">
<stream_meshfile>
<meshfile>none</meshfile>
</stream_meshfile>
<stream_datafiles>
<file first_year="2018" last_year="2019">$DIN_LOC_ROOT/atm/cdeps/v1/$NEONSITE/%ym.nc</file>
</stream_datafiles>
<stream_datavars>
<var>PRECTmms Faxa_precn</var>
<var>FSDS Faxa_swdn </var>
<var>ZBOT Sa_z </var>
<var>TBOT Sa_tbot </var>
<var>WIND Sa_wind </var>
<var>RH Sa_rh </var>
<var>PSRF Sa_pbot </var>
<var>FLDS Faxa_lwdn </var>
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<mapalgo>none</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
<stream_year_align>2018</stream_year_align>
<stream_year_first>2018</stream_year_first>
<stream_year_last>2019</stream_year_last>
<stream_offset>0</stream_offset>
<stream_tintalgo>
<tintalgo>linear</tintalgo>
</stream_tintalgo>
<stream_taxmode>
<taxmode>extend</taxmode>
</stream_taxmode>
<stream_dtlimit>
<dtlimit>1e30</dtlimit>
</stream_dtlimit>
<stream_readmode>single</stream_readmode>
</stream_entry>

<!-- =================================== -->
<!-- datm_mode CLMGSWP3v1 -->
<!-- =================================== -->
Expand All @@ -209,7 +251,7 @@
<var>FSDS Faxa_swdn</var>
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<stream_mapalgo>
<mapalgo>bilinear</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
Expand Down
3 changes: 3 additions & 0 deletions datm/datm_datamode_clmncep_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ subroutine datm_datamode_clmncep_advance(masterproc, logunit, mpicom, rc)
rtmp = maxval(Sa_tbot(:))
call shr_mpi_max(rtmp, tbotmax, mpicom, 'datm_tbot', all=.true.)
write(logunit,*) trim(subname),' tbotmax = ',tbotmax
if(tbotmax <= 0) then
call shr_sys_abort(subname//'ERROR: bad value in tbotmax')
endif

! determine anidrmax (see below for use)
if (atm_prognostic) then
Expand Down
1 change: 0 additions & 1 deletion streams/dshr_strdata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc)
! ---------------------------------------------------------

do ns = 1,nstreams

if (trim(sdat%stream(ns)%tinterpalgo) == 'coszen') then

! Determine stream lower bound index
Expand Down

0 comments on commit eceb024

Please sign in to comment.