commit 934c2a555efeceff702659449db4c68ed2bf9b23
parent f2663e1123ac994ca9f60a747addf5559786f887
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 18 Sep 2019 16:54:01 +0200
Pass pulse shape value as string
Diffstat:
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -69,7 +69,7 @@ usage(void)
" -u, --fluid-pressure-pulse-time VAL fluid pressure pulse peak time [s]\n"
" (default %g)\n"
" -S, --fluid-pressure-pulse-shape VAL\n"
- " 0: triangular (default), 1: square\n"
+ " where VAL is triangular (default) or square\n"
" -t, --time VAL simulation start time [s] (default %g)\n"
" -T, --time-end VAL simulation end time [s] (default %g)\n"
" -I, --file-interval VAL interval between output files [s] (default %g)\n"
@@ -283,7 +283,16 @@ main(int argc, char* argv[])
sim.p_f_mod_pulse_time = atof(optarg);
break;
case 'S':
- sim.p_f_mod_pulse_shape = atoi(optarg);
+ if (strcmp(optarg, "triangle") == 0)
+ sim.p_f_mod_pulse_shape = 0;
+ else if (strcmp(optarg, "square") == 0)
+ sim.p_f_mod_pulse_shape = 1;
+ else {
+ fprintf(stderr, "error: invalid pulse shape '%s'\n",
+ optarg);
+ return 1;
+ }
+ printf("pulse shape: %d\n", sim.p_f_mod_pulse_shape);
break;
case 't':
sim.t = atof(optarg);