Skip to content

Commit

Permalink
Merge pull request #2 from climbfuji/ruclsm_dom_mods
Browse files Browse the repository at this point in the history
RUC LSM - Dom's mods
  • Loading branch information
tanyasmirnova authored Oct 12, 2018
2 parents f87dcb6 + 000b913 commit 5044180
Show file tree
Hide file tree
Showing 11 changed files with 509 additions and 20 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (OPENMP)
include(detect_openmp)
detect_openmp()
set (CMAKE_Fortran_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_Fortran_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
message(STATUS "Enable OpenMP support for C/C++/Fortran compiler")
else (OPENMP)
Expand Down
5 changes: 4 additions & 1 deletion scripts/ccpp_prebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# *DH

# Local modules
from common import encode_container, decode_container, execute
from common import encode_container, decode_container, execute, CCPP_INTERNAL_VARIABLES
from metadata_parser import merge_dictionaries, parse_scheme_tables, parse_variable_tables
from mkcap import Cap, CapsMakefile, CapsCMakefile, SchemesMakefile, SchemesCMakefile
from mkdoc import metadata_to_html, metadata_to_latex
Expand Down Expand Up @@ -375,6 +375,9 @@ def create_ccpp_field_add_statements(metadata, pset, ccpp_data_structure):
# Important - adding the variables sorted is key to using hard-coded
# indices for faster retrieval of variables from cdata via ccpp_field_get
for var_name in sorted(metadata.keys()):
# Skip CCPP internal variables, these are treated differently
if var_name in CCPP_INTERNAL_VARIABLES.keys():
continue
# Add variable with var_name = standard_name once
logging.debug('Generating ccpp_field_add statement for variable {0}'.format(var_name))
var = metadata[var_name][0]
Expand Down
31 changes: 25 additions & 6 deletions scripts/ccpp_prebuild_config_FV3.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
'ccpp/physics/physics/module_nst_model.f90',
'ccpp/physics/physics/module_nst_parameters.f90',
'ccpp/physics/physics/module_nst_water_prop.f90',
# 'ccpp/physics/physics/module_mp_thompson_hrrr_radar.F90',
# 'ccpp/physics/physics/module_mp_thompson_hrrr.F90',
'ccpp/physics/physics/module_mp_thompson_hrrr_radar.F90',
'ccpp/physics/physics/module_mp_thompson_hrrr.F90',
'ccpp/physics/physics/namelist_soilveg.f',
'ccpp/physics/physics/num_parthds.F',
'ccpp/physics/physics/ozne_def.f',
Expand All @@ -58,6 +58,8 @@
'ccpp/physics/physics/sflx.f',
'ccpp/physics/physics/set_soilveg.f',
'ccpp/physics/physics/surface_perturbation.F90',
'ccpp/physics/physics/cu_gf_deep.F90',
'ccpp/physics/physics/cu_gf_sh.F90',
'ccpp/physics/physics/tridi.f',
'ccpp/physics/physics/wam_f107_kp_mod.f90',
'ccpp/physics/physics/module_sf_ruclsm.F90',
Expand Down Expand Up @@ -118,6 +120,7 @@
'ccpp/physics/physics/GFS_time_vary_pre.fv3.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/cnvc90.f' : [ 'slow_physics' ],
'ccpp/physics/physics/dcyc2.f' : [ 'slow_physics' ],
'ccpp/physics/physics/gcm_shoc.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/get_prs_fv3.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/gfdl_cloud_microphys.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/gfdl_fv_sat_adj.F90' : [ 'fast_physics' ],
Expand All @@ -128,10 +131,16 @@
'ccpp/physics/physics/h2ophys.f' : [ 'slow_physics' ],
'ccpp/physics/physics/samfdeepcnv.f' : [ 'slow_physics' ],
'ccpp/physics/physics/samfshalcnv.f' : [ 'slow_physics' ],
'ccpp/physics/physics/cu_gf_driver_pre.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/cu_gf_driver.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/cu_gf_driver_post.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/moninedmf.f' : [ 'slow_physics' ],
# 'ccpp/physics/physics/mp_thompson_hrrr.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/moninshoc.f' : [ 'slow_physics' ],
'ccpp/physics/physics/mp_thompson_hrrr_pre.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/mp_thompson_hrrr.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/mp_thompson_hrrr_post.F90' : [ 'slow_physics' ],
'ccpp/physics/physics/ozphys.f' : [ 'slow_physics' ],
'ccpp/physics/physics/ozphys_2015.f' : [ 'slow_physics' ],
'ccpp/physics/physics/ozphys_2015.f' : [ 'slow_physics' ],
'ccpp/physics/physics/precpd.f' : [ 'slow_physics' ],
'ccpp/physics/physics/radlw_main.f' : [ 'slow_physics' ],
'ccpp/physics/physics/radsw_main.f' : [ 'slow_physics' ],
Expand Down Expand Up @@ -212,20 +221,30 @@
},
'mp_thompson_hrrr' : {
'mp_thompson_hrrr_init' : [
'tendency_of_water_friendly_surface_aerosols_at_surface',
'tendency_of_water_friendly_aerosols_at_surface',
'tendency_of_ice_friendly_aerosols_at_surface',
'water_friendly_aerosol_number_concentration',
'ice_friendly_aerosol_number_concentration',
],
'mp_thompson_hrrr_run' : [
'cloud_droplet_number_concentration_updated_by_physics',
'water_friendly_aerosol_number_concentration_updated_by_physics',
'ice_friendly_aerosol_number_concentration_updated_by_physics',
'tendency_of_water_friendly_surface_aerosols_at_surface',
'tendency_of_water_friendly_aerosols_at_surface',
'tendency_of_ice_friendly_aerosols_at_surface',
'mean_effective_radius_for_liquid_cloud',
'mean_effective_radius_for_ice_cloud',
'mean_effective_radius_for_snow_flake',
],
},
'mp_thompson_hrrr_pre' : {
'mp_thompson_hrrr_pre_run' : [
'water_friendly_aerosol_number_concentration_updated_by_physics',
'ice_friendly_aerosol_number_concentration_updated_by_physics',
'tendency_of_water_friendly_aerosols_at_surface',
'tendency_of_ice_friendly_aerosols_at_surface',
],
},
'memcheck' : {
'memcheck_run' : [ 'mpi_root' ],
},
Expand Down
3 changes: 2 additions & 1 deletion scripts/ccpp_prebuild_config_SCM.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
'ccpp-physics/physics/GFS_time_vary_pre.scm.F90' : ['physics'],
'ccpp-physics/physics/cnvc90.f' : ['physics'],
'ccpp-physics/physics/dcyc2.f' : ['physics'],
'ccpp-physics/physics/gcm_shoc.F90' : ['physics'],
'ccpp-physics/physics/get_prs_fv3.F90' : ['physics'],
'ccpp-physics/physics/gfdl_cloud_microphys.F90' : ['physics'],
'ccpp-physics/physics/gscond.f' : ['physics'],
Expand All @@ -89,6 +90,7 @@
'ccpp-physics/physics/samfdeepcnv.f' : ['physics'],
'ccpp-physics/physics/samfshalcnv.f' : ['physics'],
'ccpp-physics/physics/moninedmf.f' : ['physics'],
'ccpp-physics/physics/moninshoc.f' : ['physics'],
'ccpp-physics/physics/ozphys.f' : ['physics'],
'ccpp-physics/physics/ozphys_2015.f' : ['physics'],
'ccpp-physics/physics/precpd.f' : ['physics'],
Expand All @@ -103,7 +105,6 @@
'ccpp-physics/physics/sfc_diag_post.F90' : ['physics'],
'ccpp-physics/physics/sfc_diff.f' : ['physics'],
'ccpp-physics/physics/sfc_drv.f' : ['physics'],
'ccpp-physics/physics/sfc_drv_ruc.F90' : ['physics'],
'ccpp-physics/physics/sfc_nst.f' : ['physics'],
'ccpp-physics/physics/sfc_sice.f' : ['physics'],
'ccpp-physics/physics/gmtb_scm_sfc_flux_spec.F90' : ['physics'],
Expand Down
10 changes: 8 additions & 2 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import subprocess

