star-aerosol

Describe the radiative properties of aerosols
git clone git://git.meso-star.fr/star-aerosol.git
Log | Files | Refs | README | LICENSE

sars_c.h (2150B)


      1 /* Copyright (C) 2022, 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 #ifndef SARS_C_H
     17 #define SARS_C_H
     18 
     19 #include <rsys/dynamic_array.h>
     20 #include <rsys/logger.h>
     21 #include <rsys/ref_count.h>
     22 #include <rsys/str.h>
     23 
     24 struct band {
     25   struct sars* sars;
     26   double low; /* Lower bound in nm (inclusive) */
     27   double upp; /* Upper bound in nm (exclusive) */
     28   size_t map_len;
     29   float* k_list; /* List of float[2] (ka, ks) */
     30 };
     31 
     32 static INLINE void
     33 band_init(struct mem_allocator* allocator, struct band* band)
     34 {
     35   ASSERT(band);
     36   (void)allocator;
     37   band->sars = NULL;
     38   band->low = DBL_MAX;
     39   band->upp =-DBL_MAX;
     40   band->map_len = 0;
     41   band->k_list = NULL;
     42 }
     43 
     44 extern LOCAL_SYM void
     45 band_release
     46   (struct band* band);
     47 
     48 extern LOCAL_SYM res_T
     49 band_copy
     50   (struct band* dst,
     51    const struct band* src);
     52 
     53 extern LOCAL_SYM res_T
     54 band_copy_and_release
     55   (struct band* dst,
     56    struct band* src);
     57 
     58 /* Generate the dynamic array of bands */
     59 #define DARRAY_NAME band
     60 #define DARRAY_DATA struct band
     61 #define DARRAY_FUNCTOR_INIT band_init
     62 #define DARRAY_FUNCTOR_RELEASE band_release
     63 #define DARRAY_FUNCTOR_COPY band_copy
     64 #define DARRAY_FUNCTOR_COPY_AND_RELEASE band_copy_and_release
     65 #include <rsys/dynamic_array.h>
     66 
     67 struct mem_allocator;
     68 
     69 struct sars {
     70   /* Loaded data */
     71   uint64_t pagesize;
     72   uint64_t nnodes;
     73   struct darray_band bands;
     74 
     75   size_t pagesize_os;
     76   struct str name;
     77 
     78   struct mem_allocator* allocator;
     79   struct logger* logger;
     80   struct logger logger__;
     81   int verbose;
     82   ref_T ref;
     83 };
     84 
     85 #endif /* SARS_C_H */