From b96f38dd0e8bebfe386dd9decb177f5fa5ca6416 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 25 Oct 2021 06:43:55 -0600 Subject: [PATCH] Debug array alloc ccpp caps (#407) This PR and associated PRs for ccpp-framework and ccpp-physics -enable debugging features in auto-generated CCPP physics caps -cleanup variables for Ferrier-Aligo and RRTMGP in GFS_typedefs.{F90,meta} -contain bugfixes for multigases array dimensions in CCPP_typedefs.{F90,meta} -and contain additional bug fixes in CCPP metadata in GFS_typedefs.{F90,meta} --- ccpp/CMakeLists.txt | 5 +- ccpp/data/CCPP_typedefs.F90 | 12 ++-- ccpp/data/CCPP_typedefs.meta | 3 +- ccpp/data/GFS_typedefs.F90 | 76 ++++++------------------- ccpp/data/GFS_typedefs.meta | 107 ++++++----------------------------- ccpp/framework | 2 +- ccpp/physics | 2 +- 7 files changed, 49 insertions(+), 158 deletions(-) diff --git a/ccpp/CMakeLists.txt b/ccpp/CMakeLists.txt index b614e099f..eda2180d7 100644 --- a/ccpp/CMakeLists.txt +++ b/ccpp/CMakeLists.txt @@ -20,7 +20,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/framework/cmake") #------------------------------------------------------------------------------ # Call to CCPP code generator if(DEBUG) + # Enable debugging features in auto-generated physics caps set(_ccpp_debug_arg "--debug") + # Enable verbose output from ccpp_prebuild.py + set(_ccpp_verbose_arg "--verbose") endif() if(DEFINED CCPP_SUITES) set(_ccpp_suites_arg "--suites=${CCPP_SUITES}") @@ -31,7 +34,7 @@ endif() execute_process(COMMAND ${Python_EXECUTABLE} "framework/scripts/ccpp_prebuild.py" "--config=config/ccpp_prebuild_config.py" - "--builddir=${CMAKE_CURRENT_BINARY_DIR}" ${_ccpp_suites_arg} ${_ccpp_debug_arg} + "--builddir=${CMAKE_CURRENT_BINARY_DIR}" ${_ccpp_suites_arg} ${_ccpp_debug_arg} ${_ccpp_verbose_arg} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.out ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.err diff --git a/ccpp/data/CCPP_typedefs.F90 b/ccpp/data/CCPP_typedefs.F90 index 7cd287b5d..01695bc4a 100644 --- a/ccpp/data/CCPP_typedefs.F90 +++ b/ccpp/data/CCPP_typedefs.F90 @@ -219,18 +219,18 @@ subroutine interstitial_create (Interstitial, is, ie, isd, ied, js, je, jsd, jed ! For multi-gases physics Interstitial%nwat = nwat ! If ngas, rilist and cpilist are present, then - ! multi-gases physics are used. If not, set ngas=1 + ! multi-gases physics are used. If not, set ngas=0 ! (safe value), allocate rilist/cpilist and set to zero if(present(ngas)) then Interstitial%ngas = ngas else - Interstitial%ngas = 1 + Interstitial%ngas = 0 end if - allocate(Interstitial%rilist(1:Interstitial%ngas)) - allocate(Interstitial%cpilist(1:Interstitial%ngas)) + allocate(Interstitial%rilist(0:Interstitial%ngas)) + allocate(Interstitial%cpilist(0:Interstitial%ngas)) if (present(rilist)) then - Interstitial%rilist = rilist(1:Interstitial%ngas) - Interstitial%cpilist = cpilist(1:Interstitial%ngas) + Interstitial%rilist = rilist(0:Interstitial%ngas) + Interstitial%cpilist = cpilist(0:Interstitial%ngas) else Interstitial%rilist = 0.0 Interstitial%cpilist = 0.0 diff --git a/ccpp/data/CCPP_typedefs.meta b/ccpp/data/CCPP_typedefs.meta index 60c9420c1..ed0fd63cf 100644 --- a/ccpp/data/CCPP_typedefs.meta +++ b/ccpp/data/CCPP_typedefs.meta @@ -228,9 +228,10 @@ standard_name = gas_tracers_for_multi_gas_physics_at_Lagrangian_surface long_name = gas tracers for multi gas physics at Lagrangian surface units = kg kg-1 - dimensions = (starting_x_direction_index_domain:ending_x_direction_index_domain,starting_y_direction_index_domain:ending_y_direction_index_domain,1:vertical_dimension_for_fast_physics,1:number_of_gases_for_multi_gases_physics) + dimensions = (starting_x_direction_index_domain:ending_x_direction_index_domain,starting_y_direction_index_domain:ending_y_direction_index_domain,1:vertical_dimension_for_fast_physics,0:number_of_gases_for_multi_gases_physics) type = real kind = kind_dyn + active = (number_of_gases_for_multi_gases_physics > 0) [qv] standard_name = water_vapor_specific_humidity_at_Lagrangian_surface long_name = water vapor specific humidity updated by fast physics at Lagrangian surface diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index 4d8bfed3b..242834936 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -739,7 +739,7 @@ module GFS_typedefs integer :: rrtmgp_nrghice !< Number of ice-roughness categories integer :: rrtmgp_nGauss_ang !< Number of angles used in Gaussian quadrature logical :: do_GPsw_Glw !< If set to true use rrtmgp for SW calculation, rrtmg for LW. - character(len=128) :: active_gases_array(100) !< character array for each trace gas name + character(len=128), pointer :: active_gases_array(:) => null() !< character array for each trace gas name logical :: use_LW_jacobian !< If true, use Jacobian of LW to update radiation tendency. logical :: damp_LW_fluxadj !< If true, damp the LW flux adjustment using the Jacobian w/ height with logistic function real(kind_phys) :: lfnc_k !< Logistic function transition depth (Pa) @@ -1153,8 +1153,8 @@ module GFS_typedefs integer :: n_var_lndp logical :: lndp_each_step ! flag to indicate that land perturbations are applied at every time step, ! otherwise they are applied only after gcycle is run - character(len=3) :: lndp_var_list(6) ! dimension here must match n_var_max_lndp in stochy_nml_def - real(kind=kind_phys) :: lndp_prt_list(6) ! dimension here must match n_var_max_lndp in stochy_nml_def + character(len=3) , pointer :: lndp_var_list(:) ! dimension here must match n_var_max_lndp in stochy_nml_def + real(kind=kind_phys), pointer :: lndp_prt_list(:) ! dimension here must match n_var_max_lndp in stochy_nml_def ! also previous code had dimension 5 for each pert, to allow ! multiple patterns. It wasn't fully coded (and wouldn't have worked ! with nlndp>1, so I just dropped it). If we want to code it properly, @@ -2165,7 +2165,6 @@ module GFS_typedefs real (kind=kind_phys), pointer :: sfc_alb_uvvis_dif(:,:) => null() !< real (kind=kind_phys), pointer :: toa_src_lw(:,:) => null() !< real (kind=kind_phys), pointer :: toa_src_sw(:,:) => null() !< - character(len=128), pointer :: active_gases_array(:) => null() !< Character array for each trace gas name integer, pointer :: icseed_lw(:) => null() !< RRTMGP seed for RNG for longwave radiation integer, pointer :: icseed_sw(:) => null() !< RRTMGP seed for RNG for shortwave radiation type(proflw_type), pointer :: flxprf_lw(:,:) => null() !< DDT containing RRTMGP longwave fluxes @@ -2185,26 +2184,12 @@ module GFS_typedefs type(ty_gas_concs) :: gas_concentrations !< RRTMGP DDT type(ty_source_func_lw) :: sources !< RRTMGP DDT - !-- HWRF physics: dry mixing ratios - real (kind=kind_phys), pointer :: qv_r(:,:) => null() !< - real (kind=kind_phys), pointer :: qc_r(:,:) => null() !< - real (kind=kind_phys), pointer :: qi_r(:,:) => null() !< - real (kind=kind_phys), pointer :: qr_r(:,:) => null() !< - real (kind=kind_phys), pointer :: qs_r(:,:) => null() !< - real (kind=kind_phys), pointer :: qg_r(:,:) => null() !< - !-- GSL drag suite real (kind=kind_phys), pointer :: varss(:) => null() !< real (kind=kind_phys), pointer :: ocss(:) => null() !< real (kind=kind_phys), pointer :: oa4ss(:,:) => null() !< real (kind=kind_phys), pointer :: clxss(:,:) => null() !< - !-- Ferrier-Aligo MP scheme - real (kind=kind_phys), pointer :: f_rain (:,:) => null() !< - real (kind=kind_phys), pointer :: f_ice (:,:) => null() !< - real (kind=kind_phys), pointer :: f_rimef (:,:) => null() !< - real (kind=kind_phys), pointer :: cwm (:,:) => null() !< - !-- 3D diagnostics integer :: rtg_ozone_index, rtg_tke_index @@ -3010,7 +2995,7 @@ subroutine coupling_create (Coupling, IM, Model) endif !--- stochastic land perturbation option - if (Model%lndp_type .NE. 0) then + if (Model%lndp_type /= 0) then allocate (Coupling%sfc_wts (IM,Model%n_var_lndp)) Coupling%sfc_wts = clear_val endif @@ -3964,6 +3949,13 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & Model%do_GPsw_Glw = do_GPsw_Glw Model%active_gases = active_gases Model%ngases = nGases + if (Model%do_RRTMGP) then + allocate (Model%active_gases_array(Model%nGases)) + ! Reset, will be populated by RRTMGP + do ipat=1,Model%nGases + Model%active_gases_array(ipat) = '' + enddo + endif Model%rrtmgp_root = rrtmgp_root Model%lw_file_gas = lw_file_gas Model%lw_file_clouds = lw_file_clouds @@ -4420,10 +4412,16 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & Model%use_zmtnblck = use_zmtnblck Model%do_shum = do_shum Model%do_skeb = do_skeb + !--- stochastic surface perturbation options Model%lndp_type = lndp_type Model%n_var_lndp = n_var_lndp Model%lndp_each_step = lndp_each_step - + if (Model%lndp_type/=0) then + allocate(Model%lndp_var_list(Model%n_var_lndp)) + allocate(Model%lndp_prt_list(Model%n_var_lndp)) + Model%lndp_var_list(:) = '' + Model%lndp_prt_list(:) = clear_val + end if !--- cellular automata options ! force namelist constsitency allocate(Model%vfact_ca(levs)) @@ -7200,7 +7198,6 @@ subroutine interstitial_create (Interstitial, IM, Model) allocate (Interstitial%sfc_alb_uvvis_dif (Model%rrtmgp_nBandsSW,IM)) allocate (Interstitial%toa_src_sw (IM,Model%rrtmgp_nGptsSW)) allocate (Interstitial%toa_src_lw (IM,Model%rrtmgp_nGptsLW)) - allocate (Interstitial%active_gases_array (Model%nGases)) ! ! gas_concentrations (ty_gas_concs) ! @@ -7328,21 +7325,6 @@ subroutine interstitial_create (Interstitial, IM, Model) allocate (Interstitial%cnv_ndrop (IM,Model%levs)) allocate (Interstitial%cnv_nice (IM,Model%levs)) end if - if (Model%imp_physics == Model%imp_physics_fer_hires) then - !--- if HWRF physics? - allocate (Interstitial%qv_r (IM,Model%levs)) - allocate (Interstitial%qc_r (IM,Model%levs)) - allocate (Interstitial%qi_r (IM,Model%levs)) - allocate (Interstitial%qr_r (IM,Model%levs)) - allocate (Interstitial%qs_r (IM,Model%levs)) - allocate (Interstitial%qg_r (IM,Model%levs)) - - !--- Ferrier-Aligo MP scheme - allocate (Interstitial%f_ice (IM,Model%levs)) - allocate (Interstitial%f_rain (IM,Model%levs)) - allocate (Interstitial%f_rimef (IM,Model%levs)) - allocate (Interstitial%cwm (IM,Model%levs)) - end if if (Model%do_shoc) then if (.not. associated(Interstitial%qrn)) allocate (Interstitial%qrn (IM,Model%levs)) if (.not. associated(Interstitial%qsnw)) allocate (Interstitial%qsnw (IM,Model%levs)) @@ -7609,22 +7591,6 @@ subroutine interstitial_rad_reset (Interstitial, Model) Interstitial%tsfa = clear_val Interstitial%tsfg = clear_val -! F-A scheme - if (Model%imp_physics == Model%imp_physics_fer_hires) then - Interstitial%qv_r = clear_val - Interstitial%qc_r = clear_val - Interstitial%qi_r = clear_val - Interstitial%qr_r = clear_val - Interstitial%qs_r = clear_val - Interstitial%qg_r = clear_val - if(Model%spec_adv) then - Interstitial%f_ice = clear_val - Interstitial%f_rain = clear_val - Interstitial%f_rimef = clear_val - Interstitial%cwm = clear_val - end if - end if - if (Model%do_RRTMGP) then Interstitial%tracer = clear_val Interstitial%tv_lay = clear_val @@ -7936,12 +7902,6 @@ subroutine interstitial_phys_reset (Interstitial, Model) Interstitial%cnv_ndrop = clear_val Interstitial%cnv_nice = clear_val end if - if (Model%imp_physics == Model%imp_physics_fer_hires .and. Model%spec_adv) then - Interstitial%f_ice = clear_val - Interstitial%f_rain = clear_val - Interstitial%f_rimef = clear_val - Interstitial%cwm = clear_val - end if if (Model%do_shoc) then Interstitial%qrn = clear_val Interstitial%qsnw = clear_val diff --git a/ccpp/data/GFS_typedefs.meta b/ccpp/data/GFS_typedefs.meta index 40ea9cb7f..847c20884 100644 --- a/ccpp/data/GFS_typedefs.meta +++ b/ccpp/data/GFS_typedefs.meta @@ -1855,6 +1855,7 @@ dimensions = (horizontal_loop_extent) type = real kind = kind_phys + active = (flag_for_chemistry_coupling) [snow_cpl] standard_name = cumulative_lwe_thickness_of_snow_amount_for_coupling long_name = total snow precipitation @@ -2284,7 +2285,7 @@ dimensions = (horizontal_loop_extent,number_of_perturbed_land_surface_variables) type = real kind = kind_phys - active = (control_for_stochastic_land_surface_perturbation .ne. 0) + active = (control_for_stochastic_land_surface_perturbation /= 0) [nwfa2d] standard_name = tendency_of_hygroscopic_aerosols_at_surface_adjacent_layer long_name = instantaneous water-friendly sfc aerosol source @@ -2333,6 +2334,7 @@ type = real kind = kind_phys active = (flag_for_chemistry_coupling) + ######################################################################## [ccpp-table-properties] name = GFS_control_type @@ -2879,6 +2881,14 @@ units = count dimensions = () type = integer +[active_gases_array] + standard_name = list_of_active_gases_used_by_RRTMGP + long_name = list of active gases used by RRTMGP + units = none + dimensions = (number_of_active_gases_used_by_RRTMGP) + type = character + kind = len=128 + active = (flag_for_rrtmgp_radiation_scheme) [rrtmgp_root] standard_name = directory_for_rte_rrtmgp_source_code long_name = directory for rte+rrtmgp source code (Model%rrtmgp_root) @@ -4545,6 +4555,7 @@ dimensions = (number_of_perturbed_land_surface_variables) type = real kind = kind_phys + active = (control_for_stochastic_land_surface_perturbation /= 0) [lndp_var_list] standard_name = land_surface_perturbation_variables long_name = variables to be perturbed for landperts @@ -4552,6 +4563,7 @@ dimensions = (number_of_perturbed_land_surface_variables) type = character kind = len=3 + active = (control_for_stochastic_land_surface_perturbation /= 0) [ntrac] standard_name = number_of_tracers long_name = number of tracers @@ -6921,7 +6933,7 @@ standard_name = cumulative_change_of_state_variables long_name = diagnostic tendencies for state variables units = various - dimensions = (horizontal_loop_extent,vertical_layer_dimension,number_of_cumulative_change_processes) + dimensions = (horizontal_loop_extent,vertical_layer_dimension,cumulative_change_of_state_variables_outer_index_max) type = real kind = kind_phys active = (flag_for_diagnostics_3D) @@ -6981,6 +6993,7 @@ dimensions = (horizontal_loop_extent,vertical_layer_dimension) type = real kind = kind_phys + active = (flag_for_tracer_diagnostics_3D) [dwn_mf] standard_name = cumulative_atmosphere_downdraft_convective_mass_flux long_name = cumulative downdraft mass flux @@ -6988,6 +7001,7 @@ dimensions = (horizontal_loop_extent,vertical_layer_dimension) type = real kind = kind_phys + active = (flag_for_tracer_diagnostics_3D) [det_mf] standard_name = cumulative_atmosphere_detrainment_convective_mass_flux long_name = cumulative detrainment mass flux @@ -6995,6 +7009,7 @@ dimensions = (horizontal_loop_extent,vertical_layer_dimension) type = real kind = kind_phys + active = (flag_for_tracer_diagnostics_3D) [refl_10cm] standard_name = radar_reflectivity_10cm long_name = instantaneous refl_10cm @@ -7433,86 +7448,6 @@ [ccpp-arg-table] name = GFS_interstitial_type type = ddt -[qv_r] - standard_name = humidity_mixing_ratio - long_name = the ratio of the mass of water vapor to the mass of dry air - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[qc_r] - standard_name = cloud_liquid_water_mixing_ratio_interstitial - long_name = the ratio of the mass of liquid water to the mass of dry air - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[qr_r] - standard_name = cloud_rain_water_mixing_ratio - long_name = the ratio of the mass rain water to the mass of dry air - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[qi_r] - standard_name = cloud_ice_mixing_ratio_interstitial - long_name = the ratio of the mass of ice to the mass of dry air - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[qs_r] - standard_name = cloud_snow_mixing_ratio - long_name = the ratio of the mass of snow to mass of dry air - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[qg_r] - standard_name = mass_weighted_rime_factor_mixing_ratio - long_name = the ratio of the mass of rime factor to mass of dry air - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[f_ice] - standard_name = fraction_of_ice_water_cloud - long_name = fraction of ice water cloud - units = frac - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[f_rain] - standard_name = fraction_of_rain_water_cloud - long_name = fraction of rain water cloud - units = frac - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[f_rimef] - standard_name = rime_factor - long_name = rime factor - units = frac - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) -[cwm] - standard_name = total_cloud_condensate_mixing_ratio_updated_by_physics - long_name = total cloud condensate mixing ratio (except water vapor) updated by physics - units = kg kg-1 - dimensions = (horizontal_loop_extent,vertical_layer_dimension) - type = real - kind = kind_phys - active = (control_for_microphysics_scheme == identifier_for_fer_hires_microphysics_scheme) [adjsfculw_water] standard_name = surface_upwelling_longwave_flux_over_water long_name = surface upwelling longwave flux at current time over water @@ -10483,14 +10418,6 @@ type = real kind = kind_phys active = (flag_for_rrtmgp_radiation_scheme) -[active_gases_array] - standard_name = list_of_active_gases_used_by_RRTMGP - long_name = list of active gases used by RRTMGP - units = none - dimensions = (number_of_active_gases_used_by_RRTMGP) - type = character - kind = len=128 - active = (flag_for_rrtmgp_radiation_scheme) [rtg_ozone_index] standard_name = vertically_diffused_tracer_index_of_ozone long_name = number of tracers diff --git a/ccpp/framework b/ccpp/framework index 6874fc9b4..f7a4af8c4 160000 --- a/ccpp/framework +++ b/ccpp/framework @@ -1 +1 @@ -Subproject commit 6874fc9b49237b70df7af9b513ea10df697c27d6 +Subproject commit f7a4af8c4a322b0a75e0eb3896512522bca6cfa9 diff --git a/ccpp/physics b/ccpp/physics index b12e6c328..7d7b3bcc4 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit b12e6c3280804fe04e4256654c35602cc930d5cd +Subproject commit 7d7b3bcc4b8009ef3491bd230b31bf5af5910bb5