htgop

Optical properties of a gas mixture
git clone git://git.meso-star.fr/htgop.git
Log | Files | Refs | README | LICENSE

test_htgop_fetch_radiative_properties.c (2317B)


      1 /* Copyright (C) 2018-2021, 2023 |Méso|Star> (contact@meso-star.com)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #include "htgop.h"
     17 #include "test_htgop_utils.h"
     18 
     19 #include <rsys/math.h>
     20 
     21 /* Generate the check_layer_fetch_lw_ka function */
     22 #define DOMAIN lw
     23 #define DATA ka
     24 #include "test_htgop_fetch_radiative_properties.h"
     25 /* Generate the check_layer_fetch_sw_ka function */
     26 #define DOMAIN sw
     27 #define DATA ka
     28 #include "test_htgop_fetch_radiative_properties.h"
     29 /* Generate the check_layer_fetch_sw_ks function */
     30 #define DOMAIN sw
     31 #define DATA ks
     32 #include "test_htgop_fetch_radiative_properties.h"
     33 /* Generate the check_layer_fetch_sw_ks function */
     34 #define GET_K(Tab, Id) ((Tab)->ka_tab[Id] + (Tab)->ks_tab[Id])
     35 #define DOMAIN sw
     36 #define DATA kext
     37 #include "test_htgop_fetch_radiative_properties.h"
     38 
     39 int
     40 main(int argc, char** argv)
     41 {
     42   struct mem_allocator allocator;
     43   struct htgop* htgop;
     44   size_t i, n;
     45 
     46   if(argc < 2) {
     47     fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
     48     return 1;
     49   }
     50 
     51   CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK);
     52   CHK(htgop_create(NULL, &allocator, 1, &htgop) == RES_OK);
     53   CHK(htgop_load(htgop, argv[1]) == RES_OK);
     54 
     55   CHK(htgop_get_layers_count(htgop, &n) == RES_OK);
     56   CHK(n > 0);
     57 
     58   FOR_EACH(i, 0, n) {
     59     struct htgop_layer layer;
     60     CHK(htgop_get_layer(htgop, i, &layer) == RES_OK);
     61     check_layer_fetch_lw_ka(htgop, &layer);
     62     check_layer_fetch_sw_ka(htgop, &layer);
     63     check_layer_fetch_sw_ks(htgop, &layer);
     64     check_layer_fetch_sw_kext(htgop, &layer);
     65   }
     66 
     67   CHK(htgop_ref_put(htgop) == RES_OK);
     68 
     69   check_memory_allocator(&allocator);
     70   mem_shutdown_proxy_allocator(&allocator);
     71   CHK(mem_allocated_size() == 0);
     72   return 0;
     73 }