commit cd26e116bc62d133a77007de6345fdba519bcc86
parent f911a7b09bc7e7977f0e888514a526a26d3e7976
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 4 Nov 2022 17:51:23 +0100
Fix rnatm_get_radcoef function
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/rnatm_properties.c b/src/rnatm_properties.c
@@ -1009,12 +1009,11 @@ compute_unnormalized_cumulative_radcoef
if(res != RES_OK) goto error;
k += per_cell_k;
-
cumulative[icumul] = k;
++icumul;
} while(++cpnt < naerosols);
- *cumulative_sz = naerosols + 1;
+ *cumulative_sz = icumul;
exit:
return res;
@@ -1043,13 +1042,16 @@ rnatm_get_radcoef
/* Calculate the cumulative (unormalized) of radiative coefficients. Its last
* entry is the sum of the radiative coefficients of each component, which is
* the atmospheric radiative coefficient to be returned. */
- res = compute_unnormalized_cumulative_radcoef
+ res = compute_unnormalized_cumulative_radcoef
(atm, args->radcoef, args->pos, args->iband, args->iquad, cumul, &cumul_sz);
if(res != RES_OK) goto error;
- ASSERT(cumul_sz >= 1);
- k = cumul[cumul_sz-1];
- ASSERT(args->k_min <= k && k <= args->k_max);
+ if(cumul_sz == 0) {
+ k = 0; /* No atmospheric data */
+ } else {
+ k = cumul[cumul_sz-1];
+ ASSERT(args->k_min <= k && k <= args->k_max);
+ }
exit:
*out_k = k;