Skip to content

Commit

Permalink
added logic to calculate ntrunc,lon_s and lat_s from lengthscales
Browse files Browse the repository at this point in the history
  • Loading branch information
pjpegion committed Dec 3, 2019
1 parent 23dc002 commit f97409e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compile_standalone
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh -x
compile_all=0
compile_all=1
FC=mpif90
INCS="-I. -I../FV3/gfsphysics/ -I../FMS/include -I../FV3/atmos_cubed_sphere -I../FMS/fv3gfs"
FLAGS64=" -traceback -real-size 64 -DSTOCHY_UNIT_TEST -c "$INCS
Expand Down
25 changes: 24 additions & 1 deletion compns_stochy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
character(len=*), intent(in) :: input_nml_file(sz_nml)
character(len=64), intent(in) :: fn_nml
real, intent(in) :: deltim
real tol
real tol,l_min
real :: rerth,circ
integer k,ios
integer,parameter :: two=2

! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!
Expand All @@ -58,6 +60,7 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
namelist /nam_sfcperts/nsfcpert,pertz0,pertshc,pertzt,pertlai, & ! mg, sfcperts
pertvegf,pertalb,iseed_sfc,sfc_tau,sfc_lscale,sppt_land

rerth =6.3712e+6 ! radius of earth (m)
tol=0.01 ! tolerance for calculations
! spectral resolution defintion
ntrunc=-999
Expand Down Expand Up @@ -207,6 +210,26 @@ subroutine compns_stochy (me,sz_nml,input_nml_file,fn_nml,nlunit,deltim,iret)
pertlai(1) > 0 .OR. pertvegf(1) > 0 .OR. pertalb(1) > 0) THEN
do_sfcperts=.true.
ENDIF
!calculate ntrunc if not supplied
if (ntrunc .LT. 1) then
if (me==0) print*,'ntrunc not supplied, calculating'
circ=2*3.1415928*rerth ! start with lengthscale that is circumference of the earth
l_min=circ
do k=1,5
if (sppt(k).GT.0) l_min=min(sppt_lscale(k),l_min)
if (shum(k).GT.0) l_min=min(shum_lscale(k),l_min)
if (skeb(k).GT.0) l_min=min(skeb_lscale(k),l_min)
enddo
ntrunc=(circ/l_min/two)*two
if (me==0) print*,'ntrunc calculated from l_min',l_min,ntrunc

! set up gaussian grid for ntrunc
endif
if (lon_s.LT.1 .OR. lat_s.LT.1) then
lat_s=ntrunc+2
lon_s=lat_s*2
if (me==0) print*,'gaussian grid not set, defining here',lon_s,lat_s
endif
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!
! All checks are successful.
Expand Down
1 change: 1 addition & 0 deletions get_stochy_pattern.F90
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ subroutine get_random_pattern_fv3(rpattern,npatterns,&
enddo

call mp_reduce_sum(workg,lonf,latg)


! interpolate to cube grid
allocate(rslmsk(lonf,latg))
Expand Down
2 changes: 1 addition & 1 deletion standalone_stochy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ program standalone_stochy
if (Model%do_skeb)allocate(Coupling(i)%skebu_wts(blksz,nlevs))
if (Model%do_skeb)allocate(Coupling(i)%skebv_wts(blksz,nlevs))
enddo
do i=1,2
do i=1,200
Model%kdt=i
ts=i/4.0
call run_stochastic_physics(Model, Grid, Coupling, nthreads)
Expand Down

0 comments on commit f97409e

Please sign in to comment.