Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated land perturbation scheme #148

Merged
merged 34 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6587ec6
update to pre-existing land perts scheme, ready for addition of the n…
ClaraDraper-NOAA Mar 20, 2020
c136caf
updates to land perts scheme, so that namelist input and control_type…
ClaraDraper-NOAA Mar 25, 2020
b0315a7
minor bug fix GFS_typedefs.meta
ClaraDraper-NOAA Mar 26, 2020
8c7305c
updating .gitmodules to my repository for ccpp-physics
ClaraDraper-NOAA Mar 26, 2020
069b58e
Revert "updating .gitmodules to my repository for ccpp-physics"
ClaraDraper-NOAA Mar 26, 2020
5a20c62
update gitmodules to point to my ccpp
ClaraDraper-NOAA Mar 26, 2020
1cef958
ccpp updates to old sfc pert team - does not compile
ClaraDraper-NOAA Apr 1, 2020
142a549
replace my fork with NCAR to fix clone
ClaraDraper-NOAA Apr 1, 2020
472f674
correcting missed ccp push
ClaraDraper-NOAA Apr 8, 2020
a5c653a
Phil's ccpp changes
ClaraDraper-NOAA Apr 8, 2020
6da74eb
correcting to my ccpp branch
ClaraDraper-NOAA Apr 15, 2020
5c2669b
rebasing ccpp for upstream changes
ClaraDraper-NOAA Apr 16, 2020
ef26a23
Merge commit '9b5a420cf6878cd9db391337d68c252cc0c2a905' into csd-fv3-…
ClaraDraper-NOAA Apr 16, 2020
5c57a58
minor bug fix
ClaraDraper-NOAA Apr 16, 2020
4cc6e04
Lndp updates, including moving around the calling structure.
ClaraDraper-NOAA Jun 25, 2020
c2b4d20
Merge commit '6c217fcbebf026a91fb178cf98a11a27cf5fe19f' into csd-fv3-…
ClaraDraper-NOAA Jun 30, 2020
03332e0
lndp clean-up
ClaraDraper-NOAA Jul 20, 2020
35df12e
lndp submodule clean-up
ClaraDraper-NOAA Jul 20, 2020
458e5be
Updated submodules for merge.
ClaraDraper-NOAA Jul 20, 2020
f52214d
Merge commit 'f053db29aff82456d081dda17a4962dd93ab39c5' into csd-fv3-…
ClaraDraper-NOAA Jul 20, 2020
02160db
Merge commit 'f053db29aff82456d081dda17a4962dd93ab39c5' into csd-fv3-…
ClaraDraper-NOAA Jul 20, 2020
4856f8f
cleaning-up messed up commit.
ClaraDraper-NOAA Jul 26, 2020
2fdca27
Merge branch 'temp' into csd-fv3-sfcpert
ClaraDraper-NOAA Jul 26, 2020
bba8815
Fixed typo in vegfrac name
ClaraDraper-NOAA Jul 27, 2020
dee00b4
reverting to NCAR's ccpp-framework repository.
ClaraDraper-NOAA Jul 28, 2020
e268506
ccpp/physics merge to latest
ClaraDraper-NOAA Aug 11, 2020
25a039e
Merge commit '1959bdedfa2149bf668b85771b8840db665745ec' into csd-fv3-…
ClaraDraper-NOAA Aug 11, 2020
9aa3e37
Merge commit '0975bb669bb911d2eec9cd6cf5c3dd8a78108dcf' into csd-fv3-…
ClaraDraper-NOAA Aug 25, 2020
60d6b32
updated submodules
ClaraDraper-NOAA Aug 25, 2020
e56e33a
deleted GFS_land_perts.F90 (moved to stochastic_physics)
ClaraDraper-NOAA Aug 25, 2020
3177ce1
Removing FV3 dependency from stochastic_physics, and into wrapper
ClaraDraper-NOAA Aug 26, 2020
6e6658e
Fix linker problem in gfsphysics/CMakeLists.txt by removing physics/p…
climbfuji Aug 11, 2020
71ca8e4
edits to compile with gnumake
ClaraDraper-NOAA Aug 27, 2020
4e6e1b0
Revert change to .gitmodules for ccpp-physics and update submodule po…
ClaraDraper-NOAA Aug 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
branch = master
[submodule "ccpp/physics"]
path = ccpp/physics
url = https://github.com/NCAR/ccpp-physics.git
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reverting .gitmodules to where it was originally (the new version in this PR is how it should be, no need to add .git and also good to remove the unnecessary double whitespace and the trailing whitespace below.

branch = master
url = https://github.com/ClaraDraper-NOAA/ccpp-physics
branch = csd-ccp-sfcert-fix
7 changes: 5 additions & 2 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ subroutine update_atmos_radiation_physics (Atmos)
#endif

!--- call stochastic physics pattern generation / cellular automata
call stochastic_physics_wrapper(IPD_Control, IPD_Data, Atm_block)
call stochastic_physics_wrapper(IPD_Control, IPD_Data, Atm_block, ierr)
if (ierr/=0) call mpp_error(FATAL, 'Call to stochastic_physics_wrapper failed')

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these error checks.


!--- if coupled, assign coupled fields

Expand Down Expand Up @@ -628,7 +630,8 @@ subroutine atmos_model_init (Atmos, Time_init, Time, Time_step)
#endif

!--- Initialize stochastic physics pattern generation / cellular automata for first time step
call stochastic_physics_wrapper(IPD_Control, IPD_Data, Atm_block)
call stochastic_physics_wrapper(IPD_Control, IPD_Data, Atm_block, ierr)
if (ierr/=0) call mpp_error(FATAL, 'Call to stochastic_physics_wrapper failed')

Atmos%Diag => IPD_Diag

Expand Down
2 changes: 1 addition & 1 deletion ccpp/framework
Submodule framework updated 0 files
1 change: 1 addition & 0 deletions gfsphysics/GFS_layer/GFS_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ subroutine GFS_time_vary_step (Model, Statein, Stateout, Sfcprop, Coupling, &
if (mod(Model%kdt,Model%nscyc) == 1) THEN
call gcycle (nblks, Model, Grid(:), Sfcprop(:), Cldprop(:))
endif
! if not updating surface params through fcast, perturb params once at start of fcast
endif

!--- determine if diagnostics buckets need to be cleared
Expand Down
249 changes: 249 additions & 0 deletions gfsphysics/GFS_layer/GFS_land_perts.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
module GFS_land_perts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this entire code be in the CCPP "stochastic_physics" group, either as an additional scheme or as part of the existing GFS_stochastic scheme?

Once we remove IPD, there will be no access to the soilveg data etc. anymore.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: see my comment below for file stochastic_physics/stochastic_physics_wrapper.F90.


use machine, only: kind_phys

implicit none

private

public :: GFS_apply_lndp

contains

!====================================================================
! GFS_apply_lndp
!====================================================================
! Driver for applying perturbations to sprecified land states or parameters
! Draper, July 2020.
! Note on location: requires access to namelist_soilveg

subroutine GFS_apply_lndp(blksz,lsm, lsoil,dtf, n_var_lndp, lndp_var_list, &
lndp_prt_list, sfc_wts, xlon, xlat, stype, param_update_flag, &
smc, slc, stc, vfrac, ierr)

use namelist_soilveg ! needed for maxsmc

implicit none

! intent(in)
integer, intent(in) :: blksz(:)
integer, intent(in) :: n_var_lndp, lsoil, lsm
character(len=3), intent(in) :: lndp_var_list(:)
real(kind=kind_phys), intent(in) :: lndp_prt_list(:)
real(kind=kind_phys), intent(in) :: dtf
real(kind=kind_phys), intent(in) :: sfc_wts(:,:,:)
real(kind=kind_phys), intent(in) :: xlon(:,:)
real(kind=kind_phys), intent(in) :: xlat(:,:)
logical, intent(in) :: param_update_flag
! true = parameters have been updated, apply perts
real(kind=kind_phys), intent(in) :: stype(:,:)

! intent(inout)
real(kind=kind_phys), intent(inout) :: smc(:,:,:)
real(kind=kind_phys), intent(inout) :: slc(:,:,:)
real(kind=kind_phys), intent(inout) :: stc(:,:,:)
real(kind=kind_phys), intent(inout) :: vfrac(:,:)

! intent(out)
integer, intent(out) :: ierr

! local
integer :: nblks, print_i, print_nb, i, nb
integer :: this_im, v, soiltyp, k
logical :: print_flag

real(kind=kind_phys) :: p, min_bound, max_bound, tmp_sic, pert

! decrease in applied pert with depth
real(kind=kind_phys), dimension(4), parameter :: smc_vertscale = (/1.0,0.5,0.25,0.125/)
real(kind=kind_phys), dimension(4), parameter :: stc_vertscale = (/1.0,0.5,0.25,0.125/)

! model-dependent values, hard-wired in noah code.
real(kind=kind_phys), dimension(4), parameter :: zs_noah = (/0.1, 0.3, 0.6, 1.0/)
real(kind=kind_phys), parameter :: minsmc = 0.02

ierr = 0

if (lsm .NE. 1 ) then
write(6,*) 'ERROR: GFS_land_pert assumes LSM is noah, ', &
' may need to adapt variable names for a different LSM'
ierr=10
return
endif

nblks = size(blksz)

call set_printing_nb_i(blksz,xlon,xlat,print_i,print_nb)

do nb =1,nblks
do i = 1, blksz(nb)

!if ( nint(Sfcprop(nb)%slmsk(i)) .NE. 1) cycle ! skip if not land

!if ( ((isot == 1) .and. (soiltyp == 16)) &
! .or.( (isot == 0) .and. (soiltyp == 9 )) ) cycle ! skip if land-ice

if ( smc(nb,i,1) .EQ. 1.) cycle ! skip non-soil (land-ice and non-land)
! set printing
if ( (i==print_i) .and. (nb==print_nb) ) then
print_flag = .true.
else
print_flag=.false.
endif

do v = 1,n_var_lndp
select case (trim(lndp_var_list(v)))
!=================================================================
! State updates - performed every cycle
!=================================================================
case('smc')
p=5.
soiltyp = int( stype(nb,i)+0.5 ) ! also need for maxsmc
min_bound = minsmc
max_bound = maxsmc(soiltyp)

do k=1,lsoil
!store frozen soil moisture
tmp_sic= smc(nb,i,k) - slc(nb,i,k)

! perturb total soil moisture
! factor of sldepth*1000 converts from mm to m3/m3
pert = sfc_wts(nb,i,v)*smc_vertscale(k)*lndp_prt_list(v)/(zs_noah(k)*1000.)
pert = pert*dtf/3600. ! lndp_prt_list input is per hour, convert to per timestep
! (necessary for state vars only)
call apply_pert('smc',pert,print_flag, smc(nb,i,k),ierr,p,min_bound, max_bound)

! assign all of applied pert to the liquid soil moisture
slc(nb,i,k) = smc(nb,i,k) - tmp_sic
enddo

case('stc')

do k=1,lsoil
pert = sfc_wts(nb,i,v)*stc_vertscale(k)*lndp_prt_list(v)
pert = pert*dtf/3600. ! lndp_prt_list input is per hour, convert to per timestep
! (necessary for state vars only)
call apply_pert('stc',pert,print_flag, stc(nb,i,k),ierr)
enddo
!=================================================================
! Parameter updates - only if param_update_flag = TRUE
!=================================================================
case('vgf') ! vegetation fraction
if (param_update_flag) then
p =5.
min_bound=0.
max_bound=1.

pert = sfc_wts(nb,i,v)*lndp_prt_list(v)
call apply_pert ('vfrac',pert,print_flag, vfrac(nb,i), ierr,p,min_bound, max_bound)
endif
case default
print*, &
'ERROR: unrecognised lndp_prt_list option in GFS_apply_lndp, exiting', trim(lndp_var_list(v))
ierr = 10
return
end select
enddo
enddo
enddo
end subroutine GFS_apply_lndp

!====================================================================
! apply_perts
!====================================================================
! Apply perturbations to selected land states or parameters

subroutine apply_pert(vname,pert,print_flag, state,ierr,p,vmin, vmax)

! intent in
logical, intent(in) :: print_flag
real(kind=kind_phys), intent(in) :: pert
character(len=*), intent(in) :: vname ! name of variable being perturbed

real(kind=kind_phys), optional, intent(in) :: p ! flat-top paramater, 0 = no flat-top
! flat-top function is used for bounded variables
! to reduce the magnitude of perturbations near boundaries.
real(kind=kind_phys), optional, intent(in) :: vmin, vmax ! min,max bounds of variable being perturbed

! intent (inout)
real(kind=kind_phys), intent(inout) :: state

! intent out
integer :: ierr

!local
real(kind=kind_phys) :: z

if ( print_flag ) then
write(*,*) 'LNDP - applying lndp to ',vname, ', initial value', state
endif

! apply perturbation
if (present(p) ) then
if ( .not. (present(vmin) .and. present(vmax) )) then
ierr=20
print*, 'error, flat-top function requires min & max to be specified'
endif

z = -1. + 2*(state - vmin)/(vmax - vmin) ! flat-top function
state = state + pert*(1-abs(z**p))
else
state = state + pert
endif

if (present(vmax)) state = min( state , vmax )
if (present(vmin)) state = max( state , vmin )
!state = max( min( state , vmax ), vmin )

if ( print_flag ) then
write(*,*) 'LNDP - applying lndp to ',vname, ', final value', state
endif

end subroutine apply_pert


!====================================================================
! set_printing_nb_i
!====================================================================
! routine to turn on print flag for selected location
!
subroutine set_printing_nb_i(blksz,xlon,xlat,print_i,print_nb)

implicit none

! intent (in)
integer, intent(in) :: blksz(:)
real(kind=kind_phys), intent(in) :: xlon(:,:)
real(kind=kind_phys), intent(in) :: xlat(:,:)


! intent (out)
integer, intent(out) :: print_i, print_nb

! local
integer :: nblks,nb,i
real, parameter :: plon_trunc = 114.9
real, parameter :: plat_trunc = -26.6
real, parameter :: delta = 1.

nblks = size(blksz)

print_i = -9
print_nb = -9
do nb = 1,nblks
do i = 1,blksz(nb)
if ( (xlon(nb,i)*57.29578 > plon_trunc) .and. (xlon(nb,i)*57.29578 < plon_trunc+delta ) .and. &
(xlat(nb,i)*57.29578 > plat_trunc ) .and. (xlat(nb,i)*57.29578 < plat_trunc+delta ) ) then
print_i=i
print_nb=nb
write(*,*) 'LNDP -print flag is on', xlon(nb,i)*57.29578, xlat(nb,i)*57.29578, nb, i
return
endif
enddo
enddo

end subroutine set_printing_nb_i

end module GFS_land_perts


55 changes: 26 additions & 29 deletions gfsphysics/GFS_layer/GFS_physics_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ subroutine GFS_physics_driver &
real :: pshltr,QCQ,rh02
real(kind=kind_phys), allocatable, dimension(:,:) :: den

real(kind=kind_phys) :: lndp_vgf
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we agreed to no longer accept changes to IPD unless they are backports of GFS v16 implementation bug fixes. Just mentioning it here, but I am not going to ask you to change anything.

!! Initialize local variables (for debugging purposes only,
!! because the corresponding variables Interstitial(nt)%...
!! are reset to zero every time).
Expand Down Expand Up @@ -928,34 +929,28 @@ subroutine GFS_physics_driver &
! alb1d(i) = zero
vegf1d(i) = zero
enddo
if (Model%do_sfcperts) then
if (Model%pertz0(1) > zero) then
z01d(:) = Model%pertz0(1) * Coupling%sfc_wts(:,1)
! if (me == 0) print*,'Coupling%sfc_wts(:,1) min and max',minval(Coupling%sfc_wts(:,1)),maxval(Coupling%sfc_wts(:,1))
! if (me == 0) print*,'z01d min and max ',minval(z01d),maxval(z01d)
endif
if (Model%pertzt(1) > zero) then
zt1d(:) = Model%pertzt(1) * Coupling%sfc_wts(:,2)
endif
if (Model%pertshc(1) > zero) then
bexp1d(:) = Model%pertshc(1) * Coupling%sfc_wts(:,3)
endif
if (Model%pertlai(1) > zero) then
xlai1d(:) = Model%pertlai(1) * Coupling%sfc_wts(:,4)
endif
! --- do the albedo percentile calculation in GFS_radiation_driver instead --- !
! if (Model%pertalb(1) > zero) then
! do i=1,im
! call cdfnor(Coupling%sfc_wts(i,5),cdfz)
! alb1d(i) = cdfz
! enddo
! endif
if (Model%pertvegf(1) > zero) then
do i=1,im
call cdfnor(Coupling%sfc_wts(i,6),cdfz)
vegf1d(i) = cdfz
enddo
endif
lndp_vgf=-999.

if (Model%lndp_type==1) then
do k =1,Model%n_var_lndp
select case(Model%lndp_var_list(k))
case ('rz0')
z01d(:) = Model%lndp_prt_list(k)* Coupling%sfc_wts(:,k)
case ('rzt')
zt1d(:) = Model%lndp_prt_list(k)* Coupling%sfc_wts(:,k)
case ('shc')
bexp1d(:) = Model%lndp_prt_list(k) * Coupling%sfc_wts(:,k)
case ('lai')
xlai1d(:) = Model%lndp_prt_list(k)* Coupling%sfc_wts(:,k)
case ('vgf')
! note that the pertrubed vegfrac is being used in sfc_drv, but not sfc_diff
do i=1,im
call cdfnor(Coupling%sfc_wts(i,k),cdfz)
vegf1d(i) = cdfz
enddo
lndp_vgf = Model%lndp_prt_list(k)
end select
enddo
endif
!*## CCPP ##
!
Expand Down Expand Up @@ -1856,6 +1851,7 @@ subroutine GFS_physics_driver &
! &,' pgr=',pgr(ipr),' sfcemis=',sfcemis(ipr)

!## CCPP ##* sfc_drv.f/lsm_noah_run

call sfc_drv &
! --- inputs:
(im, lsoil, Statein%pgr, &
Expand All @@ -1867,7 +1863,8 @@ subroutine GFS_physics_driver &
Sfcprop%shdmin, Sfcprop%shdmax, Sfcprop%snoalb, &
Radtend%sfalb, flag_iter, flag_guess, Model%lheatstrg, &
Model%isot, Model%ivegsrc, &
bexp1d, xlai1d, vegf1d, Model%pertvegf, &
bexp1d, xlai1d, vegf1d,lndp_vgf, &

! --- input/output:
weasd3(:,1), snowd3(:,1), tsfc3(:,1), tprcp3(:,1), &
Sfcprop%srflag, smsoil, stsoil, slsoil, Sfcprop%canopy, &
Expand Down
Loading