diff --git a/ccpp/data/GFS_typedefs.F90 b/ccpp/data/GFS_typedefs.F90 index afd4f681a..f125489af 100644 --- a/ccpp/data/GFS_typedefs.F90 +++ b/ccpp/data/GFS_typedefs.F90 @@ -1161,17 +1161,15 @@ module GFS_typedefs logical :: do_shum logical :: do_skeb integer :: skeb_npass - integer :: lndp_type + integer :: lndp_type ! integer indicating land perturbation scheme type: + ! 0 - none + ! 1 - scheme from Gehne et al, MWR, 2019. (Noah only, not maintained?) + ! 2 - scheme from Draper, JHM, 2021. 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 - 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, - ! we'd need to make this dim(6,5). + ! next two are duplicated here to support lndp_type=1. If delete that scheme, could remove from GFS defs? + character(len=3) , pointer :: lndp_var_list(:) + real(kind=kind_phys), pointer :: lndp_prt_list(:) logical :: do_spp ! Overall flag to turn on SPP or not integer :: spp_pbl integer :: spp_sfc @@ -1179,9 +1177,9 @@ module GFS_typedefs integer :: spp_rad integer :: spp_gwd integer :: n_var_spp - character(len=3) , pointer :: spp_var_list(:) ! dimension here must match n_var_spp in stochy_nml_def - real(kind=kind_phys), pointer :: spp_prt_list(:) ! dimension here must match n_var_spp in stochy_nml_def - real(kind=kind_phys), pointer :: spp_stddev_cutoff(:) ! dimension here must match n_var_spp in stochy_nml_def + character(len=3) , pointer :: spp_var_list(:) + real(kind=kind_phys), pointer :: spp_prt_list(:) + real(kind=kind_phys), pointer :: spp_stddev_cutoff(:) !--- tracer handling character(len=32), pointer :: tracer_names(:) !< array of initialized tracers from dynamic core @@ -3233,7 +3231,6 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & integer :: skeb_npass = 11 integer :: lndp_type = 0 integer :: n_var_lndp = 0 - logical :: lndp_each_step = .false. integer :: n_var_spp = 0 integer :: spp_pbl = 0 integer :: spp_sfc = 0 @@ -3334,7 +3331,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & dlqf, rbcr, shoc_parm, psauras, prauras, wminras, & do_sppt, do_shum, do_skeb, & do_spp, n_var_spp, & - lndp_type, n_var_lndp, lndp_each_step, & + lndp_type, n_var_lndp, & pert_mp,pert_clds,pert_radtend, & !--- Rayleigh friction prslrd0, ral_ts, ldiag_ugwp, do_ugwp, do_tofd, & @@ -4137,7 +4134,6 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, & !--- stochastic surface perturbation options Model%lndp_type = lndp_type Model%n_var_lndp = n_var_lndp - Model%lndp_each_step = lndp_each_step Model%do_spp = do_spp Model%n_var_spp = n_var_spp @@ -5742,7 +5738,6 @@ subroutine control_print(Model) print *, ' do_skeb : ', Model%do_skeb print *, ' lndp_type : ', Model%lndp_type print *, ' n_var_lndp : ', Model%n_var_lndp - print *, ' lndp_each_step : ', Model%lndp_each_step print *, ' do_spp : ', Model%do_spp print *, ' n_var_spp : ', Model%n_var_spp print *, ' ' diff --git a/ccpp/driver/GFS_diagnostics.F90 b/ccpp/driver/GFS_diagnostics.F90 index 9a32e8321..7b01163d8 100644 --- a/ccpp/driver/GFS_diagnostics.F90 +++ b/ccpp/driver/GFS_diagnostics.F90 @@ -2363,26 +2363,16 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop if (Model%lndp_type /= 0) then idx = idx + 1 - ExtDiag(idx)%axes = 2 - ExtDiag(idx)%name = 'sfc_wts1' + ExtDiag(idx)%axes = 3 + ExtDiag(idx)%name = 'sfc_wts' 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 => Coupling(nb)%sfc_wts(:,1) + ExtDiag(idx)%data(nb)%var3 => Coupling(nb)%sfc_wts(:,:) 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 => Coupling(nb)%sfc_wts(:,2) - enddo endif if (Model%do_ca) then diff --git a/stochastic_physics/stochastic_physics_wrapper.F90 b/stochastic_physics/stochastic_physics_wrapper.F90 index f5a285d2d..e630fcdd3 100644 --- a/stochastic_physics/stochastic_physics_wrapper.F90 +++ b/stochastic_physics/stochastic_physics_wrapper.F90 @@ -23,18 +23,15 @@ module stochastic_physics_wrapper_mod real(kind=kind_phys), dimension(:,:), allocatable, save :: vfrac !albedo real(kind=kind_phys), dimension(:,:), allocatable, save :: snoalb - real(kind=kind_phys), dimension(:,:), allocatable, save :: alvsf real(kind=kind_phys), dimension(:,:), allocatable, save :: alnsf - real(kind=kind_phys), dimension(:,:), allocatable, save :: alvwf real(kind=kind_phys), dimension(:,:), allocatable, save :: alnwf - real(kind=kind_phys), dimension(:,:), allocatable, save :: facsf - real(kind=kind_phys), dimension(:,:), allocatable, save :: facwf !emissivity real(kind=kind_phys), dimension(:,:), allocatable, save :: semis !roughness length for land real(kind=kind_phys), dimension(:,:), allocatable, save :: zorll - real(kind=kind_phys), dimension(:,:), allocatable, save :: stype + !real(kind=kind_phys), dimension(:,:), allocatable, save :: stype + integer, dimension(:,:), allocatable, save :: stype ! For cellular automata real(kind=kind_phys), dimension(:,:), allocatable, save :: sst @@ -79,7 +76,7 @@ subroutine stochastic_physics_wrapper (GFS_Control, GFS_Data, Atm_block, ierr) type(block_control_type), intent(inout) :: Atm_block integer, intent(out) :: ierr - integer :: nthreads, nb, levs, maxblk, nblks, n + integer :: nthreads, nb, levs, maxblk, nblks, n, v logical :: param_update_flag #ifdef _OPENMP @@ -143,29 +140,34 @@ subroutine stochastic_physics_wrapper (GFS_Control, GFS_Data, Atm_block, ierr) end select end do end if - if ( GFS_Control%lndp_type == 2 ) then ! this scheme updates through forecast - allocate(sfc_wts(1:nblks,maxblk,1:GFS_Control%n_var_lndp)) - end if - if (GFS_Control%lndp_type == 2) then ! save wts, and apply lndp scheme - if (GFS_Control%lsm == GFS_Control%lsm_noah) then + if ( GFS_Control%lndp_type == 2 ) then + allocate(sfc_wts(1:nblks,maxblk,1:GFS_Control%n_var_lndp)) + if ( (GFS_Control%lsm == GFS_Control%lsm_noah) .or. (GFS_Control%lsm == GFS_Control%lsm_noahmp)) then lsoil = GFS_Control%lsoil elseif (GFS_Control%lsm == GFS_Control%lsm_ruc) then lsoil = GFS_Control%lsoil_lsm endif allocate(smc (1:nblks, maxblk, lsoil)) - allocate(slc (1:nblks, maxblk, lsoil)) - allocate(stc (1:nblks, maxblk, lsoil)) - allocate(stype (1:nblks, maxblk)) - allocate(vfrac (1:nblks, maxblk)) - allocate(snoalb(1:nblks, maxblk)) - allocate(alvsf (1:nblks, maxblk)) - allocate(alnsf (1:nblks, maxblk)) - allocate(alvwf (1:nblks, maxblk)) - allocate(alnwf (1:nblks, maxblk)) - allocate(facsf (1:nblks, maxblk)) - allocate(facwf (1:nblks, maxblk)) - allocate(semis (1:nblks, maxblk)) - allocate(zorll (1:nblks, maxblk)) + do v = 1,GFS_Control%n_var_lndp + select case (trim(GFS_Control%lndp_var_list(v))) + case('smc') + allocate(slc (1:nblks, maxblk, lsoil)) + allocate(stype (1:nblks, maxblk)) + case('stc') + allocate(stc (1:nblks, maxblk, lsoil)) + case('vgf') + allocate(vfrac (1:nblks, maxblk)) + case('alb') + allocate(alnsf (1:nblks, maxblk)) + allocate(alnwf (1:nblks, maxblk)) + case('sal') + allocate(snoalb(1:nblks, maxblk)) + case('emi') + allocate(semis (1:nblks, maxblk)) + case('zol') + allocate(zorll (1:nblks, maxblk)) + endselect + enddo endif @@ -255,53 +257,76 @@ subroutine stochastic_physics_wrapper (GFS_Control, GFS_Data, Atm_block, ierr) end select end do end if + if (GFS_Control%lndp_type == 2) then ! save wts, and apply lndp scheme do nb=1,nblks GFS_Data(nb)%Coupling%sfc_wts(:,:) = sfc_wts(nb,1:GFS_Control%blksz(nb),:) end do - + do nb=1,nblks - stype(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%stype(:) - vfrac(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%vfrac(:) - snoalb(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%snoalb(:) - alvsf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%alvsf(:) - alnsf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%alnsf(:) - alvwf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%alvwf(:) - alnwf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%alnwf(:) - facsf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%facsf(:) - facwf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%facwf(:) - semis(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Radtend%semis(:) - zorll(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%zorll(:) - end do + do v = 1,GFS_Control%n_var_lndp + ! used to identify locations with land model (=soil) + if ((GFS_Control%lsm == GFS_Control%lsm_ruc) ) then + smc(nb,1:GFS_Control%blksz(nb),1:lsoil) = GFS_Data(nb)%Sfcprop%smois(1:GFS_Control%blksz(nb),1:lsoil) + else ! noah or noah-MP + smc(nb,1:GFS_Control%blksz(nb),1:lsoil) = GFS_Data(nb)%Sfcprop%smc(1:GFS_Control%blksz(nb),1:lsoil) + endif + + select case (trim(GFS_Control%lndp_var_list(v))) + case('smc') + ! stype used to fetch soil params + stype(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%stype(1:GFS_Control%blksz(nb)) + if ((GFS_Control%lsm == GFS_Control%lsm_ruc) ) then + slc(nb,1:GFS_Control%blksz(nb),1:lsoil) = GFS_Data(nb)%Sfcprop%sh2o(1:GFS_Control%blksz(nb),1:lsoil) + else ! noah or noah-MP + slc(nb,1:GFS_Control%blksz(nb),1:lsoil) = GFS_Data(nb)%Sfcprop%slc(1:GFS_Control%blksz(nb),1:lsoil) + endif + case('stc') + if ((GFS_Control%lsm == GFS_Control%lsm_ruc) ) then + stc(nb,1:GFS_Control%blksz(nb),1:lsoil) = GFS_Data(nb)%Sfcprop%tslb(1:GFS_Control%blksz(nb),1:lsoil) + else ! noah or noah-MP + stc(nb,1:GFS_Control%blksz(nb),1:lsoil) = GFS_Data(nb)%Sfcprop%stc(1:GFS_Control%blksz(nb),1:lsoil) + endif + case('vgf') + if ( (GFS_Control%lsm == GFS_Control%lsm_noahmp) ) then + ! assumes iopt_dveg = 4 (will be checked later) + vfrac(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%shdmax(1:GFS_Control%blksz(nb)) + else ! ruc or noah-MP + vfrac(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%vfrac(1:GFS_Control%blksz(nb)) + endif + case('alb') + alnsf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%alnsf(1:GFS_Control%blksz(nb)) + alnwf(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%alnwf(1:GFS_Control%blksz(nb)) + case('sal') + snoalb(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%snoalb(1:GFS_Control%blksz(nb)) + case('emi') + semis(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Radtend%semis(1:GFS_Control%blksz(nb)) + case('zol') + zorll(nb,1:GFS_Control%blksz(nb)) = GFS_Data(nb)%Sfcprop%zorll(1:GFS_Control%blksz(nb)) + endselect + enddo + enddo - if (GFS_Control%lsm == GFS_Control%lsm_noah) then - do nb=1,nblks - smc(nb,1:GFS_Control%blksz(nb),:) = GFS_Data(nb)%Sfcprop%smc(:,:) - slc(nb,1:GFS_Control%blksz(nb),:) = GFS_Data(nb)%Sfcprop%slc(:,:) - stc(nb,1:GFS_Control%blksz(nb),:) = GFS_Data(nb)%Sfcprop%stc(:,:) - end do - elseif (GFS_Control%lsm == GFS_Control%lsm_ruc) then - do nb=1,nblks - smc(nb,1:GFS_Control%blksz(nb),:) = GFS_Data(nb)%Sfcprop%smois(:,:) - slc(nb,1:GFS_Control%blksz(nb),:) = GFS_Data(nb)%Sfcprop%sh2o(:,:) - stc(nb,1:GFS_Control%blksz(nb),:) = GFS_Data(nb)%Sfcprop%tslb(:,:) - end do - endif + param_update_flag = .false. + ! noah and noah-MP treated differently, as global cycle doesn't overwrite shdmax for Noah-MP ! determine whether land paramaters have been over-written to ! trigger applying perturbations (logic copied from GFS_driver), - ! or if perturbations should be applied at every time step - if (mod(GFS_Control%kdt,GFS_Control%nscyc) == 1 ) then - param_update_flag = .true. - else - param_update_flag = .false. + if ( (GFS_Control%lsm == GFS_Control%lsm_noah) .and. GFS_Control%nscyc > 0) then + if (mod(GFS_Control%kdt,GFS_Control%nscyc) == 1 ) then + param_update_flag = .true. + endif endif - - call lndp_apply_perts(GFS_Control%blksz, GFS_Control%lsm, GFS_Control%lsm_noah, GFS_Control%lsm_ruc, lsoil, & - GFS_Control%dtp, GFS_Control%kdt, GFS_Control%lndp_each_step, & + if ( ( GFS_Control%nscyc == 0 .or. GFS_Control%lsm == GFS_Control%lsm_noahmp) .and. GFS_Control%first_time_step ) then + ! call once at start of the forecast. + param_update_flag = .true. + endif + + call lndp_apply_perts(GFS_Control%blksz, GFS_Control%lsm, GFS_Control%lsm_noah, GFS_Control%lsm_ruc, & + GFS_Control%lsm_noahmp, GFS_Control%iopt_dveg, lsoil, GFS_Control%dtp, GFS_Control%kdt, & GFS_Control%n_var_lndp, GFS_Control%lndp_var_list, GFS_Control%lndp_prt_list, & sfc_wts, xlon, xlat, stype, GFS_Control%pores, GFS_Control%resid,param_update_flag, & - smc, slc, stc, vfrac, alvsf, alnsf, alvwf, alnwf, facsf, facwf, snoalb, semis, zorll, ierr) + smc, slc, stc, vfrac, alnsf, alnwf, snoalb, semis, zorll, ierr) if (ierr/=0) then write(6,*) 'call to GFS_apply_lndp failed' @@ -309,34 +334,43 @@ subroutine stochastic_physics_wrapper (GFS_Control, GFS_Data, Atm_block, ierr) endif do nb=1,nblks - GFS_Data(nb)%Sfcprop%vfrac(:) = vfrac(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%snoalb(:) = snoalb(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%alvsf(:) = alvsf(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%alnsf(:) = alnsf(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%alvwf(:) = alvwf(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%alnwf(:) = alnwf(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%facsf(:) = facsf(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%facwf(:) = facwf(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Radtend%semis(:) = semis(nb,1:GFS_Control%blksz(nb)) - GFS_Data(nb)%Sfcprop%zorll(:) = zorll(nb,1:GFS_Control%blksz(nb)) - enddo - - if (GFS_Control%lsm == GFS_Control%lsm_noah) then - do nb=1,nblks - GFS_Data(nb)%Sfcprop%smc(:,:) = smc(nb,1:GFS_Control%blksz(nb),:) - GFS_Data(nb)%Sfcprop%slc(:,:) = slc(nb,1:GFS_Control%blksz(nb),:) - GFS_Data(nb)%Sfcprop%stc(:,:) = stc(nb,1:GFS_Control%blksz(nb),:) - enddo - elseif (GFS_Control%lsm == GFS_Control%lsm_ruc) then - do nb=1,nblks - GFS_Data(nb)%Sfcprop%smois(:,:) = smc(nb,1:GFS_Control%blksz(nb),:) - GFS_Data(nb)%Sfcprop%sh2o(:,:) = slc(nb,1:GFS_Control%blksz(nb),:) - GFS_Data(nb)%Sfcprop%tslb(:,:) = stc(nb,1:GFS_Control%blksz(nb),:) - enddo - endif - + do v = 1,GFS_Control%n_var_lndp + + select case (trim(GFS_Control%lndp_var_list(v))) + case('smc') + if ((GFS_Control%lsm == GFS_Control%lsm_ruc) ) then + GFS_Data(nb)%Sfcprop%smois(1:GFS_Control%blksz(nb),1:lsoil) = smc(nb,1:GFS_Control%blksz(nb),1:lsoil) + GFS_Data(nb)%Sfcprop%sh2o(1:GFS_Control%blksz(nb),1:lsoil) = slc(nb,1:GFS_Control%blksz(nb),1:lsoil) + else ! noah or noah-MP + GFS_Data(nb)%Sfcprop%smc(1:GFS_Control%blksz(nb),1:lsoil) = smc(nb,1:GFS_Control%blksz(nb),1:lsoil) + GFS_Data(nb)%Sfcprop%slc(1:GFS_Control%blksz(nb),1:lsoil) = slc(nb,1:GFS_Control%blksz(nb),1:lsoil) + endif + case('stc') + if ((GFS_Control%lsm == GFS_Control%lsm_ruc) ) then + GFS_Data(nb)%Sfcprop%tslb(1:GFS_Control%blksz(nb),1:lsoil) = stc(nb,1:GFS_Control%blksz(nb),1:lsoil) + else ! noah or noah-MP + GFS_Data(nb)%Sfcprop%stc(1:GFS_Control%blksz(nb),1:lsoil) = stc(nb,1:GFS_Control%blksz(nb),1:lsoil) + endif + case('vgf') + if ( (GFS_Control%lsm == GFS_Control%lsm_noahmp) ) then + GFS_Data(nb)%Sfcprop%shdmax(1:GFS_Control%blksz(nb)) = vfrac(nb,1:GFS_Control%blksz(nb)) + else + GFS_Data(nb)%Sfcprop%vfrac(1:GFS_Control%blksz(nb)) = vfrac(nb,1:GFS_Control%blksz(nb)) + endif + case('alb') + GFS_Data(nb)%Sfcprop%alnsf(1:GFS_Control%blksz(nb)) = alnsf(nb,1:GFS_Control%blksz(nb)) + GFS_Data(nb)%Sfcprop%alnwf(1:GFS_Control%blksz(nb)) = alnwf(nb,1:GFS_Control%blksz(nb)) + case('sal') + GFS_Data(nb)%Sfcprop%snoalb(1:GFS_Control%blksz(nb)) = snoalb(nb,1:GFS_Control%blksz(nb)) + case('emi') + GFS_Data(nb)%Radtend%semis(1:GFS_Control%blksz(nb)) = semis(nb,1:GFS_Control%blksz(nb)) + case('zol') + GFS_Data(nb)%Sfcprop%zorll(1:GFS_Control%blksz(nb)) = zorll(nb,1:GFS_Control%blksz(nb)) + end select + enddo + enddo endif ! lndp block - end if + endif ! if do* block if (GFS_Control%do_ca) then @@ -409,42 +443,40 @@ subroutine stochastic_physics_wrapper_end (GFS_Control) if (GFS_Control%do_spp) then if (allocated(spp_wts)) deallocate(spp_wts) end if - if ( GFS_Control%lndp_type == 2 ) then ! this scheme updates through forecast + if ( GFS_Control%lndp_type == 2 ) then lsoil = -999 if (allocated(sfc_wts)) deallocate(sfc_wts) end if - if (GFS_Control%lndp_type == 2) then ! save wts, and apply lndp scheme + if (GFS_Control%lndp_type == 2) then if (allocated(smc)) deallocate(smc) if (allocated(slc)) deallocate(slc) if (allocated(stc)) deallocate(stc) if (allocated(stype)) deallocate(stype) if (allocated(vfrac)) deallocate(vfrac) if (allocated(snoalb)) deallocate(snoalb) - if (allocated(alvsf)) deallocate(alvsf) if (allocated(alnsf)) deallocate(alnsf) - if (allocated(alvwf)) deallocate(alvwf) if (allocated(alnwf)) deallocate(alnwf) - if (allocated(facsf)) deallocate(facsf) - if (allocated(facwf)) deallocate(facwf) if (allocated(semis)) deallocate(semis) if (allocated(zorll)) deallocate(zorll) endif call finalize_stochastic_physics() endif - if(GFS_Control%ca_sgs)then - deallocate(sst ) - deallocate(lmsk ) - deallocate(lake ) - deallocate(condition ) - deallocate(ca_deep_cpl ) - deallocate(ca_turb_cpl ) - deallocate(ca_shal_cpl ) - endif - if(GFS_Control%ca_global)then - deallocate(ca1_cpl ) - deallocate(ca2_cpl ) - deallocate(ca3_cpl ) - endif + if(GFS_Control%do_ca)then + if(GFS_Control%ca_sgs)then + deallocate(sst ) + deallocate(lmsk ) + deallocate(lake ) + deallocate(condition ) + deallocate(ca_deep_cpl ) + deallocate(ca_turb_cpl ) + deallocate(ca_shal_cpl ) + endif + if(GFS_Control%ca_global)then + deallocate(ca1_cpl ) + deallocate(ca2_cpl ) + deallocate(ca3_cpl ) + endif + endif end subroutine stochastic_physics_wrapper_end end module stochastic_physics_wrapper_mod