Skip to content

Commit

Permalink
Quartet of bug fixes for: c3 scheme, quilting restart with 32-bit phy…
Browse files Browse the repository at this point in the history
…sics, and string length mismatch in dycore plus PR #705 and #699 (#695)

* GFDL_atmos_cubed_sphere: consistent string lengths in array

* stop FV3_HRRR_c3 from crashing with gnu debug

* in dycore, initialize srf_wnd_var2 and tracers_var3 arrays

* Write netcdf axis variables using the same real kind as data variables

* "GF radar reflectivity, dust bug fix, C3 updates, more fluxes output"

* Fix race condition in GFS_phys_time_vary.fv3.F90 error detection

* More bug fixes to GFS_phys_time_vary.fv3.F90:
1. detect empty errmsg from subroutines
2. Initialize err variables in set_soilveg.f, which is called from GFS_phys_time_vary.fv3.F90

* initialize errmsg & errflg in noahmp_tables.f90

* only read h2odata, ozdata and noahmp table when they are needed

* remove all constant 3D variables from clm lake

* calculate clm lake constants only once per i loop

---------

Co-authored-by: Dusan Jovic <[email protected]>
Co-authored-by: Haiqin.Li <[email protected]>
  • Loading branch information
3 people authored Oct 3, 2023
1 parent 3b4423c commit bba7da5
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 240 deletions.
2 changes: 1 addition & 1 deletion atmos_cubed_sphere
43 changes: 16 additions & 27 deletions ccpp/data/GFS_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,7 @@ module GFS_typedefs

! CLM Lake model internal variables:
real (kind=kind_phys), pointer :: lake_albedo(:) => null() !
real (kind=kind_phys), pointer :: lake_z3d(:,:) => null() !
real (kind=kind_phys), pointer :: lake_dz3d(:,:) => null() !
real (kind=kind_phys), pointer :: lake_soil_watsat3d(:,:) => null() !
real (kind=kind_phys), pointer :: lake_csol3d(:,:) => null() !
real (kind=kind_phys), pointer :: lake_soil_tkmg3d(:,:) => null() !
real (kind=kind_phys), pointer :: lake_soil_tkdry3d(:,:) => null() !
real (kind=kind_phys), pointer :: lake_soil_tksatu3d(:,:) => null() !
real (kind=kind_phys), pointer :: input_lakedepth(:) => null() !
real (kind=kind_phys), pointer :: lake_h2osno2d(:) => null() !
real (kind=kind_phys), pointer :: lake_sndpth2d(:) => null() !
real (kind=kind_phys), pointer :: lake_snl2d(:) => null() !
Expand All @@ -454,8 +448,6 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: lake_icefrac3d(:,:)=> null()
real (kind=kind_phys), pointer :: lake_rho0(:)=> null()
real (kind=kind_phys), pointer :: lake_ht(:)=> null()
real (kind=kind_phys), pointer :: lake_clay3d(:,:) => null()
real (kind=kind_phys), pointer :: lake_sand3d(:,:) => null()
integer, pointer :: lake_is_salty(:) => null()
integer, pointer :: lake_cannot_freeze(:) => null()
real (kind=kind_phys), pointer :: clm_lake_initialized(:) => null() !< lakeini was called
Expand Down Expand Up @@ -1501,6 +1493,9 @@ module GFS_typedefs
integer :: ncnvwind !< the index of surface wind enhancement due to convection for MYNN SFC and RAS CNV in phy f2d

