Skip to content

Commit b96f38d

Browse files
authored
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}
1 parent 43c0982 commit b96f38d

7 files changed

+49
-158
lines changed

ccpp/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/framework/cmake")
2020
#------------------------------------------------------------------------------
2121
# Call to CCPP code generator
2222
if(DEBUG)
23+
# Enable debugging features in auto-generated physics caps
2324
set(_ccpp_debug_arg "--debug")
25+
# Enable verbose output from ccpp_prebuild.py
26+
set(_ccpp_verbose_arg "--verbose")
2427
endif()
2528
if(DEFINED CCPP_SUITES)
2629
set(_ccpp_suites_arg "--suites=${CCPP_SUITES}")
@@ -31,7 +34,7 @@ endif()
3134
execute_process(COMMAND ${Python_EXECUTABLE}
3235
"framework/scripts/ccpp_prebuild.py"
3336
"--config=config/ccpp_prebuild_config.py"
34-
"--builddir=${CMAKE_CURRENT_BINARY_DIR}" ${_ccpp_suites_arg} ${_ccpp_debug_arg}
37+
"--builddir=${CMAKE_CURRENT_BINARY_DIR}" ${_ccpp_suites_arg} ${_ccpp_debug_arg} ${_ccpp_verbose_arg}
3538
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
3639
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.out
3740
ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.err

ccpp/data/CCPP_typedefs.F90

+6-6
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,18 @@ subroutine interstitial_create (Interstitial, is, ie, isd, ied, js, je, jsd, jed
219219
! For multi-gases physics
220220
Interstitial%nwat = nwat
221221
! If ngas, rilist and cpilist are present, then
222-
! multi-gases physics are used. If not, set ngas=1
222+
! multi-gases physics are used. If not, set ngas=0
223223
! (safe value), allocate rilist/cpilist and set to zero
224224
if(present(ngas)) then
225225
Interstitial%ngas = ngas
226226
else
227-
Interstitial%ngas = 1
227+
Interstitial%ngas = 0
228228
end if
229-
allocate(Interstitial%rilist(1:Interstitial%ngas))
230-
allocate(Interstitial%cpilist(1:Interstitial%ngas))
229+
allocate(Interstitial%rilist(0:Interstitial%ngas))
230+
allocate(Interstitial%cpilist(0:Interstitial%ngas))
231231
if (present(rilist)) then
232-
Interstitial%rilist = rilist(1:Interstitial%ngas)
233-
Interstitial%cpilist = cpilist(1:Interstitial%ngas)
232+
Interstitial%rilist = rilist(0:Interstitial%ngas)
233+
Interstitial%cpilist = cpilist(0:Interstitial%ngas)
234234
else
235235
Interstitial%rilist = 0.0
236236
Interstitial%cpilist = 0.0

ccpp/data/CCPP_typedefs.meta

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@
228228
standard_name = gas_tracers_for_multi_gas_physics_at_Lagrangian_surface
229229
long_name = gas tracers for multi gas physics at Lagrangian surface
230230
units = kg kg-1
231-
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)
231+
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)
232232
type = real
233233
kind = kind_dyn
234+
active = (number_of_gases_for_multi_gases_physics > 0)
234235
[qv]
235236
standard_name = water_vapor_specific_humidity_at_Lagrangian_surface
236237
long_name = water vapor specific humidity updated by fast physics at Lagrangian surface

ccpp/data/GFS_typedefs.F90