CCPP_ERROR_FLAG_VARIABLE = 'ccpp_error_flag'
CCPP_ERROR_MSG_VARIABLE = 'ccpp_error_message'
CCPP_LOOP_COUNTER = 'ccpp_loop_counter'
CCPP_ERROR_MSG_VARIABLE = 'ccpp_error_message'
CCPP_LOOP_COUNTER = 'ccpp_loop_counter'

CCPP_INTERNAL_VARIABLES = {
CCPP_ERROR_FLAG_VARIABLE : 'cdata%errflg',
CCPP_ERROR_MSG_VARIABLE : 'cdata%errmsg',
CCPP_LOOP_COUNTER : 'cdata%loop_cnt',
}

def execute(cmd, abort = True):
"""Runs a local command in a shell. Waits for completion and
Expand Down
23 changes: 15 additions & 8 deletions scripts/mkcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import xml.etree.ElementTree as ET

from common import CCPP_ERROR_FLAG_VARIABLE
from common import CCPP_INTERNAL_VARIABLES

###############################################################################

Expand Down Expand Up @@ -188,13 +189,11 @@ def print_get(self, index=0):
call ccpp_field_get(cdata, '{s.standard_name}', {s.local_name}, ierr=ierr, kind=ckind{index_string})
#ifdef DEBUG
if (ierr /= 0) then
write(cdata%errmsg,'(a)') 'Unable to retrieve {s.standard_name} from CCPP data structure'
!call ccpp_error('Unable to retrieve {s.standard_name} from CCPP data structure')
call ccpp_error('Unable to retrieve {s.standard_name} from CCPP data structure')
return
end if
if (kind({s.local_name}).ne.ckind) then
!call ccpp_error('Kind mismatch for variable {s.standard_name}')
write(cdata%errmsg,'(a)') 'Kind mismatch for variable {s.standard_name}'
call ccpp_error('Kind mismatch for variable {s.standard_name}')
ierr = 1
return
end if
Expand Down Expand Up @@ -258,6 +257,8 @@ def print_add(self, ccpp_data_structure, index=0):
for ccpp_field_get is not possible, since the ccpp_field_add statements may be placed
inside OpenMP parallel regions.
If index (= location of variable in cdata structure) is supplied, pass to Fortran call.'''
# Index string to test that index generated by CCPP prebuild matches
# the actual index in the cdata lookup table
if index==0:
index_string = ''
else:
Expand Down Expand Up @@ -426,14 +427,20 @@ def write(self, module, module_use, data, ccpp_field_map):
subroutine_caps = sub_caps))

for sub in data.keys():
var_defs = "\n".join([" "*8 + x.print_def() for x in data[sub]])
# Treat CCPP internal variables differently: do not retrieve
# via ccpp_field_get, use them directly via cdata%...
# (configured in common.py, needs to match what is is ccpp_types.F90)
var_defs = "\n".join([" "*8 + x.print_def() for x in data[sub] if x.standard_name not in CCPP_INTERNAL_VARIABLES.keys()])
# Use lookup index in cdata from build time for faster retrieval
var_gets = "\n".join([x.print_get(ccpp_field_map[x.standard_name]) for x in data[sub]])
var_gets = "\n".join([x.print_get(ccpp_field_map[x.standard_name]) for x in data[sub]if x.standard_name not in CCPP_INTERNAL_VARIABLES.keys()])
# Split args so that lines don't exceed 260 characters (for PGI)
args = ''
length = 0
for x in data[sub]:
arg = "{0}={0},".format(x.local_name)
if x.standard_name in CCPP_INTERNAL_VARIABLES.keys():
arg = "{0}={1},".format(x.local_name, CCPP_INTERNAL_VARIABLES[x.standard_name])
else:
arg = "{0}={0},".format(x.local_name)
args += arg
length += len(arg)
if length > 70 and not x == data[sub][-1]:
Expand All @@ -444,7 +451,7 @@ def write(self, module, module_use, data, ccpp_field_map):
ierr_assign = ''
for x in data[sub]:
if x.standard_name == CCPP_ERROR_FLAG_VARIABLE:
ierr_assign = 'ierr={x.local_name}'.format(x=x)
ierr_assign = 'ierr={0}'.format(CCPP_INTERNAL_VARIABLES[CCPP_ERROR_FLAG_VARIABLE])
break
# Write to scheme cap
f.write(Cap.sub.format(subroutine=sub,
Expand Down
91 changes: 91 additions & 0 deletions suites/suite_FV3_CPT_adv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="FV3_CPT_advanced" lib="ccppphys" ver="2">
<!-- <init></init> -->
<group name="time_vary">
<subcycle loop="1">
<scheme>GFS_time_vary_pre</scheme>
<scheme>GFS_rrtmg_setup</scheme>
<scheme>GFS_rad_time_vary</scheme>
<scheme>GFS_phys_time_vary</scheme>
<scheme>stochastic_physics</scheme>
<scheme>stochastic_physics_sfc</scheme>
</subcycle>
</group>
<group name="radiation">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_rad_reset</scheme>
<scheme>GFS_rrtmg_pre</scheme>
<scheme>rrtmg_sw_pre</scheme>
<scheme>rrtmg_sw</scheme>
<scheme>rrtmg_sw_post</scheme>
<scheme>rrtmg_lw_pre</scheme>
<scheme>rrtmg_lw</scheme>
<scheme>rrtmg_lw_post</scheme>
<scheme>GFS_rrtmg_post</scheme>
</subcycle>
</group>
<group name="physics">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_phys_reset</scheme>
<scheme>GFS_suite_stateout_reset</scheme>
<scheme>get_prs_fv3</scheme>
<scheme>GFS_suite_interstitial_1</scheme>
<scheme>dcyc2t3</scheme>
<scheme>GFS_surface_generic_pre</scheme>
<scheme>GFS_suite_interstitial_2</scheme>
</subcycle>
<!-- Surface iteration loop -->
<subcycle loop="2">
<scheme>sfc_ex_coef</scheme>
<scheme>GFS_surface_loop_control_part1</scheme>
<scheme>sfc_nst_pre</scheme>
<scheme>sfc_nst</scheme>
<scheme>sfc_nst_post</scheme>
<scheme>lsm_noah</scheme>
<scheme>sfc_sice</scheme>
<scheme>GFS_surface_loop_control_part2</scheme>
</subcycle>
<!-- End of surface iteration loop -->
<subcycle loop="1">
<scheme>dcyc2t3_post</scheme>
<scheme>sfc_diag</scheme>
<scheme>sfc_diag_post</scheme>
<scheme>GFS_surface_generic_post</scheme>
<scheme>GFS_PBL_generic_pre</scheme>
<scheme>moninshoc</scheme>
<scheme>GFS_PBL_generic_post</scheme>
<scheme>gwdps_pre</scheme>
<scheme>gwdps</scheme>
<scheme>gwdps_post</scheme>
<scheme>rayleigh_damp</scheme>
<scheme>GFS_suite_stateout_update</scheme>
<scheme>ozphys_2015</scheme>
<scheme>h2ophys</scheme>
<scheme>GFS_DCNV_generic_pre</scheme>
<scheme>get_phi_fv3</scheme>
<scheme>GFS_suite_interstitial_3</scheme>
<scheme>shoc</scheme>
<scheme>samfdeepcnv</scheme>
<scheme>GFS_DCNV_generic_post</scheme>
<scheme>gwdc_pre</scheme>
<scheme>gwdc</scheme>
<scheme>gwdc_post</scheme>
<!-- <scheme>GFS_SCNV_generic_pre</scheme>
<scheme>samfshalcnv</scheme>
<scheme>samfshalcnv_post</scheme>
<scheme>GFS_SCNV_generic_post</scheme> -->
<scheme>GFS_suite_interstitial_4</scheme>
<scheme>cnvc90</scheme>
<scheme>GFS_MP_generic_pre</scheme>
<scheme>GFS_MP_generic_post</scheme>
<scheme>sfc_sice_post</scheme>
</subcycle>
</group>
<group name="stochastics">
<subcycle loop="1">
<scheme>GFS_stochastics</scheme>
</subcycle>
</group>
<!-- <finalize></finalize> -->
</suite>
Loading

0 comments on commit 5044180

Please sign in to comment.