| 1 | /* | 
| 2 | File autogenerated by gengetopt version 2.15 | 
| 3 | generated with the following command: | 
| 4 | gengetopt -i StaticProps.ggo -F StaticPropsCmd | 
| 5 |  | 
| 6 | The developers of gengetopt consider the fixed text that goes in all | 
| 7 | gengetopt output files to be in the public domain: | 
| 8 | we make no copyright claims on it. | 
| 9 | */ | 
| 10 |  | 
| 11 | /* If we use autoconf.  */ | 
| 12 | #ifdef HAVE_CONFIG_H | 
| 13 | #include "config.h" | 
| 14 | #endif | 
| 15 |  | 
| 16 | #include <stdio.h> | 
| 17 | #include <stdlib.h> | 
| 18 | #include <string.h> | 
| 19 |  | 
| 20 | #include "getopt.h" | 
| 21 |  | 
| 22 | #include "StaticPropsCmd.h" | 
| 23 |  | 
| 24 | static | 
| 25 | void clear_given (struct gengetopt_args_info *args_info); | 
| 26 | static | 
| 27 | void clear_args (struct gengetopt_args_info *args_info); | 
| 28 |  | 
| 29 | static int | 
| 30 | cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); | 
| 31 |  | 
| 32 | static int | 
| 33 | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); | 
| 34 |  | 
| 35 | static char * | 
| 36 | gengetopt_strdup (const char *s); | 
| 37 |  | 
| 38 | static | 
| 39 | void clear_given (struct gengetopt_args_info *args_info) | 
| 40 | { | 
| 41 | args_info->help_given = 0 ; | 
| 42 | args_info->version_given = 0 ; | 
| 43 | args_info->input_given = 0 ; | 
| 44 | args_info->output_given = 0 ; | 
| 45 | args_info->step_given = 0 ; | 
| 46 | args_info->nbins_given = 0 ; | 
| 47 | args_info->nbins_x_given = 0 ; | 
| 48 | args_info->nbins_y_given = 0 ; | 
| 49 | args_info->nanglebins_given = 0 ; | 
| 50 | args_info->length_given = 0 ; | 
| 51 | args_info->rcut_given = 0 ; | 
| 52 | args_info->zoffset_given = 0 ; | 
| 53 | args_info->sele1_given = 0 ; | 
| 54 | args_info->sele2_given = 0 ; | 
| 55 | args_info->sele3_given = 0 ; | 
| 56 | args_info->refsele_given = 0 ; | 
| 57 | args_info->molname_given = 0 ; | 
| 58 | args_info->begin_given = 0 ; | 
| 59 | args_info->end_given = 0 ; | 
| 60 | args_info->radius_given = 0 ; | 
| 61 | args_info->bo_given = 0 ; | 
| 62 | args_info->gofr_given = 0 ; | 
| 63 | args_info->r_theta_given = 0 ; | 
| 64 | args_info->r_omega_given = 0 ; | 
| 65 | args_info->theta_omega_given = 0 ; | 
| 66 | args_info->gxyz_given = 0 ; | 
| 67 | args_info->p2_given = 0 ; | 
| 68 | args_info->rp2_given = 0 ; | 
| 69 | args_info->scd_given = 0 ; | 
| 70 | args_info->density_given = 0 ; | 
| 71 | args_info->slab_density_given = 0 ; | 
| 72 | args_info->hxy_given = 0 ; | 
| 73 | args_info->rho_r_given = 0 ; | 
| 74 | args_info->staticProps_group_counter = 0 ; | 
| 75 | } | 
| 76 |  | 
| 77 | static | 
| 78 | void clear_args (struct gengetopt_args_info *args_info) | 
| 79 | { | 
| 80 | args_info->input_arg = NULL; | 
| 81 | args_info->input_orig = NULL; | 
| 82 | args_info->output_arg = NULL; | 
| 83 | args_info->output_orig = NULL; | 
| 84 | args_info->step_arg = 1; | 
| 85 | args_info->step_orig = NULL; | 
| 86 | args_info->nbins_arg = 100; | 
| 87 | args_info->nbins_orig = NULL; | 
| 88 | args_info->nbins_x_arg = 100; | 
| 89 | args_info->nbins_x_orig = NULL; | 
| 90 | args_info->nbins_y_arg = 100; | 
| 91 | args_info->nbins_y_orig = NULL; | 
| 92 | args_info->nanglebins_arg = 50; | 
| 93 | args_info->nanglebins_orig = NULL; | 
| 94 | args_info->length_orig = NULL; | 
| 95 | args_info->rcut_orig = NULL; | 
| 96 | args_info->zoffset_arg = 0; | 
| 97 | args_info->zoffset_orig = NULL; | 
| 98 | args_info->sele1_arg = NULL; | 
| 99 | args_info->sele1_orig = NULL; | 
| 100 | args_info->sele2_arg = NULL; | 
| 101 | args_info->sele2_orig = NULL; | 
| 102 | args_info->sele3_arg = NULL; | 
| 103 | args_info->sele3_orig = NULL; | 
| 104 | args_info->refsele_arg = NULL; | 
| 105 | args_info->refsele_orig = NULL; | 
| 106 | args_info->molname_arg = NULL; | 
| 107 | args_info->molname_orig = NULL; | 
| 108 | args_info->begin_orig = NULL; | 
| 109 | args_info->end_orig = NULL; | 
| 110 | args_info->radius_orig = NULL; | 
| 111 |  | 
| 112 | } | 
| 113 |  | 
| 114 | void | 
| 115 | cmdline_parser_print_version (void) | 
| 116 | { | 
| 117 | printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); | 
| 118 | } | 
| 119 |  | 
| 120 | void | 
| 121 | cmdline_parser_print_help (void) | 
| 122 | { | 
| 123 | cmdline_parser_print_version (); | 
| 124 | printf("\nUsage: StaticProps [OPTIONS]...\n\n"); | 
| 125 | printf("%s\n","  -h, --help                    Print help and exit"); | 
| 126 | printf("%s\n","  -V, --version                 Print version and exit"); | 
| 127 | printf("%s\n","  -i, --input=filename          input dump file"); | 
| 128 | printf("%s\n","  -o, --output=filename         output file name"); | 
| 129 | printf("%s\n","  -n, --step=INT                process every n frame  (default=`1')"); | 
| 130 | printf("%s\n","  -b, --nbins=INT               number of bins (general purpose)  \n                                  (default=`100')"); | 
| 131 | printf("%s\n","  -x, --nbins_x=INT             number of bins in x axis  (default=`100')"); | 
| 132 | printf("%s\n","  -y, --nbins_y=INT             number of bins in y axis  (default=`100')"); | 
| 133 | printf("%s\n","  -a, --nanglebins=INT          number of bins for cos(angle)  (default=`50')"); | 
| 134 | printf("%s\n","      --length=DOUBLE           maximum length (Defaults to 1/2 smallest length \n                                  of first frame)"); | 
| 135 | printf("%s\n","  -c, --rcut=DOUBLE             cutoff radius (rcut)"); | 
| 136 | printf("%s\n","  -z, --zoffset=DOUBLE          Where to set the zero for the slab_density \n                                  calculation  (default=`0')"); | 
| 137 | printf("%s\n","      --sele1=selection script  select the first stuntdouble set"); | 
| 138 | printf("%s\n","      --sele2=selection script  select the second stuntdouble set"); | 
| 139 | printf("%s\n","      --sele3=selection script  select the third stuntdouble set"); | 
| 140 | printf("%s\n","      --refsele=selection script\n                                select reference (use and only use with --gxyz)"); | 
| 141 | printf("%s\n","      --molname=STRING          molecule name"); | 
| 142 | printf("%s\n","      --begin=INT               begin internal index"); | 
| 143 | printf("%s\n","      --end=INT                 end internal index"); | 
| 144 | printf("%s\n","      --radius=DOUBLE           nanoparticle radius"); | 
| 145 | printf("%s\n","\n Group: staticProps\n   an option of this group is required"); | 
| 146 | printf("%s\n","      --bo                      bond order parameter (--rcut must be specified"); | 
| 147 | printf("%s\n","  -g, --gofr                    g(r)"); | 
| 148 | printf("%s\n","      --r_theta                 g(r, cos(theta))"); | 
| 149 | printf("%s\n","      --r_omega                 g(r, cos(omega))"); | 
| 150 | printf("%s\n","      --theta_omega             g(cos(theta), cos(omega))"); | 
| 151 | printf("%s\n","      --gxyz                    g(x, y, z)"); | 
| 152 | printf("%s\n","  -p, --p2                      p2 order parameter (--sele1 and --sele2 must be \n                                  specified)"); | 
| 153 | printf("%s\n","      --rp2                     rp2 order parameter (--sele1 and --sele2 must \n                                  be specified)"); | 
| 154 | printf("%s\n","  -s, --scd                     scd order parameter (either --sele1, --sele2, \n                                  --sele3 are specified or --molname, --begin, \n                                  --end are specified)"); | 
| 155 | printf("%s\n","  -d, --density                 density plot"); | 
| 156 | printf("%s\n","      --slab_density            slab density"); | 
| 157 | printf("%s\n","      --hxy                     hxy"); | 
| 158 | printf("%s\n","      --rho_r                   rho of R"); | 
| 159 |  | 
| 160 | } | 
| 161 |  | 
| 162 | void | 
| 163 | cmdline_parser_init (struct gengetopt_args_info *args_info) | 
| 164 | { | 
| 165 | clear_given (args_info); | 
| 166 | clear_args (args_info); | 
| 167 | } | 
| 168 |  | 
| 169 | static void | 
| 170 | cmdline_parser_release (struct gengetopt_args_info *args_info) | 
| 171 | { | 
| 172 |  | 
| 173 | if (args_info->input_arg) | 
| 174 | { | 
| 175 | free (args_info->input_arg); /* free previous argument */ | 
| 176 | args_info->input_arg = 0; | 
| 177 | } | 
| 178 | if (args_info->input_orig) | 
| 179 | { | 
| 180 | free (args_info->input_orig); /* free previous argument */ | 
| 181 | args_info->input_orig = 0; | 
| 182 | } | 
| 183 | if (args_info->output_arg) | 
| 184 | { | 
| 185 | free (args_info->output_arg); /* free previous argument */ | 
| 186 | args_info->output_arg = 0; | 
| 187 | } | 
| 188 | if (args_info->output_orig) | 
| 189 | { | 
| 190 | free (args_info->output_orig); /* free previous argument */ | 
| 191 | args_info->output_orig = 0; | 
| 192 | } | 
| 193 | if (args_info->step_orig) | 
| 194 | { | 
| 195 | free (args_info->step_orig); /* free previous argument */ | 
| 196 | args_info->step_orig = 0; | 
| 197 | } | 
| 198 | if (args_info->nbins_orig) | 
| 199 | { | 
| 200 | free (args_info->nbins_orig); /* free previous argument */ | 
| 201 | args_info->nbins_orig = 0; | 
| 202 | } | 
| 203 | if (args_info->nbins_x_orig) | 
| 204 | { | 
| 205 | free (args_info->nbins_x_orig); /* free previous argument */ | 
| 206 | args_info->nbins_x_orig = 0; | 
| 207 | } | 
| 208 | if (args_info->nbins_y_orig) | 
| 209 | { | 
| 210 | free (args_info->nbins_y_orig); /* free previous argument */ | 
| 211 | args_info->nbins_y_orig = 0; | 
| 212 | } | 
| 213 | if (args_info->nanglebins_orig) | 
| 214 | { | 
| 215 | free (args_info->nanglebins_orig); /* free previous argument */ | 
| 216 | args_info->nanglebins_orig = 0; | 
| 217 | } | 
| 218 | if (args_info->length_orig) | 
| 219 | { | 
| 220 | free (args_info->length_orig); /* free previous argument */ | 
| 221 | args_info->length_orig = 0; | 
| 222 | } | 
| 223 | if (args_info->rcut_orig) | 
| 224 | { | 
| 225 | free (args_info->rcut_orig); /* free previous argument */ | 
| 226 | args_info->rcut_orig = 0; | 
| 227 | } | 
| 228 | if (args_info->zoffset_orig) | 
| 229 | { | 
| 230 | free (args_info->zoffset_orig); /* free previous argument */ | 
| 231 | args_info->zoffset_orig = 0; | 
| 232 | } | 
| 233 | if (args_info->sele1_arg) | 
| 234 | { | 
| 235 | free (args_info->sele1_arg); /* free previous argument */ | 
| 236 | args_info->sele1_arg = 0; | 
| 237 | } | 
| 238 | if (args_info->sele1_orig) | 
| 239 | { | 
| 240 | free (args_info->sele1_orig); /* free previous argument */ | 
| 241 | args_info->sele1_orig = 0; | 
| 242 | } | 
| 243 | if (args_info->sele2_arg) | 
| 244 | { | 
| 245 | free (args_info->sele2_arg); /* free previous argument */ | 
| 246 | args_info->sele2_arg = 0; | 
| 247 | } | 
| 248 | if (args_info->sele2_orig) | 
| 249 | { | 
| 250 | free (args_info->sele2_orig); /* free previous argument */ | 
| 251 | args_info->sele2_orig = 0; | 
| 252 | } | 
| 253 | if (args_info->sele3_arg) | 
| 254 | { | 
| 255 | free (args_info->sele3_arg); /* free previous argument */ | 
| 256 | args_info->sele3_arg = 0; | 
| 257 | } | 
| 258 | if (args_info->sele3_orig) | 
| 259 | { | 
| 260 | free (args_info->sele3_orig); /* free previous argument */ | 
| 261 | args_info->sele3_orig = 0; | 
| 262 | } | 
| 263 | if (args_info->refsele_arg) | 
| 264 | { | 
| 265 | free (args_info->refsele_arg); /* free previous argument */ | 
| 266 | args_info->refsele_arg = 0; | 
| 267 | } | 
| 268 | if (args_info->refsele_orig) | 
| 269 | { | 
| 270 | free (args_info->refsele_orig); /* free previous argument */ | 
| 271 | args_info->refsele_orig = 0; | 
| 272 | } | 
| 273 | if (args_info->molname_arg) | 
| 274 | { | 
| 275 | free (args_info->molname_arg); /* free previous argument */ | 
| 276 | args_info->molname_arg = 0; | 
| 277 | } | 
| 278 | if (args_info->molname_orig) | 
| 279 | { | 
| 280 | free (args_info->molname_orig); /* free previous argument */ | 
| 281 | args_info->molname_orig = 0; | 
| 282 | } | 
| 283 | if (args_info->begin_orig) | 
| 284 | { | 
| 285 | free (args_info->begin_orig); /* free previous argument */ | 
| 286 | args_info->begin_orig = 0; | 
| 287 | } | 
| 288 | if (args_info->end_orig) | 
| 289 | { | 
| 290 | free (args_info->end_orig); /* free previous argument */ | 
| 291 | args_info->end_orig = 0; | 
| 292 | } | 
| 293 | if (args_info->radius_orig) | 
| 294 | { | 
| 295 | free (args_info->radius_orig); /* free previous argument */ | 
| 296 | args_info->radius_orig = 0; | 
| 297 | } | 
| 298 |  | 
| 299 | clear_given (args_info); | 
| 300 | } | 
| 301 |  | 
| 302 | int | 
| 303 | cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) | 
| 304 | { | 
| 305 | FILE *outfile; | 
| 306 | int i = 0; | 
| 307 |  | 
| 308 | outfile = fopen(filename, "w"); | 
| 309 |  | 
| 310 | if (!outfile) | 
| 311 | { | 
| 312 | fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); | 
| 313 | return EXIT_FAILURE; | 
| 314 | } | 
| 315 |  | 
| 316 | if (args_info->help_given) { | 
| 317 | fprintf(outfile, "%s\n", "help"); | 
| 318 | } | 
| 319 | if (args_info->version_given) { | 
| 320 | fprintf(outfile, "%s\n", "version"); | 
| 321 | } | 
| 322 | if (args_info->input_given) { | 
| 323 | if (args_info->input_orig) { | 
| 324 | fprintf(outfile, "%s=\"%s\"\n", "input", args_info->input_orig); | 
| 325 | } else { | 
| 326 | fprintf(outfile, "%s\n", "input"); | 
| 327 | } | 
| 328 | } | 
| 329 | if (args_info->output_given) { | 
| 330 | if (args_info->output_orig) { | 
| 331 | fprintf(outfile, "%s=\"%s\"\n", "output", args_info->output_orig); | 
| 332 | } else { | 
| 333 | fprintf(outfile, "%s\n", "output"); | 
| 334 | } | 
| 335 | } | 
| 336 | if (args_info->step_given) { | 
| 337 | if (args_info->step_orig) { | 
| 338 | fprintf(outfile, "%s=\"%s\"\n", "step", args_info->step_orig); | 
| 339 | } else { | 
| 340 | fprintf(outfile, "%s\n", "step"); | 
| 341 | } | 
| 342 | } | 
| 343 | if (args_info->nbins_given) { | 
| 344 | if (args_info->nbins_orig) { | 
| 345 | fprintf(outfile, "%s=\"%s\"\n", "nbins", args_info->nbins_orig); | 
| 346 | } else { | 
| 347 | fprintf(outfile, "%s\n", "nbins"); | 
| 348 | } | 
| 349 | } | 
| 350 | if (args_info->nbins_x_given) { | 
| 351 | if (args_info->nbins_x_orig) { | 
| 352 | fprintf(outfile, "%s=\"%s\"\n", "nbins_x", args_info->nbins_x_orig); | 
| 353 | } else { | 
| 354 | fprintf(outfile, "%s\n", "nbins_x"); | 
| 355 | } | 
| 356 | } | 
| 357 | if (args_info->nbins_y_given) { | 
| 358 | if (args_info->nbins_y_orig) { | 
| 359 | fprintf(outfile, "%s=\"%s\"\n", "nbins_y", args_info->nbins_y_orig); | 
| 360 | } else { | 
| 361 | fprintf(outfile, "%s\n", "nbins_y"); | 
| 362 | } | 
| 363 | } | 
| 364 | if (args_info->nanglebins_given) { | 
| 365 | if (args_info->nanglebins_orig) { | 
| 366 | fprintf(outfile, "%s=\"%s\"\n", "nanglebins", args_info->nanglebins_orig); | 
| 367 | } else { | 
| 368 | fprintf(outfile, "%s\n", "nanglebins"); | 
| 369 | } | 
| 370 | } | 
| 371 | if (args_info->length_given) { | 
| 372 | if (args_info->length_orig) { | 
| 373 | fprintf(outfile, "%s=\"%s\"\n", "length", args_info->length_orig); | 
| 374 | } else { | 
| 375 | fprintf(outfile, "%s\n", "length"); | 
| 376 | } | 
| 377 | } | 
| 378 | if (args_info->rcut_given) { | 
| 379 | if (args_info->rcut_orig) { | 
| 380 | fprintf(outfile, "%s=\"%s\"\n", "rcut", args_info->rcut_orig); | 
| 381 | } else { | 
| 382 | fprintf(outfile, "%s\n", "rcut"); | 
| 383 | } | 
| 384 | } | 
| 385 | if (args_info->zoffset_given) { | 
| 386 | if (args_info->zoffset_orig) { | 
| 387 | fprintf(outfile, "%s=\"%s\"\n", "zoffset", args_info->zoffset_orig); | 
| 388 | } else { | 
| 389 | fprintf(outfile, "%s\n", "zoffset"); | 
| 390 | } | 
| 391 | } | 
| 392 | if (args_info->sele1_given) { | 
| 393 | if (args_info->sele1_orig) { | 
| 394 | fprintf(outfile, "%s=\"%s\"\n", "sele1", args_info->sele1_orig); | 
| 395 | } else { | 
| 396 | fprintf(outfile, "%s\n", "sele1"); | 
| 397 | } | 
| 398 | } | 
| 399 | if (args_info->sele2_given) { | 
| 400 | if (args_info->sele2_orig) { | 
| 401 | fprintf(outfile, "%s=\"%s\"\n", "sele2", args_info->sele2_orig); | 
| 402 | } else { | 
| 403 | fprintf(outfile, "%s\n", "sele2"); | 
| 404 | } | 
| 405 | } | 
| 406 | if (args_info->sele3_given) { | 
| 407 | if (args_info->sele3_orig) { | 
| 408 | fprintf(outfile, "%s=\"%s\"\n", "sele3", args_info->sele3_orig); | 
| 409 | } else { | 
| 410 | fprintf(outfile, "%s\n", "sele3"); | 
| 411 | } | 
| 412 | } | 
| 413 | if (args_info->refsele_given) { | 
| 414 | if (args_info->refsele_orig) { | 
| 415 | fprintf(outfile, "%s=\"%s\"\n", "refsele", args_info->refsele_orig); | 
| 416 | } else { | 
| 417 | fprintf(outfile, "%s\n", "refsele"); | 
| 418 | } | 
| 419 | } | 
| 420 | if (args_info->molname_given) { | 
| 421 | if (args_info->molname_orig) { | 
| 422 | fprintf(outfile, "%s=\"%s\"\n", "molname", args_info->molname_orig); | 
| 423 | } else { | 
| 424 | fprintf(outfile, "%s\n", "molname"); | 
| 425 | } | 
| 426 | } | 
| 427 | if (args_info->begin_given) { | 
| 428 | if (args_info->begin_orig) { | 
| 429 | fprintf(outfile, "%s=\"%s\"\n", "begin", args_info->begin_orig); | 
| 430 | } else { | 
| 431 | fprintf(outfile, "%s\n", "begin"); | 
| 432 | } | 
| 433 | } | 
| 434 | if (args_info->end_given) { | 
| 435 | if (args_info->end_orig) { | 
| 436 | fprintf(outfile, "%s=\"%s\"\n", "end", args_info->end_orig); | 
| 437 | } else { | 
| 438 | fprintf(outfile, "%s\n", "end"); | 
| 439 | } | 
| 440 | } | 
| 441 | if (args_info->radius_given) { | 
| 442 | if (args_info->radius_orig) { | 
| 443 | fprintf(outfile, "%s=\"%s\"\n", "radius", args_info->radius_orig); | 
| 444 | } else { | 
| 445 | fprintf(outfile, "%s\n", "radius"); | 
| 446 | } | 
| 447 | } | 
| 448 | if (args_info->bo_given) { | 
| 449 | fprintf(outfile, "%s\n", "bo"); | 
| 450 | } | 
| 451 | if (args_info->gofr_given) { | 
| 452 | fprintf(outfile, "%s\n", "gofr"); | 
| 453 | } | 
| 454 | if (args_info->r_theta_given) { | 
| 455 | fprintf(outfile, "%s\n", "r_theta"); | 
| 456 | } | 
| 457 | if (args_info->r_omega_given) { | 
| 458 | fprintf(outfile, "%s\n", "r_omega"); | 
| 459 | } | 
| 460 | if (args_info->theta_omega_given) { | 
| 461 | fprintf(outfile, "%s\n", "theta_omega"); | 
| 462 | } | 
| 463 | if (args_info->gxyz_given) { | 
| 464 | fprintf(outfile, "%s\n", "gxyz"); | 
| 465 | } | 
| 466 | if (args_info->p2_given) { | 
| 467 | fprintf(outfile, "%s\n", "p2"); | 
| 468 | } | 
| 469 | if (args_info->rp2_given) { | 
| 470 | fprintf(outfile, "%s\n", "rp2"); | 
| 471 | } | 
| 472 | if (args_info->scd_given) { | 
| 473 | fprintf(outfile, "%s\n", "scd"); | 
| 474 | } | 
| 475 | if (args_info->density_given) { | 
| 476 | fprintf(outfile, "%s\n", "density"); | 
| 477 | } | 
| 478 | if (args_info->slab_density_given) { | 
| 479 | fprintf(outfile, "%s\n", "slab_density"); | 
| 480 | } | 
| 481 | if (args_info->hxy_given) { | 
| 482 | fprintf(outfile, "%s\n", "hxy"); | 
| 483 | } | 
| 484 | if (args_info->rho_r_given) { | 
| 485 | fprintf(outfile, "%s\n", "rho_r"); | 
| 486 | } | 
| 487 |  | 
| 488 | fclose (outfile); | 
| 489 |  | 
| 490 | i = EXIT_SUCCESS; | 
| 491 | return i; | 
| 492 | } | 
| 493 |  | 
| 494 | void | 
| 495 | cmdline_parser_free (struct gengetopt_args_info *args_info) | 
| 496 | { | 
| 497 | cmdline_parser_release (args_info); | 
| 498 | } | 
| 499 |  | 
| 500 |  | 
| 501 | /* gengetopt_strdup() */ | 
| 502 | /* strdup.c replacement of strdup, which is not standard */ | 
| 503 | char * | 
| 504 | gengetopt_strdup (const char *s) | 
| 505 | { | 
| 506 | char *result = NULL; | 
| 507 | if (!s) | 
| 508 | return result; | 
| 509 |  | 
| 510 | result = (char*)malloc(strlen(s) + 1); | 
| 511 | if (result == (char*)0) | 
| 512 | return (char*)0; | 
| 513 | strcpy(result, s); | 
| 514 | return result; | 
| 515 | } | 
| 516 |  | 
| 517 | static void | 
| 518 | reset_group_staticProps(struct gengetopt_args_info *args_info); | 
| 519 |  | 
| 520 | static void | 
| 521 | reset_group_staticProps(struct gengetopt_args_info *args_info) | 
| 522 | { | 
| 523 | if (! args_info->staticProps_group_counter) | 
| 524 | return; | 
| 525 |  | 
| 526 | args_info->bo_given = 0 ; | 
| 527 | args_info->gofr_given = 0 ; | 
| 528 | args_info->r_theta_given = 0 ; | 
| 529 | args_info->r_omega_given = 0 ; | 
| 530 | args_info->theta_omega_given = 0 ; | 
| 531 | args_info->gxyz_given = 0 ; | 
| 532 | args_info->p2_given = 0 ; | 
| 533 | args_info->rp2_given = 0 ; | 
| 534 | args_info->scd_given = 0 ; | 
| 535 | args_info->density_given = 0 ; | 
| 536 | args_info->slab_density_given = 0 ; | 
| 537 | args_info->hxy_given = 0 ; | 
| 538 | args_info->rho_r_given = 0 ; | 
| 539 |  | 
| 540 | args_info->staticProps_group_counter = 0; | 
| 541 | } | 
| 542 |  | 
| 543 | int | 
| 544 | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) | 
| 545 | { | 
| 546 | return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); | 
| 547 | } | 
| 548 |  | 
| 549 | int | 
| 550 | cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) | 
| 551 | { | 
| 552 | int result; | 
| 553 |  | 
| 554 | result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); | 
| 555 |  | 
| 556 | if (result == EXIT_FAILURE) | 
| 557 | { | 
| 558 | cmdline_parser_free (args_info); | 
| 559 | exit (EXIT_FAILURE); | 
| 560 | } | 
| 561 |  | 
| 562 | return result; | 
| 563 | } | 
| 564 |  | 
| 565 | int | 
| 566 | cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) | 
| 567 | { | 
| 568 | int result = EXIT_SUCCESS; | 
| 569 |  | 
| 570 | if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) | 
| 571 | result = EXIT_FAILURE; | 
| 572 |  | 
| 573 | if (result == EXIT_FAILURE) | 
| 574 | { | 
| 575 | cmdline_parser_free (args_info); | 
| 576 | exit (EXIT_FAILURE); | 
| 577 | } | 
| 578 |  | 
| 579 | return result; | 
| 580 | } | 
| 581 |  | 
| 582 | int | 
| 583 | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) | 
| 584 | { | 
| 585 | int error = 0; | 
| 586 |  | 
| 587 | if (! args_info->input_given) | 
| 588 | { | 
| 589 | fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); | 
| 590 | error = 1; | 
| 591 | } | 
| 592 | if (args_info->staticProps_group_counter == 0) | 
| 593 | { | 
| 594 | fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", prog_name, args_info->staticProps_group_counter, (additional_error ? additional_error : "")); | 
| 595 | error = 1; | 
| 596 | } | 
| 597 |  | 
| 598 |  | 
| 599 | return error; | 
| 600 | } | 
| 601 |  | 
| 602 | int | 
| 603 | cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) | 
| 604 | { | 
| 605 | int c;        /* Character of the parsed option.  */ | 
| 606 |  | 
| 607 | int error = 0; | 
| 608 | struct gengetopt_args_info local_args_info; | 
| 609 |  | 
| 610 | if (initialize) | 
| 611 | cmdline_parser_init (args_info); | 
| 612 |  | 
| 613 | cmdline_parser_init (&local_args_info); | 
| 614 |  | 
| 615 | optarg = 0; | 
| 616 | optind = 1; | 
| 617 | opterr = 1; | 
| 618 | optopt = '?'; | 
| 619 |  | 
| 620 | while (1) | 
| 621 | { | 
| 622 | int option_index = 0; | 
| 623 | char *stop_char; | 
| 624 |  | 
| 625 | static struct option long_options[] = { | 
| 626 | { "help",       0, NULL, 'h' }, | 
| 627 | { "version",    0, NULL, 'V' }, | 
| 628 | { "input",      1, NULL, 'i' }, | 
| 629 | { "output",     1, NULL, 'o' }, | 
| 630 | { "step",       1, NULL, 'n' }, | 
| 631 | { "nbins",      1, NULL, 'b' }, | 
| 632 | { "nbins_x",    1, NULL, 'x' }, | 
| 633 | { "nbins_y",    1, NULL, 'y' }, | 
| 634 | { "nanglebins", 1, NULL, 'a' }, | 
| 635 | { "length",     1, NULL, 0 }, | 
| 636 | { "rcut",       1, NULL, 'c' }, | 
| 637 | { "zoffset",    1, NULL, 'z' }, | 
| 638 | { "sele1",      1, NULL, 0 }, | 
| 639 | { "sele2",      1, NULL, 0 }, | 
| 640 | { "sele3",      1, NULL, 0 }, | 
| 641 | { "refsele",    1, NULL, 0 }, | 
| 642 | { "molname",    1, NULL, 0 }, | 
| 643 | { "begin",      1, NULL, 0 }, | 
| 644 | { "end",        1, NULL, 0 }, | 
| 645 | { "radius",     1, NULL, 0 }, | 
| 646 | { "bo", 0, NULL, 0 }, | 
| 647 | { "gofr",       0, NULL, 'g' }, | 
| 648 | { "r_theta",    0, NULL, 0 }, | 
| 649 | { "r_omega",    0, NULL, 0 }, | 
| 650 | { "theta_omega",        0, NULL, 0 }, | 
| 651 | { "gxyz",       0, NULL, 0 }, | 
| 652 | { "p2", 0, NULL, 'p' }, | 
| 653 | { "rp2",        0, NULL, 0 }, | 
| 654 | { "scd",        0, NULL, 's' }, | 
| 655 | { "density",    0, NULL, 'd' }, | 
| 656 | { "slab_density",       0, NULL, 0 }, | 
| 657 | { "hxy",        0, NULL, 0 }, | 
| 658 | { "rho_r",      0, NULL, 0 }, | 
| 659 | { NULL, 0, NULL, 0 } | 
| 660 | }; | 
| 661 |  | 
| 662 | stop_char = 0; | 
| 663 | c = getopt_long (argc, argv, "hVi:o:n:b:x:y:a:c:z:gpsd", long_options, &option_index); | 
| 664 |  | 
| 665 | if (c == -1) break;       /* Exit from `while (1)' loop.  */ | 
| 666 |  | 
| 667 | switch (c) | 
| 668 | { | 
| 669 | case 'h':       /* Print help and exit.  */ | 
| 670 | cmdline_parser_print_help (); | 
| 671 | cmdline_parser_free (&local_args_info); | 
| 672 | exit (EXIT_SUCCESS); | 
| 673 |  | 
| 674 | case 'V':       /* Print version and exit.  */ | 
| 675 | cmdline_parser_print_version (); | 
| 676 | cmdline_parser_free (&local_args_info); | 
| 677 | exit (EXIT_SUCCESS); | 
| 678 |  | 
| 679 | case 'i':       /* input dump file.  */ | 
| 680 | if (local_args_info.input_given) | 
| 681 | { | 
| 682 | fprintf (stderr, "%s: `--input' (`-i') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 683 | goto failure; | 
| 684 | } | 
| 685 | if (args_info->input_given && ! override) | 
| 686 | continue; | 
| 687 | local_args_info.input_given = 1; | 
| 688 | args_info->input_given = 1; | 
| 689 | if (args_info->input_arg) | 
| 690 | free (args_info->input_arg); /* free previous string */ | 
| 691 | args_info->input_arg = gengetopt_strdup (optarg); | 
| 692 | if (args_info->input_orig) | 
| 693 | free (args_info->input_orig); /* free previous string */ | 
| 694 | args_info->input_orig = gengetopt_strdup (optarg); | 
| 695 | break; | 
| 696 |  | 
| 697 | case 'o':       /* output file name.  */ | 
| 698 | if (local_args_info.output_given) | 
| 699 | { | 
| 700 | fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 701 | goto failure; | 
| 702 | } | 
| 703 | if (args_info->output_given && ! override) | 
| 704 | continue; | 
| 705 | local_args_info.output_given = 1; | 
| 706 | args_info->output_given = 1; | 
| 707 | if (args_info->output_arg) | 
| 708 | free (args_info->output_arg); /* free previous string */ | 
| 709 | args_info->output_arg = gengetopt_strdup (optarg); | 
| 710 | if (args_info->output_orig) | 
| 711 | free (args_info->output_orig); /* free previous string */ | 
| 712 | args_info->output_orig = gengetopt_strdup (optarg); | 
| 713 | break; | 
| 714 |  | 
| 715 | case 'n':       /* process every n frame.  */ | 
| 716 | if (local_args_info.step_given) | 
| 717 | { | 
| 718 | fprintf (stderr, "%s: `--step' (`-n') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 719 | goto failure; | 
| 720 | } | 
| 721 | if (args_info->step_given && ! override) | 
| 722 | continue; | 
| 723 | local_args_info.step_given = 1; | 
| 724 | args_info->step_given = 1; | 
| 725 | args_info->step_arg = strtol (optarg, &stop_char, 0); | 
| 726 | if (!(stop_char && *stop_char == '\0')) { | 
| 727 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 728 | goto failure; | 
| 729 | } | 
| 730 | if (args_info->step_orig) | 
| 731 | free (args_info->step_orig); /* free previous string */ | 
| 732 | args_info->step_orig = gengetopt_strdup (optarg); | 
| 733 | break; | 
| 734 |  | 
| 735 | case 'b':       /* number of bins (general purpose).  */ | 
| 736 | if (local_args_info.nbins_given) | 
| 737 | { | 
| 738 | fprintf (stderr, "%s: `--nbins' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 739 | goto failure; | 
| 740 | } | 
| 741 | if (args_info->nbins_given && ! override) | 
| 742 | continue; | 
| 743 | local_args_info.nbins_given = 1; | 
| 744 | args_info->nbins_given = 1; | 
| 745 | args_info->nbins_arg = strtol (optarg, &stop_char, 0); | 
| 746 | if (!(stop_char && *stop_char == '\0')) { | 
| 747 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 748 | goto failure; | 
| 749 | } | 
| 750 | if (args_info->nbins_orig) | 
| 751 | free (args_info->nbins_orig); /* free previous string */ | 
| 752 | args_info->nbins_orig = gengetopt_strdup (optarg); | 
| 753 | break; | 
| 754 |  | 
| 755 | case 'x':       /* number of bins in x axis.  */ | 
| 756 | if (local_args_info.nbins_x_given) | 
| 757 | { | 
| 758 | fprintf (stderr, "%s: `--nbins_x' (`-x') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 759 | goto failure; | 
| 760 | } | 
| 761 | if (args_info->nbins_x_given && ! override) | 
| 762 | continue; | 
| 763 | local_args_info.nbins_x_given = 1; | 
| 764 | args_info->nbins_x_given = 1; | 
| 765 | args_info->nbins_x_arg = strtol (optarg, &stop_char, 0); | 
| 766 | if (!(stop_char && *stop_char == '\0')) { | 
| 767 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 768 | goto failure; | 
| 769 | } | 
| 770 | if (args_info->nbins_x_orig) | 
| 771 | free (args_info->nbins_x_orig); /* free previous string */ | 
| 772 | args_info->nbins_x_orig = gengetopt_strdup (optarg); | 
| 773 | break; | 
| 774 |  | 
| 775 | case 'y':       /* number of bins in y axis.  */ | 
| 776 | if (local_args_info.nbins_y_given) | 
| 777 | { | 
| 778 | fprintf (stderr, "%s: `--nbins_y' (`-y') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 779 | goto failure; | 
| 780 | } | 
| 781 | if (args_info->nbins_y_given && ! override) | 
| 782 | continue; | 
| 783 | local_args_info.nbins_y_given = 1; | 
| 784 | args_info->nbins_y_given = 1; | 
| 785 | args_info->nbins_y_arg = strtol (optarg, &stop_char, 0); | 
| 786 | if (!(stop_char && *stop_char == '\0')) { | 
| 787 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 788 | goto failure; | 
| 789 | } | 
| 790 | if (args_info->nbins_y_orig) | 
| 791 | free (args_info->nbins_y_orig); /* free previous string */ | 
| 792 | args_info->nbins_y_orig = gengetopt_strdup (optarg); | 
| 793 | break; | 
| 794 |  | 
| 795 | case 'a':       /* number of bins for cos(angle).  */ | 
| 796 | if (local_args_info.nanglebins_given) | 
| 797 | { | 
| 798 | fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 799 | goto failure; | 
| 800 | } | 
| 801 | if (args_info->nanglebins_given && ! override) | 
| 802 | continue; | 
| 803 | local_args_info.nanglebins_given = 1; | 
| 804 | args_info->nanglebins_given = 1; | 
| 805 | args_info->nanglebins_arg = strtol (optarg, &stop_char, 0); | 
| 806 | if (!(stop_char && *stop_char == '\0')) { | 
| 807 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 808 | goto failure; | 
| 809 | } | 
| 810 | if (args_info->nanglebins_orig) | 
| 811 | free (args_info->nanglebins_orig); /* free previous string */ | 
| 812 | args_info->nanglebins_orig = gengetopt_strdup (optarg); | 
| 813 | break; | 
| 814 |  | 
| 815 | case 'c':       /* cutoff radius (rcut).  */ | 
| 816 | if (local_args_info.rcut_given) | 
| 817 | { | 
| 818 | fprintf (stderr, "%s: `--rcut' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 819 | goto failure; | 
| 820 | } | 
| 821 | if (args_info->rcut_given && ! override) | 
| 822 | continue; | 
| 823 | local_args_info.rcut_given = 1; | 
| 824 | args_info->rcut_given = 1; | 
| 825 | args_info->rcut_arg = strtod (optarg, &stop_char); | 
| 826 | if (!(stop_char && *stop_char == '\0')) { | 
| 827 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 828 | goto failure; | 
| 829 | } | 
| 830 | if (args_info->rcut_orig) | 
| 831 | free (args_info->rcut_orig); /* free previous string */ | 
| 832 | args_info->rcut_orig = gengetopt_strdup (optarg); | 
| 833 | break; | 
| 834 |  | 
| 835 | case 'z':       /* Where to set the zero for the slab_density calculation.  */ | 
| 836 | if (local_args_info.zoffset_given) | 
| 837 | { | 
| 838 | fprintf (stderr, "%s: `--zoffset' (`-z') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 839 | goto failure; | 
| 840 | } | 
| 841 | if (args_info->zoffset_given && ! override) | 
| 842 | continue; | 
| 843 | local_args_info.zoffset_given = 1; | 
| 844 | args_info->zoffset_given = 1; | 
| 845 | args_info->zoffset_arg = strtod (optarg, &stop_char); | 
| 846 | if (!(stop_char && *stop_char == '\0')) { | 
| 847 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 848 | goto failure; | 
| 849 | } | 
| 850 | if (args_info->zoffset_orig) | 
| 851 | free (args_info->zoffset_orig); /* free previous string */ | 
| 852 | args_info->zoffset_orig = gengetopt_strdup (optarg); | 
| 853 | break; | 
| 854 |  | 
| 855 | case 'g':       /* g(r).  */ | 
| 856 | if (local_args_info.gofr_given) | 
| 857 | { | 
| 858 | fprintf (stderr, "%s: `--gofr' (`-g') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 859 | goto failure; | 
| 860 | } | 
| 861 | if (args_info->gofr_given && ! override) | 
| 862 | continue; | 
| 863 | local_args_info.gofr_given = 1; | 
| 864 | args_info->gofr_given = 1; | 
| 865 | if (args_info->staticProps_group_counter && override) | 
| 866 | reset_group_staticProps (args_info); | 
| 867 | args_info->staticProps_group_counter += 1; | 
| 868 | break; | 
| 869 |  | 
| 870 | case 'p':       /* p2 order parameter (--sele1 and --sele2 must be specified).  */ | 
| 871 | if (local_args_info.p2_given) | 
| 872 | { | 
| 873 | fprintf (stderr, "%s: `--p2' (`-p') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 874 | goto failure; | 
| 875 | } | 
| 876 | if (args_info->p2_given && ! override) | 
| 877 | continue; | 
| 878 | local_args_info.p2_given = 1; | 
| 879 | args_info->p2_given = 1; | 
| 880 | if (args_info->staticProps_group_counter && override) | 
| 881 | reset_group_staticProps (args_info); | 
| 882 | args_info->staticProps_group_counter += 1; | 
| 883 | break; | 
| 884 |  | 
| 885 | case 's':       /* scd order parameter (either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified).  */ | 
| 886 | if (local_args_info.scd_given) | 
| 887 | { | 
| 888 | fprintf (stderr, "%s: `--scd' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 889 | goto failure; | 
| 890 | } | 
| 891 | if (args_info->scd_given && ! override) | 
| 892 | continue; | 
| 893 | local_args_info.scd_given = 1; | 
| 894 | args_info->scd_given = 1; | 
| 895 | if (args_info->staticProps_group_counter && override) | 
| 896 | reset_group_staticProps (args_info); | 
| 897 | args_info->staticProps_group_counter += 1; | 
| 898 | break; | 
| 899 |  | 
| 900 | case 'd':       /* density plot.  */ | 
| 901 | if (local_args_info.density_given) | 
| 902 | { | 
| 903 | fprintf (stderr, "%s: `--density' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 904 | goto failure; | 
| 905 | } | 
| 906 | if (args_info->density_given && ! override) | 
| 907 | continue; | 
| 908 | local_args_info.density_given = 1; | 
| 909 | args_info->density_given = 1; | 
| 910 | if (args_info->staticProps_group_counter && override) | 
| 911 | reset_group_staticProps (args_info); | 
| 912 | args_info->staticProps_group_counter += 1; | 
| 913 | break; | 
| 914 |  | 
| 915 |  | 
| 916 | case 0: /* Long option with no short option */ | 
| 917 | /* maximum length (Defaults to 1/2 smallest length of first frame).  */ | 
| 918 | if (strcmp (long_options[option_index].name, "length") == 0) | 
| 919 | { | 
| 920 | if (local_args_info.length_given) | 
| 921 | { | 
| 922 | fprintf (stderr, "%s: `--length' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 923 | goto failure; | 
| 924 | } | 
| 925 | if (args_info->length_given && ! override) | 
| 926 | continue; | 
| 927 | local_args_info.length_given = 1; | 
| 928 | args_info->length_given = 1; | 
| 929 | args_info->length_arg = strtod (optarg, &stop_char); | 
| 930 | if (!(stop_char && *stop_char == '\0')) { | 
| 931 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 932 | goto failure; | 
| 933 | } | 
| 934 | if (args_info->length_orig) | 
| 935 | free (args_info->length_orig); /* free previous string */ | 
| 936 | args_info->length_orig = gengetopt_strdup (optarg); | 
| 937 | } | 
| 938 | /* select the first stuntdouble set.  */ | 
| 939 | else if (strcmp (long_options[option_index].name, "sele1") == 0) | 
| 940 | { | 
| 941 | if (local_args_info.sele1_given) | 
| 942 | { | 
| 943 | fprintf (stderr, "%s: `--sele1' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 944 | goto failure; | 
| 945 | } | 
| 946 | if (args_info->sele1_given && ! override) | 
| 947 | continue; | 
| 948 | local_args_info.sele1_given = 1; | 
| 949 | args_info->sele1_given = 1; | 
| 950 | if (args_info->sele1_arg) | 
| 951 | free (args_info->sele1_arg); /* free previous string */ | 
| 952 | args_info->sele1_arg = gengetopt_strdup (optarg); | 
| 953 | if (args_info->sele1_orig) | 
| 954 | free (args_info->sele1_orig); /* free previous string */ | 
| 955 | args_info->sele1_orig = gengetopt_strdup (optarg); | 
| 956 | } | 
| 957 | /* select the second stuntdouble set.  */ | 
| 958 | else if (strcmp (long_options[option_index].name, "sele2") == 0) | 
| 959 | { | 
| 960 | if (local_args_info.sele2_given) | 
| 961 | { | 
| 962 | fprintf (stderr, "%s: `--sele2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 963 | goto failure; | 
| 964 | } | 
| 965 | if (args_info->sele2_given && ! override) | 
| 966 | continue; | 
| 967 | local_args_info.sele2_given = 1; | 
| 968 | args_info->sele2_given = 1; | 
| 969 | if (args_info->sele2_arg) | 
| 970 | free (args_info->sele2_arg); /* free previous string */ | 
| 971 | args_info->sele2_arg = gengetopt_strdup (optarg); | 
| 972 | if (args_info->sele2_orig) | 
| 973 | free (args_info->sele2_orig); /* free previous string */ | 
| 974 | args_info->sele2_orig = gengetopt_strdup (optarg); | 
| 975 | } | 
| 976 | /* select the third stuntdouble set.  */ | 
| 977 | else if (strcmp (long_options[option_index].name, "sele3") == 0) | 
| 978 | { | 
| 979 | if (local_args_info.sele3_given) | 
| 980 | { | 
| 981 | fprintf (stderr, "%s: `--sele3' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 982 | goto failure; | 
| 983 | } | 
| 984 | if (args_info->sele3_given && ! override) | 
| 985 | continue; | 
| 986 | local_args_info.sele3_given = 1; | 
| 987 | args_info->sele3_given = 1; | 
| 988 | if (args_info->sele3_arg) | 
| 989 | free (args_info->sele3_arg); /* free previous string */ | 
| 990 | args_info->sele3_arg = gengetopt_strdup (optarg); | 
| 991 | if (args_info->sele3_orig) | 
| 992 | free (args_info->sele3_orig); /* free previous string */ | 
| 993 | args_info->sele3_orig = gengetopt_strdup (optarg); | 
| 994 | } | 
| 995 | /* select reference (use and only use with --gxyz).  */ | 
| 996 | else if (strcmp (long_options[option_index].name, "refsele") == 0) | 
| 997 | { | 
| 998 | if (local_args_info.refsele_given) | 
| 999 | { | 
| 1000 | fprintf (stderr, "%s: `--refsele' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1001 | goto failure; | 
| 1002 | } | 
| 1003 | if (args_info->refsele_given && ! override) | 
| 1004 | continue; | 
| 1005 | local_args_info.refsele_given = 1; | 
| 1006 | args_info->refsele_given = 1; | 
| 1007 | if (args_info->refsele_arg) | 
| 1008 | free (args_info->refsele_arg); /* free previous string */ | 
| 1009 | args_info->refsele_arg = gengetopt_strdup (optarg); | 
| 1010 | if (args_info->refsele_orig) | 
| 1011 | free (args_info->refsele_orig); /* free previous string */ | 
| 1012 | args_info->refsele_orig = gengetopt_strdup (optarg); | 
| 1013 | } | 
| 1014 | /* molecule name.  */ | 
| 1015 | else if (strcmp (long_options[option_index].name, "molname") == 0) | 
| 1016 | { | 
| 1017 | if (local_args_info.molname_given) | 
| 1018 | { | 
| 1019 | fprintf (stderr, "%s: `--molname' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1020 | goto failure; | 
| 1021 | } | 
| 1022 | if (args_info->molname_given && ! override) | 
| 1023 | continue; | 
| 1024 | local_args_info.molname_given = 1; | 
| 1025 | args_info->molname_given = 1; | 
| 1026 | if (args_info->molname_arg) | 
| 1027 | free (args_info->molname_arg); /* free previous string */ | 
| 1028 | args_info->molname_arg = gengetopt_strdup (optarg); | 
| 1029 | if (args_info->molname_orig) | 
| 1030 | free (args_info->molname_orig); /* free previous string */ | 
| 1031 | args_info->molname_orig = gengetopt_strdup (optarg); | 
| 1032 | } | 
| 1033 | /* begin internal index.  */ | 
| 1034 | else if (strcmp (long_options[option_index].name, "begin") == 0) | 
| 1035 | { | 
| 1036 | if (local_args_info.begin_given) | 
| 1037 | { | 
| 1038 | fprintf (stderr, "%s: `--begin' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1039 | goto failure; | 
| 1040 | } | 
| 1041 | if (args_info->begin_given && ! override) | 
| 1042 | continue; | 
| 1043 | local_args_info.begin_given = 1; | 
| 1044 | args_info->begin_given = 1; | 
| 1045 | args_info->begin_arg = strtol (optarg, &stop_char, 0); | 
| 1046 | if (!(stop_char && *stop_char == '\0')) { | 
| 1047 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 1048 | goto failure; | 
| 1049 | } | 
| 1050 | if (args_info->begin_orig) | 
| 1051 | free (args_info->begin_orig); /* free previous string */ | 
| 1052 | args_info->begin_orig = gengetopt_strdup (optarg); | 
| 1053 | } | 
| 1054 | /* end internal index.  */ | 
| 1055 | else if (strcmp (long_options[option_index].name, "end") == 0) | 
| 1056 | { | 
| 1057 | if (local_args_info.end_given) | 
| 1058 | { | 
| 1059 | fprintf (stderr, "%s: `--end' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1060 | goto failure; | 
| 1061 | } | 
| 1062 | if (args_info->end_given && ! override) | 
| 1063 | continue; | 
| 1064 | local_args_info.end_given = 1; | 
| 1065 | args_info->end_given = 1; | 
| 1066 | args_info->end_arg = strtol (optarg, &stop_char, 0); | 
| 1067 | if (!(stop_char && *stop_char == '\0')) { | 
| 1068 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 1069 | goto failure; | 
| 1070 | } | 
| 1071 | if (args_info->end_orig) | 
| 1072 | free (args_info->end_orig); /* free previous string */ | 
| 1073 | args_info->end_orig = gengetopt_strdup (optarg); | 
| 1074 | } | 
| 1075 | /* nanoparticle radius.  */ | 
| 1076 | else if (strcmp (long_options[option_index].name, "radius") == 0) | 
| 1077 | { | 
| 1078 | if (local_args_info.radius_given) | 
| 1079 | { | 
| 1080 | fprintf (stderr, "%s: `--radius' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1081 | goto failure; | 
| 1082 | } | 
| 1083 | if (args_info->radius_given && ! override) | 
| 1084 | continue; | 
| 1085 | local_args_info.radius_given = 1; | 
| 1086 | args_info->radius_given = 1; | 
| 1087 | args_info->radius_arg = strtod (optarg, &stop_char); | 
| 1088 | if (!(stop_char && *stop_char == '\0')) { | 
| 1089 | fprintf(stderr, "%s: invalid numeric value: %s\n", argv[0], optarg); | 
| 1090 | goto failure; | 
| 1091 | } | 
| 1092 | if (args_info->radius_orig) | 
| 1093 | free (args_info->radius_orig); /* free previous string */ | 
| 1094 | args_info->radius_orig = gengetopt_strdup (optarg); | 
| 1095 | } | 
| 1096 | /* bond order parameter (--rcut must be specified.  */ | 
| 1097 | else if (strcmp (long_options[option_index].name, "bo") == 0) | 
| 1098 | { | 
| 1099 | if (local_args_info.bo_given) | 
| 1100 | { | 
| 1101 | fprintf (stderr, "%s: `--bo' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1102 | goto failure; | 
| 1103 | } | 
| 1104 | if (args_info->bo_given && ! override) | 
| 1105 | continue; | 
| 1106 | local_args_info.bo_given = 1; | 
| 1107 | args_info->bo_given = 1; | 
| 1108 | if (args_info->staticProps_group_counter && override) | 
| 1109 | reset_group_staticProps (args_info); | 
| 1110 | args_info->staticProps_group_counter += 1; | 
| 1111 | break; | 
| 1112 | } | 
| 1113 | /* g(r, cos(theta)).  */ | 
| 1114 | else if (strcmp (long_options[option_index].name, "r_theta") == 0) | 
| 1115 | { | 
| 1116 | if (local_args_info.r_theta_given) | 
| 1117 | { | 
| 1118 | fprintf (stderr, "%s: `--r_theta' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1119 | goto failure; | 
| 1120 | } | 
| 1121 | if (args_info->r_theta_given && ! override) | 
| 1122 | continue; | 
| 1123 | local_args_info.r_theta_given = 1; | 
| 1124 | args_info->r_theta_given = 1; | 
| 1125 | if (args_info->staticProps_group_counter && override) | 
| 1126 | reset_group_staticProps (args_info); | 
| 1127 | args_info->staticProps_group_counter += 1; | 
| 1128 | break; | 
| 1129 | } | 
| 1130 | /* g(r, cos(omega)).  */ | 
| 1131 | else if (strcmp (long_options[option_index].name, "r_omega") == 0) | 
| 1132 | { | 
| 1133 | if (local_args_info.r_omega_given) | 
| 1134 | { | 
| 1135 | fprintf (stderr, "%s: `--r_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1136 | goto failure; | 
| 1137 | } | 
| 1138 | if (args_info->r_omega_given && ! override) | 
| 1139 | continue; | 
| 1140 | local_args_info.r_omega_given = 1; | 
| 1141 | args_info->r_omega_given = 1; | 
| 1142 | if (args_info->staticProps_group_counter && override) | 
| 1143 | reset_group_staticProps (args_info); | 
| 1144 | args_info->staticProps_group_counter += 1; | 
| 1145 | break; | 
| 1146 | } | 
| 1147 | /* g(cos(theta), cos(omega)).  */ | 
| 1148 | else if (strcmp (long_options[option_index].name, "theta_omega") == 0) | 
| 1149 | { | 
| 1150 | if (local_args_info.theta_omega_given) | 
| 1151 | { | 
| 1152 | fprintf (stderr, "%s: `--theta_omega' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1153 | goto failure; | 
| 1154 | } | 
| 1155 | if (args_info->theta_omega_given && ! override) | 
| 1156 | continue; | 
| 1157 | local_args_info.theta_omega_given = 1; | 
| 1158 | args_info->theta_omega_given = 1; | 
| 1159 | if (args_info->staticProps_group_counter && override) | 
| 1160 | reset_group_staticProps (args_info); | 
| 1161 | args_info->staticProps_group_counter += 1; | 
| 1162 | break; | 
| 1163 | } | 
| 1164 | /* g(x, y, z).  */ | 
| 1165 | else if (strcmp (long_options[option_index].name, "gxyz") == 0) | 
| 1166 | { | 
| 1167 | if (local_args_info.gxyz_given) | 
| 1168 | { | 
| 1169 | fprintf (stderr, "%s: `--gxyz' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1170 | goto failure; | 
| 1171 | } | 
| 1172 | if (args_info->gxyz_given && ! override) | 
| 1173 | continue; | 
| 1174 | local_args_info.gxyz_given = 1; | 
| 1175 | args_info->gxyz_given = 1; | 
| 1176 | if (args_info->staticProps_group_counter && override) | 
| 1177 | reset_group_staticProps (args_info); | 
| 1178 | args_info->staticProps_group_counter += 1; | 
| 1179 | break; | 
| 1180 | } | 
| 1181 | /* rp2 order parameter (--sele1 and --sele2 must be specified).  */ | 
| 1182 | else if (strcmp (long_options[option_index].name, "rp2") == 0) | 
| 1183 | { | 
| 1184 | if (local_args_info.rp2_given) | 
| 1185 | { | 
| 1186 | fprintf (stderr, "%s: `--rp2' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1187 | goto failure; | 
| 1188 | } | 
| 1189 | if (args_info->rp2_given && ! override) | 
| 1190 | continue; | 
| 1191 | local_args_info.rp2_given = 1; | 
| 1192 | args_info->rp2_given = 1; | 
| 1193 | if (args_info->staticProps_group_counter && override) | 
| 1194 | reset_group_staticProps (args_info); | 
| 1195 | args_info->staticProps_group_counter += 1; | 
| 1196 | break; | 
| 1197 | } | 
| 1198 | /* slab density.  */ | 
| 1199 | else if (strcmp (long_options[option_index].name, "slab_density") == 0) | 
| 1200 | { | 
| 1201 | if (local_args_info.slab_density_given) | 
| 1202 | { | 
| 1203 | fprintf (stderr, "%s: `--slab_density' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1204 | goto failure; | 
| 1205 | } | 
| 1206 | if (args_info->slab_density_given && ! override) | 
| 1207 | continue; | 
| 1208 | local_args_info.slab_density_given = 1; | 
| 1209 | args_info->slab_density_given = 1; | 
| 1210 | if (args_info->staticProps_group_counter && override) | 
| 1211 | reset_group_staticProps (args_info); | 
| 1212 | args_info->staticProps_group_counter += 1; | 
| 1213 | break; | 
| 1214 | } | 
| 1215 | /* hxy.  */ | 
| 1216 | else if (strcmp (long_options[option_index].name, "hxy") == 0) | 
| 1217 | { | 
| 1218 | if (local_args_info.hxy_given) | 
| 1219 | { | 
| 1220 | fprintf (stderr, "%s: `--hxy' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1221 | goto failure; | 
| 1222 | } | 
| 1223 | if (args_info->hxy_given && ! override) | 
| 1224 | continue; | 
| 1225 | local_args_info.hxy_given = 1; | 
| 1226 | args_info->hxy_given = 1; | 
| 1227 | if (args_info->staticProps_group_counter && override) | 
| 1228 | reset_group_staticProps (args_info); | 
| 1229 | args_info->staticProps_group_counter += 1; | 
| 1230 | break; | 
| 1231 | } | 
| 1232 | /* rho of R.  */ | 
| 1233 | else if (strcmp (long_options[option_index].name, "rho_r") == 0) | 
| 1234 | { | 
| 1235 | if (local_args_info.rho_r_given) | 
| 1236 | { | 
| 1237 | fprintf (stderr, "%s: `--rho_r' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); | 
| 1238 | goto failure; | 
| 1239 | } | 
| 1240 | if (args_info->rho_r_given && ! override) | 
| 1241 | continue; | 
| 1242 | local_args_info.rho_r_given = 1; | 
| 1243 | args_info->rho_r_given = 1; | 
| 1244 | if (args_info->staticProps_group_counter && override) | 
| 1245 | reset_group_staticProps (args_info); | 
| 1246 | args_info->staticProps_group_counter += 1; | 
| 1247 | break; | 
| 1248 | } | 
| 1249 |  | 
| 1250 | break; | 
| 1251 | case '?':       /* Invalid option.  */ | 
| 1252 | /* `getopt_long' already printed an error message.  */ | 
| 1253 | goto failure; | 
| 1254 |  | 
| 1255 | default:        /* bug: option not considered.  */ | 
| 1256 | fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); | 
| 1257 | abort (); | 
| 1258 | } /* switch */ | 
| 1259 | } /* while */ | 
| 1260 |  | 
| 1261 | if (args_info->staticProps_group_counter > 1) | 
| 1262 | { | 
| 1263 | fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", argv[0], args_info->staticProps_group_counter, (additional_error ? additional_error : "")); | 
| 1264 | error = 1; | 
| 1265 | } | 
| 1266 |  | 
| 1267 |  | 
| 1268 |  | 
| 1269 | if (check_required) | 
| 1270 | { | 
| 1271 | error += cmdline_parser_required2 (args_info, argv[0], additional_error); | 
| 1272 | } | 
| 1273 |  | 
| 1274 | cmdline_parser_release (&local_args_info); | 
| 1275 |  | 
| 1276 | if ( error ) | 
| 1277 | return (EXIT_FAILURE); | 
| 1278 |  | 
| 1279 | return 0; | 
| 1280 |  | 
| 1281 | failure: | 
| 1282 |  | 
| 1283 | cmdline_parser_release (&local_args_info); | 
| 1284 | return (EXIT_FAILURE); | 
| 1285 | } |