rnatm

Load and structure data describing an atmosphere
git clone git://git.meso-star.fr/rnatm.git
Log | Files | Refs | README | LICENSE

commit 8b043fed7121a45837ba9adf291c58eceed5716a
parent bf71455f0fabe51f3c6d0a22768087d19685fba1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 21 Sep 2022 17:43:51 +0200

Clean up the parsing of the test_rnatm arguments

Diffstat:
Msrc/test_rnatm.c | 34++++++++--------------------------
1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/src/test_rnatm.c b/src/test_rnatm.c @@ -18,7 +18,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define _POSIX_C_SOURCE 200809L /* strdup, strtok_r & wordexp */ +#define _POSIX_C_SOURCE 200809L /* strdup, strtok_r */ #include "rnatm.h" @@ -29,7 +29,6 @@ #include <getopt.h> #include <string.h> -#include <wordexp.h> struct args { struct rnatm_create_args rnatm; @@ -86,11 +85,11 @@ print_help(const char* cmd) printf( " -i file octrees are loaded from file\n"); printf( +" -N precompute_normals the tetrahedra normals\n"); + printf( " -n atmosphere name. Default is `%s'\n", ARGS_DEFAULT.rnatm.name); printf( -" -N precompute_normals the tetrahedra normals\n"); - printf( " -o file offload octrees to file\n"); printf( " -s nu0,nu1 spectral range to consider (in nm).\n" @@ -98,18 +97,18 @@ print_help(const char* cmd) ARGS_DEFAULT.rnatm.spectral_range[0], ARGS_DEFAULT.rnatm.spectral_range[1]); printf( -" -t nthreads hint on the number of threads. Default assumes\n" -" as many threads as CPU cores\n"); - printf( " -T threshold optical thickness criteria for octree building.\n" " Default is %g\n", ARGS_DEFAULT.rnatm.optical_thickness); printf( -" -v make the program verbose\n"); +" -t nthreads hint on the number of threads. Default assumes\n" +" as many threads as CPU cores\n"); printf( " -V definition advice on the definiton of the acceleration\n" " structure along the 3 axes. Default is %u\n", ARGS_DEFAULT.rnatm.grid_definition_hint); + printf( +" -v make the program verbose\n"); printf("\n"); printf( "This is free software released under the GNU GPL license, version 3 or\n" @@ -122,14 +121,11 @@ parse_gas_parameters(const char* str, void* ptr) { enum { MESH, CK, TEMP } iparam; char buf[BUFSIZ]; - wordexp_t wexp; struct args* args = ptr; char* key; char* val; char* tk_ctx; res_T res = RES_OK; - int wexp_is_allocated = 0; - int err = 0; ASSERT(args && str); if(strlen(str) >= sizeof(buf) -1/*NULL char*/) { @@ -157,19 +153,6 @@ parse_gas_parameters(const char* str, void* ptr) goto error; } - err = wordexp(val, &wexp, 0/*flags*/); - if(err) { - fprintf(stderr, "Unable to expand the value of the gas parameter`%s'\n", str); - res = RES_BAD_ARG; - goto error; - } - wexp_is_allocated = 1; - if(wexp.we_wordc != 1) { - fprintf(stderr, "Invalid value of the gas parameter`%s'\n", str); - res = RES_BAD_ARG; - goto error; - } - switch(iparam) { case MESH: args->rnatm.gas.smsh_filename = strdup(val); @@ -192,7 +175,6 @@ parse_gas_parameters(const char* str, void* ptr) } exit: - if(wexp_is_allocated) wordfree(&wexp); return res; error: goto exit; @@ -332,7 +314,7 @@ args_init(struct args* args, int argc, char** argv) *args = ARGS_DEFAULT; - while((opt = getopt(argc, argv, "a:cd:g:hi:n:No:s:t:T:vV:")) != -1) { + while((opt = getopt(argc, argv, "a:cd:g:hi:Nn:o:s:T:t:V:v")) != -1) { switch(opt) { case 'a': sa_add(args->rnatm.aerosols, 1);