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

HWRF RRTMG #412

Closed
wants to merge 11 commits into from
229 changes: 171 additions & 58 deletions physics/GFS_rrtmg_pre.F90

Large diffs are not rendered by default.

44 changes: 35 additions & 9 deletions physics/GFS_rrtmg_pre.meta
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
type = GFS_radtend_type
intent = inout
optional = F
[dx]
standard_name = cell_size
long_name = relative dx for the grid cell
units = m
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = in
optional = F
[f_ice]
standard_name = fraction_of_ice_water_cloud
long_name = fraction of ice water cloud
Expand Down Expand Up @@ -427,7 +436,7 @@
standard_name = total_cloud_fraction
long_name = layer total cloud fraction
units = frac
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -436,7 +445,7 @@
standard_name = cloud_liquid_water_path
long_name = layer cloud liquid water path
units = g m-2
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -445,7 +454,7 @@
standard_name = mean_effective_radius_for_liquid_cloud
long_name = mean effective radius for liquid cloud
units = micron
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -454,7 +463,7 @@
standard_name = cloud_ice_water_path
long_name = layer cloud ice water path
units = g m-2
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -463,7 +472,7 @@
standard_name = mean_effective_radius_for_ice_cloud
long_name = mean effective radius for ice cloud
units = micron
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -472,7 +481,7 @@
standard_name = cloud_rain_water_path
long_name = cloud rain water path
units = g m-2
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -481,7 +490,7 @@
standard_name = mean_effective_radius_for_rain_drop
long_name = mean effective radius for rain drop
units = micron
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -490,7 +499,7 @@
standard_name = cloud_snow_water_path
long_name = cloud snow water path
units = g m-2
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand All @@ -499,7 +508,7 @@
standard_name = mean_effective_radius_for_snow_flake
long_name = mean effective radius for snow flake
units = micron
dimensions = (horizontal_dimension,vertical_dimension)
dimensions = (horizontal_dimension,adjusted_vertical_layer_dimension_for_radiation)
type = real
kind = kind_phys
intent = out
Expand Down Expand Up @@ -564,6 +573,23 @@
type = integer
intent = out
optional = F
[mpirank]
standard_name = mpi_rank
long_name = current MPI-rank
units = index
dimensions = ()
type = integer
intent = in
optional = F
[mpiroot]
standard_name = mpi_root
long_name = master MPI-rank
units = index
dimensions = ()
type = integer
intent = in
optional = F


########################################################################
[ccpp-arg-table]
Expand Down
33 changes: 19 additions & 14 deletions physics/GFS_rrtmg_setup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module GFS_rrtmg_setup
use physparam, only : isolar , ictmflg, ico2flg, ioznflg, iaerflg,&
! & iaermdl, laswflg, lalwflg, lavoflg, icldflg, &
& iaermdl, icldflg, &
& iovrsw , iovrlw , lcrick , lcnorm , lnoprec, &
& ialbflg, iemsflg, isubcsw, isubclw, ivflip , ipsd0, &
& iswcliq, &
& lcrick , lcnorm , lnoprec, &
& ialbflg, iemsflg, ivflip , ipsd0, &
! & iswcliq, &
& kind_phys

