Skip to content

Commit

Permalink
Merge pull request #194 from nusbaume/new_atmos_phys_external_fixes
Browse files Browse the repository at this point in the history
Update CAMDEN to prepare for new atmos. physics external
  • Loading branch information
nusbaume authored Jan 6, 2023
2 parents e9f07c2 + 5b427f3 commit a6f9d49
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 55 deletions.
2 changes: 1 addition & 1 deletion Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ required = False
local_path = src/physics/ncar_ccpp
protocol = git
repo_url = https://github.com/NCAR/atmospheric_physics
tag = atmos_phys0_00_017
tag = atmos_phys0_00_018
required = True

[silhs]
Expand Down
17 changes: 9 additions & 8 deletions cime_config/cam_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,17 @@ def __init__(self, case, case_log):
# Save local (cime_config) directory path:
cime_conf_path = os.path.dirname(os.path.abspath(__file__))

# Save path to the "data" src direcotry:
data_nml_path = os.path.join(cime_conf_path, os.pardir, "src", "data")

# Create empty XML namelist definition files dictionary:
self.__xml_nml_def_files = OrderedDict()

#Add the default host model namelist:
self._add_xml_nml_file(cime_conf_path, 'namelist_definition_cam.xml')
#Add the default host model namelists:
self._add_xml_nml_file(cime_conf_path, "namelist_definition_cam.xml")
self._add_xml_nml_file(data_nml_path, "namelist_definition_physconst.xml")
self._add_xml_nml_file(data_nml_path, "namelist_definition_air_comp.xml")
self._add_xml_nml_file(data_nml_path, "namelist_definition_ref_pres.xml")

#----------------------------------------------------
# Set CAM start date (needed for namelist generation)
Expand Down Expand Up @@ -342,16 +348,11 @@ def __init__(self, case, case_log):
self.create_config("dyn_src_dirs", dyn_dirs_desc, ["se",os.path.join("se","dycore")],
valid_list_type="str")

# Set paths for the SE dycore and "air composition"
# namelist definition files:
# Set paths for the SE dycore namelist definition file:
se_dyn_nml_path = os.path.join(cime_conf_path, os.pardir, "src", "dynamics", "se")
data_nml_path = os.path.join(cime_conf_path, os.pardir, "src", "data")

#Add NML definition files to dictionary:
self._add_xml_nml_file(se_dyn_nml_path, "namelist_definition_se_dycore.xml")
self._add_xml_nml_file(data_nml_path, "namelist_definition_air_comp.xml")
self._add_xml_nml_file(data_nml_path, "namelist_definition_physconst.xml")
self._add_xml_nml_file(data_nml_path, "namelist_definition_ref_pres.xml")

# Add required CPP definitons:
self.add_cppdef("_MPI")
Expand Down
12 changes: 6 additions & 6 deletions src/data/air_composition.F90
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ subroutine air_composition_init()
!
! Q
!
case('water_vapor_specific_humidity')
case('specific_humidity')
! call air_species_info('Q', ix, mw) !!XXgoldyXX: this should be uncommented once constituents are enabled
ix = ix_qv ! this should be removed once constituents are enabled
mw = mwh2o !this should be removed once constituents are enabled
Expand All @@ -497,7 +497,7 @@ subroutine air_composition_init()
!
! CLDLIQ
!
case('cloud_liquid_water_mixing_ratio_of_moist_air')
case('cloud_liquid_water_mixing_ratio_wrt_moist_air')
! call air_species_info('CLDLIQ', ix, mw) !!XXgoldyXX: this should be uncommented once constituents are enabled
ix = ix_cld_liq ! this should be removed once constituents are enabled
thermodynamic_active_species_idx(icnst) = ix
Expand All @@ -510,7 +510,7 @@ subroutine air_composition_init()
!
! CLDICE
!
case('cloud_ice_mixing_ratio_of_moist_air')
case('cloud_ice_mixing_ratio_wrt_moist_air')
! call air_species_info('CLDICE', ix, mw) !!XXgoldyXX: this should be uncommented once constituents are enabled
ix = -1 !!XXgoldyXX: Model should die if it gets here, until constituents are enabled
thermodynamic_active_species_idx(icnst) = ix
Expand All @@ -523,7 +523,7 @@ subroutine air_composition_init()
!
! RAINQM
!
case('rain_water_mixing_ratio')
case('rain_water_mixing_ratio_wrt_moist_air')
! call air_species_info('RAINQM', ix, mw) !!XXgoldyXX: this should be uncommented once constituents are enabled
ix = ix_rain !!XXgoldyXX: this should be removed once constituents are enabled
thermodynamic_active_species_idx(icnst) = ix
Expand All @@ -536,7 +536,7 @@ subroutine air_composition_init()
!
! SNOWQM
!
case('snow_water_mixing_ratio')
case('snow_water_mixing_ratio_wrt_moist_air')
! call air_species_info('SNOWQM', ix, mw) !!XXgoldyXX: this should be uncommented once constituents are enabled
ix = -1 !!XXgoldyXX: Model should die if it gets here, until constituents are enabled
thermodynamic_active_species_idx(icnst) = ix
Expand All @@ -549,7 +549,7 @@ subroutine air_composition_init()
!
! GRAUQM
!
case('graupel_mixing_ratio')
case('graupel_mixing_ratio_wrt_moist_air')
! call air_species_info('GRAUQM', ix, mw) !!XXgoldyXX: this should be uncommented once constituents are enabled
ix = -1 !!XXgoldyXX: Model should die if it gets here, until constituents are enabled
thermodynamic_active_species_idx(icnst) = ix
Expand Down
48 changes: 24 additions & 24 deletions src/data/namelist_definition_air_comp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,45 +41,45 @@
mass and thermodynamic properties.
Default if CAM4, CAM5, or Kessler physics is used:

