From 006ec58e6f4daecabc51e62935f6f4066580e7f9 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Sat, 1 Jul 2023 15:45:16 -0700 Subject: [PATCH] Try speedup getindex --- src/optics/CloudOptics.jl | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/optics/CloudOptics.jl b/src/optics/CloudOptics.jl index 333b9f488..839108239 100644 --- a/src/optics/CloudOptics.jl +++ b/src/optics/CloudOptics.jl @@ -13,13 +13,35 @@ This function computes the longwave TwoStream clouds optics properties and adds them to the TwoStream longwave gas optics properties. """ -function add_cloud_optics_2stream(op::TwoStream, as::AtmosphericState, lkp::LookUpLW, lkp_cld, glay, gcol, ibnd, igpt) - if as.cld_mask_lw isa AbstractArray - cld_mask = as.cld_mask_lw[igpt, glay, gcol] - if cld_mask - τ_cl, τ_cl_ssa, τ_cl_ssag = compute_cld_props(lkp_cld, as, cld_mask, glay, gcol, ibnd, igpt) - increment!(op, τ_cl, τ_cl_ssa, τ_cl_ssag, glay, gcol, igpt) - end +add_cloud_optics_2stream(op::TwoStream, as::AtmosphericState, lkp::LookUpLW, lkp_cld, glay, gcol, ibnd, igpt) = + add_cloud_optics_2stream(op, as, lkp, lkp_cld, glay, gcol, ibnd, igpt, as.cld_mask_lw) +add_cloud_optics_2stream( + op::TwoStream, + as::AtmosphericState, + lkp::LookUpLW, + lkp_cld, + glay, + gcol, + ibnd, + igpt, + cld_mask_lw, +) = nothing + +function add_cloud_optics_2stream( + op::TwoStream, + as::AtmosphericState, + lkp::LookUpLW, + lkp_cld, + glay, + gcol, + ibnd, + igpt, + cld_mask_lw::AbstractArray, +) + @inbounds cld_mask = as.cld_mask_lw[igpt, glay, gcol] + if cld_mask + τ_cl, τ_cl_ssa, τ_cl_ssag = compute_cld_props(lkp_cld, as, cld_mask, glay, gcol, ibnd, igpt) + increment!(op, τ_cl, τ_cl_ssa, τ_cl_ssag, glay, gcol, igpt) end return nothing end