2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
41 #include "visibility.h"
51 int count
; /* sort order for output */
52 gmx_bool bObsolete
; /* whether it is an obsolete param value */
53 gmx_bool bSet
; /* whether it it has been read out */
54 char *name
; /* name of the parameter */
55 char *value
; /* parameter value string */
56 int inp_count
; /* number of einps read. Only valid for the first item
57 in the inpfile list. */
59 /* entry in input files (like .mdp files).
60 Initally read in with read_inpfile, then filled in with missing values
61 through get_eint, get_ereal, etc. */
66 t_inpfile
*read_inpfile(const char *fn
,int *ninp
,
69 /* Create & populate a t_inpfile struct from values in file fn.
71 ninp = the number of read parameters
72 cppopts = the cpp-style options for #include paths and #defines */
75 void write_inpfile(const char *fn
,int ninp
,t_inpfile inp
[],
76 gmx_bool bHaltOnUnknown
,
80 void replace_inp_entry(int ninp
,t_inpfile
*inp
,
81 const char *old_entry
,const char *new_entry
);
84 int get_eint(int *ninp
,t_inpfile
**inp
,const char *name
,int def
,
88 gmx_large_int_t
get_egmx_large_int(int *ninp
,t_inpfile
**inp
,
89 const char *name
,gmx_large_int_t def
,
93 double get_ereal(int *ninp
,t_inpfile
**inp
,const char *name
,double def
,
97 const char *get_estr(int *ninp
,t_inpfile
**inp
,const char *name
,const char *def
);
100 int get_eeenum(int *ninp
,t_inpfile
**inp
,const char *name
,const char **defs
,
102 /* defs must be NULL terminated */
105 int get_eenum(int *ninp
,t_inpfile
**inp
,const char *name
,const char **defs
);
106 /* defs must be NULL terminated */
108 /* Here are some dirty macros to extract data from the inp structures.
109 * Most macros assume the variables ninp, inp and wi are present.
110 * Elements are removed from the list after reading.
112 #define REM_TYPE(name) replace_inp_entry(ninp,inp,name,NULL)
113 #define REPL_TYPE(old,new) replace_inp_entry(ninp,inp,old,new)
114 #define STYPE(name,var,def) if ((tmp=get_estr(&ninp,&inp,name,def)) != NULL) strcpy(var,tmp)
115 #define STYPENC(name,def) get_estr(&ninp,&inp,name,def)
116 #define ITYPE(name,var,def) var=get_eint(&ninp,&inp,name,def,wi)
117 #define STEPTYPE(name,var,def) var=get_egmx_large_int(&ninp,&inp,name,def,wi)
118 #define RTYPE(name,var,def) var=get_ereal(&ninp,&inp,name,def,wi)
119 #define ETYPE(name,var,defs) var=get_eenum(&ninp,&inp,name,defs)
120 #define EETYPE(name,var,defs) var=get_eeenum(&ninp,&inp,name,defs,wi)
121 #define CCTYPE(s) STYPENC("\n; "s,NULL)
122 #define CTYPE(s) STYPENC("; "s,NULL)
123 /* This last one prints a comment line where you can add some explanation */
125 /* This structure is used for parsing arguments off the comand line */
127 etINT
, etGMX_LARGE_INT
, etREAL
, etTIME
, etSTR
, etBOOL
, etRVEC
, etENUM
, etNR
130 /* names to print in help info */
131 static const char *argtp
[etNR
] = {
132 "int", "step", "real", "time", "string", "bool", "vector", "enum"
140 void *v
; /* This is a nasty workaround, to be able to use initialized */
144 const char **c
; /* Must be pointer to string (when type == etSTR) */
145 /* or null terminated list of enums (when type == etENUM) */
152 void get_pargs(int *argc
,char *argv
[],int nparg
,t_pargs pa
[],
154 /* Read a number of arguments from the command line.
155 * For etINT, etREAL and etCHAR an extra argument is read (when present)
156 * for etBOOL the gmx_boolean option is changed to the negate value
157 * If !bKeepArgs, the command line arguments are removed from the command line
160 gmx_bool
is_hidden(t_pargs
*pa
);
161 /* Return TRUE when the option is a secret one */
163 char *pa_val(t_pargs
*pa
,char *buf
, int sz
);
164 /* Return the value of pa in the provided buffer buf, of size sz.
165 * The return value is also a pointer to buf.
168 int opt2parg_int(const char *option
,int nparg
,t_pargs pa
[]);
170 gmx_bool
opt2parg_gmx_bool(const char *option
,int nparg
,t_pargs pa
[]);
173 real
opt2parg_real(const char *option
,int nparg
,t_pargs pa
[]);
176 const char *opt2parg_str(const char *option
,int nparg
,t_pargs pa
[]);
178 const char *opt2parg_enum(const char *option
,int nparg
,t_pargs pa
[]);
181 gmx_bool
opt2parg_bSet(const char *option
,int nparg
,t_pargs pa
[]);
183 void print_pargs(FILE *fp
, int npargs
,t_pargs pa
[],gmx_bool bLeadingSpace
);
185 char *pargs_print_line(t_pargs
*pa
,gmx_bool bLeadingSpace
);
187 void pr_enums(FILE *fp
, int npargs
,t_pargs pa
[],int shell
);