Skip to content

Commit

Permalink
Reverted changes to GFS_rrtmgp_sw_pre.F90
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Feb 18, 2020
1 parent b57ebfd commit 1d92cfa
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 319 deletions.
101 changes: 42 additions & 59 deletions physics/GFS_rrtmgp_sw_pre.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ module GFS_rrtmgp_sw_pre
use physparam
use machine, only: &
kind_phys ! Working type
use GFS_typedefs, only: &
GFS_sfcprop_type, & ! Surface fields
GFS_control_type, & ! Model control parameters
GFS_grid_type, & ! Grid and interpolation related data
GFS_coupling_type, & !
GFS_statein_type, & !
GFS_radtend_type, & ! Radiation tendencies needed in physics
GFS_interstitial_type
use module_radiation_astronomy,only: &
coszmn ! Function to compute cos(SZA)
use module_radiation_surface, only: &
Expand All @@ -27,57 +35,29 @@ end subroutine GFS_rrtmgp_sw_pre_init
!> \section arg_table_GFS_rrtmgp_sw_pre_run
!! \htmlinclude GFS_rrtmgp_sw_pre.html
!!
subroutine GFS_rrtmgp_sw_pre_run(doLWrad, do_sfcperts, ncol, nlev, ntrac, nsfcpert, nmtvr,mpi_rank, solhr, &
pertalb, sfc_wts, xlon, coslat, sinlat, slmsk, snowd, sncovr, snoalb, zorl, coszen, coszdg, tsfc,&
hprime, alvsf, alnsf, alvwf, alnwf, facsf, facwf, fice, tisfc, p_lay, p_lev, tv_lay, &
relhum, tracer, sw_gas_props, nday, idxday, alb1d, sfalb, sfc_alb_nir_dir, sfc_alb_nir_dif, &
sfc_alb_uvvis_dir, sfc_alb_uvvis_dif, errmsg, errflg)
subroutine GFS_rrtmgp_sw_pre_run(Model, Grid, Sfcprop, Statein, ncol, p_lay, p_lev, &
tv_lay, relhum, tracer, sw_gas_props, nday, idxday, alb1d, sfc_alb_nir_dir, &
sfc_alb_nir_dif, sfc_alb_uvvis_dir, sfc_alb_uvvis_dif, RadTend, Coupling, &
errmsg, errflg)

! Inputs
logical, intent(in) :: &
doLWrad , & ! Flag for longwave radiation call
do_sfcperts ! Flag for stochastic surface perturbations option

