commit 98ff91202ebc9388e8c5dd4481fe9c1cf3326da2
parent 7ddf06d6bfa49fb5715422c86822c10f6cff4a62
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 7 Aug 2018 11:57:08 +0200
Add and test the get_kext_bounds functions
Diffstat:
5 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/src/htgop.c b/src/htgop.c
@@ -800,6 +800,12 @@ htgop_position_to_layer_id
#define DATA ks
#include "htgop_get_radiative_properties_bounds.h"
+/* Generate the functions that get the boundaries of kext in SW */
+#define GET_DATA(Tab, Id) ((Tab)->ka_tab[Id] + (Tab)->ks_tab[Id])
+#define DOMAIN sw
+#define DATA kext
+#include "htgop_get_radiative_properties_bounds.h"
+
/*******************************************************************************
* Local functions
******************************************************************************/
diff --git a/src/htgop.h b/src/htgop.h
@@ -315,6 +315,13 @@ htgop_layers_get_sw_ks_bounds
double bounds[2]);
HTGOP_API res_T
+htgop_layers_get_sw_kext_bounds
+ (const struct htgop* htgop,
+ const size_t ilayer_range[2], /* Range of layers to handle */
+ const size_t ispecint_range[2], /* Range of spectral intervals to handle */
+ double bounds[2]);
+
+HTGOP_API res_T
htgop_layer_lw_spectral_interval_quadpoints_get_ka_bounds
(const struct htgop_layer_lw_spectral_interval* specint,
const size_t iquad_range[2], /* Range of quadrature points to handle */
@@ -333,6 +340,12 @@ htgop_layer_sw_spectral_interval_quadpoints_get_ks_bounds
double bounds[2]);
HTGOP_API res_T
+htgop_layer_sw_spectral_interval_quadpoints_get_kext_bounds
+ (const struct htgop_layer_sw_spectral_interval* specint,
+ const size_t iquad_range[2], /* Range of quadrature points to handle */
+ double bounds[2]);
+
+HTGOP_API res_T
htgop_layer_lw_spectral_interval_tab_get_ka_bounds
(const struct htgop_layer_lw_spectral_interval_tab* tab,
double bounds[2]);
@@ -347,6 +360,11 @@ htgop_layer_sw_spectral_interval_tab_get_ks_bounds
(const struct htgop_layer_sw_spectral_interval_tab* tab,
double bounds[2]);
+HTGOP_API res_T
+htgop_layer_sw_spectral_interval_tab_get_kext_bounds
+ (const struct htgop_layer_sw_spectral_interval_tab* tab,
+ double bounds[2]);
+
/*******************************************************************************
* Miscellaneous functions
******************************************************************************/
diff --git a/src/htgop_get_radiative_properties_bounds.h b/src/htgop_get_radiative_properties_bounds.h
@@ -20,6 +20,10 @@
#error "Missing the <DATA|DOMAIN> macro."
#endif
+#ifndef GET_DATA
+ #define GET_DATA(Tab, Id) ((Tab)->CONCAT(DATA,_tab)[Id])
+#endif
+
/*
* Generate functions that retrieve the boundaries of the radiative properties
*/
@@ -165,8 +169,9 @@ htgop_layer_,DOMAIN),_spectral_interval_tab_get_),DATA),_bounds)
bounds[0] = DBL_MAX;
bounds[1] =-DBL_MAX;
FOR_EACH(i, 0, tab->tab_length) {
- bounds[0] = MMIN(bounds[0], tab->CONCAT(DATA,_tab[i]));
- bounds[1] = MMAX(bounds[1], tab->CONCAT(DATA,_tab[i]));
+ const double k = GET_DATA(tab, i);
+ bounds[0] = MMIN(bounds[0], k);
+ bounds[1] = MMAX(bounds[1], k);
}
return RES_OK;
@@ -182,3 +187,5 @@ error:
#undef DATA
#undef DOMAIN
+#undef GET_DATA
+
diff --git a/src/test_htgop_get_radiative_properties_bounds.c b/src/test_htgop_get_radiative_properties_bounds.c
@@ -31,6 +31,11 @@
#define DOMAIN sw
#define DATA ks
#include "test_htgop_get_radiative_properties_bounds.h"
+/* Generate the check_layer_sw_kext_bounds */
+#define GET_K(Tab, Id) ((Tab)->ka_tab[Id] + (Tab)->ks_tab[Id])
+#define DOMAIN sw
+#define DATA kext
+#include "test_htgop_get_radiative_properties_bounds.h"
int
main(int argc, char** argv)
@@ -50,6 +55,7 @@ main(int argc, char** argv)
check_layer_lw_ka_bounds(htgop);
check_layer_sw_ka_bounds(htgop);
check_layer_sw_ks_bounds(htgop);
+ check_layer_sw_kext_bounds(htgop);
CHK(htgop_ref_put(htgop) == RES_OK);
diff --git a/src/test_htgop_get_radiative_properties_bounds.h b/src/test_htgop_get_radiative_properties_bounds.h
@@ -41,7 +41,10 @@
CONCAT(CONCAT(htgop_layer_get_, DOMAIN), _spectral_interval)
#define GET_LAY_SPECINT_TAB \
CONCAT(CONCAT(htgop_layer_, DOMAIN), _spectral_interval_get_tab)
-#define K_TAB CONCAT(DATA, _tab)
+
+#ifndef GET_K
+ #define GET_K(Tab, Id) ((Tab)->CONCAT(DATA,_tab)[Id])
+#endif
static void CONCAT(CONCAT(CONCAT(CONCAT(
check_layer_,DOMAIN),_),DATA),_bounds)(struct htgop* htgop)
@@ -151,8 +154,9 @@ check_layer_,DOMAIN),_),DATA),_bounds)(struct htgop* htgop)
CHK(LAY_SPECINT_TAB_GET_BOUNDS(&tab, quad_bounds) == RES_OK);
FOR_EACH(itab, 0, tab.tab_length) {
- quad_bounds_tmp[0] = MMIN(quad_bounds_tmp[0], tab.K_TAB[itab]);
- quad_bounds_tmp[1] = MMAX(quad_bounds_tmp[1], tab.K_TAB[itab]);
+ const double k = GET_K(&tab, itab);
+ quad_bounds_tmp[0] = MMIN(quad_bounds_tmp[0], k);
+ quad_bounds_tmp[1] = MMAX(quad_bounds_tmp[1], k);
}
CHK(quad_bounds[0] == quad_bounds_tmp[0]);
CHK(quad_bounds[1] == quad_bounds_tmp[1]);
@@ -197,6 +201,6 @@ check_layer_,DOMAIN),_),DATA),_bounds)(struct htgop* htgop)
#undef LAY_SPECINT_TAB
#undef GET_LAY_SPECINT
#undef GET_LAY_SPECINT_TAB
-#undef K_TAB
+#undef GET_K
#undef DOMAIN
#undef DATA