commit 19605f842b2e99af19a737ee3fd4e1b892fd640b
parent b2e13a041398e7fdcd893840b2bac40d4c865f0f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 8 Nov 2022 12:05:24 +0100
Further verification of radiative coefficients
Diffstat:
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/rnatm_properties.c b/src/rnatm_properties.c
@@ -971,7 +971,11 @@ compute_unnormalized_cumulative_radcoef
const size_t iband,
const size_t iquad,
cumulative_T cumulative,
- size_t* cumulative_sz)
+ size_t* cumulative_sz,
+ /* For debug */
+ const double k_min,
+ const double k_max)
+
{
struct rnatm_cell_get_radcoef_args cell_args = RNATM_CELL_GET_RADCOEF_ARGS_NULL;
size_t cpnt = RNATM_GAS;
@@ -981,6 +985,7 @@ compute_unnormalized_cumulative_radcoef
res_T res = RES_OK;
ASSERT(atm && (unsigned)radcoef < RNATM_RADCOEFS_COUNT__);
ASSERT(cumulative && cumulative_sz);
+ (void)k_min;
naerosols = darray_aerosol_size_get(&atm->aerosols);
if(naerosols+1/*gas*/ > CUMULATIVE_SIZE_MAX) {
@@ -992,6 +997,7 @@ compute_unnormalized_cumulative_radcoef
cell_args.iband = iband;
cell_args.iquad = iquad;
cell_args.radcoef = radcoef;
+ cell_args.k_max = k_max; /* For Debug */
do {
double per_cell_k;
@@ -1009,12 +1015,15 @@ compute_unnormalized_cumulative_radcoef
if(res != RES_OK) goto error;
k += per_cell_k;
+ ASSERT(k <= k_max);
cumulative[icumul] = k;
++icumul;
} while(++cpnt < naerosols);
*cumulative_sz = icumul;
+ ASSERT(!icumul || k_min <= cumulative[icumul-1]);
+
exit:
return res;
error:
@@ -1039,11 +1048,11 @@ rnatm_get_radcoef
res = check_rnatm_get_radcoef_args(atm, args);
if(res != RES_OK) goto error;
- /* Calculate the cumulative (unormalized) of radiative coefficients. Its last
+ /* Calculate the cumulative (unnormalized) 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
- (atm, args->radcoef, args->pos, args->iband, args->iquad, cumul, &cumul_sz);
+ res = compute_unnormalized_cumulative_radcoef(atm, args->radcoef, args->pos,
+ args->iband, args->iquad, cumul, &cumul_sz, args->k_min, args->k_max);
if(res != RES_OK) goto error;
if(cumul_sz == 0) {