['water_vapor_specific_humidity',
'cloud_liquid_water_mixing_ratio_of_moist_air',
'rain_water_mixing_ratio']
['specific_humidity',
'cloud_liquid_water_mixing_ratio_wrt_moist_air',
'rain_water_mixing_ratio_wrt_moist_air']

Default if CAM6 physics is used:

['water_vapor_specific_humidity',
'cloud_liquid_water_mixing_ratio_of_moist_air',
'cloud_ice_water_mixing_ratio_of_moist_air',
'rain_water_mixing_ratio',
'snow_water_mixing_ratio']
['specific_humidity',
'cloud_liquid_water_mixing_ratio_wrt_moist_air',
'cloud_ice_water_mixing_ratio_wrt_moist_air',
'rain_water_mixing_ratio_wrt_moist_air',
'snow_water_mixing_ratio_wrt_moist_air']

Otherwise default is: ['water_vapor_specific_humidity']
Otherwise default is: ['specific_humidity']
</desc>
<values>
<value>
water_vapor_specific_humidity
specific_humidity
</value>
<value phys_suite="kessler">
water_vapor_specific_humidity,
cloud_liquid_water_mixing_ratio_of_moist_air,
rain_water_mixing_ratio
specific_humidity,
cloud_liquid_water_mixing_ratio_wrt_moist_air,
rain_water_mixing_ratio_wrt_moist_air
</value>
<value phys_suite="cam4">
water_vapor_specific_humidity,
cloud_liquid_water_mixing_ratio_of_moist_air,
rain_water_mixing_ratio
specific_humidity,
cloud_liquid_water_mixing_ratio_wrt_moist_air,
rain_water_mixing_ratio_wrt_moist_air
</value>
<value phys_suite="cam5">
water_vapor_specific_humidity,
cloud_liquid_water_mixing_ratio_of_moist_air,
rain_water_mixing_ratio
specific_humidity,
cloud_liquid_water_mixing_ratio_wrt_moist_air,
rain_water_mixing_ratio_wrt_moist_air
</value>
<value phys_suite="cam6">
water_vapor_specific_humidity,
cloud_liquid_water_mixing_ratio_of_moist_air,
cloud_ice_water_mixing_ratio_of_moist_air,
rain_water_mixing_ratio,
snow_water_mixing_ratio
specific_humidity,
cloud_liquid_water_mixing_ratio_wrt_moist_air,
cloud_ice_water_mixing_ratio_wrt_moist_air,
rain_water_mixing_ratio_wrt_moist_air,
snow_water_mixing_ratio_wrt_moist_air
</value>
</values>
</entry>
Expand Down
18 changes: 9 additions & 9 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
<use module="runtime_obj" reference="unset_int"/>
<!-- Constituent indices -->
<variable local_name="ix_qv"
standard_name="index_of_water_vapor_specific_humidity"
standard_name="index_of_specific_humidity"
units="index" type="integer">
<initial_value>1</initial_value>
</variable>
<variable local_name="ix_cld_liq"
standard_name="index_of_cloud_liquid_water_mixing_ratio_of_moist_air"
standard_name="index_of_cloud_liquid_water_mixing_ratio_wrt_moist_air"
units="index" type="integer">
<initial_value>2</initial_value>
</variable>
<variable local_name="ix_rain"
standard_name="index_of_rain_water_mixing_ratio"
standard_name="index_of_rain_water_mixing_ratio_wrt_moist_air"
units="index" type="integer">
<initial_value>3</initial_value>
</variable>
Expand Down Expand Up @@ -178,18 +178,18 @@
allocatable="pointer">
<dimensions>horizontal_dimension vertical_layer_dimension
number_of_constituents</dimensions>
<element standard_name="water_vapor_specific_humidity"
index_name="index_of_water_vapor_specific_humidity"
<element standard_name="specific_humidity"
index_name="index_of_specific_humidity"
index_pos="number_of_constituents">
<ic_file_input_names>Q cnst_Q</ic_file_input_names>
</element>
<element standard_name="cloud_liquid_water_mixing_ratio_of_moist_air"
index_name="index_of_cloud_liquid_water_mixing_ratio_of_moist_air"
<element standard_name="cloud_liquid_water_mixing_ratio_wrt_moist_air"
index_name="index_of_cloud_liquid_water_mixing_ratio_wrt_moist_air"
index_pos="number_of_constituents">
<ic_file_input_names>CLDLIQ cnst_CLDLIQ</ic_file_input_names>
</element>
<element standard_name="rain_water_mixing_ratio"
index_name="index_of_rain_water_mixing_ratio"
<element standard_name="rain_water_mixing_ratio_wrt_moist_air"
index_name="index_of_rain_water_mixing_ratio_wrt_moist_air"
index_pos="number_of_constituents">
<ic_file_input_names>RAINQM cnst_RAINQM</ic_file_input_names>
</element>
Expand Down
12 changes: 6 additions & 6 deletions src/dynamics/se/dyn_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,13 @@ subroutine dyn_init(cam_runtime_opts, dyn_in, dyn_out)