!-- nml variables for RRFS-SD
real(kind=kind_phys) :: dust_drylimit_factor !< factor for drylimit parameterization in fengsha
real(kind=kind_phys) :: dust_moist_correction !< factor to tune volumetric soil moisture
integer :: dust_moist_opt !< dust moisture option 1:fecan 2:shao
real(kind=kind_phys) :: dust_alpha !< alpha parameter for fengsha dust scheme
real(kind=kind_phys) :: dust_gamma !< gamma parameter for fengsha dust scheme
real(kind=kind_phys) :: wetdep_ls_alpha !< alpha parameter for wet deposition
Expand Down Expand Up @@ -2715,13 +2710,7 @@ subroutine sfcprop_create (Sfcprop, IM, Model)
allocate(Sfcprop%lake_t2m(IM))
allocate(Sfcprop%lake_q2m(IM))
allocate(Sfcprop%lake_albedo(IM))
allocate(Sfcprop%lake_z3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_dz3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_soil_watsat3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_csol3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_soil_tkmg3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_soil_tkdry3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_soil_tksatu3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%input_lakedepth(IM))
allocate(Sfcprop%lake_h2osno2d(IM))
allocate(Sfcprop%lake_sndpth2d(IM))
allocate(Sfcprop%lake_snl2d(IM))
Expand All @@ -2738,22 +2727,14 @@ subroutine sfcprop_create (Sfcprop, IM, Model)
allocate(Sfcprop%lake_icefrac3d(IM,Model%nlevlake_clm_lake))
allocate(Sfcprop%lake_rho0(IM))
allocate(Sfcprop%lake_ht(IM))
allocate(Sfcprop%lake_clay3d(IM,Model%nlevsoil_clm_lake))
allocate(Sfcprop%lake_sand3d(IM,Model%nlevsoil_clm_lake))
allocate(Sfcprop%lake_is_salty(IM))
allocate(Sfcprop%lake_cannot_freeze(IM))
allocate(Sfcprop%clm_lake_initialized(IM))

Sfcprop%lake_t2m = clear_val
Sfcprop%lake_q2m = clear_val
Sfcprop%lake_albedo = clear_val
Sfcprop%lake_z3d = clear_val
Sfcprop%lake_dz3d = clear_val
Sfcprop%lake_soil_watsat3d = clear_val
Sfcprop%lake_csol3d = clear_val
Sfcprop%lake_soil_tkmg3d = clear_val
Sfcprop%lake_soil_tkdry3d = clear_val
Sfcprop%lake_soil_tksatu3d = clear_val
Sfcprop%input_lakedepth = clear_val
Sfcprop%lake_h2osno2d = clear_val
Sfcprop%lake_sndpth2d = clear_val
Sfcprop%lake_snl2d = clear_val
Expand All @@ -2770,8 +2751,6 @@ subroutine sfcprop_create (Sfcprop, IM, Model)
Sfcprop%lake_icefrac3d = clear_val
Sfcprop%lake_rho0 = -111
Sfcprop%lake_ht = -111
Sfcprop%lake_clay3d = clear_val
Sfcprop%lake_sand3d = clear_val
Sfcprop%lake_is_salty = zero
Sfcprop%lake_cannot_freeze = zero
Sfcprop%clm_lake_initialized = zero
Expand Down Expand Up @@ -3829,9 +3808,12 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
integer :: ichoice_s = 3 !< flag for closure of C3/GF shallow convection

!-- chem nml variables for RRFS-SD
real(kind=kind_phys) :: dust_drylimit_factor = 1.0
real(kind=kind_phys) :: dust_moist_correction = 1.0
real(kind=kind_phys) :: dust_alpha = 0.
real(kind=kind_phys) :: dust_gamma = 0.
real(kind=kind_phys) :: wetdep_ls_alpha = 0.
integer :: dust_moist_opt = 1 ! fecan :1 else shao
integer :: seas_opt = 2
integer :: dust_opt = 5
integer :: drydep_opt = 1
Expand Down Expand Up @@ -3995,6 +3977,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
!--- aerosol scavenging factors ('name:value' string array)
fscav_aero, &
!--- RRFS-SD namelist
dust_drylimit_factor, dust_moist_correction, dust_moist_opt, &
dust_alpha, dust_gamma, wetdep_ls_alpha, &
seas_opt, dust_opt, drydep_opt, coarsepm_settling, &
wetdep_ls_opt, smoke_forecast, aero_ind_fdb, aero_dir_fdb, &
Expand Down Expand Up @@ -4214,6 +4197,9 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &

