Octopus
getopt_f.c
Go to the documentation of this file.
1/*
2 Copyright (C) 2002 M. Marques, A. Castro, A. Rubio, G. Bertsch
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18
19*/
20
21#include <config.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <getopt.h>
25#include "string_f.h" /* Fortran <-> c string compatibility issues */
26#include <string.h>
27
28#if __has_include(<unistd.h>)
29#include <unistd.h>
30#endif
31
32// Below we check whether _POSIX_VERSION is defined to decide whether we can use
33// getopt_long. This is not entirely correct, becaues getopt_long is a GNU
34// extension which is not mandated by POSIX. However, most relevant major
35// UNIX-like operating systems that define _POSIX_VERSION also have getopt_long
36// in their standard C library. The list below is incomplete.
37//
38// Support is present in: Support is absent in:
39//
40// - Linux with both glibc and musl - HP-UX
41// - macOS - AIX
42// - FreeBSD, NetBSD, OpenBSD
43// - Solaris
44#if defined(_POSIX_VERSION) && !defined(__hpux) && !defined(_AIX)
45#define HAVE_GETOPT_LONG 1
46#endif
47
48/* GENERAL FUNCTIONS AND VARIABLES */
49
50char **argv;
51int argc;
52
53void FC_FUNC_(set_number_clarg, SET_NUMBER_CLARG)(int *nargc) {
54 argc = *nargc + 1;
55 argv = (char **)malloc(argc * sizeof(char *));
56}
58void FC_FUNC_(set_clarg, SET_CLARG)(int *i, STR_F_TYPE arg STR_ARG1) {
59 char *c;
60 TO_C_STR1(arg, c)
61 argv[*i] = c;
62}
63
64void FC_FUNC_(clean_clarg, CLEAN_CLARG)() {
65 int i;
66 for (i = 0; i < argc; i++)
67 free(argv[i]);
68 free(argv);
69}
70
71/* FUNCTIONS TO BE USED BY THE PROGRAM oct-oscillator-strength */
73 printf("Usage: oct-oscillator-strength [OPTIONS] [w]\n");
74 printf("\n");
75 printf("Options:\n");
76 printf(" -h Prints this help and exits.\n");
77 printf(" -m <mode> Select the run mode:\n");
78 printf(" 1 (default) analyzes the signal present in an "
79 "'ot' file.\n");
80 printf(" This should have been generated by this same "
81 "utility\n");
82 printf(" (run mode 2).\n");
83 printf(" 2 Reads a number of 'multipoles' files, which "
84 "should be\n");
85 printf(" present in the working directory, and be "
86 "called\n");
87 printf(" 'multipoles.1', 'multipoles.2', ..., and "
88 "generate an 'ot'\n");
89 printf(" file with the k-th order response of a given "
90 "operator O.\n");
91 printf(" The order k is decided by the '-k' option. The "
92 "operator\n");
93 printf(" is decided by the '-O' option.\n");
94 printf(" 3 Peforms an analysis of the second-order "
95 "response of an\n");
96 printf(" operator O, present in the working directory, "
97 "and\n");
98 printf(" previously generated with run mode 2. It also "
99 "reads a\n");
100 printf(" file with a list of frequecies around which "
101 "the search\n");
102 printf(" for resonances is performed.\n");
103 printf(" 4 Reads an 'ot' file, and generates an 'omega' "
104 "file with\n");
105 printf(" either the sine or cosine Fourier transform of "
106 "the\n");
107 printf(" signal present in 'ot'.\n");
108 printf(" -O <operator> Selects the operator to be analyzed:\n");
109 printf(" o If <operator> is a pair of integers in the "
110 "form '(l,m)'\n");
111 printf(
112 " then the operator will be the (l,m) multipole.\n");
113 printf(" o If <operator> is x, y, or z, then the response "
114 "operator\n");
115 printf(" to be analyzed will be the dipole in the given "
116 "direction.\n");
117 printf(" o If the -O option is not given in the command "
118 "line, then\n");
119 printf(" the observation operator O will be the same as "
120 "the\n");
121 printf(" perturbation operator that defines the initial "
122 "kick.\n");
123 printf(" -f <file> This is the file where the frequencies needed in "
124 "run mode\n");
125 printf(" 3 are stored.\n");
126 printf(" -d <gamma> gamma is the damping factor used in the SOS "
127 "formulae that\n");
128 printf(" produce (hyper)-polarizabilities.\n");
129 printf(" -s <dw> Limits of the search interval: [w-dw,w+dw]\n");
130 printf(" -r <r> Number of resonances to search for.\n");
131 printf(
132 " -n <N> Number of frequencies in which the search interval\n");
133 printf(" is discretized (default 1000)\n");
134 printf(" -k <k> Process, or generate, the k-th order response.\n");
135 printf(" -t <time> The signal analysis will be done by integrating in "
136 "the \n");
137 printf(" time interval [0, <time>]. If this argument is "
138 "absent,\n");
139 printf(" it makes use of all the time-window present in "
140 "the\n");
141 printf(" multipoles files.\n");
142 exit(-1);
143}
144
145void FC_FUNC_(getopt_oscillator_strength, GETOPT_OSCILLATOR_STRENGTH)(
146 int *mode, double *omega, double *searchinterval, int *order,
147 int *nresonances, int *nfrequencies, double *time, int *l, int *m,
148 double *damping, STR_F_TYPE ffile STR_ARG1) {
149 int c;
150
151 /* This line would be present if we wanted to make the omega a
152 mandatory argument. But for the moment I think it should not be mandatory.
153 if(argc==1) oscillator_strength_help(); */
154
155 while (1) {
156 c = getopt(argc, argv, "hm:s:k:O:r:n:t:d:f:");
157 if (c == -1)
158 break;
159 switch (c) {
161 case 'h':
163 break;
165 case 'm':
166 *mode = (int)atoi(optarg);
167 break;
169 case 's':
170 *searchinterval = (double)atof(optarg);
171 break;
172
173 case 'O':
174 c = sscanf(optarg, "(%d,%d)", l, m);
175 if (c != 2) {
176 switch (optarg[0]) {
177 case 'x':
178 *l = 0;
179 *m = 1;
180 break;
181 case 'y':
182 *l = 0;
183 *m = 2;
184 break;
185 case 'z':
186 *l = 0;
187 *m = 3;
188 break;
189 default:
190 printf("Problem reading the -O option value.\n\n");
192 }
193 }
194 break;
195
196 case 'k':
197 *order = (int)atoi(optarg);
198 break;
199
200 case 'r':
201 *nresonances = (int)atoi(optarg);
202 break;
203
204 case 'n':
205 *nfrequencies = (int)atoi(optarg);
206 break;
208 case 't':
209 *time = (double)atof(optarg);
210 break;
211
212 case 'f':
213 TO_F_STR1(optarg, ffile);
214 break;
215
216 case 'd':
217 *damping = (double)atof(optarg);
218 break;
219
220 case '?':
222 break;
223 }
225 if (optind < argc) {
226 while (optind < argc)
227 *omega = (double)atof(argv[optind++]);
228 }
229}
230/***************************************************************/
231
232/* FUNCTIONS TO BE USED BY THE PROGRAM oct-harmonic-spectrum */
234 printf("Usage: oct-harmonic-spectrum [OPTIONS] \n");
235 printf("\n");
236 printf("Options:\n");
237 printf(" -h, --help Prints this help and exits.\n");
238 printf(" -v, --version Prints octopus version.\n");
239 printf(" -w, --freq=freq Specifies the fundamental frequency.\n");
240 printf(
241 " -p, --pol=pol Specifies the direction of the light polarization.\n");
242 printf(" The oct-harmonic-spectrum utility program needs to "
243 "know\n");
244 printf(" the direction along which the emission radiation "
245 "is\n");
246 printf(" considered to be polarized. It may be linearly "
247 "polarized\n");
248 printf(" or circularly polarized. The valid options are:\n");
249 printf(" 'x' : Linearly polarized field in the x "
250 "direction.\n");
251 printf(" 'y' : Linearly polarized field in the x "
252 "direction.\n");
253 printf(" 'z' : Linearly polarized field in the x "
254 "direction.\n");
255 printf(" '+' : Circularly polarized field, "
256 "counterclockwise.\n");
257 printf(" '-' : Circularly polarized field, clockwise.\n");
258 printf(" 'v' : Along a direction specified by -x X -y Y "
259 "-z Z.\n");
260 printf(" The default is 'x'\n");
261 printf(" -a, --ar Calculates the angle-resolved harmonic-spectrum "
262 "along a\n");
263 printf(
264 " direction (X,Y,Z) specified by by -x X -y Y -z Z.\n");
265 printf(" -m, --mode=mode Whether the harmonic spectrum is computed by "
266 "taking the\n");
267 printf(" second derivative of the dipole moment "
268 "numerically, the \n");
269 printf(" the time derivative of the current, or by making "
270 "use of \n:");
271 printf(" the dipole acceleration.\n");
272 printf(" ' The options are:\n");
273 printf(" '1' : use the dipole, take second derivative "
274 "numerically.\n");
275 printf(" '2' : use the acceleration file.\n");
276 printf(" '3' : use the total current file.\n");
277 printf(" The default is '1'\n");
278 exit(-1);
280
281void FC_FUNC_(getopt_harmonic_spectrum,
282 GETOPT_HARMONIC_SPECTRUM)(double *w0, int *m, int *ar, double *x,
283 double *y, double *z,
284 STR_F_TYPE pol STR_ARG1) {
285 int c;
286
287#if defined(HAVE_GETOPT_LONG)
288 static struct option long_options[] = {
289 {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'},
290 {"freq", required_argument, 0, 'w'}, {"pol", required_argument, 0, 'p'},
291 {"mode", required_argument, 0, 'm'}, {"ar", required_argument, 0, 'a'},
292 {"x", required_argument, 0, 'x'}, {"y", required_argument, 0, 'y'},
293 {"z", required_argument, 0, 'z'}, {0, 0, 0, 0}};
294#endif
295
296 while (1) {
297 int option_index = 0;
298#if defined(HAVE_GETOPT_LONG)
299 c = getopt_long(argc, argv, "hvw:p:m:x:y:z:a", long_options, &option_index);
300#else
301 c = getopt(argc, argv, "hvw:p:m:x:y:z:a");
302#endif
303 if (c == -1)
304 break;
305 switch (c) {
307 case 'h':
309 break;
310
311 case 'v':
312 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
313 exit(0);
314
315 case 'w':
316 *w0 = (double)atof(optarg);
317 break;
318
319 case 'p':
320 TO_F_STR1(optarg, pol);
321 break;
322
323 case 'm':
324 *m = (int)atoi(optarg);
325 break;
326
327 case 'a':
328 *ar = 1;
329 break;
330
331 case 'x':
332 *x = (double)atof(optarg);
333 break;
334
335 case 'y':
336 *y = (double)atof(optarg);
337 break;
339 case 'z':
340 *z = (double)atof(optarg);
341 break;
342 }
343 }
345/***************************************************************/
346
347/* FUNCTIONS TO BE USED BY THE PROGRAM oct-help */
348void help_help() {
349 printf("Usage: oct-help [options] \n");
350 printf("\n");
351 printf("Options:\n");
352 printf(" -h, --help Prints this help and exits.\n");
353 printf(" -v, --version Prints octopus version.\n");
354 printf(" -s, --search=STRING Search variables whose names contain string "
355 "'STRING'.\n");
356 printf(" -p, --print=VARNAME Prints description of variable 'VARNAME'.\n");
357 exit(-1);
358}
359
360void FC_FUNC_(getopt_help, GETOPT_HELP)(STR_F_TYPE mode,
361 STR_F_TYPE name STR_ARG2) {
362 int c;
363
364#if defined(HAVE_GETOPT_LONG)
365 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
366 {"version", no_argument, 0, 'v'},
367 {"list", no_argument, 0, 'l'},
368 {"search", required_argument, 0, 's'},
369 {"print", required_argument, 0, 'p'},
370 {0, 0, 0, 0}};
371#endif
372
373 while (1) {
374 int option_index = 0;
375#if defined(HAVE_GETOPT_LONG)
376 c = getopt_long(argc, argv, "hvls:p:", long_options, &option_index);
377#else
378 c = getopt(argc, argv, "hvls:p:");
379#endif
380 if (argc == 1)
381 help_help();
382 if (c == -1)
383 break;
384 switch (c) {
385
386 case 'h':
387 help_help();
388 break;
389
390 case 'v':
391 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
392 exit(0);
393
394 case 'l':
395 TO_F_STR1("list", mode);
396 return;
397
398 case 's':
399 TO_F_STR1("search", mode);
400 TO_F_STR2(optarg, name);
401 return;
402
403 case 'p':
404 TO_F_STR1("print", mode);
405 TO_F_STR2(optarg, name);
406 return;
407 }
408 }
409 if (optind < argc)
410 help_help();
411}
412
413/***************************************************************/
414
415/* FUNCTIONS TO BE USED BY THE PROGRAM octopus */
416void octopus_help() {
417 printf("Usage: octopus [options] \n");
418 printf("\n");
419 printf("Options:\n");
420 printf(" -h, --help Prints this help and exits.\n");
421 printf(" -v, --version Prints octopus version.\n");
422 printf(" -c, --config Prints compilation configuration options.\n");
423 exit(-1);
424}
425
426void FC_FUNC_(getopt_octopus, GETOPT_OCTOPUS)(STR_F_TYPE config_str STR_ARG1) {
427 int c;
428 char *config_str_c;
429#if defined(HAVE_GETOPT_LONG)
430 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
431 {"version", no_argument, 0, 'v'},
432 {"config", no_argument, 0, 'c'},
433 {0, 0, 0, 0}};
434#endif
435
436 while (1) {
437 int option_index = 0;
438#if defined(HAVE_GETOPT_LONG)
439 c = getopt_long(argc, argv, "hvc", long_options, &option_index);
440#else
441 c = getopt(argc, argv, "hvc");
442#endif
443 if (c == -1)
444 break;
445 switch (c) {
446 case 'h':
447 octopus_help();
448 break;
449 case 'v':
450 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
451 exit(0);
452 break;
453 case 'c':
454 TO_C_STR1(config_str, config_str_c);
455 printf("%s\n", config_str_c);
456 free(config_str_c);
457 exit(0);
458 break;
459 }
460 }
461 if (optind < argc)
462 octopus_help();
463}
464
465/***************************************************************/
466
467/* FUNCTIONS TO BE USED BY THE PROGRAM oct-casida_spectrum */
469 printf("Usage: oct-casida_spectrum [options] \n");
470 printf("\n");
471 printf("Options:\n");
472 printf(" -h, --help Prints this help and exits.\n");
473 printf(" -v, --version Prints octopus version.\n");
474 exit(-1);
475}
476
477void FC_FUNC_(getopt_casida_spectrum, GETOPT_CASIDA_SPECTRUM)() {
478 int c;
479#if defined(HAVE_GETOPT_LONG)
480 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
481 {"version", no_argument, 0, 'v'},
482 {0, 0, 0, 0}};
483#endif
484
485 while (1) {
486 int option_index = 0;
487#if defined(HAVE_GETOPT_LONG)
488 c = getopt_long(argc, argv, "hv", long_options, &option_index);
489#else
490 c = getopt(argc, argv, "hv");
491#endif
492 if (c == -1)
493 break;
494 switch (c) {
495 case 'h':
497 break;
498 case 'v':
499 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
500 exit(0);
501 }
502 }
503 if (optind < argc)
505}
506
507/***************************************************************/
508
509/* FUNCTIONS TO BE USED BY THE PROGRAM oct-center-geom */
510void center_geom_help() {
511 printf("Usage: oct-center-geom [options] \n");
512 printf("\n");
513 printf("Options:\n");
514 printf(" -h, --help Prints this help and exits.\n");
515 printf(" -v, --version Prints octopus version.\n");
516 exit(-1);
517}
518
519void FC_FUNC_(getopt_center_geom, GETOPT_CENTER_GEOM)() {
520 int c;
521#if defined(HAVE_GETOPT_LONG)
522 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
523 {"version", no_argument, 0, 'v'},
524 {0, 0, 0, 0}};
525#endif
526
527 while (1) {
528 int option_index = 0;
529#if defined(HAVE_GETOPT_LONG)
530 c = getopt_long(argc, argv, "hv", long_options, &option_index);
531#else
532 c = getopt(argc, argv, "hv");
533#endif
534 if (c == -1)
535 break;
536 switch (c) {
537 case 'h':
539 break;
540 case 'v':
541 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
542 exit(0);
543 }
544 }
545 if (optind < argc)
547}
548
549/***************************************************************/
550
551/* FUNCTIONS TO BE USED BY THE PROGRAM oct-center-geom */
553 printf("Usage: oct-dielectric-function [options] \n");
554 printf("\n");
555 printf("Options:\n");
556 printf(" -h, --help Prints this help and exits.\n");
557 printf(" -v, --version Prints octopus version.\n");
558 exit(-1);
559}
560
561void FC_FUNC_(getopt_dielectric_function, GETOPT_DIELECTRIC_FUNCTION)() {
562 int c;
563#if defined(HAVE_GETOPT_LONG)
564 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
565 {"version", no_argument, 0, 'v'},
566 {0, 0, 0, 0}};
567#endif
568
569 while (1) {
570 int option_index = 0;
571#if defined(HAVE_GETOPT_LONG)
572 c = getopt_long(argc, argv, "hv", long_options, &option_index);
573#else
574 c = getopt(argc, argv, "hv");
575#endif
576 if (c == -1)
577 break;
578 switch (c) {
579 case 'h':
581 break;
582 case 'v':
583 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
584 exit(0);
585 }
586 }
587 if (optind < argc)
589}
590
591/***************************************************************/
592
593/* FUNCTIONS TO BE USED BY THE PROGRAM oct-propagation_spectrum */
595 printf("Usage: oct-propagation_spectrum [options] \n");
596 printf("\n");
597 printf("Options:\n");
598 printf(" -h, --help Prints this help and exits.\n");
599 printf(" -v, --version Prints octopus version.\n");
600 printf(" -r, --reference REF REF should be the name of the 'reference' "
601 "multipoles file,.\n");
602 printf(" whenever you want to do a time-dependent "
603 "response function.\n");
604 printf(" calculation.\n");
605 exit(-1);
606}
607
608void FC_FUNC_(getopt_propagation_spectrum,
609 GETOPT_PROPAGATION_SPECTRUM)(STR_F_TYPE fname STR_ARG1) {
610 int c;
611#if defined(HAVE_GETOPT_LONG)
612 static struct option long_options[] = {
613 {"help", no_argument, 0, 'h'},
614 {"version", no_argument, 0, 'v'},
615 {"reference", required_argument, 0, 'r'},
616 {0, 0, 0, 0}};
617#endif
618
619 while (1) {
620 int option_index = 0;
621#if defined(HAVE_GETOPT_LONG)
622 c = getopt_long(argc, argv, "hvr:", long_options, &option_index);
623#else
624 c = getopt(argc, argv, "hvr:");
625#endif
626 if (c == -1)
627 break;
628 switch (c) {
629 case 'h':
631 break;
632 case 'v':
633 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
634 exit(0);
635 case 'r':
636 TO_F_STR1(optarg, fname);
637 break;
638 }
639 }
640 if (optind < argc)
642}
643
644/***************************************************************/
645
646/* FUNCTIONS TO BE USED BY THE PROGRAM oct-xyz-anim */
647void xyz_anim_help() {
648 printf("Usage: oct-xyz-anim [options] \n");
649 printf("\n");
650 printf("Options:\n");
651 printf(" -h, --help Prints this help and exits.\n");
652 printf(" -v, --version Prints octopus version.\n");
653 exit(-1);
654}
655
656void FC_FUNC_(getopt_xyz_anim, GETOPT_XYZ_ANIM)() {
657 int c;
658#if defined(HAVE_GETOPT_LONG)
659 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
660 {"version", no_argument, 0, 'v'},
661 {0, 0, 0, 0}};
662#endif
663
664 while (1) {
665 int option_index = 0;
666#if defined(HAVE_GETOPT_LONG)
667 c = getopt_long(argc, argv, "hv", long_options, &option_index);
668#else
669 c = getopt(argc, argv, "hv");
670#endif
671 if (c == -1)
672 break;
673 switch (c) {
674 case 'h':
676 break;
677 case 'v':
678 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
679 exit(0);
680 }
681 }
682 if (optind < argc)
684}
685
686/***************************************************************/
687
688/* FUNCTIONS TO BE USED BY THE PROGRAM oct-photoelectron_spectrum */
690 printf("Usage: oct-photoelectron_spectrum [OPTIONS] \n");
691 printf("\n");
692 printf("Options:\n");
693 printf(" -h, --help Prints this help and exits.\n");
694 printf(" -v, --version Prints octopus version.\n");
695 printf(" -V, --vec=x,y,z The polar zenith direction in comma-separated "
696 "format \n");
697 printf(" (without spaces). Default is the laser "
698 "polarization. \n");
699 printf(" -u, --pvec=x,y,z The plane cut vector in comma-separated "
700 "format.\n");
701 printf(" Default is 0,0,1 (px-py plane). \n");
702 printf(" -C, --center=x,y,z Center of the coordinates in p-space in "
703 "comma-separated format \n");
704 printf(" Default: 0,0,0. \n");
705 printf(" -E, Maximum and minimum energy in colon-separated "
706 "values. \n");
707 printf(" --espan=Emin:Emax "
708 " \n");
709 printf(" -e, --de The resolution in energy.\n");
710 printf(" -T, Maximum and minimum theta in colon-separated "
711 "format. \n");
712 printf(" --thspan=thetamin:thetamax "
713 " \n");
714 printf(" -t, --dth The resolution in theta.\n");
715 printf(" -P, Maximum and minimum phi in colon separated "
716 "format. \n");
717 printf(" --phspan=phimin:phimax "
718 " \n");
719 printf(" -p, --dph The resolution in phi.\n");
720 printf(" -I, --integr=var The spectrum is integrated over the specified "
721 "variable. For \n");
722 printf(" example \"-I phi\" integrates over phi. \n");
723
724 exit(-1);
725}
726
727void FC_FUNC_(getopt_photoelectron_spectrum,
728 GETOPT_PHOTOELECTRON_SPECTRUM)(double *estep, double *espan,
729 double *thstep, double *thspan,
730 double *phstep, double *phspan,
731 double *pol, double *center,
732 double *pvec, int *integrate) {
733 int c;
734 char delims[] = ",:";
735 char *tok = NULL;
736
737#if defined(HAVE_GETOPT_LONG)
738 static struct option long_options[] = {{"help", no_argument, 0, 'h'},
739 {"version", no_argument, 0, 'v'},
740 {"integr", required_argument, 0, 'I'},
741 {"de", required_argument, 0, 'e'},
742 {"espan", required_argument, 0, 'E'},
743 {"dth", required_argument, 0, 't'},
744 {"thspan", required_argument, 0, 'T'},
745 {"dph", required_argument, 0, 'p'},
746 {"phspan", required_argument, 0, 'P'},
747 {"vec", required_argument, 0, 'V'},
748 {"pvec", required_argument, 0, 'v'},
749 {"center", required_argument, 0, 'C'},
750 {0, 0, 0, 0}};
751#endif
752
753 while (1) {
754 int option_index = 0;
755#if defined(HAVE_GETOPT_LONG)
756 c = getopt_long(argc, argv, "hve:E:P:p:T:t:V:C:u:I:", long_options,
757 &option_index);
758#else
759 c = getopt(argc, argv, "hve:E:P:p:T:t:V:C:u:I:");
760#endif
761 if (c == -1)
762 break;
763 switch (c) {
764
765 case 'h':
767 break;
768
769 case 'v':
770 printf("octopus %s (git commit %s)\n", PACKAGE_VERSION, GIT_COMMIT);
771 exit(0);
772 break;
773
774 case 'I':
775 if ((strcmp(optarg, "phi") == 0)) {
776 *integrate = 1;
777 } else if ((strcmp(optarg, "theta") == 0)) {
778 *integrate = 2;
779 } else if ((strcmp(optarg, "r") == 0)) {
780 *integrate = 3;
781 } else if ((strcmp(optarg, "kx") == 0)) {
782 *integrate = 4;
783 } else if ((strcmp(optarg, "ky") == 0)) {
784 *integrate = 5;
785 } else if ((strcmp(optarg, "kz") == 0)) {
786 *integrate = 6;
787 } else {
788 printf("Unrecognized integration variable %s.\n", optarg);
789 *integrate = -1;
791 break;
792
793 case 'e':
794 *estep = atof(optarg);
795 break;
796
797 case 'E':
798 tok = strtok(optarg, delims);
799 espan[0] = atof(tok);
800 tok = strtok(NULL, delims);
801 espan[1] = atof(tok);
802
803 break;
804
805 case 't':
806 *thstep = atof(optarg);
807 break;
808
809 case 'T':
810 tok = strtok(optarg, delims);
811 thspan[0] = atof(tok);
812 tok = strtok(NULL, delims);
813 thspan[1] = atof(tok);
814
815 break;
816
817 case 'p':
818 *phstep = atof(optarg);
819 break;
820
821 case 'P':
822 tok = strtok(optarg, delims);
823 phspan[0] = atof(tok);
824 tok = strtok(NULL, delims);
825 phspan[1] = atof(tok);
826
827 break;
828
829 case 'V':
830 tok = strtok(optarg, delims);
831 pol[0] = atof(tok);
832 tok = strtok(NULL, delims);
833 pol[1] = atof(tok);
834 tok = strtok(NULL, delims);
835 pol[2] = atof(tok);
836
837 break;
838
839 case 'u':
840 tok = strtok(optarg, delims);
841 pvec[0] = atof(tok);
842 tok = strtok(NULL, delims);
843 pvec[1] = atof(tok);
844 tok = strtok(NULL, delims);
845 pvec[2] = atof(tok);
846
847 break;
848
849 case 'C':
850 tok = strtok(optarg, delims);
851 center[0] = atof(tok);
852 tok = strtok(NULL, delims);
853 center[1] = atof(tok);
854 tok = strtok(NULL, delims);
855 center[2] = atof(tok);
856
857 break;
858 }
859 }
860}
void octopus_help()
Definition: getopt_f.c:3831
void casida_spectrum_help()
Definition: getopt_f.c:3895
void center_geom_help()
Definition: getopt_f.c:3945
void dielectric_function_help()
Definition: getopt_f.c:3995
void oscillator_strength_help()
Definition: getopt_f.c:3431
void help_help()
Definition: getopt_f.c:3743
void propagation_spectrum_help()
Definition: getopt_f.c:4045
void harmonic_spectrum_help()
Definition: getopt_f.c:3592
void photoelectron_spectrum_help()
Definition: getopt_f.c:4160
void xyz_anim_help()
Definition: getopt_f.c:4110
int getopt_long(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind) __attribute__((__nothrow__
if write to the Free Software Franklin Fifth USA !If the compiler accepts long Fortran it is better to use that and build all the preprocessor definitions in one line In !this the debuggers will provide the right line numbers !If the compiler accepts line number then CARDINAL and ACARDINAL !will put them just a new line or a ampersand plus a new line !These macros should be used in macros that span several lines They should by !put immedialty before a line where a compilation error might occur and at the !end of the macro !Note that the cardinal and newline words are substituted by the program !preprocess pl by the ampersand and by a real new line just before compilation !The assertions are ignored if the code is compiled in not debug mode(NDEBUG ! is defined). Otherwise it is merely a logical assertion that
pure real(real64) function center(this)
Center of the filter interval.
ptrdiff_t l
Definition: operate_inc.c:12
ptrdiff_t i
Definition: operate_inc.c:12