Skip to content

Commit

Permalink
Corrected the RRTMG interface to match with the 2009 version. Fixed the
Browse files Browse the repository at this point in the history
compilation for the SW.
  • Loading branch information
lsoucasse committed Dec 1, 2023
1 parent eb68acc commit cc31bd2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
14 changes: 13 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@ set(target_lib dales)

# Add all Fortran90 files from this directory
# This will also add some unwated files, which we will remove again below
FILE(GLOB sourcefiles "*.f90" "RRTMG/RRTMG_LW/modules/*.f90" "RRTMG/RRTMG_LW/src/*.f90")
FILE(GLOB sourcefiles "*.f90" "RRTMG/RRTMG_LW/modules/*.f90" "RRTMG/RRTMG_LW/src/*.f90" "RRTMG/RRTMG_SW/modules/*.f90" "RRTMG/RRTMG_SW/src/*.f90")

# TODO: make more concise
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/test_transposes.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/mcica_random_numbers.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/mcica_subcol_gen_lw.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/mcica_subcol_gen_lw.1col.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/rrtmg_lw.1col.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/rrtmg_lw_cldprmc.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/rrtmg_lw_k_g.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/rrtmg_lw_rad.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/rrtmg_lw_rrtmc.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/mcica_random_numbers.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/mcica_subcol_gen_sw.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/mcica_subcol_gen_sw.1col.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/rrtmg_sw.1col.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/rrtmg_sw_cldprmc.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/rrtmg_sw_k_g.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/rrtmg_sw_rad.f90)
list(REMOVE_ITEM sourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/rrtmg_sw_spcvmc.f90)

# Still a hack and only works for GCC
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_LW/src/rrtmg_lw_init.f90 PROPERTIES COMPILE_FLAGS -Wno-error=implicit-interface)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/RRTMG/RRTMG_SW/src/rrtmg_sw_init.f90 PROPERTIES COMPILE_FLAGS -Wno-error=implicit-interface)

