4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Giving Russians Opium May Alter Current Situation
40 static char *SRCID_statutil_h = "$Id$";
55 typedef int t_first_x(int *status,char *fn,real *t,rvec **x,matrix box);
56 typedef bool t_next_x(int status,real *t,int natoms,rvec x[],matrix box);
58 /* I/O function types */
60 extern char *Program(void);
61 /* Return the name of the program */
62 extern char *ShortProgram(void);
63 /* Id. without leading directory */
65 /************************************************
66 * Trajectory functions
67 ************************************************/
69 extern int prec2ndec(real prec);
70 /* Convert precision in 1/(nm) to number of decimal places */
72 extern void clear_trxframe(t_trxframe *fr,bool bFirst);
73 /* Set all content booleans to FALSE.
74 * When bFirst = TRUE, set natoms=-1, all pointers to NULL
75 * and all data to zero.
78 extern int nframes_read(void);
79 /* Returns the number of frames read from the trajectory */
81 int write_trxframe_indexed(int status,t_trxframe *fr,int nind,atom_id *ind);
82 /* Write an indexed frame to a TRX file, see write_trxframe */
84 int write_trxframe(int status,t_trxframe *fr);
85 /* Write a frame to a TRX file.
86 * Only entries for which the boolean is TRUE will be written,
87 * except for step, time, lambda and/or box, which may not be
88 * omitted for certain trajectory formats.
89 * The precision for .xtc and .gro is fr->prec, when fr->bPrec=FALSE,
90 * the precision is set to 1000.
93 int write_trx(int status,int nind,atom_id *ind,t_atoms *atoms,
94 int step,real time,matrix box,rvec x[],rvec *v);
95 /* Write an indexed frame to a TRX file.
97 * atoms can be NULL for file types which don't need atom names.
100 void close_trx(int status);
101 /* Close trj file as opened with read_first_x, read_frist_frame
102 * or open_trx. Identical to close_trj.
105 int open_trx(char *outfile,char *filemode);
106 /* Open a TRX file and return the file number */
108 extern bool bRmod(double a,double b);
109 /* Returns TRUE when a MOD b = 0, using a margin which is slightly
110 * larger than the float/double precision.
113 extern int check_times2(real t,real t0,real tp,real tpp);
114 /* This routine checkes if the read-in time is correct or not;
115 * returns -1 if t<tbegin or t MOD dt = t0,
116 * 0 if tbegin <= t <=tend+margin,
118 * where margin is 0.1*min(t-tp,tp-tpp), if this positive, 0 otherwise.
119 * tp and tpp should be the time of the previous frame and the one before.
122 extern int check_times(real t);
123 /* This routine checkes if the read-in time is correct or not;
124 * returns -1 if t<tbegin,
125 * 0 if tbegin <= t <=tend,
129 extern char *time_unit(void);
130 /* return time unit (e.g. ps or ns) */
132 extern char *time_label(void);
133 /* return time unit label (e.g. "Time (ps)") */
135 extern char *xvgr_tlabel(void);
136 /* retrun x-axis time label for xmgr */
138 extern real time_factor(void);
139 /* return time conversion factor from ps (i.e. 1e-3 for ps->ns) */
141 extern real convert_time(real time);
142 /* return converted time */
144 extern void convert_times(int n, real *time);
145 /* convert array of times */
147 extern void default_time(void);
148 /* set time conversion to default (i.e. ps) */
150 /* For trxframe.flags, used in trxframe read routines.
151 * When a READ flag is set, the field will be read when present,
152 * but a frame might be returned which does not contain the field.
153 * When a NEED flag is set, frames not containing the field will be skipped.
155 #define TRX_READ_X (1<<0)
156 #define TRX_NEED_X (1<<1)
157 #define TRX_READ_V (1<<2)
158 #define TRX_NEED_V (1<<3)
159 #define TRX_READ_F (1<<4)
160 #define TRX_NEED_F (1<<5)
161 /* Useful for reading natoms from a trajectory without skipping */
162 #define TRX_DONT_SKIP (1<<6)
164 /* For trxframe.not_ok */
165 #define HEADER_NOT_OK (1<<0)
166 #define DATA_NOT_OK (1<<1)
167 #define FRAME_NOT_OK (HEADER_NOT_OK | DATA_NOT_OK)
169 extern bool read_first_frame(int *status,char *fn,t_trxframe *fr,int flags);
170 /* Read the first frame which is in accordance with flags, which are
171 * defined further up in this file.
172 * Returns natoms when succeeded, 0 otherwise.
173 * Memory will be allocated for flagged entries.
174 * The flags are copied to fr for subsequent calls to read_next_frame.
175 * Returns TRUE when succeeded, FALSE otherwise.
178 extern bool read_next_frame(int status,t_trxframe *fr);
179 /* Reads the next frame which is in accordance with fr->flags.
180 * Returns TRUE when succeeded, FALSE otherwise.
183 extern int read_first_x(int *status,char *fn,
184 real *t,rvec **x,matrix box);
185 /* These routines read first coordinates and box, and allocates
186 * memory for the coordinates, for a trajectory file.
187 * The routine returns the number of atoms, or 0 when something is wrong.
188 * The integer in status should be passed to calls of read_next_x
191 extern bool read_next_x(int status,real *t,int natoms,rvec x[],matrix box);
192 /* Read coordinates and box from a trajectory file. Return TRUE when all well,
193 * or FALSE when end of file (or last frame requested by user).
194 * status is the integer set in read_first_x.
197 extern void close_trj(int status);
198 /* Close trj file as opened with read_first_x, read_frist_frame
199 * or open_trx. Identical to close_trx.
202 extern void rewind_trj(int status);
203 /* Rewind trj file as opened with read_first_x */
205 extern t_topology *read_top(char *fn);
206 /* Extract a topology data structure from a topology file */
208 extern void mk_single_top(t_topology *top);
209 /* Make the topology file single node ready */
211 extern bool bDoView(void);
212 /* Return TRUE when user requested viewing of the file */
214 /*****************************************************
215 * Some command line parsing routines
216 *****************************************************/
218 #define PCA_CAN_VIEW (1<<5)
219 /* add option -w to view output files (must be implemented in program) */
220 #define PCA_CAN_BEGIN (1<<6)
221 #define PCA_CAN_END (1<<7)
222 #define PCA_CAN_DT (1<<14)
223 #define PCA_CAN_TIME (PCA_CAN_BEGIN | PCA_CAN_END | PCA_CAN_DT)
224 /* adds options -b and -e for begin and end time for reading trajectories */
225 #define PCA_TIME_UNIT (1<<15)
226 /* set time unit for output */
227 #define PCA_KEEP_ARGS (1<<8)
228 /* keep parsed args in argv (doesn't make sense without NOEXIT_ON_ARGS) */
229 #define PCA_SILENT (1<<9)
230 /* don't print options by default */
231 #define PCA_CAN_SET_DEFFNM (1<<10)
232 /* does something for non-master mdrun nodes */
233 #define PCA_NOEXIT_ON_ARGS (1<<11)
234 /* no fatal_error when invalid options are encountered */
235 #define PCA_QUIET (1<<12)
236 /* does something for non-master mdrun nodes */
237 #define PCA_BE_NICE (1<<13)
238 /* Default to low priority, unless configured with --disable-nice */
240 extern int iscan(int argc,char *argv[],int *i);
241 /* Scan an int from the argument at *i. If the argument length
242 * is > 2, the int is assumed to be in the remainder of the arg,
243 * eg: -p32, else the int is assumed to be in the next argument
244 * eg: -p 32. If neither is the case the routine exits with an error,
245 * otherwise it returns the value found. If the value is in the next
246 * argument *i is incremented. You typically would want to pass
247 * a loop variable to this routine.
250 extern double dscan(int argc,char *argv[],int *i);
251 /* Routine similar to the above, but working on doubles. */
253 extern char *sscan(int argc,char *argv[],int *i);
254 /* Routine similar to the above, but working on strings. The pointer
255 * returned is a pointer to the argv field.
258 extern void vscan(int argc,char *argv[],int *i,rvec *vec);
259 /* Routine similar to the above, but working on rvecs. */
261 extern int nenum(char *enumc[]);
262 /* returns ordinal number of selected enum from args
263 * depends on enumc[0] pointing to one of the other elements
264 * array must be terminated by a NULL pointer
268 extern void gmx_gui(int *argc,char *argv[],
269 int nfile,t_filenm fnm[],int npargs,t_pargs pa[],
270 int ndesc,char *desc[],int nbugs,char *bugs[]);
271 /* This function plops up a Motif dialog box in which the command-line options
276 extern void parse_common_args(int *argc,char *argv[],unsigned long Flags,
277 int nfile,t_filenm fnm[],int npargs,t_pargs *pa,
278 int ndesc,char **desc,int nbugs,char **bugs);
279 /* Get arguments from the arg-list. The arguments extracted
280 * are removed from the list. If manual is NULL a default message is displayed
281 * when errors are encountered. The Flags argument, when non-0 enables
282 * some input checks. Using this routine also means that the arguments
283 * -b and -e will be used for begin and end time, whether this is
284 * appropriate or not!