!--- RRFS-SD
Model%rrfs_sd = rrfs_sd
Model%dust_drylimit_factor = dust_drylimit_factor
Model%dust_moist_correction = dust_moist_correction
Model%dust_moist_opt = dust_moist_opt
Model%dust_alpha = dust_alpha
Model%dust_gamma = dust_gamma
Model%wetdep_ls_alpha = wetdep_ls_alpha
Expand Down Expand Up @@ -6314,6 +6300,9 @@ subroutine control_print(Model)
if(model%rrfs_sd) then
print *, ' '
print *, 'smoke parameters'
print *, 'dust_drylimit_factor: ',Model%dust_drylimit_factor
print *, 'dust_moist_correction: ',Model%dust_moist_correction
print *, 'dust_moist_opt : ',Model%dust_moist_opt
print *, 'dust_alpha : ',Model%dust_alpha
print *, 'dust_gamma : ',Model%dust_gamma
print *, 'wetdep_ls_alpha : ',Model%wetdep_ls_alpha
Expand Down
93 changes: 27 additions & 66 deletions ccpp/data/GFS_typedefs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -2034,59 +2034,11 @@
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_z3d]
standard_name = depth_of_lake_interface_layers
long_name = depth of lake interface layers
units = fraction
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_dz3d]
standard_name = thickness_of_lake_layers
long_name = thickness of lake layers
units = fraction
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_soil_watsat3d]
standard_name = saturated_volumetric_soil_water_in_lake_model
long_name = saturated volumetric soil water in lake model
units = m
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_csol3d]
standard_name = soil_heat_capacity_in_lake_model
long_name = soil heat capacity in lake model
units = m
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_soil_tkmg3d]
standard_name = soil_mineral_thermal_conductivity_in_lake_model
long_name = soil mineral thermal conductivity in lake model
[input_lakedepth]
standard_name = lake_depth_before_correction
long_name = lake depth_before_correction
units = m
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_soil_tkdry3d]
standard_name = dry_soil_thermal_conductivity_in_lake_model
long_name = dry soil thermal conductivity in lake model
units = m
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_soil_tksatu3d]
standard_name = saturated_soil_thermal_conductivity_in_lake_model
long_name = saturated soil thermal conductivity in lake model
units = m
dimensions = (horizontal_loop_extent, lake_vertical_dimension_for_clm_lake_model)
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
Expand Down Expand Up @@ -2218,20 +2170,6 @@
type = real
kind = kind_phys
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_clay3d]
standard_name = clm_lake_percent_clay
long_name = percent clay in clm lake model
units = percent
dimensions = (horizontal_loop_extent,soil_vertical_dimension_for_clm_lake_model)
type = integer
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_sand3d]
standard_name = clm_lake_percent_sand
long_name = percent sand in clm lake model
units = percent
dimensions = (horizontal_loop_extent,soil_vertical_dimension_for_clm_lake_model)
type = integer
active = (control_for_lake_model_selection == 2 .and. control_for_lake_model_execution_method > 0)
[lake_is_salty]
standard_name = clm_lake_is_salty
long_name = lake at this point is salty (1) or not (0)
Expand Down Expand Up @@ -6462,6 +6400,29 @@
type = real
kind = kind_phys
active = (do_smoke_coupling)
[dust_moist_correction]
standard_name = dust_moist_correction_fengsha_dust_scheme
long_name = moisture correction term for fengsha dust emission
units = none
dimensions = ()
type = real
kind = kind_phys
active = (do_smoke_coupling)
[dust_drylimit_factor]
standard_name = dust_drylimit_factor_fengsha_dust_scheme
long_name = moisture correction term for drylimit in fengsha dust emission
units = none
dimensions = ()
type = real
kind = kind_phys
active = (do_smoke_coupling)
[dust_moist_opt]
standard_name = control_for_dust_soil_moisture_option
long_name = smoke dust moisture parameterization 1 - fecan 2 - shao
units = index
dimensions = ()
type = integer
active = (do_smoke_coupling)
[dust_alpha]
standard_name = alpha_fengsha_dust_scheme
long_name = alpha paramter for fengsha dust scheme
Expand Down
80 changes: 44 additions & 36 deletions ccpp/driver/GFS_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4061,6 +4061,50 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%data(nb)%var2 => sfcprop(nb)%wetness(:)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'nirbmdi'
ExtDiag(idx)%desc = 'sfc nir beam sw downward flux'
ExtDiag(idx)%unit = 'W/m**2'
ExtDiag(idx)%mod_name = 'gfs_sfc'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%nirbmdi(:)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'nirdfdi'
ExtDiag(idx)%desc = 'sfc nir diff sw downward flux'
ExtDiag(idx)%unit = 'W/m**2'
ExtDiag(idx)%mod_name = 'gfs_sfc'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%nirdfdi(:)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'visbmdi'
ExtDiag(idx)%desc = 'sfc uv+vis beam sw downward flux'
ExtDiag(idx)%unit = 'W/m**2'
ExtDiag(idx)%mod_name = 'gfs_sfc'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%visbmdi(:)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'visdfdi'
ExtDiag(idx)%desc = ' sfc uv+vis diff sw downward flux'
ExtDiag(idx)%unit = 'W/m**2'
ExtDiag(idx)%mod_name = 'gfs_sfc'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%visdfdi(:)
enddo

