From e7b332f8f97cfd48e38bef0f512a5997831398d9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 20 Nov 2024 09:39:42 -0800 Subject: [PATCH] fix Kb_sing calculation Using a do loop in place of broadcasting is necessary here per the fortran standard since the pointers and arrays are not contiguous in memory. --- radiation/TwoStreamMLPEMod.F90 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/radiation/TwoStreamMLPEMod.F90 b/radiation/TwoStreamMLPEMod.F90 index c4bb99fec1..25b8efdc1b 100644 --- a/radiation/TwoStreamMLPEMod.F90 +++ b/radiation/TwoStreamMLPEMod.F90 @@ -979,10 +979,12 @@ subroutine ZenithPrep(this,cosz_in) iter_sing = 0 ! Compute the singularity for all bands - Kb_sing(:) = this%band(:)%scelb(ican,icol)%a - if (scelg%lai>nearzero) then - Kb_sing(:) = (Kb_sing(:) * (scelg%lai+scelg%sai) - scelg%sai*Kb_stem)/scelg%lai - end if + do ib = 1,this%n_bands + Kb_sing(ib) = this%band(ib)%scelb(ican,icol)%a + if (scelg%lai>nearzero) then + Kb_sing(ib) = (Kb_sing(ib) * (scelg%lai+scelg%sai) - scelg%sai*Kb_stem)/scelg%lai + end if + end do do_test_sing: do while(is_sing) ! Now that we have commited to testing it, assume the solution works