Skip to content

Commit

Permalink
Try #386:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Jul 14, 2023
2 parents b2e2fdb + efe950c commit f80ecb0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
24 changes: 8 additions & 16 deletions test/rfmip_clear_sky_lw.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using Pkg.Artifacts
using NCDatasets
using ClimaComms

using RRTMGP
using RRTMGP.Vmrs
Expand All @@ -21,15 +22,11 @@ include(joinpath(pkgdir(RRTMGP), "parameters", "create_parameters.jl"))
include("reference_files.jl")
include("read_rfmip_clear_sky.jl")
#---------------------------------------------------------------
function lw_rfmip(
::Type{OPC},
::Type{SRC},
::Type{VMR},
::Type{FT},
::Type{DA},
) where {FT <: AbstractFloat, OPC, SRC, VMR, DA}
function lw_rfmip(context, ::Type{OPC}, ::Type{SRC}, ::Type{VMR}, ::Type{FT}) where {FT <: AbstractFloat, OPC, SRC, VMR}
overrides = (; grav = 9.80665, molmass_dryair = 0.028964, molmass_water = 0.018016)
param_set = create_insolation_parameters(FT, overrides)
device = ClimaComms.device(context)
DA = ClimaComms.array_type(device)
opc = Symbol(OPC)
lw_file = get_ref_filename(:lookup_tables, :clearsky, λ = :lw) # lw lookup tables
lw_input_file = get_ref_filename(:atmos_state, :clearsky) # clear-sky atmos state
Expand Down Expand Up @@ -57,20 +54,15 @@ function lw_rfmip(
ncol, nlay, ngpt = as.ncol, as.nlay, lookup_lw.n_gpt
nlev = nlay + 1
op = OPC(FT, ncol, nlay, DA) # allocating optical properties object
src_lw = SRC(FT, DA, nlay, ncol) # allocating longwave source function object
src_lw = source_func_longwave(param_set, FT, ncol, nlay, opc, DA) # allocating longwave source function object
bcs_lw = LwBCs{FT, typeof(sfc_emis), Nothing}(sfc_emis, nothing) # setting up boundary conditions
fluxb_lw = FluxLW(ncol, nlay, FT, DA) # flux storage for bandwise calculations
flux_lw = FluxLW(ncol, nlay, FT, DA) # longwave fluxes

# initializing RTE solver
slv = Solver(as, op, src_lw, nothing, bcs_lw, nothing, fluxb_lw, nothing, flux_lw, nothing)
slv = Solver(context, as, op, src_lw, nothing, bcs_lw, nothing, fluxb_lw, nothing, flux_lw, nothing)

solve_lw!(slv, max_threads, lookup_lw)
println("Timing ==================================================")
for i in 1:5
@time solve_lw!(slv, max_threads, lookup_lw)
println("*************************************************")
end
# comparing with data from RRTMGP FORTRAN code
flip_ind = nlev:-1:1

Expand All @@ -97,5 +89,5 @@ function lw_rfmip(
return nothing
end

lw_rfmip(OneScalar, SourceLWNoScat, VmrGM, Float64, Int, array_type())
lw_rfmip(TwoStream, SourceLW2Str, VmrGM, Float64, Int, array_type())
lw_rfmip(ClimaComms.context(), OneScalar, SourceLWNoScat, VmrGM, Float64)
lw_rfmip(ClimaComms.context(), TwoStream, SourceLW2Str, VmrGM, Float64)
11 changes: 3 additions & 8 deletions test/rfmip_clear_sky_sw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function sw_rfmip(context, ::Type{OPC}, ::Type{SRC}, ::Type{VMR}, ::Type{FT}) wh
ncol, nlay, ngpt = as.ncol, as.nlay, lookup_sw.n_gpt
nlev = nlay + 1
op = OPC(FT, ncol, nlay, DA) # allocating optical properties object
src_sw = SRC(FT, DA, nlay, ncol) # allocating longwave source function object
#src_sw = source_func_shortwave(FT, ncol, nlay, opc, DA) # allocating longwave source function object
#src_sw = SRC(FT, DA, nlay, ncol) # allocating longwave source function object
src_sw = source_func_shortwave(FT, ncol, nlay, opc, DA) # allocating longwave source function object

# setting up boundary conditions
inc_flux_diffuse = nothing
Expand All @@ -69,10 +69,6 @@ function sw_rfmip(context, ::Type{OPC}, ::Type{SRC}, ::Type{VMR}, ::Type{FT}) wh
#--------------------------------------------------
solve_sw!(slv, max_threads, lookup_sw)

for i in 1:10
@time solve_sw!(slv, max_threads, lookup_sw)
end

# reading comparison data
flip_ind = nlev:-1:1

Expand Down Expand Up @@ -108,6 +104,5 @@ function sw_rfmip(context, ::Type{OPC}, ::Type{SRC}, ::Type{VMR}, ::Type{FT}) wh
return nothing
end

context = ClimaComms.context()
sw_rfmip(context, TwoStream, SourceSW2Str, VmrGM, Float64) # two-stream solver should be used for the short-wave problem
sw_rfmip(ClimaComms.context(), TwoStream, SourceSW2Str, VmrGM, Float64) # two-stream solver should be used for the short-wave problem
#sw_rfmip(OneScalar, VmrGM, Float64, Int, array_type()) # this only computes flux_dn_dir
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ println("================================================================\n\n\n"
end
println("================================================================\n\n\n")

@testset "RRTMGP stand-alone clear-sky lw solver tests" begin
include("rfmip_clear_sky_lw.jl")
end
println("================================================================\n\n\n")

@testset "RRTMGP stand-alone clear-sky sw solver tests" begin
include("rfmip_clear_sky_sw.jl")
end
println("================================================================\n\n\n")

@testset "Aqua" begin
include("aqua.jl")
end
10 changes: 10 additions & 0 deletions test/runtests_gpu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ println("================================================================\n\n\n"
include("all_sky.jl")
end
println("================================================================\n\n\n")

@testset "RRTMGP stand-alone clear-sky lw solver tests" begin
include("rfmip_clear_sky_lw.jl")
end
println("================================================================\n\n\n")

@testset "RRTMGP stand-alone clear-sky sw solver tests" begin
include("rfmip_clear_sky_sw.jl")
end
println("================================================================\n\n\n")

0 comments on commit f80ecb0

Please sign in to comment.