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

Add the stochastic pattern interval option to SPP and LNDP #72

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 27 additions & 2 deletions compns_stochy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
epbl,epbl_lscale,epbl_tau,iseed_epbl, &
ocnsppt,ocnsppt_lscale,ocnsppt_tau,iseed_ocnsppt,pbl_taper
namelist /nam_sfcperts/lndp_type,lndp_model_type, lndp_var_list, lndp_prt_list, &
iseed_lndp, lndp_tau,lndp_lscale
iseed_lndp,lndpint,lndp_tau,lndp_lscale
! For SPP physics parameterization perterbations
namelist /nam_sppperts/spp_var_list, spp_prt_list, iseed_spp, &
spp_tau,spp_lscale,spp_sigtop1, spp_sigtop2,spp_stddev_cutoff
sppint,spp_tau,spp_lscale,spp_sigtop1,spp_sigtop2,spp_stddev_cutoff

rerth =6.3712e+6 ! radius of earth (m)
tol=0.01 ! tolerance for calculations
Expand Down Expand Up @@ -156,6 +156,8 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
spp_tau = -999. ! time scales
spp_stddev_cutoff = 0 ! cutoff/limit for std-dev (zero==no limit applied)
iseed_spp = 0 ! random seeds (if 0 use system clock)
sppint = 0 ! SPP interval in seconds
lndpint = 0 ! lndp interval in seconds

#ifdef INTERNAL_FILE_NML
read(input_nml_file, nml=nam_stochy)
Expand Down Expand Up @@ -212,6 +214,9 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
skeb=skeb*1.111e-9*sqrt(deltim)
endif
ENDIF
IF (spp_prt_list(1) > 0 ) THEN
do_spp=.true.
ENDIF
! compute frequencty to estimate dissipation timescale
IF (do_skeb) THEN
IF (skebint == 0.) skebint=deltim
Expand Down Expand Up @@ -240,6 +245,26 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
return
ENDIF
ENDIF
IF (do_spp) THEN
IF (sppint == 0.) sppint=deltim
nsspp=nint(sppint/deltim) ! sppint in seconds
IF(nsspp<=0 .or. abs(nsspp-sppint/deltim)>tol) THEN
WRITE(0,*) "SPP interval is invalid",sppint
iret=9
return
ENDIF
ENDIF

IF (lndp_type > 0) THEN
IF (lndpint == 0.) lndpint=deltim
nslndp=nint(lndpint/deltim)
IF(nslndp<=0 .or. abs(nslndp-lndpint/deltim)>tol) THEN
WRITE(0,*) "lndp interval is invalid",lndpint
iret=9
return
ENDIF
ENDIF

