htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

htrdr.h (4804B)


      1 /* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
      2  * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
      3  * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
      4  * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
      5  * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
      6  * Copyright (C) 2022-2025 Observatoire de Paris
      7  * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
      8  * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
      9  * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
     10  *
     11  * This program is free software: you can redistribute it and/or modify
     12  * it under the terms of the GNU General Public License as published by
     13  * the Free Software Foundation, either version 3 of the License, or
     14  * (at your option) any later version.
     15  *
     16  * This program is distributed in the hope that it will be useful,
     17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     19  * GNU General Public License for more details.
     20  *
     21  * You should have received a copy of the GNU General Public License
     22  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     23 
     24 #ifndef HTRDR_H
     25 #define HTRDR_H
     26 
     27 #include <rsys/rsys.h>
     28 #include <stdio.h>
     29 
     30 #if defined(HTRDR_SHARED_BUILD) /* Build shared library */
     31   #define HTRDR_API extern EXPORT_SYM
     32 #elif defined(HTRDR_STATIC) /* Use/build static library */
     33   #define HTRDR_API extern LOCAL_SYM
     34 #else /* Use shared library */
     35   #define HTRDR_API extern IMPORT_SYM
     36 #endif
     37 
     38 /* Helper macro that asserts if the invocation of the htrdr function `Func'
     39  * returns an error. One should use this macro on htrdr function calls for
     40  * which no explicit error checking is performed */
     41 #ifndef NDEBUG
     42   #define HTRDR(Func) ASSERT(htrdr_ ## Func == RES_OK)
     43 #else
     44   #define HTRDR(Func) htrdr_ ## Func
     45 #endif
     46 
     47 /* Forward declarations */
     48 struct htrdr_buffer;
     49 struct mem_allocator;
     50 struct mutex;
     51 
     52 struct htrdr_args {
     53   unsigned nthreads; /* #threads of the process */
     54   int verbose; /* Verbosity level */
     55 };
     56 #define HTRDR_ARGS_DEFAULT__ { (unsigned)~0, 1 }
     57 static const struct htrdr_args HTRDR_ARGS_DEFAULT = HTRDR_ARGS_DEFAULT__;
     58 
     59 /* Forward declaration */
     60 struct htrdr;
     61 
     62 static INLINE void
     63 htrdr_fprint_copyright(const char* cmd, FILE* stream)
     64 {
     65   (void)cmd;
     66   fprintf(stream,
     67 "Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique\n"
     68 "Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux\n"
     69 "Copyright (C) 2022-2025 Institut de Physique du Globe de Paris\n"
     70 "Copyright (C) 2018-2025 |Méso|Star> <contact@meso-star.com>\n"
     71 "Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne\n"
     72 "Copyright (C) 2022-2025 Université de Versaille Saint-Quentin\n"
     73 "Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier\n");
     74 }
     75 
     76 static INLINE void
     77 htrdr_fprint_license(const char* cmd, FILE* stream)
     78 {
     79   ASSERT(cmd);
     80   fprintf(stream,
     81 "%s is free software released under the GNU GPL license,\n"
     82 "version 3 or later. You are free to change or redistribute it\n"
     83 "under certain conditions <http://gnu.org/licenses/gpl.html>\n",
     84     cmd);
     85 }
     86 
     87 BEGIN_DECLS
     88 
     89 /* Initialize the MPI execution environment. Must be called priorly to any MPI
     90  * invocation, e.g. at the beginning of the main function */
     91 HTRDR_API res_T
     92 htrdr_mpi_init
     93   (int argc,
     94    char** argv);
     95 
     96 /* Terminate the MPI execution environment */
     97 HTRDR_API void
     98 htrdr_mpi_finalize
     99   (void);
    100 
    101 /*******************************************************************************
    102  * HTRDR api
    103  ******************************************************************************/
    104 HTRDR_API res_T
    105 htrdr_create
    106   (struct mem_allocator* allocator,
    107    const struct htrdr_args* args,
    108    struct htrdr** htrdr);
    109 
    110 HTRDR_API void
    111 htrdr_ref_get
    112   (struct htrdr* htrdr);
    113 
    114 HTRDR_API void
    115 htrdr_ref_put
    116   (struct htrdr* htrdr);
    117 
    118 /* Return the number of threads used by the process */
    119 HTRDR_API size_t
    120 htrdr_get_threads_count
    121   (const struct htrdr* htrdr);
    122 
    123 /* Return the number of running processes for the current htrdr instance */
    124 HTRDR_API size_t
    125 htrdr_get_procs_count
    126   (const struct htrdr* htrdr);
    127 
    128 HTRDR_API int
    129 htrdr_get_mpi_rank
    130   (const struct htrdr* htrdr);
    131 
    132 HTRDR_API struct mem_allocator*
    133 htrdr_get_allocator
    134   (struct htrdr* htrdr);
    135 
    136 HTRDR_API struct mem_allocator*
    137 htrdr_get_thread_allocator
    138   (struct htrdr* htrdr,
    139    const size_t ithread);
    140 
    141 HTRDR_API struct logger*
    142 htrdr_get_logger
    143   (struct htrdr* htrdr);
    144 
    145 HTRDR_API int
    146 htrdr_get_verbosity_level
    147   (const struct htrdr* htrdr);
    148 
    149 HTRDR_API struct s3d_device*
    150 htrdr_get_s3d
    151   (struct htrdr* htrdr);
    152 
    153 HTRDR_API res_T
    154 htrdr_open_output_stream
    155   (struct htrdr* htrdr,
    156    const char* filename,
    157    const int read,
    158    int force_overwrite,
    159    FILE** out_fp);
    160 
    161 END_DECLS
    162 
    163 #endif /* HTRDR_H */
    164