Skip to content

Commit

Permalink
updates associated with CA restart and PE decomposition bugs (#396)
Browse files Browse the repository at this point in the history
* This PR contains updates for new ca code, it fixes the CA restart and decomposition issues. Code changes are also in CCPP physics PR and stochastic physics PR.
  • Loading branch information
pjpegion authored Sep 30, 2021
1 parent 931f8a3 commit 376d374
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 179 deletions.
12 changes: 6 additions & 6 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ subroutine atmos_model_init (Atmos, Time_init, Time, Time_step)
GFS_data%Coupling, GFS_data%Grid, GFS_data%Tbd, GFS_data%Cldprop, GFS_data%Radtend, &
GFS_data%IntDiag, Init_parm, GFS_Diag)
call FV3GFS_restart_read (GFS_data, GFS_restart_var, Atm_block, GFS_control, Atmos%domain, Atm(mygrid)%flagstruct%warm_start)
if(GFS_control%ca_sgs)then
call read_ca_restart (Atmos%domain,GFS_control%scells)
if(GFS_control%do_ca .and. Atm(mygrid)%flagstruct%warm_start)then
call read_ca_restart (Atmos%domain,GFS_control%scells,GFS_control%nca,GFS_control%ncells_g,GFS_control%nca_g)
endif
! Populate the GFS_data%Statein container with the prognostic state
! in Atm_block, which contains the initial conditions/restart data.
Expand Down Expand Up @@ -979,8 +979,8 @@ subroutine atmos_model_end (Atmos)
GFS_Control%lndp_type > 0 .or. GFS_Control%do_ca ) then
if(restart_endfcst) then
call write_stoch_restart_atm('RESTART/atm_stoch.res.nc')
if (GFS_control%ca_sgs)then
call write_ca_restart(Atmos%domain,GFS_control%scells)
if (GFS_control%do_ca)then
call write_ca_restart()
endif
endif
call stochastic_physics_wrapper_end(GFS_control)
Expand Down Expand Up @@ -1008,8 +1008,8 @@ subroutine atmos_model_restart(Atmos, timestamp)
call atmosphere_restart(timestamp)
call FV3GFS_restart_write (GFS_data, GFS_restart_var, Atm_block, &
GFS_control, Atmos%domain, timestamp)
if(GFS_control%ca_sgs)then
call write_ca_restart(Atmos%domain,GFS_control%scells,timestamp)
if(GFS_control%do_ca)then
call write_ca_restart(timestamp)
endif
end subroutine atmos_model_restart
! </SUBROUTINE>
Expand Down
57 changes: 8 additions & 49 deletions ccpp/data/GFS_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module GFS_typedefs

use machine, only: kind_phys
use machine, only: kind_phys,kind_dbl_prec
use physcons, only: con_cp, con_fvirt, con_g, &
con_hvap, con_hfus, con_pi, con_rd, con_rv, &
con_t0c, con_cvap, con_cliq, con_eps, con_epsq, &
Expand Down Expand Up @@ -526,7 +526,6 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: ca_rad (:) => null() !
real (kind=kind_phys), pointer :: ca_micro (:) => null() !
real (kind=kind_phys), pointer :: condition(:) => null() !
real (kind=kind_phys), pointer :: vfact_ca(:) => null() !
!--- stochastic physics
real (kind=kind_phys), pointer :: shum_wts (:,:) => null() !
real (kind=kind_phys), pointer :: sppt_wts (:,:) => null() !
Expand Down Expand Up @@ -1122,7 +1121,7 @@ module GFS_typedefs
logical :: ca_sgs !< switch for sgs ca
logical :: ca_global !< switch for global ca
logical :: ca_smooth !< switch for gaussian spatial filter
integer :: iseed_ca !< seed for random number generation in ca scheme
integer(kind=kind_dbl_prec) :: iseed_ca !< seed for random number generation in ca scheme
integer :: nspinup !< number of iterations to spin up the ca
real(kind=kind_phys) :: rcell !< threshold used for CA scheme
real(kind=kind_phys) :: nthresh !< threshold used for convection coupling
Expand All @@ -1131,6 +1130,7 @@ module GFS_typedefs
logical :: ca_closure !< logical switch for ca on closure
logical :: ca_entr !< logical switch for ca on entrainment
logical :: ca_trigger !< logical switch for ca on trigger
real (kind=kind_phys), allocatable :: vfact_ca(:) !< vertical tapering for ca_global

!--- stochastic physics control parameters
logical :: do_sppt
Expand Down Expand Up @@ -1633,20 +1633,6 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: tdomip (:) => null() !< dominant accumulated sleet type
real (kind=kind_phys), pointer :: tdoms (:) => null() !< dominant accumulated snow type

real (kind=kind_phys), pointer :: ca1 (:) => null() !
real (kind=kind_phys), pointer :: ca2 (:) => null() !
real (kind=kind_phys), pointer :: ca3 (:) => null() !
real (kind=kind_phys), pointer :: ca_deep (:) => null() !< cellular automata fraction
real (kind=kind_phys), pointer :: ca_turb (:) => null() !< cellular automata fraction
real (kind=kind_phys), pointer :: ca_shal (:) => null() !< cellular automata fraction
real (kind=kind_phys), pointer :: ca_rad (:) => null() !< cellular automata fraction
real (kind=kind_phys), pointer :: ca_micro (:) => null() !< cellular automata fraction

real (kind=kind_phys), pointer :: skebu_wts(:,:) => null() !< 10 meter u wind speed
real (kind=kind_phys), pointer :: skebv_wts(:,:) => null() !< 10 meter v wind speed
real (kind=kind_phys), pointer :: sppt_wts(:,:) => null() !<
real (kind=kind_phys), pointer :: shum_wts(:,:) => null() !<
real (kind=kind_phys), pointer :: sfc_wts(:,:) => null() !<
real (kind=kind_phys), pointer :: zmtnblck(:) => null() !<mountain blocking evel

! dtend/dtidxt: Multitudinous 3d tendencies in a 4D array: (i,k,1:100+ntrac,nprocess)
Expand Down Expand Up @@ -2963,7 +2949,6 @@ subroutine coupling_create (Coupling, IM, Model)

!-- cellular automata
allocate (Coupling%condition(IM))
allocate (Coupling%vfact_ca(Model%levs))
if (Model%do_ca) then
allocate (Coupling%ca1 (IM))
allocate (Coupling%ca2 (IM))
Expand All @@ -2973,7 +2958,6 @@ subroutine coupling_create (Coupling, IM, Model)
allocate (Coupling%ca_shal (IM))
allocate (Coupling%ca_rad (IM))
allocate (Coupling%ca_micro (IM))
Coupling%vfact_ca = clear_val
Coupling%ca1 = clear_val
Coupling%ca2 = clear_val
Coupling%ca3 = clear_val
Expand Down Expand Up @@ -4423,6 +4407,11 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
Model%lndp_each_step = lndp_each_step

!--- cellular automata options
! force namelist constsitency
allocate(Model%vfact_ca(levs))
if ( .not. ca_global ) nca_g=0
if ( .not. ca_sgs ) nca=0

Model%nca = nca
Model%scells = scells
Model%tlives = tlives
Expand Down Expand Up @@ -6519,28 +6508,14 @@ subroutine diag_create (Diag, IM, Model)
allocate (Diag%tdomzr (IM))
allocate (Diag%tdomip (IM))
allocate (Diag%tdoms (IM))
allocate (Diag%skebu_wts(IM,Model%levs))
allocate (Diag%skebv_wts(IM,Model%levs))
allocate (Diag%sppt_wts (IM,Model%levs))
allocate (Diag%shum_wts (IM,Model%levs))
allocate (Diag%sfc_wts (IM,Model%n_var_lndp))
allocate (Diag%zmtnblck (IM))
allocate (Diag%ca1 (IM))
allocate (Diag%ca2 (IM))
allocate (Diag%ca3 (IM))

! F-A MP scheme
if (Model%imp_physics == Model%imp_physics_fer_hires) then
allocate (Diag%train (IM,Model%levs))
end if
allocate (Diag%cldfra (IM,Model%levs))

allocate (Diag%ca_deep (IM))
allocate (Diag%ca_turb (IM))
allocate (Diag%ca_shal (IM))
allocate (Diag%ca_rad (IM))
allocate (Diag%ca_micro (IM))

!--- 3D diagnostics
if (Model%ldiag3d) then
allocate(Diag%dtend(IM,Model%levs,Model%ndtend))
Expand Down Expand Up @@ -6791,12 +6766,6 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center)
Diag%tdomzr = zero
Diag%tdomip = zero
Diag%tdoms = zero
Diag%skebu_wts = zero
Diag%skebv_wts = zero
Diag%sppt_wts = zero
Diag%shum_wts = zero
Diag%sfc_wts = zero
Diag%zmtnblck = zero

if (Model%imp_physics == Model%imp_physics_fer_hires) then
Diag%train = zero
Expand Down Expand Up @@ -6830,16 +6799,6 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center)
Diag%exch_m = clear_val
endif

if (Model%do_ca) then
Diag%ca1 = zero
Diag%ca2 = zero
Diag%ca3 = zero
Diag%ca_deep = zero
Diag%ca_turb = zero
Diag%ca_shal = zero
Diag%ca_rad = zero
Diag%ca_micro = zero
endif
! if(Model%me == Model%master) print *,'in diag_phys_zero, totprcpb set to 0,kdt=',Model%kdt

if (Model%ldiag3d) then
Expand Down
49 changes: 7 additions & 42 deletions ccpp/data/GFS_typedefs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -2193,13 +2193,6 @@
type = real
kind = kind_phys
active = (flag_for_cellular_automata)
[vfact_ca]
standard_name = cellular_automata_vertical_weight
long_name = vertical weight for ca
units = frac
dimensions = (vertical_layer_dimension)
type = real
kind = kind_phys
[ca1]
standard_name = cellular_automata_global_pattern_from_coupled_process
long_name = cellular automata global pattern
Expand Down Expand Up @@ -4408,6 +4401,13 @@
units = flag
dimensions = ()
type = logical
[vfact_ca]
standard_name = cellular_automata_vertical_weight
long_name = vertical weight for ca
units = frac
dimensions = (vertical_layer_dimension)
type = real
kind = kind_phys
[ca_closure]
standard_name = flag_for_global_cellular_automata_closure
long_name = switch for ca on closure
Expand Down Expand Up @@ -6859,41 +6859,6 @@
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
[skebu_wts]
standard_name = weights_for_stochastic_skeb_perturbation_of_x_wind_flipped
long_name = weights for stochastic skeb perturbation of x wind, flipped
units = none
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
[skebv_wts]
standard_name = weights_for_stochastic_skeb_perturbation_of_y_wind_flipped
long_name = weights for stochastic skeb perturbation of y wind, flipped
units = none
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
[sppt_wts]
standard_name = weights_for_stochastic_sppt_perturbation_flipped
long_name = weights for stochastic sppt perturbation, flipped
units = none
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
[shum_wts]
standard_name = weights_for_stochastic_shum_perturbation_flipped
long_name = weights for stochastic shum perturbation, flipped
units = none
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
[sfc_wts]
standard_name = weights_for_stochastic_surface_physics_perturbation_flipped
long_name = weights for stochastic surface physics perturbation, flipped
units = none
dimensions = (horizontal_loop_extent,number_of_perturbed_land_surface_variables)
type = real
kind = kind_phys
[zmtnblck]
standard_name = level_of_dividing_streamline
long_name = level of the dividing streamline
Expand Down
24 changes: 12 additions & 12 deletions ccpp/driver/GFS_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%skebu_wts(:,:)
ExtDiag(idx)%data(nb)%var3 => Coupling(nb)%skebu_wts(:,:)
enddo

idx = idx + 1
Expand All @@ -2048,7 +2048,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%skebv_wts(:,:)
ExtDiag(idx)%data(nb)%var3 => Coupling(nb)%skebv_wts(:,:)
enddo

idx = idx + 1
Expand Down Expand Up @@ -2091,7 +2091,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%sppt_wts(:,:)
ExtDiag(idx)%data(nb)%var3 => Coupling(nb)%sppt_wts(:,:)
enddo

idx = idx + 1
Expand All @@ -2102,7 +2102,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%shum_wts(:,:)
ExtDiag(idx)%data(nb)%var3 => Coupling(nb)%shum_wts(:,:)
enddo

idx = idx + 1
Expand All @@ -2113,7 +2113,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%sfc_wts(:,1)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%sfc_wts(:,1)
enddo

idx = idx + 1
Expand All @@ -2124,7 +2124,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%sfc_wts(:,2)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%sfc_wts(:,2)
enddo

idx = idx + 1
Expand All @@ -2135,7 +2135,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ca1(:)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%ca1(:)
enddo

idx = idx + 1
Expand All @@ -2146,7 +2146,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ca_deep(:)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%ca_deep(:)
enddo

idx = idx + 1
Expand All @@ -2157,7 +2157,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ca_turb(:)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%ca_turb(:)
enddo

idx = idx + 1
Expand All @@ -2168,7 +2168,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ca_shal(:)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%ca_shal(:)
enddo

idx = idx + 1
Expand All @@ -2179,7 +2179,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ca_rad(:)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%ca_rad(:)
enddo

idx = idx + 1
Expand All @@ -2190,7 +2190,7 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%mod_name = 'gfs_phys'
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%ca_micro(:)
ExtDiag(idx)%data(nb)%var2 => Coupling(nb)%ca_micro(:)
enddo

if (Model%ldiag_ugwp) THEN
Expand Down
2 changes: 1 addition & 1 deletion ccpp/physics
Loading

0 comments on commit 376d374

Please sign in to comment.