Skip to content

Commit

Permalink
Split up init into gas and cloud _init routines. Renamed some variabl…
Browse files Browse the repository at this point in the history
…es to be more clear.
  • Loading branch information
dustinswales committed Jun 3, 2019
1 parent 4e0cfc8 commit f86636b
Show file tree
Hide file tree
Showing 11 changed files with 1,586 additions and 1,498 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Auto-generated include files in Fortran code
*.inc
physics/*cap.F90
physics/*.xml
*.cmake
*.mk
*.html
91 changes: 35 additions & 56 deletions physics/GFS_rrtmg_pre.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module GFS_rrtmg_pre
!! \section arg_table_GFS_rrtmg_pre_init Argument Table
!!
subroutine GFS_rrtmg_pre_init ()
open(58,file='GFS_rrtmg_aux_dump.txt',status='unknown')
end subroutine GFS_rrtmg_pre_init

!> \section arg_table_GFS_rrtmg_pre_run Argument Table
Expand Down Expand Up @@ -325,7 +324,7 @@ subroutine GFS_rrtmg_pre_run (Model, Grid, Sfcprop, Statein, & ! input
tracer1(:,k1,j) = max(0.0, Statein%qgrs(:,k2,j))
enddo
enddo
!

if (ivflip == 0) then ! input data from toa to sfc
do i = 1, IM
plvl(i,1+kd) = 0.01 * Statein%prsi(i,1) ! pa to mb (hpa)
Expand Down Expand Up @@ -704,7 +703,39 @@ subroutine GFS_rrtmg_pre_run (Model, Grid, Sfcprop, Statein, & ! input
ccnd(1:IM,1:LMK,1) = ccnd(1:IM,1:LMK,1) + cnvw(1:IM,1:LMK) + ccnd(1:IM,1:LMK,2)
endif

! DJS2019: START
if (Model%uni_cld) then
if (Model%effr_in) then
do k=1,lm
k1 = k + kd
do i=1,im
cldcov(i,k1) = Tbd%phy_f3d(i,k,Model%indcld)
effrl(i,k1) = Tbd%phy_f3d(i,k,2)
effri(i,k1) = Tbd%phy_f3d(i,k,3)
effrr(i,k1) = Tbd%phy_f3d(i,k,4)
effrs(i,k1) = Tbd%phy_f3d(i,k,5)
enddo
enddo
else
do k=1,lm
k1 = k + kd
do i=1,im
cldcov(i,k1) = Tbd%phy_f3d(i,k,Model%indcld)
if (tracer1(i,k,ntcw) .gt. 0 .or. tracer1(i,k,ntiw) .gt. 0) then
cldcov(i,k1) = 0.1
else
cldcov(i,k1) = 0.0
endif
enddo
enddo
endif
elseif (Model%imp_physics == Model%imp_physics_gfdl) then ! GFDL MP
cldcov(1:IM,1+kd:LM+kd) = tracer1(1:IM,1:LM,Model%ntclamt)
else ! neither of the other two cases
cldcov = 0.0
endif


! DJS2019: START Hack
! Compute layer cloud fraction.
clwmin = 0.0
cldcov(:,:) = 0.0
Expand Down Expand Up @@ -743,51 +774,8 @@ subroutine GFS_rrtmg_pre_run (Model, Grid, Sfcprop, Statein, & ! input
enddo
enddo
endif
! DJS2019: END
! DJS2019: END

if (Model%uni_cld) then
if (Model%effr_in) then
do k=1,lm
k1 = k + kd
do i=1,im
cldcov(i,k1) = Tbd%phy_f3d(i,k,Model%indcld)
effrl(i,k1) = Tbd%phy_f3d(i,k,2)
effri(i,k1) = Tbd%phy_f3d(i,k,3)
effrr(i,k1) = Tbd%phy_f3d(i,k,4)
effrs(i,k1) = Tbd%phy_f3d(i,k,5)
enddo
enddo
else
do k=1,lm
k1 = k + kd
do i=1,im
! DJS2019: Tbd%phy_f3d(:,:,1) is mean layer temperature, not cloud amount
!cldcov(i,k1) = Tbd%phy_f3d(i,k,Model%indcld)
!if (tracer1(i,k,ntcw) .gt. 0 .or. tracer1(i,k,ntiw) .gt. 0) then
! cldcov(i,k1) = 0.1
!else
! cldcov(i,k1) = 0.0
!endif
enddo
enddo
endif
elseif (Model%imp_physics == Model%imp_physics_gfdl) then ! GFDL MP
cldcov(1:IM,1+kd:LM+kd) = tracer1(1:IM,1:LM,Model%ntclamt)
else ! neither of the other two cases
!cldcov = 0.0
endif

write(58,*) "Model%imp_physics: ",Model%imp_physics
write(58,*) "Model%uni_cld: ",Model%uni_cld
write(58,*) "Model%ncld: ",Model%ncld
write(58,*) "Model%lgfdlmprad: ",Model%lgfdlmprad
write(58,*) "Model%lmfshal: ",Model%lmfshal
write(58,*) "Model%lmfdeep2: ",Model%lmfdeep2
do k = 1, LMK
do i = 1, IM
write(58,'(a19,2i8,f10.2)') " Cloud-cover: ",k,i,cldcov(i,k)
end do
enddo

if (Model%imp_physics == 99 .or. Model%imp_physics == 10) then ! zhao/moorthi's prognostic cloud scheme
! or unified cloud and/or with MG microphysics
Expand All @@ -802,8 +790,6 @@ subroutine GFS_rrtmg_pre_run (Model, Grid, Sfcprop, Statein, & ! input
call progcld1 (plyr ,plvl, tlyr, tvly, qlyr, qstl, rhly, & ! --- inputs
ccnd(1:IM,1:LMK,1), Grid%xlat,Grid%xlon, &
Sfcprop%slmsk, dz, delp, IM, LMK, LMP, &
!DJS2019: Pass uni_cld=true to use prescribed cloud-cover amount
! .true., Model%lmfshal, &
Model%uni_cld, Model%lmfshal, &
Model%lmfdeep2, cldcov, &
effrl, effri, effrr, effrs, Model%effr_in, &
Expand Down Expand Up @@ -880,12 +866,6 @@ subroutine GFS_rrtmg_pre_run (Model, Grid, Sfcprop, Statein, & ! input
enddo
enddo

write(58,*) "#"
do k=1,Model%levr+LTP
write(58,"(5F10.3)") plyr(1,k),tlyr(1,k),clouds2(1,k), &
& clouds4(1,k), clouds1(1,k)
enddo


! mg, sfc-perts
! --- scale random patterns for surface perturbations with
Expand All @@ -906,7 +886,6 @@ end subroutine GFS_rrtmg_pre_run
!> \section arg_table_GFS_rrtmg_pre_finalize Argument Table
!!
subroutine GFS_rrtmg_pre_finalize ()
close(58)
end subroutine GFS_rrtmg_pre_finalize

!! @}
Expand Down
38 changes: 19 additions & 19 deletions physics/GFS_rrtmgp_lw.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module GFS_rrtmgp_lw
use GFS_typedefs, only: GFS_control_type
use machine, only: kind_phys
use physparam, only: isubclw, iovrlw
use rrtmgp_lw, only: nrghice_lw => nrghice, ipsdlw0
use rrtmgp_aux, only: nrghice_lw, ipsdlw0
use mo_gas_optics_rrtmgp, only: ty_gas_optics_rrtmgp
use mo_cloud_optics, only: ty_cloud_optics
use mo_optical_props, only: ty_optical_props_1scl, ty_optical_props_2str
Expand Down Expand Up @@ -37,9 +37,9 @@ end subroutine GFS_rrtmgp_lw_init
!! | cld_rerain | mean_effective_radius_for_rain_drop | mean effective radius for rain cloud | micron | 2 | real | kind_phys | in | F |
!! | gas_concentrations | Gas_concentrations_for_RRTMGP_suite | DDT containing gas concentrations for RRTMGP radiation scheme | DDT | 0 | ty_gas_concs | | in | F |
!! | icseed_lw | seed_random_numbers_sw | seed for random number generation for shortwave radiation | none | 1 | integer | | in | F |
!! | kdist_lw | K_distribution_file_for_RRTMGP_LW_scheme | DDT containing spectral information for RRTMGP LW radiation scheme | DDT | 0 | ty_gas_optics_rrtmgp | | in | F |
!! | lw_gas_props | coefficients_for_lw_gas_optics | DDT containing spectral information for RRTMGP LW radiation scheme | DDT | 0 | ty_gas_optics_rrtmgp | | in | F |
!! | aerosols | aerosol_optical_properties_for_longwave_bands_01-16 | aerosol optical properties for longwave bands 01-16 | various | 4 | real | kind_phys | in | F |
!! | kdist_cldy_lw | K_distribution_file_for_cloudy_RRTMGP_LW_scheme | DDT containing spectral information for cloudy RRTMGP LW radiation scheme | DDT | 0 | ty_cloud_optics | | in | F |
!! | lw_cloud_props | coefficients_for_lw_cloud_optics | DDT containing spectral information for cloudy RRTMGP LW radiation scheme | DDT | 0 | ty_cloud_optics | | in | F |
!! | optical_props_clouds | longwave_optical_properties_for_cloudy_atmosphere | Fortran DDT containing RRTMGP optical properties | DDT | 0 | ty_optical_props_1scl | | out | F |
!! | optical_props_aerosol | longwave_optical_properties_for_aerosols | Fortran DDT containing RRTMGP optical properties | DDT | 0 | ty_optical_props_1scl | | out | F |
!! | cldtaulw | cloud_optical_depth_layers_at_10mu_band | approx 10mu band layer cloud optical depth | none | 2 | real | kind_phys | out | F |
Expand All @@ -50,7 +50,7 @@ end subroutine GFS_rrtmgp_lw_init
! #########################################################################################
subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_frac, &
cld_lwp, cld_reliq, cld_iwp, cld_reice, cld_swp, cld_resnow, cld_rwp, cld_rerain, &
gas_concentrations, kdist_lw, aerosols, kdist_cldy_lw, &
gas_concentrations, lw_gas_props, aerosols, lw_cloud_props, &
optical_props_clouds, optical_props_aerosol, cldtaulw, errmsg, errflg)

! Inputs
Expand Down Expand Up @@ -81,10 +81,10 @@ subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_fr
type(ty_gas_concs),intent(in) :: &
gas_concentrations !
type(ty_gas_optics_rrtmgp),intent(in) :: &
kdist_lw ! RRTMGP DDT containing spectral information for LW calculation
lw_gas_props ! RRTMGP DDT containing spectral information for LW calculation
type(ty_cloud_optics),intent(in) :: &
kdist_cldy_lw !
real(kind_phys), intent(in),dimension(ncol, model%levs, kdist_lw%get_nband(),3) :: &
lw_cloud_props !
real(kind_phys), intent(in),dimension(ncol, model%levs, lw_gas_props%get_nband(),3) :: &
aerosols !
real(kind_phys), dimension(ncol,Model%levs), intent(out) :: &
cldtaulw ! approx 10.mu band layer cloud optical depth
Expand All @@ -102,10 +102,10 @@ subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_fr
logical,dimension(ncol,model%levs) :: liqmask, icemask
type(ty_optical_props_1scl) :: optical_props_cloudsByBand
type(random_stat) :: rng_stat
real(kind_phys), dimension(kdist_lw%get_ngpt(),model%levs,ncol) :: rng3D
real(kind_phys), dimension(kdist_lw%get_ngpt()*model%levs) :: rng1D
logical, dimension(ncol,model%levs,kdist_lw%get_ngpt()) :: cldfracMCICA
real(kind_phys), dimension(ncol,model%levs,kdist_lw%get_nband()) :: &
real(kind_phys), dimension(lw_gas_props%get_ngpt(),model%levs,ncol) :: rng3D
real(kind_phys), dimension(lw_gas_props%get_ngpt()*model%levs) :: rng1D
logical, dimension(ncol,model%levs,lw_gas_props%get_ngpt()) :: cldfracMCICA
real(kind_phys), dimension(ncol,model%levs,lw_gas_props%get_nband()) :: &
tau_cld

! Initialize CCPP error handling variables
Expand Down Expand Up @@ -137,11 +137,11 @@ subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_fr
! Allocate space for RRTMGP DDTs containing cloud and aerosol radiative properties
! #######################################################################################
! Cloud optics [nCol,model%levs,nBands]
call check_error_msg('GFS_rrtmgp_lw_run',optical_props_cloudsByBand%alloc_1scl(ncol, model%levs, kdist_lw%get_band_lims_wavenumber()))
call check_error_msg('GFS_rrtmgp_lw_run',optical_props_cloudsByBand%alloc_1scl(ncol, model%levs, lw_gas_props%get_band_lims_wavenumber()))
! Aerosol optics [Ccol,model%levs,nBands]
call check_error_msg('GFS_rrtmgp_lw_run',optical_props_aerosol%alloc_1scl(ncol, model%levs, kdist_lw%get_band_lims_wavenumber()))
call check_error_msg('GFS_rrtmgp_lw_run',optical_props_aerosol%alloc_1scl(ncol, model%levs, lw_gas_props%get_band_lims_wavenumber()))
! Cloud optics [nCol,model%levs,nGpts]
call check_error_msg('GFS_rrtmgp_lw_run',optical_props_clouds%alloc_1scl(ncol, model%levs, kdist_lw))
call check_error_msg('GFS_rrtmgp_lw_run',optical_props_clouds%alloc_1scl(ncol, model%levs, lw_gas_props))

! #######################################################################################
! Copy aerosol optical information to RRTMGP DDT
Expand All @@ -151,12 +151,12 @@ subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_fr
! #######################################################################################
! Compute cloud-optics for RTE.
! #######################################################################################
if (Model%rrtmgp_cld_phys .gt. 0) then
if (Model%rrtmgp_cld_optics .gt. 0) then
! i) RRTMGP cloud-optics.
call check_error_msg('GFS_rrtmgp_lw_run',kdist_cldy_lw%cloud_optics(&
call check_error_msg('GFS_rrtmgp_lw_run',lw_cloud_props%cloud_optics(&
ncol, & ! IN - Number of horizontal gridpoints
model%levs, & ! IN - Number of vertical layers
kdist_lw%get_nband(), & ! IN - Number of LW bands
lw_gas_props%get_nband(), & ! IN - Number of LW bands
nrghice_lw, & ! IN - Number of ice-roughness categories
liqmask, & ! IN - Liquid-cloud mask
icemask, & ! IN - Ice-cloud mask
Expand All @@ -169,7 +169,7 @@ subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_fr
else
! ii) RRTMG cloud-optics.
if (any(cld_frac .gt. 0)) then
call rrtmgp_lw_cloud_optics(ncol, model%levs, kdist_lw%get_nband(), cld_lwp, &
call rrtmgp_lw_cloud_optics(ncol, model%levs, lw_gas_props%get_nband(), cld_lwp, &
cld_reliq, cld_iwp, cld_reice, cld_rwp, cld_rerain, cld_swp, cld_resnow, &
cld_frac, tau_cld)
optical_props_cloudsByBand%tau = tau_cld
Expand All @@ -184,7 +184,7 @@ subroutine GFS_rrtmgp_lw_run(Model, ncol, icseed_lw, p_lay, t_lay, p_lev, cld_fr
do iCol=1,ncol
call random_setseed(ipseed_lw(icol),rng_stat)
call random_number(rng1D,rng_stat)
rng3D(:,:,iCol) = reshape(source = rng1D,shape=[kdist_lw%get_ngpt(),model%levs])
rng3D(:,:,iCol) = reshape(source = rng1D,shape=[lw_gas_props%get_ngpt(),model%levs])
enddo

! Call McICA
Expand Down
17 changes: 4 additions & 13 deletions physics/GFS_rrtmgp_lw_post.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module GFS_rrtmgp_lw_post
use mo_gas_optics_rrtmgp, only: ty_gas_optics_rrtmgp
use mo_fluxes_byband, only: ty_fluxes_byband
use mo_heating_rates, only: compute_heating_rate
use rrtmgp_aux, only: check_error_msg
implicit none

public GFS_rrtmgp_lw_post_init,GFS_rrtmgp_lw_post_run,GFS_rrtmgp_lw_post_finalize
Expand Down Expand Up @@ -41,7 +42,7 @@ end subroutine GFS_rrtmgp_lw_post_init
!! | fluxlwDOWN_allsky | lw_flux_profile_downward_allsky | RRTMGP downward longwave all-sky flux profile | W m-2 | 2 | real | kind_phys | in | F |
!! | fluxlwUP_clrsky | lw_flux_profile_upward_clrsky | RRTMGP upward longwave clr-sky flux profile | W m-2 | 2 | real | kind_phys | in | F |
!! | fluxlwDOWN_clrsky | lw_flux_profile_downward_clrsky | RRTMGP downward longwave clr-sky flux profile | W m-2 | 2 | real | kind_phys | in | F |
!! | kdist_lw | K_distribution_file_for_RRTMGP_LW_scheme | DDT containing spectral information for RRTMGP LW radiation scheme | DDT | 0 | ty_gas_optics_rrtmgp | | in | F |
!! | lw_gas_props | coefficients_for_lw_gas_optics | DDT containing spectral information for RRTMGP LW radiation scheme | DDT | 0 | ty_gas_optics_rrtmgp | | in | F |
!! | hlwc | tendency_of_air_temperature_due_to_longwave_heating_on_radiation_time_step | longwave total sky heating rate | K s-1 | 2 | real | kind_phys | out | F |
!! | topflx_lw | lw_fluxes_top_atmosphere | longwave total sky fluxes at the top of the atm | W m-2 | 1 | topflw_type | | inout | F |
!! | sfcflx_lw | lw_fluxes_sfc | longwave total sky fluxes at the Earth surface | W m-2 | 1 | sfcflw_type | | inout | F |
Expand All @@ -52,7 +53,7 @@ end subroutine GFS_rrtmgp_lw_post_init
!!
#endif
subroutine GFS_rrtmgp_lw_post_run (Model, Grid, Diag, Radtend, Statein, &
Coupling, im, p_lev, kdist_lw, &
Coupling, im, p_lev, lw_gas_props, &
tsfa, fluxlwUP_allsky, fluxlwDOWN_allsky, fluxlwUP_clrsky, fluxlwDOWN_clrsky, &
hlwc, topflx_lw, sfcflx_lw, flxprf_lw, hlw0, errmsg, errflg)

Expand All @@ -74,7 +75,7 @@ subroutine GFS_rrtmgp_lw_post_run (Model, Grid, Diag, Radtend, Statein, &
real(kind_phys), dimension(size(Grid%xlon,1)), intent(in) :: &
tsfa ! Lowest model layer air temperature for radiation
type(ty_gas_optics_rrtmgp),intent(in) :: &
kdist_lw ! DDT containing LW spectral information
lw_gas_props ! DDT containing LW spectral information
real(kind_phys), dimension(size(Grid%xlon,1), Model%levs+1), intent(in) :: &
p_lev ! Pressure @ model layer-interfaces (hPa)
real(kind_phys), dimension(size(Grid%xlon,1), Model%levs+1), intent(in) :: &
Expand Down Expand Up @@ -200,14 +201,4 @@ end subroutine GFS_rrtmgp_lw_post_run
subroutine GFS_rrtmgp_lw_post_finalize ()
end subroutine GFS_rrtmgp_lw_post_finalize

subroutine check_error_msg(routine_name, error_msg)
character(len=*), intent(in) :: &
error_msg, routine_name

if(error_msg /= "") then
print*,"ERROR("//trim(routine_name)//"): "
print*,trim(error_msg)
return
end if
end subroutine check_error_msg
end module GFS_rrtmgp_lw_post
Loading

0 comments on commit f86636b

Please sign in to comment.