From 669723e892fa550fb67e50715f9914a235baa2f7 Mon Sep 17 00:00:00 2001 From: amullen01 Date: Wed, 12 Jun 2024 19:35:59 +0000 Subject: [PATCH 1/2] fix frootfrac re-adjustment to frootfrac cannot be nan if rootfracsum = 0 --- src/WildFire.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/WildFire.cpp b/src/WildFire.cpp index 23d0c719..4f80f455 100644 --- a/src/WildFire.cpp +++ b/src/WildFire.cpp @@ -286,13 +286,19 @@ void WildFire::burn(int year) { BOOST_LOG_SEV(glg, note) << "Re-do the soil root fraction for each PFT modified by burning?"; for (int ip = 0; ip < NUM_PFT; ip++) { double rootfracsum = 0.0; - for (int il = 0; il < cd->m_soil.numsl; il++) { - rootfracsum += cd->m_soil.frootfrac[il][ip]; + if (cd->m_soil.type[il]>0 && cd->m_soil.frootfrac[il][ip]>0.) { + rootfracsum += cd->m_soil.frootfrac[il][ip]; + } } for (int il =0; il m_soil.numsl; il++) { - cd->m_soil.frootfrac[il][ip] /= rootfracsum; + if (cd->m_soil.type[il]>0 && cd->m_soil.frootfrac[il][ip]>0. && rootfracsum>0.) { + cd->m_soil.frootfrac[il][ip] /= rootfracsum; + } + else { + cd->m_soil.frootfrac[il][ip] = 0.0; + } } } From da7013861a32cc8222bcce52574a4a848fac85ae Mon Sep 17 00:00:00 2001 From: amullen01 Date: Fri, 14 Jun 2024 19:03:26 +0000 Subject: [PATCH 2/2] consolidate rootfracsum checks --- src/WildFire.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/WildFire.cpp b/src/WildFire.cpp index 4f80f455..bddad364 100644 --- a/src/WildFire.cpp +++ b/src/WildFire.cpp @@ -286,19 +286,18 @@ void WildFire::burn(int year) { BOOST_LOG_SEV(glg, note) << "Re-do the soil root fraction for each PFT modified by burning?"; for (int ip = 0; ip < NUM_PFT; ip++) { double rootfracsum = 0.0; + for (int il = 0; il < cd->m_soil.numsl; il++) { - if (cd->m_soil.type[il]>0 && cd->m_soil.frootfrac[il][ip]>0.) { - rootfracsum += cd->m_soil.frootfrac[il][ip]; - } + rootfracsum += cd->m_soil.frootfrac[il][ip]; } for (int il =0; il m_soil.numsl; il++) { - if (cd->m_soil.type[il]>0 && cd->m_soil.frootfrac[il][ip]>0. && rootfracsum>0.) { + if (rootfracsum > 0.) { cd->m_soil.frootfrac[il][ip] /= rootfracsum; } else { cd->m_soil.frootfrac[il][ip] = 0.0; - } + } } }