+18-58
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ module GFS_typedefs
739739
integer :: rrtmgp_nrghice !< Number of ice-roughness categories
740740
integer :: rrtmgp_nGauss_ang !< Number of angles used in Gaussian quadrature
741741
logical :: do_GPsw_Glw !< If set to true use rrtmgp for SW calculation, rrtmg for LW.
742-
character(len=128) :: active_gases_array(100) !< character array for each trace gas name
742+
character(len=128), pointer :: active_gases_array(:) => null() !< character array for each trace gas name
743743
logical :: use_LW_jacobian !< If true, use Jacobian of LW to update radiation tendency.
744744
logical :: damp_LW_fluxadj !< If true, damp the LW flux adjustment using the Jacobian w/ height with logistic function
745745
real(kind_phys) :: lfnc_k !< Logistic function transition depth (Pa)
@@ -1153,8 +1153,8 @@ module GFS_typedefs
11531153
integer :: n_var_lndp
11541154
logical :: lndp_each_step ! flag to indicate that land perturbations are applied at every time step,
11551155
! otherwise they are applied only after gcycle is run
1156-
character(len=3) :: lndp_var_list(6) ! dimension here must match n_var_max_lndp in stochy_nml_def
1157-
real(kind=kind_phys) :: lndp_prt_list(6) ! dimension here must match n_var_max_lndp in stochy_nml_def
1156+
character(len=3) , pointer :: lndp_var_list(:) ! dimension here must match n_var_max_lndp in stochy_nml_def
1157+
real(kind=kind_phys), pointer :: lndp_prt_list(:) ! dimension here must match n_var_max_lndp in stochy_nml_def
11581158
! also previous code had dimension 5 for each pert, to allow
11591159
! multiple patterns. It wasn't fully coded (and wouldn't have worked
11601160
! with nlndp>1, so I just dropped it). If we want to code it properly,
@@ -2165,7 +2165,6 @@ module GFS_typedefs
21652165
real (kind=kind_phys), pointer :: sfc_alb_uvvis_dif(:,:) => null() !<
21662166
real (kind=kind_phys), pointer :: toa_src_lw(:,:) => null() !<
21672167
real (kind=kind_phys), pointer :: toa_src_sw(:,:) => null() !<
2168-
character(len=128), pointer :: active_gases_array(:) => null() !< Character array for each trace gas name
21692168
integer, pointer :: icseed_lw(:) => null() !< RRTMGP seed for RNG for longwave radiation
21702169
integer, pointer :: icseed_sw(:) => null() !< RRTMGP seed for RNG for shortwave radiation
21712170
type(proflw_type), pointer :: flxprf_lw(:,:) => null() !< DDT containing RRTMGP longwave fluxes
@@ -2185,26 +2184,12 @@ module GFS_typedefs
21852184
type(ty_gas_concs) :: gas_concentrations !< RRTMGP DDT
21862185
type(ty_source_func_lw) :: sources !< RRTMGP DDT
21872186

2188-
!-- HWRF physics: dry mixing ratios
2189-
real (kind=kind_phys), pointer :: qv_r(:,:) => null() !<
2190-
real (kind=kind_phys), pointer :: qc_r(:,:) => null() !<
2191-
real (kind=kind_phys), pointer :: qi_r(:,:) => null() !<
2192-
real (kind=kind_phys), pointer :: qr_r(:,:) => null() !<
2193-
real (kind=kind_phys), pointer :: qs_r(:,:) => null() !<
2194-
real (kind=kind_phys), pointer :: qg_r(:,:) => null() !<
2195-
21962187
!-- GSL drag suite
21972188
real (kind=kind_phys), pointer :: varss(:) => null() !<
21982189
real (kind=kind_phys), pointer :: ocss(:) => null() !<
21992190
real (kind=kind_phys), pointer :: oa4ss(:,:) => null() !<
22002191
real (kind=kind_phys), pointer :: clxss(:,:) => null() !<
22012192

2202-
!-- Ferrier-Aligo MP scheme
2203-
real (kind=kind_phys), pointer :: f_rain (:,:) => null() !<
2204-
real (kind=kind_phys), pointer :: f_ice (:,:) => null() !<
2205-
real (kind=kind_phys), pointer :: f_rimef (:,:) => null() !<
2206-
real (kind=kind_phys), pointer :: cwm (:,:) => null() !<
2207-
22082193
!-- 3D diagnostics
22092194
integer :: rtg_ozone_index, rtg_tke_index
22102195

@@ -3010,7 +2995,7 @@ subroutine coupling_create (Coupling, IM, Model)
30102995
endif
30112996