if (Model%rdlai) then
idx = idx + 1
ExtDiag(idx)%axes = 2
Expand Down Expand Up @@ -5086,42 +5130,6 @@ subroutine clm_lake_externaldiag_populate(ExtDiag, Model, Sfcprop, idx, cn_one,

integer :: nk, idx0, iblk

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_z3d, 'lake_z3d', 'lake_depth_on_interface_levels', 'm')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_clay3d, 'lake_clay3d', 'percent clay on soil levels in clm lake model', '%')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_sand3d, 'lake_sand3d', 'percent sand on soil levels in clm lake model', '%')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_dz3d, 'lake_dz3d', 'lake level thickness', 'm')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_soil_watsat3d, 'lake_soil_watsat3d', 'saturated volumetric soil water', 'm3 m-3')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_csol3d, 'lake_csol3d', 'soil heat capacity', 'J m-3 K-1')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_soil_tkmg3d, 'lake_soil_tkmg3d', 'soil thermal conductivity, minerals', 'W m-1 K-1')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_soil_tkdry3d, 'lake_soil_tkdry3d', 'soil thermal conductivity, dry soil', 'W m-1 K-1')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_soil_tksatu3d, 'lake_soil_tksatu3d', 'soil thermal conductivity, saturated soil', 'W m-1 K-1')
enddo

do iblk=1,nblks
call link_all_levels(Sfcprop(iblk)%lake_snow_z3d, 'lake_snow_z3d', 'lake snow level depth', 'm')
enddo
Expand Down
2 changes: 2 additions & 0 deletions ccpp/suites/suite_FV3_GFS_v17_p8_c3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
<group name="radiation">
<subcycle loop="1">
<scheme>GFS_suite_interstitial_rad_reset</scheme>
<scheme>sgscloud_radpre</scheme>
<scheme>GFS_rrtmg_pre</scheme>
<scheme>GFS_radiation_surface</scheme>
<scheme>rad_sw_pre</scheme>
<scheme>rrtmg_sw</scheme>
<scheme>rrtmg_sw_post</scheme>
<scheme>rrtmg_lw_pre</scheme>
<scheme>rrtmg_lw</scheme>
<scheme>sgscloud_radpost</scheme>
<scheme>rrtmg_lw_post</scheme>
<scheme>GFS_rrtmg_post</scheme>
</subcycle>
Expand Down
Loading

0 comments on commit bba7da5

Please sign in to comment.