type(GFS_control_type), intent(in) :: &
Model ! DDT: FV3-GFS model control parameters
type(GFS_grid_type), intent(in) :: &
Grid ! DDT: FV3-GFS grid and interpolation related data
type(GFS_sfcprop_type), intent(in) :: &
Sfcprop ! DDT: FV3-GFS surface fields
type(GFS_statein_type), intent(in) :: &
Statein ! DDT: FV3-GFS prognostic state data in from dycore
integer, intent(in) :: &
ncol, & ! Number of horizontal grid points
nlev, & ! Number of vertical levels
ntrac, & ! Number of tracers
nsfcpert, & ! number of surface perturbations
nmtvr, & ! number of topographic variables in GWD
mpi_rank ! Current MPI-rank
real(kind_phys), intent(in) :: &
solhr ! Time after 00z at the current timestep (hours)
real(kind_phys), dimension(nsfcpert), intent(in) :: &
pertalb ! Magnitude of surface albedo perturbation
real(kind_phys), dimension(ncol,nsfcpert), intent(in) :: &
sfc_wts ! Magnitude of surface albedo perturbation
real(kind_phys), dimension(ncol), intent(in) :: &
xlon, & ! Longitude
coslat, & ! Cosine of latitude
sinlat, & ! Sine of latitude
slmsk, & ! Lank/sea mask
snowd, & ! Water equivalent snow depth (mm)
sncovr, & ! Surface snow area fraction
snoalb, & ! Maximum snow albedo
zorl, & ! Surface roughness length
tsfc, & ! Surface skin temperature (K)
alvsf, & ! Mean vis albedo with strong cosz dependency
alnsf, & ! Mean nIR albedo with strong cosz dependency
alvwf, & ! Mean vis albedo with weak cosz dependency
alnwf, & ! Mean nIR albedo with weak cosz dependency
facsf, & ! Fractional coverage with strong cosz dependency
facwf, & ! Fractional coverage with weak cosz dependency
fice, & ! Ice fraction over open water
tisfc ! Sea ice surface skin temperature
real(kind_phys), dimension(ncol), intent(in) :: &
hprime ! orographic metrics
real(kind_phys), dimension(ncol,nlev),intent(in) :: &
ncol ! Number of horizontal grid points
real(kind_phys), dimension(ncol,Model%levs),intent(in) :: &
p_lay, & ! Layer pressure
tv_lay, & ! Layer virtual-temperature
relhum ! Layer relative-humidity
real(kind_phys), dimension(ncol, nlev, 2:ntrac),intent(in) :: &
tracer ! Chemical tracers (g/g)
real(kind_phys), dimension(ncol,nlev+1),intent(in) :: &
real(kind_phys), dimension(ncol, Model%levs, 2:Model%ntrac),intent(in) :: &
tracer
real(kind_phys), dimension(ncol,Model%levs+1),intent(in) :: &
p_lev ! Pressure @ layer interfaces (Pa)
type(ty_gas_optics_rrtmgp),intent(in) :: &
sw_gas_props ! RRTMGP DDT: spectral information for SW calculation
Expand All @@ -88,15 +68,16 @@ subroutine GFS_rrtmgp_sw_pre_run(doLWrad, do_sfcperts, ncol, nlev, ntrac, nsfcpe
integer, dimension(ncol), intent(out) :: &
idxday ! Indices for daylit points
real(kind_phys), dimension(ncol), intent(out) :: &
coszen, & ! mean cos of zenith angle over rad call period
coszdg, & ! daytime mean cosz over rad call period
sfalb, & ! mean surface diffused SW albedo
alb1d ! Surface albedo pertubation
alb1d ! Surface albedo pertubation
real(kind_phys), dimension(sw_gas_props%get_nband(),ncol), intent(out) :: &
sfc_alb_nir_dir, & ! Surface albedo (direct)
sfc_alb_nir_dif, & ! Surface albedo (diffuse)
sfc_alb_uvvis_dir, & ! Surface albedo (direct)
sfc_alb_uvvis_dif ! Surface albedo (diffuse)
type(GFS_radtend_type), intent(inout) :: &
Radtend ! DDT: FV3-GFS radiation tendencies
type(GFS_coupling_type), intent(inout) :: &
Coupling ! DDT: FV3-GFS coupling arrays
character(len=*), intent(out) :: &
errmsg ! Error message
integer, intent(out) :: &
Expand All @@ -110,21 +91,21 @@ subroutine GFS_rrtmgp_sw_pre_run(doLWrad, do_sfcperts, ncol, nlev, ntrac, nsfcpe
errmsg = ''
errflg = 0

if (.not. doLWrad) return
if (.not. Model%lsswr) return

! #######################################################################################
! Compute cosine of zenith angle (only when SW is called)
! #######################################################################################
call coszmn (xlon, sinlat, coslat, solhr, NCOL, mpi_rank, &
coszen, coszdg)
call coszmn (Grid%xlon, Grid%sinlat, Grid%coslat, Model%solhr, NCOL, Model%me, &
Radtend%coszen, Radtend%coszdg)

! #######################################################################################
! For SW gather daylit points
! #######################################################################################
nday = 0
idxday = 0
do i = 1, NCOL
if (coszen(i) >= 0.0001) then
if (Radtend%coszen(i) >= 0.0001) then
nday = nday + 1
idxday(nday) = i
endif
Expand All @@ -136,22 +117,24 @@ subroutine GFS_rrtmgp_sw_pre_run(doLWrad, do_sfcperts, ncol, nlev, ntrac, nsfcpe
! --- turn vegetation fraction pattern into percentile pattern
! #######################################################################################
alb1d(:) = 0.
if (do_sfcperts) then
if (pertalb(1) > 0.) then
if (Model%do_sfcperts) then
if (Model%pertalb(1) > 0.) then
do i=1,ncol
call cdfnor(sfc_wts(i,5),alb1d(i))
call cdfnor(Coupling%sfc_wts(i,5),alb1d(i))
enddo
endif
endif

! #######################################################################################
! Call module_radiation_surface::setalb() to setup surface albedo.
! #######################################################################################
call setalb (slmsk, snowd, sncovr, snoalb, zorl, coszen, tsfc, tsfc, hprime, alvsf, &
alnsf, alvwf, alnwf, facsf, facwf, fice, tisfc, NCOL, alb1d, pertalb, sfcalb)
call setalb (Sfcprop%slmsk, Sfcprop%snowd, Sfcprop%sncovr, Sfcprop%snoalb, Sfcprop%zorl, &
Radtend%coszen, Sfcprop%tsfc, Sfcprop%tsfc, Sfcprop%hprime(:,1), Sfcprop%alvsf, &
Sfcprop%alnsf, Sfcprop%alvwf, Sfcprop%alnwf, Sfcprop%facsf, Sfcprop%facwf, &
Sfcprop%fice, Sfcprop%tisfc, NCOL, alb1d, Model%pertalb, sfcalb)

! Approximate mean surface albedo from vis- and nir- diffuse values.
sfalb(:) = max(0.01, 0.5 * (sfcalb(:,2) + sfcalb(:,4)))
Radtend%sfalb(:) = max(0.01, 0.5 * (sfcalb(:,2) + sfcalb(:,4)))

! Spread across all SW bands
do iBand=1,sw_gas_props%get_nband()
Expand Down
Loading

0 comments on commit 1d92cfa

Please sign in to comment.