30122997
!--- stochastic land perturbation option
3013-
if (Model%lndp_type .NE. 0) then
2998+
if (Model%lndp_type /= 0) then
30142999
allocate (Coupling%sfc_wts (IM,Model%n_var_lndp))
30153000
Coupling%sfc_wts = clear_val
30163001
endif
@@ -3964,6 +3949,13 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
39643949
Model%do_GPsw_Glw = do_GPsw_Glw
39653950
Model%active_gases = active_gases
39663951
Model%ngases = nGases
3952+
if (Model%do_RRTMGP) then
3953+
allocate (Model%active_gases_array(Model%nGases))
3954+
! Reset, will be populated by RRTMGP
3955+
do ipat=1,Model%nGases
3956+
Model%active_gases_array(ipat) = ''
3957+
enddo
3958+
endif
39673959
Model%rrtmgp_root = rrtmgp_root
39683960
Model%lw_file_gas = lw_file_gas
39693961
Model%lw_file_clouds = lw_file_clouds
@@ -4420,10 +4412,16 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
44204412
Model%use_zmtnblck = use_zmtnblck
44214413
Model%do_shum = do_shum
44224414
Model%do_skeb = do_skeb
4415+
!--- stochastic surface perturbation options
44234416
Model%lndp_type = lndp_type
44244417
Model%n_var_lndp = n_var_lndp
44254418
Model%lndp_each_step = lndp_each_step
4426-
4419+
if (Model%lndp_type/=0) then
4420+
allocate(Model%lndp_var_list(Model%n_var_lndp))
4421+
allocate(Model%lndp_prt_list(Model%n_var_lndp))
4422+
Model%lndp_var_list(:) = ''
4423+
Model%lndp_prt_list(:) = clear_val
4424+
end if
44274425
!--- cellular automata options
44284426
! force namelist constsitency
44294427
allocate(Model%vfact_ca(levs))
@@ -7200,7 +7198,6 @@ subroutine interstitial_create (Interstitial, IM, Model)
72007198
allocate (Interstitial%sfc_alb_uvvis_dif (Model%rrtmgp_nBandsSW,IM))
72017199
allocate (Interstitial%toa_src_sw (IM,Model%rrtmgp_nGptsSW))
72027200
allocate (Interstitial%toa_src_lw (IM,Model%rrtmgp_nGptsLW))
7203-
allocate (Interstitial%active_gases_array (Model%nGases))
72047201
!
72057202
! gas_concentrations (ty_gas_concs)
72067203
!
@@ -7328,21 +7325,6 @@ subroutine interstitial_create (Interstitial, IM, Model)
73287325
allocate (Interstitial%cnv_ndrop (IM,Model%levs))
73297326
allocate (Interstitial%cnv_nice (IM,Model%levs))
73307327
end if
7331-
if (Model%imp_physics == Model%imp_physics_fer_hires) then
7332-
!--- if HWRF physics?
7333-
allocate (Interstitial%qv_r (IM,Model%levs))
7334-
allocate (Interstitial%qc_r (IM,Model%levs))
7335-
allocate (Interstitial%qi_r (IM,Model%levs))
7336-
allocate (Interstitial%qr_r (IM,Model%levs))
7337-
allocate (Interstitial%qs_r (IM,Model%levs))
7338-
allocate (Interstitial%qg_r (IM,Model%levs))
7339-
7340-
!--- Ferrier-Aligo MP scheme
7341-
allocate (Interstitial%f_ice (IM,Model%levs))
7342-
allocate (Interstitial%f_rain (IM,Model%levs))
7343-
allocate (Interstitial%f_rimef (IM,Model%levs))
7344-
allocate (Interstitial%cwm (IM,Model%levs))
7345-
end if
73467328
if (Model%do_shoc) then
73477329
if (.not. associated(Interstitial%qrn)) allocate (Interstitial%qrn (IM,Model%levs))
73487330
if (.not. associated(Interstitial%qsnw)) allocate (Interstitial%qsnw (IM,Model%levs))
@@ -7609,22 +7591,6 @@ subroutine interstitial_rad_reset (Interstitial, Model)
76097591
Interstitial%tsfa = clear_val
76107592
Interstitial%tsfg = clear_val
76117593

7612-
! F-A scheme
7613-
if (Model%imp_physics == Model%imp_physics_fer_hires) then
7614-
Interstitial%qv_r = clear_val
7615-
Interstitial%qc_r = clear_val
7616-
Interstitial%qi_r = clear_val
7617-
Interstitial%qr_r = clear_val
7618-
Interstitial%qs_r = clear_val
7619-
Interstitial%qg_r = clear_val
7620-
if(Model%spec_adv) then
7621-
Interstitial%f_ice = clear_val
7622-
Interstitial%f_rain = clear_val
7623-
Interstitial%f_rimef = clear_val
7624-
Interstitial%cwm = clear_val
7625-
end if
7626-
end if
7627-
76287594
if (Model%do_RRTMGP) then
76297595
Interstitial%tracer = clear_val
76307596
Interstitial%tv_lay = clear_val
@@ -7936,12 +7902,6 @@ subroutine interstitial_phys_reset (Interstitial, Model)
79367902
Interstitial%cnv_ndrop = clear_val
79377903
Interstitial%cnv_nice = clear_val
79387904
end if
7939-
if (Model%imp_physics == Model%imp_physics_fer_hires .and. Model%spec_adv) then
7940-
Interstitial%f_ice = clear_val
7941-
Interstitial%f_rain = clear_val
7942-
Interstitial%f_rimef = clear_val
7943-
Interstitial%cwm = clear_val
7944-
end if
79457905
if (Model%do_shoc) then
79467906
Interstitial%qrn = clear_val
79477907
Interstitial%qsnw = clear_val

0 commit comments

Comments
 (0)