if (m == ix_qv) then
cnst_name_gll(m) = 'Q'
cnst_longname_gll(m) = 'water_vapor_specific_humidity'
cnst_longname_gll(m) = 'specific_humidity'
else if (m == ix_cld_liq) then
cnst_name_gll(m) = 'CLDLIQ'
cnst_longname_gll(m) = 'cloud_liquid_water_mixing_ratio'
cnst_longname_gll(m) = 'cloud_liquid_water_mixing_ratio_wrt_moist_air'
else
cnst_name_gll(m) = 'RAINQM'
cnst_longname_gll(m) = 'rain_water_mixing_ratio'
cnst_longname_gll(m) = 'rain_water_mixing_ratio_wrt_moist_air'
end if
end do
#endif
Expand Down Expand Up @@ -1866,9 +1866,9 @@ subroutine read_inidat(dyn_in)
call mark_as_initialized("air_temperature")

!These calls will need to be modified once constituents are enabled:
call mark_as_initialized("water_vapor_specific_humidity")
call mark_as_initialized("cloud_liquid_water_mixing_ratio_of_moist_air")
call mark_as_initialized("rain_water_mixing_ratio")
call mark_as_initialized("specific_humidity")
call mark_as_initialized("cloud_liquid_water_mixing_ratio_wrt_moist_air")
call mark_as_initialized("rain_water_mixing_ratio_wrt_moist_air")

!These calls may be removed if geopotential_t is only allowed to run
!in a CCPP physics suite:
Expand Down
13 changes: 12 additions & 1 deletion test/unit/test_cam_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,20 @@ def test_xml_nml_file(self):
#Create new, expected dictionary:
xml_fil_list = OrderedDict()

#This file will always be present:
#Create path to "src/data" directory:
data_path = os.path.join(CAM_CONF_DIR, os.pardir,
"src", "data")

#These files will always be present:
xml_fil_list['namelist_definition_cam.xml'] = os.path.join(CAM_CONF_DIR,
'namelist_definition_cam.xml')
xml_fil_list['namelist_definition_physconst.xml'] = os.path.join(data_path,
'namelist_definition_physconst.xml')
xml_fil_list['namelist_definition_air_comp.xml'] = os.path.join(data_path,
'namelist_definition_air_comp.xml')
xml_fil_list['namelist_definition_ref_pres.xml'] = os.path.join(data_path,
'namelist_definition_ref_pres.xml')

#This is the file being added:
xml_fil_list['test_file.xml'] = '/fake/path/test_file.xml'

Expand Down

0 comments on commit a6f9d49

Please sign in to comment.