Move pargs.cpp into src/gromacs/commandline/
[alexxy/gromacs.git] / src / gromacs / legacyheaders / readinp.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  *                        VERSION 3.2.0
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.
14
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.
19  *
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.
26  *
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.
29  *
30  * For more info, check our website at http://www.gromacs.org
31  *
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #ifndef _readinp_h
37 #define _readinp_h
38
39 #include "typedefs.h"
40 #include "warninp.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 typedef struct {
47     int      count;     /* sort order for output  */
48     gmx_bool bObsolete; /* whether it is an obsolete param value */
49     gmx_bool bSet;      /* whether it it has been read out */
50     char    *name;      /* name of the parameter */
51     char    *value;     /* parameter value string */
52     int      inp_count; /* number of einps read. Only valid for the first item
53                                                  in the inpfile list. */
54 } t_inpfile;
55 /* entry in input files (like .mdp files).
56    Initally read in with read_inpfile, then filled in with missing values
57    through get_eint, get_ereal, etc. */
58
59 t_inpfile *read_inpfile(const char *fn, int *ninp,
60                         warninp_t wi);
61 /* Create & populate a t_inpfile struct from values in file fn.
62    fn = the file name
63    ninp = the number of read parameters
64    cppopts = the cpp-style options for #include paths and #defines */
65
66 void write_inpfile(const char *fn, int ninp, t_inpfile inp[],
67                    gmx_bool bHaltOnUnknown,
68                    warninp_t wi);
69
70 void replace_inp_entry(int ninp, t_inpfile *inp,
71                        const char *old_entry, const char *new_entry);
72
73 int get_eint(int *ninp, t_inpfile **inp, const char *name, int def,
74              warninp_t wi);
75
76 gmx_large_int_t get_egmx_large_int(int *ninp, t_inpfile **inp,
77                                    const char *name, gmx_large_int_t def,
78                                    warninp_t);
79
80 double get_ereal(int *ninp, t_inpfile **inp, const char *name, double def,
81                  warninp_t wi);
82
83 const char *get_estr(int *ninp, t_inpfile **inp, const char *name, const char *def);
84
85 int get_eeenum(int *ninp, t_inpfile **inp, const char *name, const char **defs,
86                warninp_t wi);
87 /* defs must be NULL terminated */
88
89 int get_eenum(int *ninp, t_inpfile **inp, const char *name, const char **defs);
90 /* defs must be NULL terminated */
91
92 /* Here are some dirty macros to extract data from the inp structures.
93  * Most macros assume the variables ninp, inp and wi are present.
94  * Elements are removed from the list after reading.
95  */
96 #define REM_TYPE(name)       replace_inp_entry(ninp, inp, name, NULL)
97 #define REPL_TYPE(old, new)   replace_inp_entry(ninp, inp, old, new)
98 #define STYPE(name, var, def)  if ((tmp = get_estr(&ninp, &inp, name, def)) != NULL) strcpy(var, tmp)
99 #define STYPENC(name, def) get_estr(&ninp, &inp, name, def)
100 #define ITYPE(name, var, def)  var    = get_eint(&ninp, &inp, name, def, wi)
101 #define STEPTYPE(name, var, def)  var = get_egmx_large_int(&ninp, &inp, name, def, wi)
102 #define RTYPE(name, var, def)  var    = get_ereal(&ninp, &inp, name, def, wi)
103 #define ETYPE(name, var, defs) var    = get_eenum(&ninp, &inp, name, defs)
104 #define EETYPE(name, var, defs) var   = get_eeenum(&ninp, &inp, name, defs, wi)
105 #define CCTYPE(s) STYPENC("\n; " s, NULL)
106 #define CTYPE(s)  STYPENC("; " s, NULL)
107 /* This last one prints a comment line where you can add some explanation */
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif