Skip to content

Commit

Permalink
Cld perts (ufs-community#233)
Browse files Browse the repository at this point in the history
Addition of stochastic physics restarts in netCDF format that will be written at the restart interval, and at end of run.  
Also, addition of stochastic cloud perturbation and microphyiscs perturbations for SPPT.
  • Loading branch information
pjpegion authored Mar 21, 2021
1 parent dbaff1c commit 07b00a9
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 554 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ add_dependencies(fv3atm ccppdriver ccppdata ccppphys ccpp)
target_link_libraries(fv3atm PUBLIC ccppdriver ccppdata ccppphys ccpp)

target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics)
target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../stochastic_physics)
target_compile_definitions(fv3atm PRIVATE "${_fv3atm_defs_private}")

target_link_libraries(fv3atm PUBLIC fv3dycore
Expand Down Expand Up @@ -192,7 +193,7 @@ endif()
### Install
###############################################################################
install(
TARGETS fv3atm fv3dycore io ${CCPP_LIBRARIES} cpl stochastic_physics stochastic_physics_wrapper
TARGETS fv3atm fv3dycore io ${CCPP_LIBRARIES} cpl stochastic_physics_wrapper
EXPORT fv3atm-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
Expand Down
5 changes: 3 additions & 2 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ end subroutine update_atmos_model_state
! </INOUT>

subroutine atmos_model_end (Atmos)
use get_stochy_pattern_mod, only: write_stoch_restart_atm
type (atmos_data_type), intent(inout) :: Atmos
!---local variables
integer :: idx, seconds, ierr
Expand All @@ -878,12 +879,12 @@ subroutine atmos_model_end (Atmos)

call atmosphere_end (Atmos % Time, Atmos%grid, restart_endfcst)

call stochastic_physics_wrapper_end(GFS_control)

if(restart_endfcst) then
call FV3GFS_restart_write (GFS_data, GFS_restart_var, Atm_block, &
GFS_control, Atmos%domain)
call write_stoch_restart_atm('RESTART/atm_stoch.res.nc')
endif
call stochastic_physics_wrapper_end(GFS_control)

! Fast physics (from dynamics) are finalized in atmosphere_end above;
! standard/slow physics (from IPD) are finalized in CCPP_step 'finalize'.
Expand Down
12 changes: 0 additions & 12 deletions ccpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,6 @@ else (SIONLIB)
message (STATUS "Disable SIONlib support")
endif (SIONLIB)

#------------------------------------------------------------------------------
# Set Intel MKL flags for preprocessor, compiler and linker (if defined)
if(MKL_DIR)
set (MKL_INC "-m64 -I${MKL_DIR}/include")
set (MKL_LIB "-L${MKL_DIR}/lib -Wl,-rpath,${MKL_DIR}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MKL_INC} ${MKL_LIB}")
ADD_DEFINITIONS(-DMKL)
message (STATUS "Enable Intel MKL support")
else(MKL_DIR)
message (STATUS "Disable Intel MKL support")
endif(MKL_DIR)

#------------------------------------------------------------------------------
# Set netCDF flags for preprocessor, compiler and linker (if defined)
# Legacy settings for old make build
Expand Down
28 changes: 20 additions & 8 deletions ccpp/data/GFS_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1065,11 +1065,15 @@ module GFS_typedefs

!--- stochastic physics control parameters
logical :: do_sppt
logical :: pert_clds
logical :: pert_radtend
logical :: pert_mp
logical :: use_zmtnblck
logical :: do_shum
logical :: do_skeb
integer :: skeb_npass
integer :: lndp_type
real(kind=kind_phys) :: sppt_amp ! pjp cloud perturbations
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
Expand Down Expand Up @@ -1282,7 +1286,7 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: acvt (:) => null() !< arrays used by cnvc90 top (cnvc90.f)

!--- Stochastic physics properties calculated in physics_driver
real (kind=kind_phys), pointer :: dtdtr (:,:) => null() !< temperature change due to radiative heating per time step (K)
real (kind=kind_phys), pointer :: dtdtnp (:,:) => null() !< temperature change from physics that should not be perturbed with SPPT (k)
real (kind=kind_phys), pointer :: dtotprcp (:) => null() !< change in totprcp (diag_type)
real (kind=kind_phys), pointer :: dcnvprcp (:) => null() !< change in cnvprcp (diag_type)
real (kind=kind_phys), pointer :: drain_cpl (:) => null() !< change in rain_cpl (coupling_type)
Expand Down Expand Up @@ -1531,6 +1535,7 @@ module GFS_typedefs
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
real (kind=kind_phys), pointer :: du3dt (:,:,:) => null() !< u momentum change due to physics
real (kind=kind_phys), pointer :: dv3dt (:,:,:) => null() !< v momentum change due to physics
Expand Down Expand Up @@ -1752,7 +1757,6 @@ module GFS_typedefs
real (kind=kind_phys), pointer :: drain(:) => null() !<
real (kind=kind_phys), pointer :: drain_in_m_sm1(:) => null() !<
real (kind=kind_phys), pointer :: dtdt(:,:) => null() !<
real (kind=kind_phys), pointer :: dtdtc(:,:) => null() !<
real (kind=kind_phys), pointer :: dtsfc1(:) => null() !<
real (kind=kind_phys), pointer :: dtzm(:) => null() !<
real (kind=kind_phys), pointer :: dt_mf(:,:) => null() !<
Expand Down Expand Up @@ -3380,6 +3384,9 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &

!--- stochastic physics control parameters
logical :: do_sppt = .false.
logical :: pert_mp = .false.
logical :: pert_clds = .false.
logical :: pert_radtend = .true.
logical :: use_zmtnblck = .false.
logical :: do_shum = .false.
logical :: do_skeb = .false.
Expand Down Expand Up @@ -3462,6 +3469,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
dlqf, rbcr, shoc_parm, psauras, prauras, wminras, &
do_sppt, do_shum, do_skeb, &
lndp_type, n_var_lndp, lndp_each_step, &
pert_mp,pert_clds,pert_radtend, &
!--- Rayleigh friction
prslrd0, ral_ts, ldiag_ugwp, do_ugwp, do_tofd, &
! --- Ferrier-Aligo
Expand Down Expand Up @@ -4142,6 +4150,9 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
! physics that are parsed here and then compared in init_stochastic_physics
! to the stochastic physics namelist parametersto ensure consistency.
Model%do_sppt = do_sppt
Model%pert_mp = pert_mp
Model%pert_clds = pert_clds
Model%pert_radtend = pert_radtend
Model%use_zmtnblck = use_zmtnblck
Model%do_shum = do_shum
Model%do_skeb = do_skeb
Expand Down Expand Up @@ -5163,6 +5174,9 @@ subroutine control_print(Model)
print *, ' '
print *, 'stochastic physics'
print *, ' do_sppt : ', Model%do_sppt
print *, ' pert_mp : ', Model%pert_mp
print *, ' pert_clds : ', Model%pert_clds
print *, ' pert_radtend : ', Model%pert_radtend
print *, ' do_shum : ', Model%do_shum
print *, ' do_skeb : ', Model%do_skeb
print *, ' lndp_type : ', Model%lndp_type
Expand Down Expand Up @@ -5405,10 +5419,10 @@ subroutine tbd_create (Tbd, IM, Model)
endif

if (Model%do_sppt .or. Model%ca_global) then
allocate (Tbd%dtdtr (IM,Model%levs))
allocate (Tbd%dtdtnp (IM,Model%levs))
allocate (Tbd%dtotprcp (IM))
allocate (Tbd%dcnvprcp (IM))
Tbd%dtdtr = clear_val
Tbd%dtdtnp = clear_val
Tbd%dtotprcp = clear_val
Tbd%dcnvprcp = clear_val
endif
Expand Down Expand Up @@ -5680,7 +5694,8 @@ subroutine diag_create (Diag, IM, Model)
allocate (Diag%skebv_wts(IM,Model%levs))
allocate (Diag%sppt_wts(IM,Model%levs))
allocate (Diag%shum_wts(IM,Model%levs))
allocate (Diag%zmtnblck(IM))
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))
Expand Down Expand Up @@ -6267,7 +6282,6 @@ subroutine interstitial_create (Interstitial, IM, Model)
allocate (Interstitial%dqsfc1 (IM))
allocate (Interstitial%drain (IM))
allocate (Interstitial%dtdt (IM,Model%levs))
allocate (Interstitial%dtdtc (IM,Model%levs))
allocate (Interstitial%dtsfc1 (IM))
allocate (Interstitial%dt_mf (IM,Model%levs))
allocate (Interstitial%dtzm (IM))
Expand Down Expand Up @@ -6961,7 +6975,6 @@ subroutine interstitial_phys_reset (Interstitial, Model)
Interstitial%drain = clear_val
Interstitial%dt_mf = clear_val
Interstitial%dtdt = clear_val
Interstitial%dtdtc = clear_val
Interstitial%dtsfc1 = clear_val
Interstitial%dtzm = clear_val
Interstitial%dudt = clear_val
Expand Down Expand Up @@ -7313,7 +7326,6 @@ subroutine interstitial_print(Interstitial, Model, mpirank, omprank, blkno)
write (0,*) 'sum(Interstitial%dqsfc1 ) = ', sum(Interstitial%dqsfc1 )
write (0,*) 'sum(Interstitial%drain ) = ', sum(Interstitial%drain )
write (0,*) 'sum(Interstitial%dtdt ) = ', sum(Interstitial%dtdt )
write (0,*) 'sum(Interstitial%dtdtc ) = ', sum(Interstitial%dtdtc )
write (0,*) 'sum(Interstitial%dtsfc1 ) = ', sum(Interstitial%dtsfc1 )
write (0,*) 'sum(Interstitial%dtzm ) = ', sum(Interstitial%dtzm )
write (0,*) 'sum(Interstitial%dt_mf ) = ', sum(Interstitial%dt_mf )
Expand Down
47 changes: 36 additions & 11 deletions ccpp/data/GFS_typedefs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -4267,6 +4267,31 @@
units = flag
dimensions = ()
type = logical
[pert_mp]
standard_name = flag_for_stochastic_microphysics_perturbations
long_name = flag for stochastic microphysics perturbations
units = flag
dimensions = ()
type = logical
[pert_clds]
standard_name = flag_for_stochastic_cloud_fraction_perturbations
long_name = flag for stochastic cloud fraction perturbations
units = flag
dimensions = ()
type = logical
[sppt_amp]
standard_name = total_ampltiude_of_sppt_perturbation
long_name = toal ampltidue of stochastic sppt perturbation
units = none
dimensions = ()
type = real
kind = kind_phys
[pert_radtend]
standard_name = flag_for_stochastic_radiative_heating_perturbations
long_name = flag for stochastic radiative heating perturbations
units = flag
dimensions = ()
type = logical
[use_zmtnblck]
standard_name = flag_for_mountain_blocking
long_name = flag for mountain blocking
Expand Down Expand Up @@ -5386,10 +5411,10 @@
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
[dtdtr]
standard_name = tendency_of_air_temperature_due_to_radiative_heating_on_physics_time_step
long_name = temp. change due to radiative heating per time step
units = K
[dtdtnp]
standard_name = tendency_of_air_temperature_to_withold_from_sppt
long_name = temp. change from physics that should not be perturbed by sppt
units = K s-1
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
Expand Down Expand Up @@ -6504,6 +6529,13 @@
dimensions = (horizontal_loop_extent,vertical_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_land_surface_variables_perturbed)
type = real
kind = kind_phys
[zmtnblck]
standard_name = level_of_dividing_streamline
long_name = level of the dividing streamline
Expand Down Expand Up @@ -8085,13 +8117,6 @@
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[dtdtc]
standard_name = tendency_of_air_temperature_due_to_radiative_heating_assuming_clear_sky
long_name = clear sky radiative (shortwave + longwave) heating rate at current time
units = K s-1
dimensions = (horizontal_loop_extent,vertical_dimension)
type = real
kind = kind_phys
[dtsfc1]
standard_name = instantaneous_surface_upward_sensible_heat_flux
long_name = surface upward sensible heat flux
Expand Down
22 changes: 22 additions & 0 deletions ccpp/driver/GFS_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,28 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%shum_wts(:,:)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'sfc_wts1'
ExtDiag(idx)%desc = 'perturbation amplitude'
ExtDiag(idx)%unit = 'none'
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)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'sfc_wts2'
ExtDiag(idx)%desc = 'perturbation amplitude'
ExtDiag(idx)%unit = 'none'
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)
enddo

idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'ca1'
Expand Down
Loading

0 comments on commit 07b00a9

Please sign in to comment.