Skip to content

Commit

Permalink
Vectorized cloud generator is default on NEC
Browse files Browse the repository at this point in the history
  • Loading branch information
rjhogan committed Jun 18, 2021
1 parent e746c8e commit 95009dd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 36 deletions.
74 changes: 39 additions & 35 deletions radiation/radiation_cloud_generator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ subroutine generate_columns_exp_ran(ng, nlev, iseed, pdf_sampler, &
! Uniform deviates between 0 and 1
real(jprb) :: rand_top(ng)

! Height indices
integer :: jlev, jcloud
! Loop indices
integer :: jlev, jcloud, jg

integer :: iy

Expand Down Expand Up @@ -629,39 +629,43 @@ subroutine generate_columns_exp_ran(ng, nlev, iseed, pdf_sampler, &
do jlev = ibegin,iend

if (is_any_cloud(jlev)) then
! The intention is that all these operations are vectorizable,
! since all are vector operations on vectors of length ng...

! Copy the cloud mask between levels
prev_cloud = is_cloud

! For each spectral interval, has the first cloud appeared at this level?
first_cloud = (trigger <= cum_cloud_cover(jlev) .and. .not. found_cloud)

! ...if so, add to found_cloud
found_cloud = found_cloud .or. first_cloud

! There is cloud at this level either if a first cloud has
! appeared, or using separate probability calculations
! depending on whether there is a cloud above (given by
! prev_cloud)
is_cloud = first_cloud &
& .or. found_cloud .and. merge(rand_cloud(:,jlev)*frac(jlev-1) &
& < frac(jlev)+frac(jlev-1)-pair_cloud_cover(jlev-1), &
& rand_cloud(:,jlev)*(cum_cloud_cover(jlev-1) - frac(jlev-1)) &
& < pair_cloud_cover(jlev-1) - overhang(jlev-1) - frac(jlev-1), &
& prev_cloud)
! The random number determining cloud structure decorrelates
! with the one above it according to the overlap parameter,
! but always decorrelates if there is clear-sky above. If
! there is clear-sky in the present level, the random number
! is set to zero to ensure that the optical depth scaling is
! also zero.
rand_inhom(:,jlev) = merge(merge(rand_inhom(:,jlev-1), rand_inhom(:,jlev), &
& rand_inhom2(:,jlev) < overlap_param_inhom(jlev-1) &
& .and. prev_cloud), &
& 0.0_jprb, is_cloud)


! Added for DWD (2020)
!NEC$ shortloop
do jg = 1,ng
! The intention is that all these operations are vectorizable,
! since all are vector operations on vectors of length ng...

! Copy the cloud mask between levels
prev_cloud(jg) = is_cloud(jg)

! For each spectral interval, has the first cloud appeared at this level?
first_cloud(jg) = (trigger(jg) <= cum_cloud_cover(jlev) .and. .not. found_cloud(jg))

! ...if so, add to found_cloud
found_cloud(jg) = found_cloud(jg) .or. first_cloud(jg)

! There is cloud at this level either if a first cloud has
! appeared, or using separate probability calculations
! depending on whether there is a cloud above (given by
! prev_cloud)
is_cloud(jg) = first_cloud(jg) &
& .or. found_cloud(jg) .and. merge(rand_cloud(jg,jlev)*frac(jlev-1) &
& < frac(jlev)+frac(jlev-1)-pair_cloud_cover(jlev-1), &
& rand_cloud(jg,jlev)*(cum_cloud_cover(jlev-1) - frac(jlev-1)) &
& < pair_cloud_cover(jlev-1) - overhang(jlev-1) - frac(jlev-1), &
& prev_cloud(jg))
! The random number determining cloud structure decorrelates
! with the one above it according to the overlap parameter,
! but always decorrelates if there is clear-sky above. If
! there is clear-sky in the present level, the random number
! is set to zero to ensure that the optical depth scaling is
! also zero.
rand_inhom(jg,jlev) = merge(merge(rand_inhom(jg,jlev-1), rand_inhom(jg,jlev), &
& rand_inhom2(jg,jlev) < overlap_param_inhom(jlev-1) &
& .and. prev_cloud(jg)), &
& 0.0_jprb, is_cloud(jg))
end do
else
! No cloud at this level
is_cloud = .false.
Expand Down
7 changes: 6 additions & 1 deletion radiation/radiation_config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@ module radiation_config
logical :: use_beta_overlap = .false.

! Use a more vectorizable McICA cloud generator, at the expense of
! more random numbers being generated?
! more random numbers being generated? This is the default on NEC
! SX.
#ifdef __SX__
logical :: use_vectorizable_generator = .true.
#else
logical :: use_vectorizable_generator = .false.
#endif

! Shape of sub-grid cloud water PDF
integer :: i_cloud_pdf_shape = IPdfShapeGamma
Expand Down

0 comments on commit 95009dd

Please sign in to comment.