use radcons, only: ltp, lextop
Expand Down Expand Up @@ -136,6 +136,7 @@ subroutine GFS_rrtmg_setup_init ( &
! =1: max/ran overlapping clouds !
! =2: maximum overlap clouds (mcica only) !
! =3: decorrelation-length overlap (mcica only) !
! =4: exponential overlap clouds
! isubc_sw/isubc_lw: sub-column cloud approx control flag (sw/lw rad) !
! =0: with out sub-column cloud approximation !
! =1: mcica sub-col approx. prescribed random seed !
Expand Down Expand Up @@ -177,8 +178,8 @@ subroutine GFS_rrtmg_setup_init ( &
integer, intent(in) :: num_p3d
integer, intent(in) :: npdf3d
integer, intent(in) :: ntoz
integer, intent(in) :: iovr_sw
integer, intent(in) :: iovr_lw
integer, intent(inout) :: iovr_sw
integer, intent(inout) :: iovr_lw
integer, intent(in) :: isubc_sw
integer, intent(in) :: isubc_lw
integer, intent(in) :: icliq_sw
Expand All @@ -204,6 +205,8 @@ subroutine GFS_rrtmg_setup_init ( &
real(kind_phys), dimension(im,NSPC1) :: aerodp_check
! End for consistency checks

integer :: iswcliq

! Initialize the CCPP error handling variables
errmsg = ''
errflg = 0
Expand Down Expand Up @@ -268,14 +271,14 @@ subroutine GFS_rrtmg_setup_init ( &

iswcliq = icliq_sw ! optical property for liquid clouds for sw

iovrsw = iovr_sw ! cloud overlapping control flag for sw
iovrlw = iovr_lw ! cloud overlapping control flag for lw
! iovrsw = iovr_sw ! cloud overlapping control flag for sw
! iovrlw = iovr_lw ! cloud overlapping control flag for lw

lcrick = crick_proof ! control flag for eliminating CRICK
lcnorm = ccnorm ! control flag for in-cld condensate
lnoprec = norad_precip ! precip effect on radiation flag (ferrier microphysics)
isubcsw = isubc_sw ! sub-column cloud approx flag in sw radiation
isubclw = isubc_lw ! sub-column cloud approx flag in lw radiation
! isubcsw = isubc_sw ! sub-column cloud approx flag in sw radiation
! isubclw = isubc_lw ! sub-column cloud approx flag in lw radiation

ialbflg= ialb ! surface albedo control flag
iemsflg= iems ! surface emissivity control flag
Expand Down Expand Up @@ -303,7 +306,7 @@ subroutine GFS_rrtmg_setup_init ( &

call radinit &
! --- inputs:
& ( si, levr, imp_physics, me )
& ( si, levr, imp_physics,iswcliq, iovr_lw, iovr_sw, isubc_lw, isubc_sw, me )
! --- outputs:
! ( none )

Expand Down Expand Up @@ -384,7 +387,7 @@ end subroutine GFS_rrtmg_setup_finalize
! Private functions


subroutine radinit( si, NLAY, imp_physics, me )
subroutine radinit( si, NLAY, imp_physics,iswcliq, iovrlw,iovrsw,isubclw,isubcsw, me )
!...................................

! --- inputs:
Expand Down Expand Up @@ -509,8 +512,10 @@ subroutine radinit( si, NLAY, imp_physics, me )
implicit none

! --- inputs:
integer, intent(in) :: NLAY, me, imp_physics
integer, intent(in) :: NLAY, me, imp_physics, &
& isubclw,isubcsw,iswcliq

integer, intent(inout) :: iovrlw,iovrsw
real (kind=kind_phys), intent(in) :: si(:)

! --- outputs: (none, to module variables)
Expand Down Expand Up @@ -619,9 +624,9 @@ subroutine radinit( si, NLAY, imp_physics, me )

call cld_init ( si, NLAY, imp_physics, me) ! --- ... cloud initialization routine

call rlwinit ( me ) ! --- ... lw radiation initialization routine
call rlwinit (iovrlw,isubclw, me ) ! --- ... lw radiation initialization routine

call rswinit ( me ) ! --- ... sw radiation initialization routine
call rswinit (iswcliq, iovrsw,isubcsw, me ) ! --- ... sw radiation initialization routine
!
return
!...................................
Expand Down
20 changes: 10 additions & 10 deletions physics/GFS_rrtmg_setup.meta
Original file line number Diff line number Diff line change
Expand Up @@ -107,32 +107,32 @@
intent = in
optional = F
[iovr_sw]
standard_name = flag_for_max_random_overlap_clouds_for_shortwave_radiation
long_name = sw: max-random overlap clouds
standard_name = flag_for_cloud_overlapping_method_for_shortwave_radiation
long_name = control flag for cloud overlapping method for SW
units = flag
dimensions = ()
type = integer
intent = in
intent = inout
optional = F
[iovr_lw]
standard_name = flag_for_max_random_overlap_clouds_for_longwave_radiation
long_name = lw: max-random overlap clouds
standard_name = flag_for_cloud_overlapping_method_for_longwave_radiation
long_name = control flag for cloud overlapping method for LW
units = flag
dimensions = ()
type = integer
intent = in
intent = inout
optional = F
[isubc_sw]
standard_name = flag_for_sw_clouds_without_sub_grid_approximation
long_name = flag for sw clouds without sub-grid approximation
standard_name = flag_for_sw_clouds_grid_approximation
long_name = flag for sw clouds sub-grid approximation
units = flag
dimensions = ()
type = integer
intent = in
optional = F
[isubc_lw]
standard_name = flag_for_lw_clouds_without_sub_grid_approximation
long_name = flag for lw clouds without sub-grid approximation
standard_name = flag_for_lw_clouds_sub_grid_approximation
long_name = flag for lw clouds sub-grid approximation
units = flag
dimensions = ()
type = integer
Expand Down
109 changes: 109 additions & 0 deletions physics/HWRF_mcica_random_numbers.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
module mcica_random_numbers

! Generic module to wrap random number generators.
! The module defines a type that identifies the particular stream of random
! numbers, and has procedures for initializing it and getting real numbers
! in the range 0 to 1.
! This version uses the Mersenne Twister to generate random numbers on [0, 1].
!
use MersenneTwister, only: randomNumberSequence, & ! The random number engine.
new_RandomNumberSequence, getRandomReal
!! mji
!! use time_manager_mod, only: time_type, get_date

!mz use parkind, only : im => kind_im, rb => kind_rb
use machine, only: im => kind_io4, rb => kind_phys

implicit none
private

type randomNumberStream
type(randomNumberSequence) :: theNumbers
end type randomNumberStream

interface getRandomNumbers
module procedure getRandomNumber_Scalar, getRandomNumber_1D, getRandomNumber_2D
end interface getRandomNumbers

interface initializeRandomNumberStream
module procedure initializeRandomNumberStream_S, initializeRandomNumberStream_V
end interface initializeRandomNumberStream

public :: randomNumberStream, &
initializeRandomNumberStream, getRandomNumbers
!! mji
!! initializeRandomNumberStream, getRandomNumbers, &
!! constructSeed
contains
! ---------------------------------------------------------
! Initialization
! ---------------------------------------------------------
function initializeRandomNumberStream_S(seed) result(new)
integer(kind=im), intent( in) :: seed
type(randomNumberStream) :: new

new%theNumbers = new_RandomNumberSequence(seed)

end function initializeRandomNumberStream_S
! ---------------------------------------------------------
function initializeRandomNumberStream_V(seed) result(new)
integer(kind=im), dimension(:), intent( in) :: seed
type(randomNumberStream) :: new

new%theNumbers = new_RandomNumberSequence(seed)

end function initializeRandomNumberStream_V

! ---------------------------------------------------------
! Procedures for drawing random numbers
! ---------------------------------------------------------
subroutine getRandomNumber_Scalar(stream, number)
type(randomNumberStream), intent(inout) :: stream
real(kind=rb), intent( out) :: number

number = getRandomReal(stream%theNumbers)
end subroutine getRandomNumber_Scalar
! ---------------------------------------------------------
subroutine getRandomNumber_1D(stream, numbers)
type(randomNumberStream), intent(inout) :: stream
real(kind=rb), dimension(:), intent( out) :: numbers

! Local variables
integer(kind=im) :: i

do i = 1, size(numbers)
numbers(i) = getRandomReal(stream%theNumbers)
end do
end subroutine getRandomNumber_1D
! ---------------------------------------------------------
subroutine getRandomNumber_2D(stream, numbers)
type(randomNumberStream), intent(inout) :: stream
real(kind=rb), dimension(:, :), intent( out) :: numbers

! Local variables
integer(kind=im) :: i

do i = 1, size(numbers, 2)
call getRandomNumber_1D(stream, numbers(:, i))
end do
end subroutine getRandomNumber_2D

! mji
! ! ---------------------------------------------------------
! ! Constructing a unique seed from grid cell index and model date/time
! ! Once we have the GFDL stuff we'll add the year, month, day, hour, minute
! ! ---------------------------------------------------------
! function constructSeed(i, j, time) result(seed)
! integer(kind=im), intent( in) :: i, j
! type(time_type), intent( in) :: time
! integer(kind=im), dimension(8) :: seed
!
! ! Local variables
! integer(kind=im) :: year, month, day, hour, minute, second
!
!
! call get_date(time, year, month, day, hour, minute, second)
! seed = (/ i, j, year, month, day, hour, minute, second /)
! end function constructSeed

end module mcica_random_numbers
Loading