Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions GEOS_RadiationShared/RRTMGP_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ if (MKL_FOUND)
rng/mo_rng_mklvsl.F90
rng/mo_rng_mklvsl_plus.F90
)

message(STATUS "MKL found. The mklvsl rng will be compiled.")
else ()
ecbuild_warn("MKL was not found. The mklvsl rng will not be compiled. RRTMGP should not be used.")
list (APPEND SRCS
rng/mo_rng_mt19937.F90
)
message(STATUS "MKL not found. The mt19937 rng will be compiled.")
endif()

esma_add_library(${this}
Expand Down
10 changes: 8 additions & 2 deletions GEOSirrad_GridComp/GEOS_IrradGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,8 @@ subroutine LW_Driver(IM,JM,LM,LATS,LONS,RC)
!
use MKL_VSL_TYPE
use mo_rng_mklvsl_plus, only: ty_rng_mklvsl_plus
#else
use mo_rng_mt19937, only: ty_rng_mt
#endif

! for RRTMGP (use implicit inside RRTMG)
Expand Down Expand Up @@ -1459,6 +1461,8 @@ subroutine LW_Driver(IM,JM,LM,LATS,LONS,RC)
! a column random number generator
#ifdef HAVE_MKL
type(ty_rng_mklvsl_plus) :: rng
#else
type(ty_rng_mt) :: rng
#endif
integer, dimension(:), allocatable :: seeds

Expand Down Expand Up @@ -2647,7 +2651,6 @@ subroutine LW_Driver(IM,JM,LM,LATS,LONS,RC)

! Generate McICA random numbers for block.
! Perhaps later this can be parallelized?
#ifdef HAVE_MKL
do isub = 1, ncols_block
! local 1d column index
icol = colS + isub - 1
Expand All @@ -2658,8 +2661,12 @@ subroutine LW_Driver(IM,JM,LM,LATS,LONS,RC)
! set word1 of key based on GLOBAL location
! 32-bits can hold all forseeable resolutions
seeds(1) = (jBeg + J - 1) * IM_World + (iBeg + I - 1)
#ifdef HAVE_MKL
! instantiate a random number stream for the column
call rng%init(VSL_BRNG_PHILOX4X32X10,seeds)
#else
call rng%init(seeds)
#endif
! draw the random numbers for the column
urand(:,:,isub) = reshape(rng%get_random(ngpt*LM),(/ngpt,LM/))
if (gen_mro) then
Expand All @@ -2672,7 +2679,6 @@ subroutine LW_Driver(IM,JM,LM,LATS,LONS,RC)
! free the rng
call rng%end()
end do
#endif

! cloud sampling to gpoints
select case (cloud_overlap_type)
Expand Down
10 changes: 8 additions & 2 deletions GEOSsolar_GridComp/GEOS_SolarGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3495,6 +3495,8 @@ subroutine SORADCORE(IM,JM,LM,include_aerosols,CURRTIME,MaxPasses,LoadBalance,RC
!
use MKL_VSL_TYPE
use mo_rng_mklvsl_plus, only: ty_rng_mklvsl_plus
#else
use mo_rng_mt19937, only: ty_rng_mt
#endif

! for RRTMGP (use implicit inside RRTMG)
Expand Down Expand Up @@ -3733,6 +3735,8 @@ subroutine SORADCORE(IM,JM,LM,include_aerosols,CURRTIME,MaxPasses,LoadBalance,RC
! a column random number generator
#ifdef HAVE_MKL
type(ty_rng_mklvsl_plus) :: rng
#else
type(ty_rng_mt) :: rng
#endif
integer, dimension(:), allocatable :: seeds

Expand Down Expand Up @@ -5470,16 +5474,19 @@ subroutine SORADCORE(IM,JM,LM,include_aerosols,CURRTIME,MaxPasses,LoadBalance,RC

! generate McICA random numbers for block
! Perhaps later this can be parallelized?
#ifdef HAVE_MKL
do isub = 1, ncols_block
! local 1d column index
icol = colS + isub - 1
! initialize the Philox PRNG
! set word1 of key based on GLOBAL location
! 32-bits can hold all forseeable resolutions
seeds(1) = nint(Jg1D(icol)) * IM_World + nint(Ig1D(icol))
#ifdef HAVE_MKL
! instantiate a random number stream for the column
call rng%init(VSL_BRNG_PHILOX4X32X10,seeds)
#else
call rng%init(seeds)
#endif
! draw the random numbers for the column
urand(:,:,isub) = reshape(rng%get_random(ngpt*LM),(/ngpt,LM/))
if (gen_mro) then
Expand All @@ -5492,7 +5499,6 @@ subroutine SORADCORE(IM,JM,LM,include_aerosols,CURRTIME,MaxPasses,LoadBalance,RC
! free the rng
call rng%end()
end do
#endif

! cloud sampling to gpoints
select case (cloud_overlap_type)
Expand Down
Loading