Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
c8e1b4b
pmn: first draft of OSR band output
dr0cloud Apr 12, 2024
ed0b526
pmn: bugfix to allow pre-init access to wavenums
dr0cloud Apr 15, 2024
fc63031
pmn: better handling of pre-first-full-calc output
dr0cloud Apr 16, 2024
201ff62
latest tunings for HWT SFE 2024
wmputman Apr 17, 2024
d34ee6a
Merge branch 'feature/wmputman/KM_v11_5_1_HWT_SFE2024' into feature/s…
sdrabenh Apr 17, 2024
0ddafb8
pmn: add ISRBbbRG
dr0cloud Apr 18, 2024
3f61087
latest bands output from peter
wmputman Apr 19, 2024
a6e520d
hand-resolve merge conflicts from feature/wmputman/KM_v11_5_1_HWT_SFE…
sdrabenh Apr 26, 2024
8479680
hand-resolve merge conflicts from feature/wmputman/KM_v11_5_1_HWT_SFE…
sdrabenh Apr 29, 2024
17b5762
Port fixes from feature/pnorris/OSR_per_band_instrumentation
mathomp4 May 1, 2024
0f33fff
Merge pull request #40 from GEOS-ESM/bugfix/mathomp4/fix-uninit-with-…
sdrabenh May 1, 2024
3fb21f7
pmn: compiling version with draft implementation of RRTMGP band outpu…
dr0cloud May 1, 2024
5364ada
pmn: OLRB bugfix
dr0cloud May 8, 2024
c581320
Merge branch 'feature/sdrabenh/gcm_v12-rc1' into feature/pnorris/OSR_…
mathomp4 May 17, 2024
09c0458
Turn Solar Band 11 to .true.
mathomp4 May 17, 2024
a5bdf44
added the use of suspended precip in the radiation for new model configs
wmputman Jun 6, 2024
fe124c5
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12_BETA00' …
sdrabenh Jun 7, 2024
010a87a
Merge branch 'feature/sdrabenh/gcm_v12-rc1' into feature/pnorris/OSR_…
mathomp4 Jun 7, 2024
2214311
Fix bad merge
mathomp4 Jun 7, 2024
493ab42
Hand-merge feature/pnorris/OSR_per_band_instrumentation-merge-scott i…
sdrabenh Jun 10, 2024
0c0d977
Merge branch 'feature/sdrabenh/gcm_v12-rc1' into feature/pnorris/OSR_…
mathomp4 Jun 10, 2024
28b9703
Update GEOS_IrradGridComp.F90
mathomp4 Jun 10, 2024
ca10292
Update GEOS_SolarGridComp.F90
mathomp4 Jun 10, 2024
408d4c6
Merge pull request #41 from GEOS-ESM/feature/pnorris/OSR_per_band_ins…
sdrabenh Jun 10, 2024
eaf393f
v12: Fix issue with COT calculations
mathomp4 Aug 21, 2024
cb49213
Merge pull request #46 from GEOS-ESM/hotfix/mathomp4/cot-fix-v12
mathomp4 Aug 21, 2024
54a3687
Merge tag 'v1.9.0' into feature/sdrabenh/gcm_v12
sdrabenh Oct 5, 2024
9c1e0a5
Convert Solar GC to use gFTL StringVector
mathomp4 Nov 27, 2024
05026aa
Fix typo
mathomp4 Nov 27, 2024
2096b6f
Remove ifx from coupled run
mathomp4 Nov 27, 2024
9af8e8c
Merge pull request #49 from GEOS-ESM/feature/mathomp4/v12-solar-strin…
mathomp4 Dec 2, 2024
9c9a00f
added LW no aerosol export
wmputman Dec 19, 2024
6e34bf0
adjusted the O3 dissipation function near model top to avoid extreme …
wmputman Dec 19, 2024
7d9acd0
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12rc8_WMP' …
sdrabenh Dec 20, 2024
32d7d08
put O3 diurnal function back to original since RRTMGP has no issues w…
wmputman Dec 23, 2024
6aa5281
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12rc8_WMP' …
sdrabenh Dec 25, 2024
f8167fb
v12: Convert Irrad GC to use gFTL StringVector
mathomp4 Jan 6, 2025
6873624
Use gftl
mathomp4 Jan 6, 2025
95d1269
Begin the iterators
mathomp4 Jan 6, 2025
795d209
Merge pull request #54 from GEOS-ESM/bugfix/mathomp4/v12-irrad-stringvec
sdrabenh Jan 6, 2025
8b87c30
bumped the max T adjustment in RRTMGP
wmputman Jan 26, 2025
8870965
bumped RRTMGP_LW_TMIN_INC_OK_K to 30K
wmputman Feb 4, 2025
ba383bc
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12rc8_WMP' …
sdrabenh Feb 6, 2025
061514a
Add protections on aer_props passed to RRTMGP
mathomp4 Feb 7, 2025
82571a5
Touch comment to re-trigger CI
mathomp4 Feb 8, 2025
fdc5ba6
v12: Update Intel Release build of RRTMGP
mathomp4 Feb 11, 2025
882a84b
undo bad commit
mathomp4 Feb 11, 2025
3c31d8f
v12: Update Intel Release build of RRTMGP
mathomp4 Feb 11, 2025
21b1624
removed traps on RRTMGP range differences, and removed protection for…
wmputman Feb 11, 2025
a52e0ef
Merge pull request #63 from GEOS-ESM/feature/mathomp4/v12-new-intel-f…
mathomp4 Feb 11, 2025
53649ac
Merge branch 'feature/sdrabenh/gcm_v12' into bugfix/mathomp4/55-aggre…
mathomp4 Feb 13, 2025
2c3a8e8
Add protection to irrad
mathomp4 Feb 13, 2025
bf32a36
Hand-merge feature/wmputman/LM_v12rc8_WMP into feature/sdrabenh/gcm_v12
sdrabenh Feb 13, 2025
4fdcf3c
Merge remote-tracking branch 'origin/bugfix/mathomp4/55-aggressive-fi…
sdrabenh Feb 13, 2025
71fbfd8
Merge pull request #64 from GEOS-ESM/feature/sdrabenh/v12_merg_dev
sdrabenh Feb 14, 2025
bfab19a
Merge pull request #65 from GEOS-ESM/develop
mathomp4 Feb 18, 2025
211eab9
Remove Irrad protections
sdrabenh Feb 20, 2025
f727465
Support for no-MKL RRTMGP
mathomp4 Mar 18, 2025
87830a3
updated diffusion in FV3, chemistry handling of plid, 1M aerosol acti…
wmputman Mar 25, 2025
3fff73d
Merge remote-tracking branch 'origin/feature/67-support-nomkl' into f…
sdrabenh Mar 25, 2025
bb34ff8
Merge branch 'feature/sdrabenh/gcm_v12' into bugfix/mathomp4/55-aggre…
mathomp4 Mar 25, 2025
3fd6bd8
Merge remote-tracking branch 'origin/bugfix/mathomp4/55-aggressive-fi…
sdrabenh Mar 25, 2025
aaa2b8c
Merge develop into v12 for chem split
mathomp4 Apr 7, 2025
98e20f1
Turn off ifx to save money
mathomp4 Apr 7, 2025
d5a94a9
declare CF type
mathomp4 Apr 7, 2025
cbd2b99
Get the CF
mathomp4 Apr 7, 2025
3d723d2
Merge pull request #69 from GEOS-ESM/feature/split-chem-v12
sdrabenh Apr 14, 2025
01b6dd9
added band08 output for lightning param
wmputman Apr 24, 2025
892a5ca
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12rc12_WMP'…
sdrabenh Apr 29, 2025
abe8919
Merge pull request #71 from GEOS-ESM/feature/sdrabenh/GCMv12-rc14
sdrabenh May 2, 2025
01888a5
updated protections for RRTMGP temp and press
wmputman Jul 17, 2025
83340ec
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12rc14_WMP'…
sdrabenh Jul 17, 2025
22e1ece
latest traps for extreme T values in RRTMGP
wmputman Aug 29, 2025
4295ee6
protections and warnings about negative active species
wmputman Sep 3, 2025
07ae39f
Use _RETURN which seems to fix GCC. zerodiff
mathomp4 Sep 8, 2025
cd243ca
Latest changes from Bill for floating point protection and stability
wmputman Sep 30, 2025
b17ef63
Merge remote-tracking branch 'origin/feature/wmputman/LM_v12rc20_WMP'…
sdrabenh Oct 1, 2025
bebdccf
radiation protections for aerosol optics and O3 settings from PCHEM
wmputman Mar 2, 2026
f358d16
radiation protections for aerosol optics and O3 settings from PCHEM
wmputman Mar 2, 2026
31a06db
Refactor(Step 1): uniform per-block alloc/dealloc in RRTMGP block loop
tclune May 4, 2026
67eab50
Refactor(Step 2a): extract compute_gas_optics from RRTMGP block loop
tclune May 4, 2026
ea71b08
Refactor(Step 2b): extract compute_aer_optics from RRTMGP block loop
tclune May 4, 2026
df4f377
Step 2c: extract compute_cloud_optics_mcica
tclune May 4, 2026
7b48629
Step 2d: extract compute_sprlyr_diags_predelta
tclune May 4, 2026
b12e93c
Step 2e: extract compute_delta_scale
tclune May 4, 2026
d3e9d03
Step 2f: extract compute_sprlyr_diags_postdelta from SORADCORE block …
tclune May 4, 2026
835c814
Step 2g: extract compute_rte_sw from SORADCORE block loop
tclune May 4, 2026
e3bd356
Step 3: assemble PROCESS_RRTMGP_BLOCK wrapper with all per-block stat…
tclune May 4, 2026
9fc54cc
Step 4: add ! PARALLEL DO over block loop; comment out non-thread-saf…
tclune May 4, 2026
b751310
Fix: move aer_props increment to call site to avoid passing unallocat…
tclune May 4, 2026
b7a460d
bugfix3: guard compute_aer_optics call when aer_props unallocated
tclune May 4, 2026
4760fd1
Merge pull request #86 from GEOS-ESM/feature/tclune/solar_openmp
tclune May 7, 2026
f9afe58
lw step1: uniform per-block alloc/dealloc in LW_Driver RRTMGP block loop
tclune May 7, 2026
b34963f
lw step2a: extract compute_lw_aer_optics
tclune May 7, 2026
c2e22b9
Step 2b: extract compute_lw_cloud_optics_mcica
tclune May 7, 2026
76e3834
Steps 2c+2d: extract compute_lw_gas_optics and compute_lw_rte
tclune May 7, 2026
4720c9d
Step 3: add PROCESS_RRTMGP_LW_BLOCK wrapper; make adl/rdl optional in…
tclune May 7, 2026
4b920df
Step 4: add ! PARALLEL DO to LW block loop with ATOMIC error handling
tclune May 7, 2026
050a17d
Merge pull request #88 from GEOS-ESM/feature/tclune/lw_openmp
mathomp4 May 11, 2026
b46eb1a
hand-merge v1.12.0 into feature/sdrabenh/gcm_v12
sdrabenh May 22, 2026
323b885
Remove choose_solar_scheme subroutine in merge from v1.12.0
sdrabenh May 25, 2026
82f4140
Merge pull request #90 from GEOS-ESM/feature/sdrabenh/gcm_v11_into_v12
sdrabenh May 26, 2026
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
13 changes: 8 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: 2.1

