star-gs

Literate program for a geometric sensitivity calculation
git clone git://git.meso-star.fr/star-gs.git
Log | Files | Refs | README | LICENSE

sgs_main.c (1942B)


      1 /* Copyright (C) 2021-2023 Centre National de la Recherche Scientifique
      2  * Copyright (C) 2021-2023 INSA Lyon
      3  * Copyright (C) 2021-2023 Institut Mines Télécom Albi-Carmaux
      4  * Copyright (C) 2021-2023 |Méso|Star> (contact@meso-star.com)
      5  * Copyright (C) 2021-2023 Institut Pascal
      6  * Copyright (C) 2021-2023 PhotonLyX (info@photonlyx.com)
      7  * Copyright (C) 2021-2023 Université de Lorraine
      8  * Copyright (C) 2021-2023 Université Paul Sabatier
      9  * Copyright (C) 2021-2023 Université Toulouse - Jean Jaurès
     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 #include "sgs.h"
     25 #include "sgs_args.h"
     26 #include "sgs_log.h"
     27 
     28 #include <rsys/mem_allocator.h>
     29 
     30 int
     31 main(int argc, char** argv)
     32 {
     33   struct sgs_args args = SGS_ARGS_DEFAULT;
     34   struct sgs* sgs = NULL;
     35   size_t memsz = 0;
     36   int err = 0;
     37   res_T res = RES_OK;
     38 
     39   res = sgs_args_init(&args, argc, argv);
     40   if(res != RES_OK) goto error;
     41   if(args.quit) goto exit;
     42 
     43   res = sgs_create(NULL, &args, &sgs);
     44   if(res != RES_OK) goto error;
     45 
     46   res = sgs_run(sgs);
     47   if(res != RES_OK) goto error;
     48 
     49 exit:
     50   sgs_args_release(&args);
     51   if(sgs) sgs_release(sgs);
     52 
     53   /* Check memory leaks */
     54   memsz = mem_allocated_size();
     55   if(memsz) {
     56     fprintf(stderr, SGS_LOG_WARNING_PREFIX"Memory leaks: %lu Bytes\n",
     57       (unsigned long)memsz);
     58     err = -1;
     59   }
     60   return err;
     61 error:
     62   err = -1;
     63   goto exit;
     64 }