Skip to content

Commit

Permalink
Merge branch 'main' into add_jra1_5
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b authored Oct 25, 2024
2 parents 37b1a13 + 1eacdcc commit 573df5d
Show file tree
Hide file tree
Showing 37 changed files with 1,565 additions and 760 deletions.
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ add_subdirectory(streams)
add_subdirectory(dshr)

if(NOT DISABLE_FoX)
FetchContent_Declare(fox
GIT_REPOSITORY https://github.com/ESMCI/fox.git
GIT_TAG 4.1.2.1
SOURCE_DIR ${FOX_ROOT}
BINARY_DIR ${FOX_ROOT}/..
)
FetchContent_GetProperties(fox)
if(NOT fox_POPULATED)
FetchContent_Populate(fox)
message(STATUS "FoX source dir: ${fox_SOURCE_DIR}")
message(STATUS "FoX binary dir: ${fox_BINARY_DIR}")
endif()
add_subdirectory(fox)

target_include_directories(streams PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fox/include>
Expand Down
18 changes: 18 additions & 0 deletions cime_config/stream_cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def create_stream_xml(
data_list_file,
user_mods_file,
available_neon_data=None,
available_plumber_data=None
):
"""
Create the stream xml file and append the required stream input data to the input data list file
Expand Down Expand Up @@ -187,7 +188,17 @@ def create_stream_xml(
{"name": "NEON.NEON_PRECIP.$NEONSITE"},
err_msg="No stream_entry {} found".format(stream_name),
)
elif stream_name.startswith("PLUMBER2"):
self.stream_nodes = super(StreamCDEPS, self).get_child(
"stream_entry",
{"name": "PLUMBER2.$PLUMBER2SITE"},
err_msg="No stream_entry {} found".format(stream_name),
)
elif stream_name.startswith("CLM_USRDAT."):
if 'PLUMBER2' in stream_name:
# if PLUMBER2 is in the stream name
# we want to use PLUMBER2.PLUMBER2SITE instead of CLM_USRDAT.PLUMBER2
continue
self.stream_nodes = super(StreamCDEPS, self).get_child(
"stream_entry",
{"name": "CLM_USRDAT.$CLM_USRDAT_NAME"},
Expand Down Expand Up @@ -244,6 +255,13 @@ def create_stream_xml(
os.path.join(rundir, "inputdata", "atm", neon)
+ "\n"
)
elif available_plumber_data and stream_name.startswith("PLUMBER2"):
rundir = case.get_value("RUNDIR")
for plumber in available_plumber_data:
stream_datafiles += (
os.path.join(rundir, "inputdata", "atm", plumber)
+ "\n"
)
else:
_stream_datafiles = child.xml_element.text
_stream_datafiles = self._resolve_values(
Expand Down
3 changes: 2 additions & 1 deletion cime_config/stream_definition_v2.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="model_grid" type="xs:string" />
<xs:attribute name="compset" type="xs:string" />
<xs:attribute name="compset" type="xs:string" />
<xs:attribute name="CLM_USRDAT_NAME" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Expand Down
87 changes: 22 additions & 65 deletions datm/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,60 +33,44 @@ module cdeps_datm_comp
use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck
use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_config, shr_strdata_advance
use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_setOrbs
use dshr_mod , only : dshr_model_initphase, dshr_init
use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_restart_write
use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_log_clock_advance
use dshr_mod , only : dshr_mesh_init, dshr_check_restart_alarm
use dshr_mod , only : dshr_mesh_init, dshr_check_restart_alarm, dshr_restart_read
use dshr_mod , only : dshr_orbital_init, dshr_orbital_update
use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy
use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize

use datm_datamode_core2_mod , only : datm_datamode_core2_advertise
use datm_datamode_core2_mod , only : datm_datamode_core2_init_pointers
use datm_datamode_core2_mod , only : datm_datamode_core2_advance
use datm_datamode_core2_mod , only : datm_datamode_core2_restart_write
use datm_datamode_core2_mod , only : datm_datamode_core2_restart_read

use datm_datamode_jra_mod , only : datm_datamode_jra_advertise
use datm_datamode_jra_mod , only : datm_datamode_jra_init_pointers
use datm_datamode_jra_mod , only : datm_datamode_jra_advance
use datm_datamode_jra_mod , only : datm_datamode_jra_restart_write
use datm_datamode_jra_mod , only : datm_datamode_jra_restart_read

use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advertise
use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_init_pointers
use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advance
use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_write
use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_read

use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advertise
use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_init_pointers
use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advance
use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_write
use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_read

use datm_datamode_era5_mod , only : datm_datamode_era5_advertise
use datm_datamode_era5_mod , only : datm_datamode_era5_init_pointers
use datm_datamode_era5_mod , only : datm_datamode_era5_advance
use datm_datamode_era5_mod , only : datm_datamode_era5_restart_write
use datm_datamode_era5_mod , only : datm_datamode_era5_restart_read

use datm_datamode_gefs_mod , only : datm_datamode_gefs_advertise
use datm_datamode_gefs_mod , only : datm_datamode_gefs_init_pointers
use datm_datamode_gefs_mod , only : datm_datamode_gefs_advance
use datm_datamode_gefs_mod , only : datm_datamode_gefs_restart_write
use datm_datamode_gefs_mod , only : datm_datamode_gefs_restart_read

use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_advertise
use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_init_pointers
use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_advance
use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_restart_write
use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_restart_read

use datm_datamode_simple_mod , only : datm_datamode_simple_advertise
use datm_datamode_simple_mod , only : datm_datamode_simple_init_pointers
use datm_datamode_simple_mod , only : datm_datamode_simple_advance
use datm_datamode_simple_mod , only : datm_datamode_simple_restart_write
use datm_datamode_simple_mod , only : datm_datamode_simple_restart_read

implicit none
private ! except
Expand Down Expand Up @@ -157,7 +141,6 @@ module cdeps_datm_comp
integer :: idt ! integer model timestep
logical :: diagnose_data = .true.
integer , parameter :: main_task = 0 ! task number of main task
character(len=*) , parameter :: rpfile = 'rpointer.atm'
#ifdef CESMCOUPLED
character(*) , parameter :: modName = "(atm_comp_nuopc)"
#else
Expand Down Expand Up @@ -479,7 +462,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Run datm
call datm_comp_run(importstate, exportstate, current_ymd, current_tod, current_mon, &
call datm_comp_run(gcomp, importstate, exportstate, current_ymd, current_tod, current_mon, &
orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write=.false., rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -561,7 +544,7 @@ subroutine ModelAdvance(gcomp, rc)

! Run datm
call ESMF_TraceRegionEnter('datm_run')
call datm_comp_run(importstate, exportstate, next_ymd, next_tod, mon, &
call datm_comp_run(gcomp, importstate, exportstate, next_ymd, next_tod, mon, &
orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TraceRegionExit('datm_run')
Expand All @@ -579,14 +562,15 @@ subroutine ModelAdvance(gcomp, rc)
end subroutine ModelAdvance

!===============================================================================
subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, target_mon, &
subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod, target_mon, &
orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc)

use nuopc_shr_methods, only : shr_get_rpointer_name
! ----------------------------------
! run method for datm model
! ----------------------------------

! input/output variables
type(ESMF_GridComp) , intent(inout) :: gcomp
type(ESMF_State) , intent(inout) :: importState
type(ESMF_State) , intent(inout) :: exportState
integer , intent(in) :: target_ymd ! model date
Expand All @@ -601,6 +585,7 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe

! local variables
logical :: first_time = .true.
character(len=CL) :: rpfile
character(*), parameter :: subName = '(datm_comp_run) '
!-------------------------------------------------------------------------------

Expand All @@ -613,7 +598,6 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe
!--------------------

if (first_time) then

! Initialize dfields
call datm_init_dfields(rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -648,23 +632,14 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe

! Read restart if needed
if (restart_read .and. .not. skip_restart_read) then
call shr_get_rpointer_name(gcomp, 'atm', target_ymd, target_tod, rpfile, 'read', rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
select case (trim(datamode))
case('CORE2_NYF','CORE2_IAF')
call datm_datamode_core2_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('CORE_IAF_JRA')
call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('CLMNCEP')
call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('CPLHIST')
call datm_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('ERA5')
call datm_datamode_era5_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('GEFS')
call datm_datamode_gefs_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('CFSR')
call datm_datamode_cfsr_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('SIMPLE')
call datm_datamode_simple_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
case('CORE2_NYF','CORE2_IAF','CORE_IAF_JRA','CLMNCEP','CPLHIST','ERA5','GEFS','CFSR','SIMPLE')
call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case default
call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized')
end select
end if

Expand Down Expand Up @@ -727,33 +702,15 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe

! Write restarts if needed
if (restart_write) then
call shr_get_rpointer_name(gcomp, 'atm', target_ymd, target_tod, rpfile, 'write', rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
select case (trim(datamode))
case('CORE2_NYF','CORE2_IAF')
call datm_datamode_core2_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case('CORE_IAF_JRA')
call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case('CLMNCEP')
call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case('CPLHIST')
call datm_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case('ERA5')
call datm_datamode_era5_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case('GEFS')
call datm_datamode_gefs_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case('CORE2_NYF','CORE2_IAF','CORE_IAF_JRA','CLMNCEP','CPLHIST','ERA5','GEFS','CFSR','SIMPLE')
call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, target_ymd, target_tod, logunit, &
my_task, sdat, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('CFSR')
call datm_datamode_cfsr_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('SIMPLE')
call datm_datamode_simple_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
case default
call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized')
end select
end if

Expand Down
17 changes: 12 additions & 5 deletions datm/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
available_neon_data = None
if 'CLM_USRDAT' in model_grid:
config['model_grid'] = 'CLM_USRDAT'
neonsite = case.get_value("NEONSITE")
if neonsite:
config['neon'] = "True"
# download and use the listing.csv file to determine data availablity
available_neon_data = _get_neon_data_availability(case, neonsite)
if 'NEON' in clm_usrdat_name:
neonsite = case.get_value("NEONSITE")
if neonsite:
config['neon'] = "True"
# download and use the listing.csv file to determine data availablity
available_neon_data = _get_neon_data_availability(case, neonsite)
if 'PLUMBER2' in clm_usrdat_name:
plumber2site = case.get_value('PLUMBER2SITE')
if plumber2site:
config['plumber'] = "True"
else:
config['model_grid'] = model_grid

Expand Down Expand Up @@ -194,6 +199,8 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
streamlist.append(clm_usrdat_name+"_PRECIP."+neonsite)
if clm_usrdat_name == 'NEON':
streamlist.append(clm_usrdat_name+".NEON_PRECIP."+neonsite)
if clm_usrdat_name == 'PLUMBER2':
streamlist.append(clm_usrdat_name+"."+plumber2site)

bias_correct = nmlgen.get_value("bias_correct")
if bias_correct is not None:
Expand Down
9 changes: 9 additions & 0 deletions datm/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@
<desc>starting year to loop data over</desc>
</entry>

<entry id="DATM_YR_START_FILENAME">
<type>integer</type>
<valid_values></valid_values>
<default_value>9999</default_value>
<group>run_component_datm</group>
<file>env_run.xml</file>
<desc>Start year listed in PLUMBER2 filenames for certain datm_modes. Currently only used in PLUMBER2; leave as the default value (9999) for other cases.</desc>
</entry>

<entry id="DATM_YR_END">
<type>integer</type>
<valid_values></valid_values>
Expand Down
3 changes: 3 additions & 0 deletions datm/cime_config/namelist_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<value datm_mode="1PT" model_grid="CLM_USRDAT" neon="True">
NEON.$NEONSITE
</value>
<value datm_mode="1PT" model_grid="CLM_USRDAT" neon="True">
PLUMBER2.$PLUMBER2SITE
</value>
<value datm_mode="1PT" model_grid="CLM_USRDAT">
CLM_USRDAT.$CLM_USRDAT_NAME
</value>
Expand Down
48 changes: 48 additions & 0 deletions datm/cime_config/stream_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
CORE_RYF9091_JRA = JRA55 repeat year forcing, v1.3, 1990-1991 (for forcing MOM6 and CICE)
CORE_RYF0304_JRA = JRA55 repeat year forcing, v1.3, 2003-2004 (for forcing MOM6 and CICE)
ERA5 = ERA5 intra-annual year forcing
NEON = Run with forcing from NEON tower data
PLUMBER2 = Run with forcing from PLUMBER2 tower data
SIMPLE = Namelist-configurable, constant datm forcing for simple experiments
CPLHIST = Streams for lnd or ocn/ice forcing used for spinup
Expand Down Expand Up @@ -342,6 +344,50 @@
<stream_readmode>single</stream_readmode>
</stream_entry>


<!-- =================================== -->
<!-- datm_mode PLUMBER2.$PLUMBER2SITE -->
<!-- =================================== -->

<stream_entry name="PLUMBER2.$PLUMBER2SITE">
<stream_meshfile>
<meshfile>none</meshfile>
</stream_meshfile>
<stream_datafiles>
<file first_year="$DATM_YR_START" last_year="$DATM_YR_END">$DIN_LOC_ROOT/atm/datm7/CLM1PT_data/PLUMBER2/${PLUMBER2SITE}/CLM1PT_data/CTSM_DATM_${PLUMBER2SITE}_${DATM_YR_START_FILENAME}-${DATM_YR_END}.nc</file>
</stream_datafiles>
<stream_datavars>
<var>ZBOT Sa_z</var>
<var>TBOT Sa_tbot</var>
<var>QBOT Sa_shum</var>
<var>WIND Sa_wind</var>
<var>PRECTmms Faxa_precn</var>
<var>FSDS Faxa_swdn</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>$DATM_YR_ALIGN</stream_year_align>
<stream_year_first>$DATM_YR_START</stream_year_first>
<stream_year_last>$DATM_YR_END</stream_year_last>
<stream_offset>0</stream_offset>
<stream_tintalgo>
<tintalgo>linear</tintalgo>
</stream_tintalgo>
<stream_taxmode>
<taxmode >cycle</taxmode>
<taxmode compset="HIST">limit</taxmode>
</stream_taxmode>
<stream_dtlimit>
<dtlimit>1.5</dtlimit>
</stream_dtlimit>
<stream_readmode>single</stream_readmode>
</stream_entry>

<!-- =================================== -->
<!-- datm_mode CLMGSWP3v1 -->
<!-- =================================== -->
Expand Down Expand Up @@ -4313,6 +4359,7 @@
</stream_taxmode>
<stream_dtlimit>
<dtlimit>1.5</dtlimit>
<dtlimit CLM_USRDAT_NAME="PLUMBER2">30</dtlimit>
</stream_dtlimit>
<stream_readmode>single</stream_readmode>
</stream_entry>
Expand Down Expand Up @@ -4852,6 +4899,7 @@
</stream_taxmode>
<stream_dtlimit>
<dtlimit>1.5</dtlimit>
<dtlimit CLM_USRDAT_NAME="PLUMBER2">30</dtlimit>
</stream_dtlimit>
<stream_readmode>single</stream_readmode>
</stream_entry>
Expand Down
Loading

0 comments on commit 573df5d

Please sign in to comment.