| 35 |
|
printf("\n" |
| 36 |
|
"Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
| 37 |
|
printf("\n"); |
| 38 |
< |
printf(" -h, --help Print help and exit\n"); |
| 39 |
< |
printf(" -V, --version Print version and exit\n"); |
| 40 |
< |
printf(" -i, --input=filename input dump file\n"); |
| 41 |
< |
printf(" -o, --output=filename output file name\n"); |
| 42 |
< |
printf(" -n, --frame=INT print every n frame (default=`1')\n"); |
| 43 |
< |
printf(" -d, --dipole print the dipole moments (default=off)\n"); |
| 44 |
< |
printf(" -w, --water skip the the waters (default=off)\n"); |
| 45 |
< |
printf(" -m, --periodicBox map to the periodic box (default=off)\n"); |
| 46 |
< |
printf(" -z, --zconstraint replace the atom types of zconstraint \n molecules (default=off)\n"); |
| 47 |
< |
printf(" -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)\n"); |
| 48 |
< |
printf(" -t, --watertype replace the atom type of water model \n (default=on)\n"); |
| 49 |
< |
printf(" -g, --ignore=atomtype ignore the atom types\n"); |
| 50 |
< |
printf(" -s, --selection=selection script selection syntax:\n" |
| 51 |
< |
" select DMPC -- select DMPC molecule\n" |
| 52 |
< |
" select DMPC.* -- select all atoms and all rigidbodies belong to DMPC molecule(same as above)\n" |
| 53 |
< |
" select not DMPC -- select all atoms and all rigidbodies do not belong to DMPC molecule\n" |
| 54 |
< |
" select C* and 4 to 7 -- select stuntdoubles which match C* and which index is between [4, 7)\n" |
| 55 |
< |
" select 5 -- select stuntdobule whose global index is 5\n" |
| 56 |
< |
" select within (5.0, HDP or PO4) -- select stuntdoubles which is within 5 A to HDP or PO4\n" |
| 57 |
< |
" select DMPC.DMPC_RB_*.* --select atoms belong to rigid body inside DMPC molecule \n"); |
| 58 |
< |
printf(" --repeatX=INT The number of images to repeat in the x \n direction (default=`0')\n"); |
| 59 |
< |
printf(" --repeatY=INT The number of images to repeat in the y \n direction (default=`0')\n"); |
| 60 |
< |
printf(" --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')\n"); |
| 38 |
> |
printf(" -h, --help Print help and exit\n"); |
| 39 |
> |
printf(" -V, --version Print version and exit\n"); |
| 40 |
> |
printf(" -i, --input=filename input dump file\n"); |
| 41 |
> |
printf(" -o, --output=filename output file name\n"); |
| 42 |
> |
printf(" -n, --frame=INT print every n frame (default=`1')\n"); |
| 43 |
> |
printf(" -w, --water skip the the waters (default=off)\n"); |
| 44 |
> |
printf(" -m, --periodicBox map to the periodic box (default=off)\n"); |
| 45 |
> |
printf(" -z, --zconstraint replace the atom types of zconstraint \n molecules (default=off)\n"); |
| 46 |
> |
printf(" -r, --rigidbody add a pseudo COM atom to rigidbody \n (default=off)\n"); |
| 47 |
> |
printf(" -t, --watertype replace the atom type of water model \n (default=on)\n"); |
| 48 |
> |
printf(" -s, --selection=selection script general selection syntax(now only support \n select atoms within a specified range)\n"); |
| 49 |
> |
printf(" --originsele=selection script select origin\n"); |
| 50 |
> |
printf(" --refsele=selection script select reference\n"); |
| 51 |
> |
printf(" --repeatX=INT The number of images to repeat in the x \n direction (default=`0')\n"); |
| 52 |
> |
printf(" --repeatY=INT The number of images to repeat in the y \n direction (default=`0')\n"); |
| 53 |
> |
printf(" --repeatZ=INT The number of images to repeat in the z \n direction (default=`0')\n"); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
|
| 72 |
|
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 73 |
|
{ |
| 74 |
|
int c; /* Character of the parsed option. */ |
| 82 |
– |
int i; /* Counter */ |
| 83 |
– |
struct ignore_list |
| 84 |
– |
{ |
| 85 |
– |
char * ignore_arg; |
| 86 |
– |
struct ignore_list * next; |
| 87 |
– |
}; |
| 88 |
– |
struct ignore_list * ignore_list = NULL,* ignore_new = NULL; |
| 89 |
– |
|
| 75 |
|
int missing_required_options = 0; |
| 76 |
|
|
| 77 |
|
args_info->help_given = 0 ; |
| 79 |
|
args_info->input_given = 0 ; |
| 80 |
|
args_info->output_given = 0 ; |
| 81 |
|
args_info->frame_given = 0 ; |
| 97 |
– |
args_info->dipole_given = 0 ; |
| 82 |
|
args_info->water_given = 0 ; |
| 83 |
|
args_info->periodicBox_given = 0 ; |
| 84 |
|
args_info->zconstraint_given = 0 ; |
| 85 |
|
args_info->rigidbody_given = 0 ; |
| 86 |
|
args_info->watertype_given = 0 ; |
| 103 |
– |
args_info->ignore_given = 0 ; |
| 87 |
|
args_info->selection_given = 0 ; |
| 88 |
+ |
args_info->originsele_given = 0 ; |
| 89 |
+ |
args_info->refsele_given = 0 ; |
| 90 |
|
args_info->repeatX_given = 0 ; |
| 91 |
|
args_info->repeatY_given = 0 ; |
| 92 |
|
args_info->repeatZ_given = 0 ; |
| 94 |
|
args_info->input_arg = NULL; \ |
| 95 |
|
args_info->output_arg = NULL; \ |
| 96 |
|
args_info->frame_arg = 1 ;\ |
| 112 |
– |
args_info->dipole_flag = 0;\ |
| 97 |
|
args_info->water_flag = 0;\ |
| 98 |
|
args_info->periodicBox_flag = 0;\ |
| 99 |
|
args_info->zconstraint_flag = 0;\ |
| 100 |
|
args_info->rigidbody_flag = 0;\ |
| 101 |
|
args_info->watertype_flag = 1;\ |
| 118 |
– |
args_info->ignore_arg = NULL; \ |
| 102 |
|
args_info->selection_arg = NULL; \ |
| 103 |
+ |
args_info->originsele_arg = NULL; \ |
| 104 |
+ |
args_info->refsele_arg = NULL; \ |
| 105 |
|
args_info->repeatX_arg = 0 ;\ |
| 106 |
|
args_info->repeatY_arg = 0 ;\ |
| 107 |
|
args_info->repeatZ_arg = 0 ;\ |
| 125 |
|
{ "input", 1, NULL, 'i' }, |
| 126 |
|
{ "output", 1, NULL, 'o' }, |
| 127 |
|
{ "frame", 1, NULL, 'n' }, |
| 143 |
– |
{ "dipole", 0, NULL, 'd' }, |
| 128 |
|
{ "water", 0, NULL, 'w' }, |
| 129 |
|
{ "periodicBox", 0, NULL, 'm' }, |
| 130 |
|
{ "zconstraint", 0, NULL, 'z' }, |
| 131 |
|
{ "rigidbody", 0, NULL, 'r' }, |
| 132 |
|
{ "watertype", 0, NULL, 't' }, |
| 149 |
– |
{ "ignore", 1, NULL, 'g' }, |
| 133 |
|
{ "selection", 1, NULL, 's' }, |
| 134 |
+ |
{ "originsele", 1, NULL, 0 }, |
| 135 |
+ |
{ "refsele", 1, NULL, 0 }, |
| 136 |
|
{ "repeatX", 1, NULL, 0 }, |
| 137 |
|
{ "repeatY", 1, NULL, 0 }, |
| 138 |
|
{ "repeatZ", 1, NULL, 0 }, |
| 140 |
|
}; |
| 141 |
|
|
| 142 |
|
stop_char = 0; |
| 143 |
< |
c = getopt_long (argc, argv, "hVi:o:n:dwmzrtg:s:", long_options, &option_index); |
| 143 |
> |
c = getopt_long (argc, argv, "hVi:o:n:wmzrts:", long_options, &option_index); |
| 144 |
|
|
| 145 |
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
| 146 |
|
|
| 189 |
|
args_info->frame_arg = strtol (optarg,&stop_char,0); |
| 190 |
|
break; |
| 191 |
|
|
| 207 |
– |
case 'd': /* print the dipole moments. */ |
| 208 |
– |
if (args_info->dipole_given) |
| 209 |
– |
{ |
| 210 |
– |
fprintf (stderr, "%s: `--dipole' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 211 |
– |
clear_args (); |
| 212 |
– |
exit (EXIT_FAILURE); |
| 213 |
– |
} |
| 214 |
– |
args_info->dipole_given = 1; |
| 215 |
– |
args_info->dipole_flag = !(args_info->dipole_flag); |
| 216 |
– |
break; |
| 217 |
– |
|
| 192 |
|
case 'w': /* skip the the waters. */ |
| 193 |
|
if (args_info->water_given) |
| 194 |
|
{ |
| 244 |
|
args_info->watertype_flag = !(args_info->watertype_flag); |
| 245 |
|
break; |
| 246 |
|
|
| 247 |
< |
case 'g': /* ignore the atom types. */ |
| 274 |
< |
args_info->ignore_given++; |
| 275 |
< |
ignore_new = (struct ignore_list *) malloc (sizeof (struct ignore_list)); |
| 276 |
< |
ignore_new->next = ignore_list; |
| 277 |
< |
ignore_list = ignore_new; |
| 278 |
< |
ignore_new->ignore_arg = gengetopt_strdup (optarg); |
| 279 |
< |
break; |
| 280 |
< |
|
| 281 |
< |
case 's': /* general selection syntax:\n |
| 282 |
< |
select DMPC -- select DMPC molecule\n \ |
| 283 |
< |
select DMPC.* -- select all atoms and all rigidbodies belong to DMPC molecule\n \ |
| 284 |
< |
select 5 -- select stuntdobule whose global index is 5\n \ |
| 285 |
< |
select within (5.0, HDP or PO4) -- select stuntdoubles which is within 5 A to HDP or PO4\n \ |
| 286 |
< |
select DMPC.DMPC_RB_*.* --select atoms belong to rigid body inside DMPC molecule . */ |
| 247 |
> |
case 's': /* general selection syntax(now only support select atoms within a specified range). */ |
| 248 |
|
if (args_info->selection_given) |
| 249 |
|
{ |
| 250 |
|
fprintf (stderr, "%s: `--selection' (`-s') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 257 |
|
|
| 258 |
|
|
| 259 |
|
case 0: /* Long option with no short option */ |
| 260 |
+ |
/* select origin. */ |
| 261 |
+ |
if (strcmp (long_options[option_index].name, "originsele") == 0) |
| 262 |
+ |
{ |
| 263 |
+ |
if (args_info->originsele_given) |
| 264 |
+ |
{ |
| 265 |
+ |
fprintf (stderr, "%s: `--originsele' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 266 |
+ |
clear_args (); |
| 267 |
+ |
exit (EXIT_FAILURE); |
| 268 |
+ |
} |
| 269 |
+ |
args_info->originsele_given = 1; |
| 270 |
+ |
args_info->originsele_arg = gengetopt_strdup (optarg); |
| 271 |
+ |
break; |
| 272 |
+ |
} |
| 273 |
+ |
|
| 274 |
+ |
/* select reference. */ |
| 275 |
+ |
else if (strcmp (long_options[option_index].name, "refsele") == 0) |
| 276 |
+ |
{ |
| 277 |
+ |
if (args_info->refsele_given) |
| 278 |
+ |
{ |
| 279 |
+ |
fprintf (stderr, "%s: `--refsele' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 280 |
+ |
clear_args (); |
| 281 |
+ |
exit (EXIT_FAILURE); |
| 282 |
+ |
} |
| 283 |
+ |
args_info->refsele_given = 1; |
| 284 |
+ |
args_info->refsele_arg = gengetopt_strdup (optarg); |
| 285 |
+ |
break; |
| 286 |
+ |
} |
| 287 |
+ |
|
| 288 |
|
/* The number of images to repeat in the x direction. */ |
| 289 |
< |
if (strcmp (long_options[option_index].name, "repeatX") == 0) |
| 289 |
> |
else if (strcmp (long_options[option_index].name, "repeatX") == 0) |
| 290 |
|
{ |
| 291 |
|
if (args_info->repeatX_given) |
| 292 |
|
{ |
| 347 |
|
if ( missing_required_options ) |
| 348 |
|
exit (EXIT_FAILURE); |
| 349 |
|
|
| 361 |
– |
if (args_info->ignore_given) |
| 362 |
– |
{ |
| 363 |
– |
args_info->ignore_arg = (char * *) malloc (args_info->ignore_given * sizeof (char *)); |
| 364 |
– |
for (i = 0; i < args_info->ignore_given; i++) |
| 365 |
– |
{ |
| 366 |
– |
args_info->ignore_arg [i] = ignore_list->ignore_arg; |
| 367 |
– |
ignore_list = ignore_list->next; |
| 368 |
– |
} |
| 369 |
– |
} |
| 370 |
– |
|
| 350 |
|
return 0; |
| 351 |
|
} |