# Anchors in case we need to override the defaults from the orb
#baselibs_version: &baselibs_version v7.29.0
#bcs_version: &bcs_version v11.6.0
#baselibs_version: &baselibs_version v8.5.0
#bcs_version: &bcs_version v12.0.0

orbs:
ci: geos-esm/circleci-tools@4
ci: geos-esm/circleci-tools@5

workflows:
build-test:
Expand All @@ -21,7 +21,10 @@ workflows:
#baselibs_version: *baselibs_version
repo: GEOSgcm
checkout_fixture: true
mepodevelop: true
# V12 code uses a special branch for now.
fixture_branch: feature/sdrabenh/gcm_v12
# We comment out this as it will "undo" the fixture_branch
#mepodevelop: true
persist_workspace: true # Needs to be true to run fv3/gcm experiment, costs extra

# Run AMIP GCM (1 hour, no ExtData)
Expand All @@ -45,7 +48,7 @@ workflows:
- docker-hub-creds
matrix:
parameters:
compiler: [gfortran, ifort]
compiler: [ifort]
requires:
- build-GEOSgcm-on-<< matrix.compiler >>
repo: GEOSgcm
Expand Down
21 changes: 20 additions & 1 deletion GEOS_RadiationGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ subroutine SetServices ( GC, RC )
RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( GC, &
SHORT_NAME = 'RADLWNA', &
LONG_NAME = 'air_temperature_tendency_due_to_longwave_no_aerosol', &
UNITS = 'K s-1', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, &
RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( GC, &
SHORT_NAME = 'RADSWNA', &
LONG_NAME = 'air_temperature_tendency_due_to_shortwave_no_aerosol', &
Expand Down Expand Up @@ -639,6 +648,7 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
real, pointer, dimension(:,: ) :: DSFDTS
real, pointer, dimension(:,: ) :: TRD
real, pointer, dimension(:,:,:) :: FLW
real, pointer, dimension(:,:,:) :: FLWNA
real, pointer, dimension(:,:,:) :: FLWCLR
real, pointer, dimension(:,:,:) :: FLA

Expand All @@ -660,6 +670,7 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
real, pointer, dimension(:,:,:) :: RADSW
real, pointer, dimension(:,:,:) :: RADLWC
real, pointer, dimension(:,:,:) :: RADSWC
real, pointer, dimension(:,:,:) :: RADLWNA
real, pointer, dimension(:,:,:) :: RADSWNA
real, pointer, dimension(:,:,:) :: RADLWCNA
real, pointer, dimension(:,:,:) :: RADSWCNA
Expand Down Expand Up @@ -730,6 +741,8 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
VERIFY_(STATUS)
call MAPL_GetPointer ( EXPORT, RADSWC , 'RADSWC' , RC=STATUS )
VERIFY_(STATUS)
call MAPL_GetPointer ( EXPORT, RADLWNA , 'RADLWNA' , RC=STATUS )
VERIFY_(STATUS)
call MAPL_GetPointer ( EXPORT, RADSWNA , 'RADSWNA' , RC=STATUS )
VERIFY_(STATUS)
call MAPL_GetPointer ( EXPORT, RADLWCNA, 'RADLWCNA', RC=STATUS )
Expand Down Expand Up @@ -770,6 +783,11 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
VERIFY_(STATUS)
end if

if (associated(RADLWNA) ) then
call MAPL_GetPointer ( GEX(IRR), FLWNA, 'FLXA' , alloc=.TRUE.,RC=STATUS )
VERIFY_(STATUS)
end if

if (associated(RADLWCNA) ) then
call MAPL_GetPointer ( GEX(IRR), FLA , 'FLA' , alloc=.TRUE.,RC=STATUS )
VERIFY_(STATUS)
Expand Down Expand Up @@ -804,7 +822,7 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
if( associated (RADLW ) .or. associated (RADSW ) .or. &
associated (RADLWC) .or. associated (RADSWC) .or. &
associated (RADSWNA).or. associated (RADSWCNA) .or. &
associated (RADLWCNA) ) then
associated (RADLWNA).or. associated (RADLWCNA) ) then

allocate(DMI(IM,JM,LM),stat=STATUS)
VERIFY_(STATUS)
Expand All @@ -814,6 +832,7 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
if( associated (RADSW ) ) RADSW = (FSW (:,:,0:LM-1) - FSW (:,:,1:LM))*DMI
if( associated (RADLWC ) ) RADLWC = (FLWCLR(:,:,0:LM-1) - FLWCLR(:,:,1:LM))*DMI
if( associated (RADSWC ) ) RADSWC = (FSWCLR(:,:,0:LM-1) - FSWCLR(:,:,1:LM))*DMI
if( associated (RADLWNA ) ) RADLWNA = (FLWNA (:,:,0:LM-1) - FLWNA (:,:,1:LM))*DMI
if( associated (RADSWNA ) ) RADSWNA = (FSWNA (:,:,0:LM-1) - FSWNA (:,:,1:LM))*DMI
if( associated (RADLWCNA) ) RADLWCNA = (FLA (:,:,0:LM-1) - FLA (:,:,1:LM))*DMI
if( associated (RADSWCNA) ) RADSWCNA = (FSCNA (:,:,0:LM-1) - FSCNA (:,:,1:LM))*DMI
Expand Down
2 changes: 2 additions & 0 deletions GEOS_RadiationShared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ esma_set_this ()
set (srcs
radconstants.F90
gettau.F90
rad_types.F90
rad_utils.F90
cloud_condensate_inhomogeneity.F90
cloud_subcol_gen.F90
)
Expand Down
13 changes: 8 additions & 5 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 All @@ -69,9 +72,9 @@ esma_add_library(${this}
# Use of the GEOS Vectorized flags in RRTMGP caused a segfault leading to
# line 726 of mo_gas_optics_kernels.F90. Moving to the "old" no-vect flags
# allows RRTMGP to run again.
if (CMAKE_Fortran_COMPILER_ID MATCHES Intel AND CMAKE_BUILD_TYPE MATCHES Release)
set (CMAKE_Fortran_FLAGS_RELEASE "${GEOS_Fortran_FLAGS_NOVECT}")
endif ()
#if (CMAKE_Fortran_COMPILER_ID MATCHES Intel AND CMAKE_BUILD_TYPE MATCHES Release)
# set (CMAKE_Fortran_FLAGS_RELEASE "${GEOS_Fortran_FLAGS_NOVECT}")
#endif ()

if (MKL_FOUND)
target_include_directories (${this} PRIVATE ${MKL_INCLUDE_DIRS})
Expand Down
9 changes: 9 additions & 0 deletions GEOS_RadiationShared/rad_types.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module rad_types

! Handy wrappers to pointer arrays.
! Used to provide ragged arrays, etc.
type :: rptr1d_wrap
real, pointer, dimension(:) :: p
end type rptr1d_wrap

end module rad_types
234 changes: 234 additions & 0 deletions GEOS_RadiationShared/rad_utils.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
#include "MAPL_Generic.h"

module rad_utils

use ESMF
use MAPL

implicit none
private

public :: Tbr_from_band_flux
public :: choose_solar_scheme, choose_irrad_scheme

contains

! -----------------------------------------------------
! Routines to estimate brightness temperature from flux
! -----------------------------------------------------

! estimate brightness temperature from a band flux
subroutine Tbr_from_band_flux(IM, JM, Fband_, wn1, wn2, Tbr_, RC)

! input arguments
integer, intent(in ) :: IM, JM
real, intent(in ) :: Fband_(IM,JM) ! band flux [W/m2]
real, intent(in ) :: wn1, wn2 ! bounds of band [m-1]

! output arguments
real, intent(out) :: Tbr_(IM,JM) ! brightness temp [K]

! error code
integer, optional, intent(out) :: RC

! fundamental constants
double precision, parameter :: h = 6.626070040d-34 ! Plancks constant [J.s]
double precision, parameter :: c = 2.99792458d8 ! Speed of light in vacuum [m/s]
double precision, parameter :: kB = 1.38064852d-23 ! Boltzmann constant [J/K]
double precision, parameter :: pi = MAPL_PI_R8

! other constants
double precision, parameter :: alT = h * c / kB
double precision, parameter :: bigS = 2.0d0 * kB**4 * pi / (h**3 * c**2)
double precision, parameter :: bigC = 2.0d0 * h * c**2

! locals
integer :: STATUS
double precision, dimension(IM,JM) :: Fband, Tbr, Bmean
real :: wnMid

_ASSERT(wn2 > wn1,'band wavenumber bounds mis-ordered!')

! calculations done in double precision
Fband = dble(Fband_)

! first guess Tbr from narrow band approximation ...
! (1) estimate mean Planck function for a narrow band
Bmean = Fband / (pi * (wn2 - wn1))
! (2) invert Planck function for temp at mid-point wavenumber
wnMid = (wn1 + wn2) / 2.0d0
call invert_Planck_for_T(IM, JM, Bmean, wnMid, bigC, alT, Tbr, __RC__)

! now refine with a wide band esimate
! PMN: Iterative routine not ready for prime time
! Produces erroneously large Tbr in cloudy regions
!call Tbr_wide_band(IM, JM, Fband, wn1, wn2, bigS, alT, Tbr, __RC__)

! put output back in real
where (Tbr > 0.0d0)
Tbr_ = real(Tbr)
elsewhere
Tbr_ = MAPL_UNDEF
endwhere

_RETURN(_SUCCESS)

end subroutine Tbr_from_band_flux

! invert Planck function for temperature
subroutine invert_Planck_for_T(IM, JM, Bwn, wn, bigC, alT, T, RC)

! input arguments
integer, intent(in ) :: IM, JM
double precision, intent(in ) :: Bwn(IM,JM) ! PlanckFn(wavenumber)
real, intent(in ) :: wn ! wavenumber [m-1]
double precision, intent(in ) :: bigC, alT ! necessary constants

! output arguments
double precision, intent(out) :: T(IM,JM) ! temperature [K]

! error code
integer, optional, intent(out) :: RC

! error checking
_ASSERT(wn > 0.,'non-positive wavenumber!')

! invert Planck function for temp
where (Bwn > 0.0d0)
T = (alT * wn) / log((bigC * wn**3) / Bwn + 1.0d0)
elsewhere
T = 0.0d0
endwhere

_RETURN(_SUCCESS)

end subroutine invert_Planck_for_T

! Tbr from wide band approximation
subroutine Tbr_wide_band(IM, JM, Fband, wn1, wn2, bigS, alT, Tbr, RC)

! input arguments
integer, intent(in ) :: IM, JM
double precision, intent(in ) :: Fband(IM,JM) ! band flux [W/m2]
real, intent(in ) :: wn1, wn2 ! bounds of band [m-1]
double precision, intent(in ) :: bigS, alT ! necessary constant

! Tbr inputs first guess and outputs better estimate
double precision, intent(inout) :: Tbr(IM,JM) ! brightness temp [K]

! error code
integer, optional, intent(out) :: RC

! number of iterations for wide band estimate (converges slowly)
integer, parameter :: Nits = 16

! locals
integer :: n
real :: alTwn1, alTwn2

! error checking
_ASSERT(Nits >= 1,'must have at least one iteration!')

! iterate from first guess Tbr to better estimate
alTwn1 = alT * wn1
alTwn2 = alT * wn2
do n = 1, Nits
where (Tbr > 0.0d0) &
Tbr = ( Fband / (bigS * (Tfunc(alTwn1/Tbr) - Tfunc(alTwn2/Tbr))) ) ** 0.25d0
end do

_RETURN(_SUCCESS)

end subroutine Tbr_wide_band

elemental double precision function Tfunc(x)

double precision, intent(in) :: x

! maximum number of terms in series (converges quickly)
integer, parameter :: nmax = 4

! locals
integer :: n, n2, n3
double precision :: emx, cx0, cx1, cx2, cx3, zn

! setup
emx = exp(-x)
cx0 = 6.0d0
cx1 = 6.0d0 * x
cx2 = 3.0d0 * x**2
cx3 = x**3

! do at least 1st order
Tfunc = (cx3 + cx2 + cx1 + cx0) * emx
if (nmax <= 1) return

! higher orders
zn = emx
do n = 2, nmax
n2 = n * n
n3 = n * n2
zn = zn * emx
Tfunc = Tfunc + (cx3 + cx2/n + cx1/n2 + cx0/n3) * zn / n
end do

end function Tfunc


! ----------------------------------------------------------------------
! Decide which radiation to use for thermodynamics state evolution.
! RRTMGP dominates RRTMG dominates Chou-Suarez.
! Chou-Suarez is the default if nothing else asked for in Resource file.
! ----------------------------------------------------------------------

subroutine choose_solar_scheme (MAPL, &
USE_RRTMGP, USE_RRTMG, USE_CHOU, &
RC)

type (MAPL_MetaComp), pointer, intent(in) :: MAPL
logical, intent(out) :: USE_RRTMGP, USE_RRTMG, USE_CHOU
integer, optional, intent(out) :: RC ! return code

real :: RFLAG
integer :: STATUS

USE_RRTMGP = .false.
USE_RRTMG = .false.
USE_CHOU = .false.
call MAPL_GetResource (MAPL, RFLAG, LABEL='USE_RRTMGP_SORAD:', DEFAULT=0., __RC__)
USE_RRTMGP = RFLAG /= 0.
if (.not. USE_RRTMGP) then
call MAPL_GetResource (MAPL, RFLAG, LABEL='USE_RRTMG_SORAD:', DEFAULT=0., __RC__)
USE_RRTMG = RFLAG /= 0.
USE_CHOU = .not.USE_RRTMG
end if

_RETURN(_SUCCESS)
end subroutine choose_solar_scheme

subroutine choose_irrad_scheme (MAPL, &
USE_RRTMGP, USE_RRTMG, USE_CHOU, &
RC)

type (MAPL_MetaComp), pointer, intent(in) :: MAPL
logical, intent(out) :: USE_RRTMGP, USE_RRTMG, USE_CHOU
integer, optional, intent(out) :: RC ! return code

real :: RFLAG
integer :: STATUS

USE_RRTMGP = .false.
USE_RRTMG = .false.
USE_CHOU = .false.
call MAPL_GetResource (MAPL, RFLAG, LABEL='USE_RRTMGP_IRRAD:', DEFAULT=0., __RC__)
USE_RRTMGP = RFLAG /= 0.
if (.not. USE_RRTMGP) then
call MAPL_GetResource (MAPL, RFLAG, LABEL='USE_RRTMG_IRRAD:', DEFAULT=0., __RC__)
USE_RRTMG = RFLAG /= 0.
USE_CHOU = .not.USE_RRTMG
end if

_RETURN(_SUCCESS)
end subroutine choose_irrad_scheme

end module rad_utils
Loading
Loading