!calculate ntrunc if not supplied
if (ntrunc .LT. 1) then
if (me==0) print*,'ntrunc not supplied, calculating'
Expand Down
36 changes: 20 additions & 16 deletions stochastic_physics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ subroutine run_stochastic_physics(levs, kdt, fhour, blksz, sppt_wts, shum_wts, s
rpattern_spp, nspp, vfact_spp
use get_stochy_pattern_mod,only : get_random_pattern_scalar,get_random_pattern_vector, &
get_random_pattern_sfc,get_random_pattern_spp
use stochy_namelist_def, only : do_shum,do_sppt,do_skeb,nssppt,nsshum,nsskeb,sppt_logit, &
use stochy_namelist_def, only : do_shum,do_sppt,do_skeb,nssppt,nsshum,nsskeb,nsspp,nslndp,sppt_logit, &
lndp_type, n_var_lndp, n_var_spp, do_spp, spp_stddev_cutoff, spp_prt_list
use mpi_wrapper, only: is_rootpe
implicit none
Expand Down Expand Up @@ -432,6 +432,7 @@ subroutine run_stochastic_physics(levs, kdt, fhour, blksz, sppt_wts, shum_wts, s
endif
if ( lndp_type .EQ. 2 ) then
! add time check?
if (mod(kdt,nslndp) == 1 .or. nslndp == 1) then
allocate(tmpl_wts(gis_stochy%nx,gis_stochy%ny,n_var_lndp))
call get_random_pattern_sfc(rpattern_sfc,nlndp,gis_stochy,tmpl_wts)
DO blk=1,nblks
Expand All @@ -442,23 +443,26 @@ subroutine run_stochastic_physics(levs, kdt, fhour, blksz, sppt_wts, shum_wts, s
ENDDO
ENDDO
deallocate(tmpl_wts)
endif
endif
if (n_var_spp .GE. 1) then
allocate(tmp_spp_wts(gis_stochy%nx,gis_stochy%ny,n_var_spp))
call get_random_pattern_spp(rpattern_spp,nspp,gis_stochy,tmp_spp_wts)
DO v=1,n_var_spp
DO blk=1,nblks
len=blksz(blk)
DO k=1,levs
if (spp_stddev_cutoff(v).gt.0.0) then
spp_wts(blk,1:len,k,v)=MAX(MIN(tmp_spp_wts(1:len,blk,v)*vfact_spp(k),spp_stddev_cutoff(v)),-1.0*spp_stddev_cutoff(v))*spp_prt_list(v)
else
spp_wts(blk,1:len,k,v)=tmp_spp_wts(1:len,blk,v)*vfact_spp(k)*spp_prt_list(v)
endif
ENDDO
ENDDO
ENDDO
deallocate(tmp_spp_wts)
if (mod(kdt,nsspp) == 1 .or. nsspp == 1) then
allocate(tmp_spp_wts(gis_stochy%nx,gis_stochy%ny,n_var_spp))
call get_random_pattern_spp(rpattern_spp,nspp,gis_stochy,tmp_spp_wts)
DO v=1,n_var_spp
DO blk=1,nblks
len=blksz(blk)
DO k=1,levs
if (spp_stddev_cutoff(v).gt.0.0) then
spp_wts(blk,1:len,k,v)=MAX(MIN(tmp_spp_wts(1:len,blk,v)*vfact_spp(k),spp_stddev_cutoff(v)),-1.0*spp_stddev_cutoff(v))*spp_prt_list(v)
else
spp_wts(blk,1:len,k,v)=tmp_spp_wts(1:len,blk,v)*vfact_spp(k)*spp_prt_list(v)
endif
ENDDO
ENDDO
ENDDO
deallocate(tmp_spp_wts)
end if
endif
deallocate(tmp_wts)
deallocate(tmpu_wts)
Expand Down
4 changes: 2 additions & 2 deletions stochy_data_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret)
endif
endif
ones = 1.
call patterngenerator_init(lndp_lscale(1:nlndp),real(delt,kind_phys),lndp_tau(1:nlndp),ones(1:nlndp),iseed_lndp,rpattern_sfc, &
call patterngenerator_init(lndp_lscale(1:nlndp),lndpint,lndp_tau(1:nlndp),ones(1:nlndp),iseed_lndp,rpattern_sfc, &
lonf,latg,jcap,gis_stochy%ls_node,nlndp,n_var_lndp,0,new_lscale)
do n=1,nlndp
if (is_rootpe()) print *, 'Initialize random pattern for LNDP PERTS'
Expand Down Expand Up @@ -433,7 +433,7 @@ subroutine init_stochdata(nlevs,delt,input_nml_file,fn_nml,nlunit,iret)
endif
endif
ones = 1.
call patterngenerator_init(spp_lscale(1:nspp),real(delt,kind_phys),spp_tau(1:nspp),ones(1:nspp),iseed_spp,rpattern_spp, &
call patterngenerator_init(spp_lscale(1:nspp),sppint,spp_tau(1:nspp),ones(1:nspp),iseed_spp,rpattern_spp, &
lonf,latg,jcap,gis_stochy%ls_node,nspp,n_var_spp,0,new_lscale)
do n=1,nspp
if (is_rootpe()) print *, 'Initialize random pattern for SPP PERTS'
Expand Down
5 changes: 3 additions & 2 deletions stochy_namelist_def.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module stochy_namelist_def
public
integer, parameter :: max_n_var_lndp = 20 ! must match value used in GFS_typedefs
integer, parameter :: max_n_var_spp = 6 ! must match value used in GFS_typedefs
integer nssppt,nsshum,nsepbl,nsocnsppt,nsskeb,lon_s,lat_s,ntrunc
integer nsspp,nssppt,nsshum,nsepbl,nsocnsppt,nsskeb,nslndp,lon_s,lat_s,ntrunc

! pjp stochastic phyics
integer skeb_varspect_opt,skeb_npass
Expand All @@ -21,7 +21,8 @@ module stochy_namelist_def
real(kind=kind_phys) :: skeb_sigtop1,skeb_sigtop2, &
sppt_sigtop1,sppt_sigtop2,shum_sigefold, &
skeb_vdof
real(kind=kind_phys) skeb_diss_smooth,epblint,ocnspptint,spptint,shumint,skebint,skebnorm
real(kind=kind_phys) skeb_diss_smooth,epblint,ocnspptint,sppint,spptint,shumint,skebint,skebnorm
real(kind=kind_phys) lndpint
real(kind=kind_phys), dimension(5) :: skeb,skeb_lscale,skeb_tau
real(kind=kind_phys), dimension(5) :: sppt,sppt_lscale,sppt_tau
real(kind=kind_phys), dimension(5) :: shum,shum_lscale,shum_tau
Expand Down