3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gromacs Runs On Most of All Computer Systems
46 int count
; /* sort order for output */
47 bool bObsolete
; /* whether it is an obsolete param value */
48 bool bSet
; /* whether it it has been read out */
49 char *name
; /* name of the parameter */
50 char *value
; /* parameter value string */
52 /* entry in input files (like .mdp files).
53 Initally read in with read_inpfile, then filled in with missing values
54 through get_eint, get_ereal, etc. */
58 extern t_inpfile
*read_inpfile(const char *fn
,int *ninp
,
60 /* Create & populate a t_inpfile struct from values in file fn.
62 ninp = the number of read parameters
63 cppopts = the cpp-style options for #include paths and #defines */
65 extern void write_inpfile(const char *fn
,int ninp
,t_inpfile inp
[],
68 extern void replace_inp_entry(int ninp
,t_inpfile
*inp
,
69 const char *old_entry
,const char *new_entry
);
71 extern int get_eint(int *ninp
,t_inpfile
**inp
,const char *name
,int def
);
73 extern gmx_large_int_t
get_egmx_large_int(int *ninp
,t_inpfile
**inp
,const char *name
,gmx_large_int_t def
);
75 extern double get_ereal(int *ninp
,t_inpfile
**inp
,const char *name
,double def
);
77 extern const char *get_estr(int *ninp
,t_inpfile
**inp
,const char *name
,const char *def
);
79 extern int get_eeenum(int *ninp
,t_inpfile
**inp
,const char *name
,const char **defs
,
80 int *nerror
,bool bPrintError
);
81 /* defs must be NULL terminated,
82 * Add errors to nerror
83 * When bPrintError=TRUE and invalid enum: print "ERROR: ..."
86 extern int get_eenum(int *ninp
,t_inpfile
**inp
,const char *name
,const char **defs
);
87 /* defs must be NULL terminated */
89 /* Here are some macros to extract data from the inp structures.
90 * Elements that are removed from the list after reading
92 #define REM_TYPE(name) replace_inp_entry(ninp,inp,name,NULL)
93 #define REPL_TYPE(old,new) replace_inp_entry(ninp,inp,old,new)
94 #define STYPE(name,var,def) if ((tmp=get_estr(&ninp,&inp,name,def)) != NULL) strcpy(var,tmp)
95 #define STYPENC(name,def) get_estr(&ninp,&inp,name,def)
96 #define ITYPE(name,var,def) var=get_eint(&ninp,&inp,name,def)
97 #define STEPTYPE(name,var,def) var=get_egmx_large_int(&ninp,&inp,name,def)
98 #define RTYPE(name,var,def) var=get_ereal(&ninp,&inp,name,def)
99 #define ETYPE(name,var,defs) var=get_eenum(&ninp,&inp,name,defs)
100 #define EETYPE(name,var,defs,nerr,bErr) var=get_eeenum(&ninp,&inp,name,defs,nerr,bErr)
101 #define CCTYPE(s) STYPENC("\n; "s,NULL)
102 #define CTYPE(s) STYPENC("; "s,NULL)
103 /* This last one prints a comment line where you can add some explanation */
105 /* This structure is used for parsing arguments off the comand line */
107 etINT
, etGMX_LARGE_INT
, etREAL
, etTIME
, etSTR
, etBOOL
, etRVEC
, etENUM
, etNR
110 /* names to print in help info */
111 static const char *argtp
[etNR
] = {
112 "int", "step", "real", "time", "string", "bool", "vector", "enum"
120 void *v
; /* This is a nasty workaround, to be able to use initialized */
124 const char **c
; /* Must be pointer to string (when type == etSTR) */
125 /* or null terminated list of enums (when type == etENUM) */
132 extern void get_pargs(int *argc
,char *argv
[],int nparg
,t_pargs pa
[],
134 /* Read a number of arguments from the command line.
135 * For etINT, etREAL and etCHAR an extra argument is read (when present)
136 * for etBOOL the boolean option is changed to the negate value
137 * If !bKeepArgs, the command line arguments are removed from the command line
140 extern bool is_hidden(t_pargs
*pa
);
141 /* Return TRUE when the option is a secret one */
143 extern char *pa_val(t_pargs
*pa
,char *buf
, int sz
);
144 /* Return the value of pa in the provided buffer buf, of size sz.
145 * The return value is also a pointer to buf.
148 extern int opt2parg_int(const char *option
,int nparg
,t_pargs pa
[]);
150 extern bool opt2parg_bool(const char *option
,int nparg
,t_pargs pa
[]);
152 extern real
opt2parg_real(const char *option
,int nparg
,t_pargs pa
[]);
154 extern const char *opt2parg_str(const char *option
,int nparg
,t_pargs pa
[]);
156 extern const char *opt2parg_enum(const char *option
,int nparg
,t_pargs pa
[]);
158 extern bool opt2parg_bSet(const char *option
,int nparg
,t_pargs pa
[]);
160 extern void print_pargs(FILE *fp
, int npargs
,t_pargs pa
[],bool bLeadingSpace
);
162 extern char *pargs_print_line(t_pargs
*pa
,bool bLeadingSpace
);
164 extern void pr_enums(FILE *fp
, int npargs
,t_pargs pa
[],int shell
);