commit d4a0d9c73ec3e9c7bed7914bc196afad1f2c98e4
parent 7f04a1c6ba1242c1133d74aac6edcb9ba71d081a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 15 May 2026 16:25:11 +0200
Translate schiff man page from man to mdoc macros
Unlike writing manuals with man's roff macros, mdoc macros take care of
layout, font handling and all the other typesetting details which, by
construction, guarantee the consistency of all manuals without leaving
the responsibility to the individual author. This also facilitates
translation into other formats and documentation tools. These are the
main reasons for writing manual pages with mdoc macros.
So far, only the Schiff manual pages have been converted to Mandoc
format. During the conversion, their content was slightly updated. In
particular, the "EXIT STATUS" section, which was missing, has been
added. The "COPYRIGHT" section has been removed, as it does not conform to
the writing conventions for Linux manual pages, and there is no mention
of it in the mdoc documentation.
During this translation, the --version option was replaced with the
short -v option. This not only complies with POSIX utility conventions
but also makes the option compatible with the POSIX getopt function for
argument parsing.
Finally, the command's brief help message now simply displays its
synopsis. A summary of the manual page is completely unnecessary.
Diffstat:
| M | Makefile | | | 3 | ++- |
| M | doc/schiff.1.in | | | 433 | ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------- |
| M | src/schiff_args.c | | | 141 | +++++++++++++++++++------------------------------------------------------------ |
3 files changed, 312 insertions(+), 265 deletions(-)
diff --git a/Makefile b/Makefile
@@ -109,9 +109,10 @@ clean:
rm -f src/schiff_version.h src/schiff_args.h doc/schiff.1
rm -f .config schiff
-lint:
+lint: doc/schiff.1
shellcheck -o all src/test_schiff_cylinder.sh
shellcheck -o all src/test_schiff_sphere.sh
+ mandoc -Tlint -Wwarning doc/schiff.1
################################################################################
# Test
diff --git a/doc/schiff.1.in b/doc/schiff.1.in
@@ -1,161 +1,280 @@
-.\" Copying and distribution of this file, with or without modification,
-.\" are permitted in any medium without royalty provided the copyright
-.\" notice and this notice are preserved. This file is offered as-is,
-.\" without any warranty.
-.TH SCHIFF 1
-.SH NAME
-schiff \- estimate radiative properties of soft particles
-.SH SYNOPSIS
-.nf
-\fBschiff \fR[\fIOPTIONS\fR]... [\fIFILE\fR]
-.fi
-.SH DESCRIPTION
-\fBschiff\fR computes the radiative properties of soft particles with an
-"Approximation Method for Short Wavelength or High Energy Scattering" [1]. The
-implemented model is detailed in [2]. It relies on the Monte\-Carlo method to
-solve Maxwell's equations within Schiff's approximation; it estimates total
-cross sections (extinction, absorption and scattering cross-sections) in
-addition of the inverse cumulative phase function.
-.PP
+.\" Copyright (C) 2015, 2016, 2026 Centre National de la Recherche Scientifique
+.\" Copyright (C) 2026 Clermont Auvergne INP
+.\" Copyright (C) 2026 Institut Mines Télécom Albi-Carmaux
+.\" Copyright (C) 2017, 2019-2021, 2026 |Méso|Star> (contact@meso-star.com)
+.\" Copyright (C) 2026 Université de Lorraine
+.\" Copyright (C) 2026 Université de Toulouse
+.\"
+.\" This program is free software: you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation, either version 3 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
+.Dd May 15, 2026
+.Dt SCHIFF 1
+.Os
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh NAME
+.Nm schiff
+.Nd estimate radiative properties of soft particles
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SYNOPSIS
+.Nm
+.Op Fl Dhqv
+.Op Fl a Ar nangles_phase_func
+.Op Fl A Ar nangles_phase_func_invcumul
+.Op Fl d Ar ninner_samples
+.Op Fl g Ar nrealisations
+.Op Fl G Ar nparticles
+.Op Fl i Ar distribution
+.Op Fl l Ar particles_length
+.Op Fl n Ar nthreads
+.Op Fl o Ar output
+.Op Fl w Ar wavelelength Ns Op : Ns Ar wavelelength No ...
+.Op Ar optical_props
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh DESCRIPTION
+.Nm
+computes the radiative properties of soft particles with an
+.Dq Approximation Method for Short Wavelength or High Energy Scattering
+.Pq Schiff, 1956 .
+The implemented model is detailed in
+.Dq Monte Carlo Implementation of Schiff's Approximation for \
+Estimating Radiative Properties of Homogeneous, Simple-Shaped and \
+Optically Soft Particles: Application to Photosynthetic \
+Micro-Organisms
+.Pq Charon et al., 2015 .
+It relies on the Monte Carlo method to solve Maxwell's equations within
+Schiff's approximation; it estimates total cross sections
+.Pq extinction, absorption and scattering cross-sections
+in addition of the inverse cumulative phase function.
+.Pp
The shapes of the soft particles are controlled by the
-.BR schiff-geometry (5)
-file submitted by the \fB\-i\fR option. The per wavelength optical properties
-of the soft particles are stored in \fIFILE\fR where each line is formatted as
-"W N K Ne" whith "W" is the wavelength in vacuum expressed in micron, "N" and
-"K" are the real and imaginary parts, respectively, of the refractive index,
-and "Ne" the refractive index of the medium. With no \fIFILE\fR, the optical
-properties are read from standard input.
-.PP
+.Xr schiff-geometry 5
+file submitted by the
+.Fl i
+option.
+The per wavelength optical properties
+of the soft particles are stored in
+.Ar optical_props
+where each line is formatted as
+.Dq W N K Ne
+with
+.Dq W
+is the wavelength in vacuum expressed in micron,
+.Dq N
+and
+.Dq K
+are the real and imaginary parts, respectively, of the refractive index,
+and
+.Dq Ne
+the refractive index of the medium.
+With no
+.Ar optical_props ,
+the optical properties are read from standard input.
+.Pp
The estimated results follows the
-.BR schiff-output (5)
-format and are written to the \fIOUTPUT\fR file or to standard ouptut whether
-the \fB\-o \fIOUTPUT\fR option is defined or not, respectively.
-.SH OPTIONS
-.TP
-.B \-a \fINUM_ANGLES\fR
-number of phase function scattering angles to estimate. These angles are
-uniformaly distributed in [0, PI], i.e. the value of the i^th angle, i in [0,
-\fINUM_ANGLES\fR-1], is i*PI/(\fINUM_ANGLES\fR-1). Default is
-@SCHIFF_ARGS_DEFAULT_NANGLES@.
-.TP
-.B \-A \fINUM_ANGLES\fR
-number of scattering angles computed from the inverse cumulative phase
-function. The value of the i^th angle, i in [0, \fINUM_ANGLES\fR-1], is
-CDF^-1(i/(\fINUM_ANGLES-1\fR). Default is @SCHIFF_ARGS_DEFAULT_NANGLES_INV@.
-.TP
-.B \-d \fINUM_INNER_SAMPLES\fR
-number of conditioned integration variable sampling (incident direction,
-volume, ray(s)) for each sampled particle-shape. Default is
-@SCHIFF_ARGS_DEFAULT_NINSAMPLES@. Calculation of optimal value is presented in
-[3].
-.TP
-.B \-D
-discard computations of the [[inverse] cumulative] phase functions for large
-scattering angles. See the \fB\-l\fR option for the definition of large
-scattering angles.
-.TP
-.B \-g \fINUM_PARTICLES\fR
-number of sampled particle-shapes. This is actually the number of realizations
-of the Monte Carlo algorithm. Default is @SCHIFF_ARGS_DEFAULT_NREALISATIONS@.
-.TP
-.B \-G \fICOUNT\fR
-sample \fICOUNT\fR soft particles with respect to the defined distribution,
-dump their geometric data and exit. The data are written to \fIOUTPUT\fR or the
-standard output whether the \fB-o\fR \fIOUTPUT\fR option is defined or not,
-respectively. The outputted data followed the Alias Wavefront obj file format.
-.TP
-.B \-h
-display short help and exit.
-.TP
-.B \-i \fIDISTRIBUTION\fR
-define the
-.BR schiff-geometry (5)
+.Xr schiff-output 5
+format and are written to the
+.Ar output
+file or to standard ouptut whether
+the
+.Fl o
+is defined or not, respectively.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.\""""""""""""""""""""""""""""""""""
+.It Fl a Ar nangles_phase_func
+Number of phase function scattering angles to estimate.
+These angles are
+uniformaly distributed in
+.Bq 0,PI ,
+i.e. the value of the i^th angle
+.Pq i in Bq 0, Ns Ar nangles_phase_func
+is
+.No i*PI/ Ns Pq Ar nangles_phase_func Ns -1 .
+Default is @SCHIFF_ARGS_DEFAULT_NANGLES@.
+.\""""""""""""""""""""""""""""""""""
+.It Fl A Ar nangles_phase_func_invcumul
+Number of scattering angles computed from the inverse cumulative phase
+function.
+The value of the i^th angle
+.Pq i in Bq 0, Ns Ar nangles_phase_func_invcumul Ns -1
+is
+.No CDF^-1 Ns Po i/ Ns Po Ar nangles_phase_func_invcumul Ns -1 Pc Pc .
+Default is @SCHIFF_ARGS_DEFAULT_NANGLES_INV@.
+.\""""""""""""""""""""""""""""""""""
+.It Fl d Ar ninner_samples
+Number of conditioned integration variable sampling
+.Pq incident direction, volume, ray Ns Pq s
+for each sampled particle-shape.
+Calculation of optimal value is presented in
+.Dq Monte Carlo efficiency improvement by multiple sampling \
+of conditioned integration variables
+.Pq Weitz et al., 2016 .
+Default is @SCHIFF_ARGS_DEFAULT_NINSAMPLES@.
+.\""""""""""""""""""""""""""""""""""
+.It Fl D
+discard computations of the
+.Bq Ns Bo inverse- Bc Ns cumulative
+phase functions for large scattering angles.
+See the
+.Fl l
+option for the definition of large scattering angles.
+.\""""""""""""""""""""""""""""""""""
+.It Fl g Ar nrealisations
+Number of sampled particle-shapes.
+This the number of realisations of the Monte Carlo algorithm.
+Default is @SCHIFF_ARGS_DEFAULT_NREALISATIONS@.
+.\""""""""""""""""""""""""""""""""""
+.It Fl G Ar nparticles
+Sample
+.Ar nparticles
+soft particles with respect to the defined distribution, dump their
+geometric data and exit.
+The data are written to
+.Ar output
+or the standard output whether the
+.Fl o
+option is defined or not, respectively.
+The outputted data followed the Alias Wavefront obj file format.
+.\""""""""""""""""""""""""""""""""""
+.It Fl h
+Display short help and exit.
+.\""""""""""""""""""""""""""""""""""
+.It Fl i Ar distribution
+Define the
+.Xr schiff-geometry 5
file that controls the geometry distribution of the soft particles.
-.TP
-.B \-l \fILENGTH\fR
-characteristic length in micron of the soft particles. Used for the definition
-of the angle that sets the limit between small and large scattering angles (see
-equation. 7 in [2]).
-.TP
-.B \-n \fINUM_THREADS\fR
-hint on the number of threads to use during the integration. By default use as
-many threads as CPU cores.
-.TP
-.B \-o \fIOUTPUT\fR
-write results to \fIOUTPUT\fR with respect to the
-.BR schiff-output (5)
-format. If not defined, write results to standard output.
-.TP
-.B \-q
-do not print the helper message when no \fIFILE\fR is submitted.
-.TP
-.B \-w \fIW0\fR[\fB:\fIW1\fR]...
-list of wavelengths in vacuum (expressed in micron) to integrate.
-.TP
-.B \-\-version
-display version information and exit.
-.SH EXAMPLES
-Estimate the radiative properties of soft particles whose shape is described in
-the \fBgeometry.yaml\fR file and its optical properties in the \fBproperties\fR
-file. The characteristic length of the soft particle shapes is \fB2.3\fR
-microns and the estimations is performed for the wavelengths \fB0.45\fR and
-\fB0.6\fR microns. The results are written to the standard output:
-.PP
-.RS 4
-.nf
-$ schiff -i geometry.yaml -l 2.3 -w 0.45:0.6 properties
-.fi
-.RE
-.PP
-The soft particles have a characteristic length of \fB1\fR and their shape is
-controlled by the \fBmy_geom.yaml\fR file. Their optical properties are read
-from the standard input. The estimated wavelelength is \fB0.66\fR microns and
-the results are written to the \fBmy_result\fR file:
-.PP
-.RS 4
-.nf
-$ schiff -w 0.66 -l 1.0 -i my_geom.yaml -o my_result
-.fi
-.RE
-.PP
-Sample \fB10\fR soft particles whose shape is defined by the \fBgeometry.yaml\fR
-file and write their triangulated geometric data to the \fBtemp_output\fR file.
+.\""""""""""""""""""""""""""""""""""
+.It Fl l Ar particles_length
+Characteristic length in micron of the soft particles.
+Used for the definition of the angle that sets the limit between small
+and large scattering angles
+.Po
+see equation 7 in
+.Dq Approximation for Estimating Radiative Properties of Homogeneous, \
+Simple-Shaped and Optically Soft Particles: Application to \
+Photosynthetic Micro-Organisms ,
+Charon et al. 2015
+.Pc .
+.\""""""""""""""""""""""""""""""""""
+.It Fl n Ar nthreads
+Hint on the number of threads to use during the integration.
+Advice on the number of threads to use.
+By default,
+.Nm
+uses as many threads as processor cores.
+.\""""""""""""""""""""""""""""""""""
+.It Fl o Ar output
+Output file.
+If not defined, the results are written to standard output.
+.\""""""""""""""""""""""""""""""""""
+.It Fl q
+Do not print the helper message when no
+.Ar optical_props
+is submitted.
+.\""""""""""""""""""""""""""""""""""
+.It Fl w Ar wavelelength Ns Op : Ns Ar wavelelength No ...
+List of wavelengths in vacuum
+.Pq expressed in micron
+to integrate.
+.\""""""""""""""""""""""""""""""""""
+.It Fl v
+Display version information and exit.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh EXAMPLES
+Estimate the radiative properties of soft particles whose shape is
+described in the
+.Pa geometry.yaml
+file and its optical properties in the
+.Pa properties
+file.
+The characteristic length of the soft particle shapes is 2.3 microns
+and the estimations is performed for the wavelengths 0.45 and 0.6
+microns.
+The results are written to the standard output:
+.Bd -literal -offset Ds
+schiff -i geometry.yaml -l 2.3 -w 0.45:0.6 properties
+.Ed
+.\""""""""""""""""""""""""""""""""""
+.Pp
+The soft particles have a characteristic length of 1 and their shape is
+controlled by the
+.Pa my_geom.yaml
+file.
+Their optical properties are read from the standard input.
+The estimated wavelelength is 0.66 microns and the results are written
+to the
+.Pa my_result
+file:
+.Bd -literal -offset Ds
+schiff -w 0.66 -l 1.0 -i my_geom.yaml -o my_result
+.Ed
+.\""""""""""""""""""""""""""""""""""
+.Pp
+Sample 10
+soft particles whose shape is defined by the
+.Pa geometry.yaml
+file and write their triangulated geometric data to the
+.Pa temp_output
+file.
Use the
-.BR csplit (1)
-Unix command to split the \fBtemp_output\fR file in 10 files named
-particle<\fINUM\fR>.obj, with NUM in [0, 9], each storing the geometric data of
-a sampled soft particle:
-.PP
-.RS 4
-.nf
-$ schiff -i geometry.yaml -G 10 -o temp_output
-$ csplit temp_output -z /^g\\ / {*} -f particle -b %d.obj
-.fi
-.RE
-.PP
-.SH NOTES
-.PP
-[1] L. I. Schiff, 1956. Approximation Method for Short Wavelength or High\-Energy
-Scattering. Phys. Rev. 104 \- 1481\-1485.
-.PP
-[2] J. Charon, S. Blanco, J. F. Cornet, J. Dauchet, M. El Hafi, R. Fournier, M.
-Kaissar Abboud, S. Weitz, 2015. Monte Carlo Implementation of Schiff's
-Approximation for Estimating Radiative Properties of Homogeneous,
-Simple\-Shaped and Optically Soft Particles: Application to Photosynthetic
-Micro-Organisms. Journal of Quantitative Spectroscopy and Radiative Transfer
-172 \- 3\-23.
-.PP
-[3] S. Weitz, S. Blanco, J. Charon, J. Dauchet, M. El Hafi, V. Eymet, O.
-Farges, R. Fournier, and J. Gautrais, 2016. Monte Carlo efficiency
-improvement by multiple sampling of conditioned integration variables. Journal
-of Computational Physics 326 \- 30\-34.
-.SH COPYRIGHT
-Copyright \(co 2020 |Meso|Star> <contact@meso-star.com>. Copyright \(co 2015,
-2016 CNRS. License GPLv3+: GNU GPL version 3 or later
-<http://gnu.org/licenses/gpl.html>. This is free software: you are free to
-change and redistribute it. There is NO WARRANTY, to the extent permitted by
-law.
-.SH SEE ALSO
-.BR csplit (1),
-.BR schiff-geometry (5),
-.BR schiff-output (5)
+.Xr csplit 1
+command to split the
+.Pa output
+file in 10 files named
+.No particle Ns Ar N ,
+with
+.Ar N
+in
+.Bq 0,9 ,
+each storing the geometric data of a sampled soft particle:
+.Bd -literal -offset Ds
+schiff -i geometry.yaml -G 10 -o output
+N="$(grep -ce "^g " output)"
+csplit -f particle -k -n1 output %^g\e % /^g\e / {$((N-2))}
+.Ed
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SEE ALSO
+.Xr csplit 1 ,
+.Xr schiff-geometry 5 ,
+.Xr schiff-output 5
+.Rs
+.%A Leonard Isaac Schiff
+.%T Approximation Method for Short Wavelength or High-Energy Scattering
+.%J Physical Review
+.%V 104
+.%P pp. 1481\(en1485
+.%D 1956
+.Re
+.Rs
+.%A Julien Charon et al.
+.%T Approximation for Estimating Radiative Properties of Homogeneous, \
+Simple-Shaped and Optically Soft Particles: Application to \
+Photosynthetic Micro-Organisms
+.%J Journal of Quantitative Spectroscopy and Radiative Transfer
+.%V 172
+.%P pp. 3\(en23
+.%D 2015
+.Re
+.Rs
+.%A Sebastian Weitz et al.
+.%T Monte Carlo efficiency improvement by multiple sampling of \
+conditioned integration variables
+.%J Journal of Computational Physics
+.%V 326
+.%P pp. 30\(en34
+.%D 2016
+.Re
diff --git a/src/schiff_args.c b/src/schiff_args.c
@@ -47,75 +47,22 @@
* Helper function
******************************************************************************/
static void
-print_help(const char* binary)
+usage(FILE* stream)
{
- printf(
-"Usage: %s [OPTIONS] [FILE]\n"
-"Estimate the radiative properties of soft particles whose per wavelength\n"
-"optical properties are stored in FILE. If not defined, optical\n"
-"porperties are read from standard input. Implement the model described\n"
-"in \"Monte Carlo Implementation of Schiff's Approximation for Estimating\n"
-"Radiative Properties of Homogeneous, Simple-Shaped and Optically Soft\n"
-"Particles: Application to Photosynthetic Micro-Organisms\" (Charon et\n"
-"al. 2015).\n\n",
- binary);
- printf(
-" -a NUM_ANGLES number of phase function scattering angles.\n"
-" Default is %u.\n",
- SCHIFF_ARGS_NULL.nangles);
- printf(
-" -A NUM_ANGLES number of computed inverse cumulative phase function\n"
-" values. Default is %u.\n",
- SCHIFF_ARGS_NULL.nangles_inv);
- printf(
-" -d NUM_INSAMPS number of (incident direction, volume, ray(s)) sampling\n"
-" for each sampled particle-shape. Default is %u.\n",
- SCHIFF_ARGS_NULL.ninsamps);
- printf(
-" -D discard computations of the [[inverse] cumulative]\n"
-" phase functions for large scattering angles.\n");
- printf(
-" -g NUM_SHAPES number of sampled particle-shapes. This is actually the\n"
-" number of realizations of the Monte Carlo algorithm.\n"
-" Default is %u.\n",
- SCHIFF_ARGS_NULL.nrealisations);
- printf(
-" -G NUM sampled `NUM' particle shapes with respect to the\n"
-" defined distribution, dump their geometry and exit.\n");
- printf(
-" -h display this help and exit.\n");
- printf(
-" -i DISTRIB YAML file that defines the geometry distributions of\n"
-" the soft particles.\n");
- printf(
-" -l LENGTH characteristic length of the soft particles.\n");
- printf(
-" -n NTHREADS hint on the number of threads to use during the\n"
-" integration. By default use as many threads as CPU\n"
-" cores.\n");
- printf(
-" -o OUTPUT write results to OUTPUT. If not defined, write results\n"
-" to standard output.\n");
- printf(
-" -q do not print the helper message when no FILE is\n"
-" submitted.\n");
- printf(
-" -w A[:B]... list of wavelengths in vacuum (expressed in micron) to\n"
-" integrate.\n");
- printf(
-" --version display version information and exit.\n");
- printf("\n");
- printf(
-"Copyright (C) 2015, 2016, 2026 Centre National de la Recherche Scientifique\n"
-"Copyright (C) 2026 Clermont Auvergne INP\n"
-"Copyright (C) 2026 Institut Mines Télécom Albi-Carmaux\n"
-"Copyright (C) 2017, 2019-2021, 2026 |Méso|Star> (contact@meso-star.com)\n"
-"Copyright (C) 2026 Université de Lorraine\n"
-"Copyright (C) 2026 Université de Toulouse\n"
-"\n"
-"This is free software released under the GNU GPL license, version 3 or later.\n"
-"You are free to change or redistribute it under certain conditions\n"
-"<http://gnu.org/licenses/gpl.html>\n");
+ fprintf(stream,
+"schiff [-Dhqv] [-a nangles_phase_func] [-A nangles_phase_func_invcumul]\n"
+" [-d ninner_samples] [-g nrealisations] [-G nparticles]\n"
+" [-i distribution] [-l particles_length] [-n nthreads] [-o output]\n"
+" [-w wavelelength[:wavelelength ...]] [optical_props]\n");
+}
+
+static INLINE void
+print_version(void)
+{
+ printf("Schiff %d.%d.%d\n",
+ SCHIFF_VERSION_MAJOR,
+ SCHIFF_VERSION_MINOR,
+ SCHIFF_VERSION_PATCH);
}
static int
@@ -1476,23 +1423,12 @@ schiff_args_init
{
int quiet = 0;
int opt;
- int i;
res_T res = RES_OK;
ASSERT(argc && argv && args);
*args = SCHIFF_ARGS_NULL;
- FOR_EACH(i, 1, argc) {
- if(!strcmp(argv[i], "--version")) {
- printf("Schiff %d.%d.%d\n",
- SCHIFF_VERSION_MAJOR,
- SCHIFF_VERSION_MINOR,
- SCHIFF_VERSION_PATCH);
- goto exit;
- }
- }
-
- while((opt = getopt(argc, argv, "a:A:d:Dg:G:hi:l:n:o:qw:")) != -1) {
+ while((opt = getopt(argc, argv, "a:A:d:Dg:G:hi:l:n:o:qvw:")) != -1) {
switch(opt) {
case 'a':
res = cstr_to_uint(optarg, &args->nangles);
@@ -1532,7 +1468,7 @@ schiff_args_init
break;
case 'G': res = cstr_to_uint(optarg, &args->ngeoms_dump); break;
case 'h':
- print_help(argv[0]);
+ usage(stderr);
schiff_args_release(args);
return RES_OK;
case 'i':
@@ -1551,6 +1487,10 @@ schiff_args_init
case 'o': args->output_filename = optarg; break;
case 'q': quiet = 1; break;
case 'w': res = parse_wavelengths(optarg, args); break;
+ case 'v':
+ print_version();
+ schiff_args_release(args);
+ return RES_OK;
default: res = RES_BAD_ARG; break;
}
if(res != RES_OK) {
@@ -1562,35 +1502,23 @@ schiff_args_init
}
}
- if(args->geoms == NULL) {
- fprintf(stderr,
- "%s: missing geometry distribution.\nTry '%s -h' for more informations.\n",
- argv[0], argv[0]);
- res = RES_BAD_ARG;
- goto error;
- }
-
+ #define MANDATORY(Cond, Name, Opt) { \
+ if(!(Cond)) { \
+ fprintf(stderr, "%s: %s missing -- option '-%c'\n", argv[0], (Name), (Opt)); \
+ res = RES_BAD_ARG; \
+ goto error; \
+ } \
+ } (void)0
+ MANDATORY(args->geoms != NULL, "geometry distribution", 'i');
if(args->ngeoms_dump) goto exit;
+ MANDATORY(args->wavelengths != NULL, "wavelengths", 'w');
+ MANDATORY(args->characteristic_length >= 0, "characteristic length", 'l');
+ #undef MANDATORY
- if(!args->wavelengths) {
- fprintf(stderr,
- "%s: missing wavelengths.\nTry '%s -h' for more informations.\n",
- argv[0], argv[0]);
- res = RES_BAD_ARG;
- goto error;
- }
/* Sort the submitted wavelengths in ascending order */
qsort(args->wavelengths, sa_size(args->wavelengths),
sizeof(args->wavelengths[0]), cmp_double);
- if(args->characteristic_length < 0.0) {
- fprintf(stderr,
-"%s: missing the characteristic length.\nTry '%s -h' for more informations\n",
- argv[0], argv[0]);
- res = RES_BAD_ARG;
- goto error;
- }
-
if(optind == argc) {
if(!quiet) {
#ifdef OS_WINDOWS
@@ -1609,9 +1537,7 @@ schiff_args_init
if(res != RES_OK) goto error;
if(!args->properties) {
- fprintf(stderr,
- "%s: missing optical properties.\nTry '%s -h' for more information.\n",
- argv[0], argv[0]);
+ fprintf(stderr, "%s: missing optical properties.\n", argv[0]);
res = RES_BAD_ARG;
goto error;
}
@@ -1619,6 +1545,7 @@ schiff_args_init
exit:
return res;
error:
+ usage(stderr);
schiff_args_release(args);
*args = SCHIFF_ARGS_NULL;
goto exit;