Skip to content

Commit

Permalink
Implements CCPP-ized tropopause_find (#293)
Browse files Browse the repository at this point in the history
Companion PR: ESCOMP/atmospheric_physics#112

Note: I think I brought in more changes than necessary in `ncar_ccpp`
due to the my `atmospheric_physics` branch being based off `development`
rather than the released used in CAM-SIMA. I can do a rebase if
necessary...

## Changes made to support CCPP-ized tropopause_find
* Copied utility module `interpolate_data.F90` from CAM
* Added utility module `tropopause_read_file.F90` to provide
climatological tropopause data to tropopause_find from CAM-SIMA
* `&tropopause_nl tropopause_climo_file` is read from
`tropopause_read_file.F90` inside SIMA and not in the parameterization,
to avoid passing this file name back and forth between the
parameterization to CAM-SIMA
* Adds `get_curr_calday()` result to new standard name variable
`fractional_calendar_days_on_end_of_current_timestep`
* Submodule update (possibly need a rebase?)

I recommend manually merging in the history PR for testing. It might be
easier to merge my branch (`jimmielin:hplin/tropopause_find`) into
`peverwhee:history_court`.
  • Loading branch information
jimmielin authored Oct 7, 2024
2 parents 27eacea + d8f13a5 commit 0b6a468
Show file tree
Hide file tree
Showing 10 changed files with 1,551 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[submodule "ncar-physics"]
path = src/physics/ncar_ccpp
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = 098585940ad763be58ebab849bb8eaf325fda42a
fxtag = atmos_phys0_05_000
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
[submodule "ccs_config"]
Expand Down
15 changes: 14 additions & 1 deletion cime_config/namelist_definition_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,19 @@
</values>
</entry>

<!-- Tropopause -->
<entry id="tropopause_climo_file">
<type>char*256</type>
<category>tropopause</category>
<group>tropopause_nl</group>
<desc>
Full pathname of boundary dataset for tropopause climatology.
</desc>
<values>
<value>${DIN_LOC_ROOT}/atm/cam/chem/trop_mozart/ub/clim_p_trop.nc</value>
</values>
</entry>

<!-- Vertical Coordinate -->

<entry id="pver">
Expand Down Expand Up @@ -364,7 +377,7 @@
<group>cam_logfile_nl</group>
<valid_values>0,1,2,3</valid_values>
<desc>
Include exra checks and logging output.
Include extra checks and logging output.
0: No extra checks or output
1: Extra informational output
2: Level 1 plus extra checks and informational output
Expand Down
14 changes: 14 additions & 0 deletions src/control/cam_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ module cam_comp
use time_manager, only: timemgr_init, get_step_size
use time_manager, only: get_nstep
use time_manager, only: is_first_step, is_first_restart_step
use time_manager, only: get_curr_calday

use camsrfexch, only: cam_out_t, cam_in_t
use physics_types, only: phys_state, phys_tend
use physics_types, only: dtime_phys
use physics_types, only: calday
use dyn_comp, only: dyn_import_t, dyn_export_t

use perf_mod, only: t_barrierf, t_startf, t_stopf
Expand Down Expand Up @@ -98,6 +100,7 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
use physics_grid, only: columns_on_task
use vert_coord, only: pver
use phys_vars_init_check, only: mark_as_initialized
use tropopause_climo_read, only: tropopause_climo_read_file

! Arguments
character(len=cl), intent(in) :: caseid ! case ID
Expand Down Expand Up @@ -163,11 +166,16 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &

call cam_ctrl_set_orbit(eccen, obliqr, lambm0, mvelpp)


call timemgr_init( &
dtime, calendar, start_ymd, start_tod, ref_ymd, &
ref_tod, stop_ymd, stop_tod, curr_ymd, curr_tod, &
perpetual_run, perpetual_ymd, initial_run_in)

! Get current fractional calendar day. Needs to be updated at every timestep.
calday = get_curr_calday()
call mark_as_initialized('fractional_calendar_days_on_end_of_current_timestep')

! Read CAM namelists.
filein = "atm_in" // trim(inst_suffix)
call read_namelist(filein, single_column, scmlat, scmlon)
Expand Down Expand Up @@ -224,6 +232,9 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
!!XXgoldyXX: ^ need to import this
end if

! Read tropopause climatology
call tropopause_climo_read_file()

call phys_init()

!!XXgoldyXX: v need to import this
Expand Down Expand Up @@ -270,6 +281,9 @@ subroutine cam_timestep_init()
!
call phys_timestep_init()

! Update current fractional calendar day. Needs to be updated at every timestep.
calday = get_curr_calday()

end subroutine cam_timestep_init
!
!-----------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/control/runtime_opts.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
! use cam_diagnostics, only: diag_readnl
use inic_analytic_utils, only: analytic_ic_readnl

use tropopause_climo_read, only: tropopause_climo_readnl

! use tracers, only: tracers_readnl
! use nudging, only: nudging_readnl

Expand Down Expand Up @@ -99,6 +101,7 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
! call diag_readnl(nlfilename)
! call check_energy_readnl(nlfilename)
call analytic_ic_readnl(nlfilename)
call tropopause_climo_readnl(nlfilename)
! call scam_readnl(nlfilename, single_column, scmlat, scmlon)
! call nudging_readnl(nlfilename)

Expand Down
5 changes: 3 additions & 2 deletions src/data/generate_registry_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
sys.path.append(__SPINSCRIPTS)
# end if
_ALL_STRINGS_REGEX = re.compile(r'[A-Za-z][A-Za-z_0-9]+')
_FORTRAN_NUMERIC_REGEX = re.compile(r'^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?(_kind_phys)?$')

# CCPP framework imports
# pylint: disable=wrong-import-position
Expand Down Expand Up @@ -940,9 +941,9 @@ def add_variable(self, newvar):
all_strings = _ALL_STRINGS_REGEX.findall(newvar.initial_value)
init_val_vars = set()
excluded_initializations = {'null', 'nan', 'false', 'true'}
# Exclude NULL and nan variables
# Exclude NULL and nan variables and valid Fortran numeric values that pass the string regex (e.g. 1.e36, -3.2e5)
for var in all_strings:
if var.lower() not in excluded_initializations:
if var.lower() not in excluded_initializations and not _FORTRAN_NUMERIC_REGEX.match(newvar.initial_value):
init_val_vars.add(var)
# end if
# end if
Expand Down
15 changes: 15 additions & 0 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<metadata_file>$SRCROOT/src/data/physconst.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/physics_grid.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/cam_constituents.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/tropopause_climo_read.meta</metadata_file>
<metadata_file>$SRCROOT/src/data/air_composition.meta</metadata_file>
<metadata_file>$SRCROOT/src/data/cam_thermo.meta</metadata_file>
<metadata_file>$SRCROOT/src/data/ref_pres.meta</metadata_file>
Expand Down Expand Up @@ -348,6 +349,12 @@
<long_name>current timestep number</long_name>
<initial_value>0</initial_value>
</variable>
<!-- Date and time variables -->
<variable local_name="calday"
standard_name="fractional_calendar_days_on_end_of_current_timestep"
units="1" type="real" kind="kind_phys">
<long_name>fractional calendar day at end of current timestep</long_name>
</variable>
<!-- Error handling variables -->
<variable local_name="errcode"
standard_name="ccpp_error_code"
Expand All @@ -361,6 +368,14 @@
<long_name>ccpp error message</long_name>
<initial_value>''</initial_value>
</variable>
<!-- SIMA History (diagnostic output) variables -->
<variable local_name="fillvalue"
standard_name="fill_value_for_diagnostic_output"
units="1" type="real" kind="kind_phys"
allocatable="parameter">
<long_name>Fill value for diagnostic/history outputs</long_name>
<initial_value>1.e36_kind_phys</initial_value>
</variable>
<!-- Composition-dependent Variables -->
<variable local_name="cpairv"
standard_name="composition_dependent_specific_heat_of_dry_air_at_constant_pressure"
Expand Down
Loading

0 comments on commit 0b6a468

Please sign in to comment.