# Use git-version.cmake to create modversion.f90, containing a version string from git, e.g. "4.2-34-g62b85a-dirty"
add_custom_target(tag_git_version ALL
Expand Down
15 changes: 8 additions & 7 deletions src/modraddata.f90
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ module modraddata
real :: cnstZenith=0. !< constant zenith angle, only used when lCnstZenith=.true. (degrees!)

! Options in NAMRADIATION that apply to the rrtmg script
integer(kind=kind_im) :: ioverlap = 2 ! Cloud overlap method; 0: Clear only; 1: Random; 2: Maximum/random; 3: Maximum
integer(kind=kind_im) :: inflglw = 2 ! 0:inp. cld fr and opt. depth; 1:cf and LWP are input; 2:also ice fraction inp.
integer(kind=kind_im) :: iceflglw = 3 ! 0,1,2,3: ice influence calculations
integer(kind=kind_im) :: liqflglw = 1 ! 0:optical depths computed; 1:drop eff. rad. is input, opt. depth computed
integer(kind=kind_im) :: inflgsw = 2 ! 0:inp. cld fr and opt. depth; 1:cf and LWP are input; 2:also ice fraction inp.
integer(kind=kind_im) :: iceflgsw = 3 ! 0,1,2,3: ice influence calculations
integer(kind=kind_im) :: liqflgsw = 1 ! 0:optical depths computed; 1:drop eff. rad. is input, opt. depth computed
integer(kind=kind_im) :: iaer = 0 ! Aerosol option (SW flag); 0: No aerosol; 6: ECMWF method; 10: Input aerosol optical properties
integer(kind=kind_im) :: ioverlap = 2 ! Cloud overlap method; 0: Clear only; 1: Random; 2: Maximum/random; 3: Maximum
integer(kind=kind_im) :: inflglw = 2 ! 0:inp. cld fr and opt. depth; 1:cf and LWP are input; 2:also ice fraction inp.
integer(kind=kind_im) :: iceflglw = 3 ! 0,1,2,3: ice influence calculations
integer(kind=kind_im) :: liqflglw = 1 ! 0:optical depths computed; 1:drop eff. rad. is input, opt. depth computed
integer(kind=kind_im) :: inflgsw = 2 ! 0:inp. cld fr and opt. depth; 1:cf and LWP are input; 2:also ice fraction inp.
integer(kind=kind_im) :: iceflgsw = 3 ! 0,1,2,3: ice influence calculations
integer(kind=kind_im) :: liqflgsw = 1 ! 0:optical depths computed; 1:drop eff. rad. is input, opt. depth computed
logical :: ocean = .false. ! if true, run is over ocean.
logical :: usero3 = .false. ! if true, the o3 profile is taken from backrad.inp, otherwise from stnd prof RRTMG
real :: co2factor = 1. ! The co2 concentration that is read from the NetCDF input file by RRTMG is multiplied by this factor (CGILS)
Expand Down
10 changes: 5 additions & 5 deletions src/modradrrtmg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -206,32 +206,32 @@ subroutine radrrtmg

if (rad_longw) then
call rrtmg_lw & !comments = corresponding variable names in the RRTMGP library
(int(imax,kind_im), int(nzrad+1,kind_im), ioverlap, int(0,kind_im), & !ncol, nlay, icld, idrv
(int(imax,kind_im), int(nzrad+1,kind_im), ioverlap, & !ncol, nlay, icld, (+ idrv in later versions !)
layerP, interfaceP, layerT, interfaceT, tg_slice, & !play, plev, tlay, tlev, tsfc
h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr, & !h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr
cfc11vmr, cfc12vmr, cfc22vmr, ccl4vmr, emis, & !cfc11vmr, cfc12vmr, cfc22vmr, ccl4vmr, emis
inflglw, iceflglw, liqflglw, cloudFrac, & !inflglw, iceflglw, liqflglw, cldfr,
taucldlw, IWP_slice, LWP_slice, iceRe, liquidRe, & !taucld, cicewp, cliqwp, reice, reliq
tauaerlw, lwUp_slice, lwDown_slice, lwHR_slice, & !tauaer, uflx, dflx, hr
lwUpCS_slice, lwDownCS_slice, lwHRCS_slice) !uflxc, dflxc, hrc
!duflx_dt,duflxc_dt (extra optional arguments only if idrv=1)
!duflx_dt,duflxc_dt (extra optional arguments only if idrv=1 for later versions)
!if(myid==0) write(*,*) 'after call to rrtmg_lw'
end if
if (rad_shortw) then
call setupSW(sunUp)
if (sunUp) then
call rrtmg_sw & !comments = corresponding variable names in the RRTMGP library
(int(imax,kind_im), int(nzrad+1,kind_im), ioverlap, int(0,kind_im), & !ncol, nlay, icld, iaer
(int(imax,kind_im), int(nzrad+1,kind_im), ioverlap, & !ncol, nlay, icld, (+ iaer in later versions !)
layerP, interfaceP, layerT, interfaceT, tg_slice, & !play, plev, tlay, tlev, tsfc
h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr, & !h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr
asdir, asdif, aldir, aldif, & !asdir, asdif, aldir, aldif
solarZenithAngleCos, real(eccf,kind_rb), int(0,kind_im), real(sw0,kind_rb), int(0,kind_im), & !coszen, adjes, dyofyr, scon, isolvar
solarZenithAngleCos, real(eccf,kind_rb), int(0,kind_im), real(sw0,kind_rb), & !coszen, adjes, dyofyr, scon, (+ isolvar in later versions)
inflgsw, iceflgsw, liqflgsw, cloudFrac, & !inflgsw, iceflgsw, liqflgsw, cldfr
taucldsw, ssacldsw, asmcldsw, fsfcldsw, & !taucld, ssacld, asmcld, fsfcld
IWP_slice, LWP_slice, iceRe, liquidRe, & !cicewp, cliqwp, reice, reliq
tauaersw, ssaaersw, asmaersw, ecaersw, & !tauaer, ssaaer, asmaer, ecaer
swUp_slice, swDown_slice, swHR_slice, swUpCS_slice, swDownCS_slice, swHRCS_slice) !swuflx, swdflx, swhr, swuflxc, swdflxc, swhrc
!bndsolvar, indsolvar, solcycfrac (extra optional inputs)
!bndsolvar, indsolvar, solcycfrac (extra optional inputs in later versions)
end if
end if

Expand Down

0 comments on commit cc31bd2

Please sign in to comment.