4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
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 * For more info, check our website at http://www.gromacs.org
34 * Gromacs Runs On Most of All Computer Systems
54 typedef int t_first_x(int *status
,char *fn
,real
*t
,rvec
**x
,matrix box
);
55 typedef bool t_next_x(int status
,real
*t
,int natoms
,rvec x
[],matrix box
);
57 /* I/O function types */
59 extern char *Program(void);
60 /* Return the name of the program */
61 extern char *ShortProgram(void);
62 /* Id. without leading directory */
63 extern void set_program_name(char *argvzero
);
64 /* set the program name to the provided string, but note
65 * that it must be a real file - we determine the library
66 * directory from its location!
69 /************************************************
70 * Trajectory functions
71 ************************************************/
73 extern int prec2ndec(real prec
);
74 /* Convert precision in 1/(nm) to number of decimal places */
76 extern void clear_trxframe(t_trxframe
*fr
,bool bFirst
);
77 /* Set all content booleans to FALSE.
78 * When bFirst = TRUE, set natoms=-1, all pointers to NULL
79 * and all data to zero.
82 extern int nframes_read(void);
83 /* Returns the number of frames read from the trajectory */
85 int write_trxframe_indexed(int status
,t_trxframe
*fr
,int nind
,atom_id
*ind
);
86 /* Write an indexed frame to a TRX file, see write_trxframe */
88 int write_trxframe(int status
,t_trxframe
*fr
);
89 /* Write a frame to a TRX file.
90 * Only entries for which the boolean is TRUE will be written,
91 * except for step, time, lambda and/or box, which may not be
92 * omitted for certain trajectory formats.
93 * The precision for .xtc and .gro is fr->prec, when fr->bPrec=FALSE,
94 * the precision is set to 1000.
97 int write_trx(int status
,int nind
,atom_id
*ind
,t_atoms
*atoms
,
98 int step
,real time
,matrix box
,rvec x
[],rvec
*v
);
99 /* Write an indexed frame to a TRX file.
101 * atoms can be NULL for file types which don't need atom names.
104 void close_trx(int status
);
105 /* Close trj file as opened with read_first_x, read_frist_frame
106 * or open_trx. Identical to close_trj.
109 int open_trx(char *outfile
,char *filemode
);
110 /* Open a TRX file and return the file number */
112 extern bool bRmod(double a
, double b
, double c
);
113 /* Returns TRUE when (a - b) MOD c = 0, using a margin which is slightly
114 * larger than the float/double precision.
117 extern int check_times2(real t
,real t0
,real tp
,real tpp
);
118 /* This routine checkes if the read-in time is correct or not;
119 * returns -1 if t<tbegin or t MOD dt = t0,
120 * 0 if tbegin <= t <=tend+margin,
122 * where margin is 0.1*min(t-tp,tp-tpp), if this positive, 0 otherwise.
123 * tp and tpp should be the time of the previous frame and the one before.
126 extern int check_times(real t
);
127 /* This routine checkes if the read-in time is correct or not;
128 * returns -1 if t<tbegin,
129 * 0 if tbegin <= t <=tend,
133 extern char *time_unit(void);
134 /* return time unit (e.g. ps or ns) */
136 extern char *time_label(void);
137 /* return time unit label (e.g. "Time (ps)") */
139 extern char *xvgr_tlabel(void);
140 /* retrun x-axis time label for xmgr */
142 extern real
time_factor(void);
143 /* return time conversion factor from ps (i.e. 1e-3 for ps->ns) */
145 extern real
convert_time(real time
);
146 /* return converted time */
148 extern void convert_times(int n
, real
*time
);
149 /* convert array of times */
151 extern void default_time(void);
152 /* set time conversion to default (i.e. ps) */
154 /* For trxframe.flags, used in trxframe read routines.
155 * When a READ flag is set, the field will be read when present,
156 * but a frame might be returned which does not contain the field.
157 * When a NEED flag is set, frames not containing the field will be skipped.
159 #define TRX_READ_X (1<<0)
160 #define TRX_NEED_X (1<<1)
161 #define TRX_READ_V (1<<2)
162 #define TRX_NEED_V (1<<3)
163 #define TRX_READ_F (1<<4)
164 #define TRX_NEED_F (1<<5)
165 /* Useful for reading natoms from a trajectory without skipping */
166 #define TRX_DONT_SKIP (1<<6)
168 /* For trxframe.not_ok */
169 #define HEADER_NOT_OK (1<<0)
170 #define DATA_NOT_OK (1<<1)
171 #define FRAME_NOT_OK (HEADER_NOT_OK | DATA_NOT_OK)
173 extern bool read_first_frame(int *status
,char *fn
,t_trxframe
*fr
,int flags
);
174 /* Read the first frame which is in accordance with flags, which are
175 * defined further up in this file.
176 * Returns natoms when succeeded, 0 otherwise.
177 * Memory will be allocated for flagged entries.
178 * The flags are copied to fr for subsequent calls to read_next_frame.
179 * Returns TRUE when succeeded, FALSE otherwise.
182 extern bool read_next_frame(int status
,t_trxframe
*fr
);
183 /* Reads the next frame which is in accordance with fr->flags.
184 * Returns TRUE when succeeded, FALSE otherwise.
187 extern int read_first_x(int *status
,char *fn
,
188 real
*t
,rvec
**x
,matrix box
);
189 /* These routines read first coordinates and box, and allocates
190 * memory for the coordinates, for a trajectory file.
191 * The routine returns the number of atoms, or 0 when something is wrong.
192 * The integer in status should be passed to calls of read_next_x
195 extern bool read_next_x(int status
,real
*t
,int natoms
,rvec x
[],matrix box
);
196 /* Read coordinates and box from a trajectory file. Return TRUE when all well,
197 * or FALSE when end of file (or last frame requested by user).
198 * status is the integer set in read_first_x.
201 extern void close_trj(int status
);
202 /* Close trj file as opened with read_first_x, read_frist_frame
203 * or open_trx. Identical to close_trx.
206 extern void rewind_trj(int status
);
207 /* Rewind trj file as opened with read_first_x */
209 extern t_topology
*read_top(char *fn
);
210 /* Extract a topology data structure from a topology file */
212 extern void mk_single_top(t_topology
*top
);
213 /* Make the topology file single node ready */
215 extern bool bDoView(void);
216 /* Return TRUE when user requested viewing of the file */
218 /*****************************************************
219 * Some command line parsing routines
220 *****************************************************/
222 #define PCA_CAN_VIEW (1<<5)
223 /* add option -w to view output files (must be implemented in program) */
224 #define PCA_CAN_BEGIN (1<<6)
225 #define PCA_CAN_END (1<<7)
226 #define PCA_CAN_DT (1<<14)
227 #define PCA_CAN_TIME (PCA_CAN_BEGIN | PCA_CAN_END | PCA_CAN_DT)
228 /* adds options -b and -e for begin and end time for reading trajectories */
229 #define PCA_TIME_UNIT (1<<15)
230 /* set time unit for output */
231 #define PCA_KEEP_ARGS (1<<8)
232 /* keep parsed args in argv (doesn't make sense without NOEXIT_ON_ARGS) */
233 #define PCA_SILENT (1<<9)
234 /* don't print options by default */
235 #define PCA_CAN_SET_DEFFNM (1<<10)
236 /* does something for non-master mdrun nodes */
237 #define PCA_NOEXIT_ON_ARGS (1<<11)
238 /* no fatal_error when invalid options are encountered */
239 #define PCA_QUIET (1<<12)
240 /* does something for non-master mdrun nodes */
241 #define PCA_BE_NICE (1<<13)
242 /* Default to low priority, unless configured with --disable-nice */
244 extern int iscan(int argc
,char *argv
[],int *i
);
245 /* Scan an int from the argument at *i. If the argument length
246 * is > 2, the int is assumed to be in the remainder of the arg,
247 * eg: -p32, else the int is assumed to be in the next argument
248 * eg: -p 32. If neither is the case the routine exits with an error,
249 * otherwise it returns the value found. If the value is in the next
250 * argument *i is incremented. You typically would want to pass
251 * a loop variable to this routine.
254 extern double dscan(int argc
,char *argv
[],int *i
);
255 /* Routine similar to the above, but working on doubles. */
257 extern char *sscan(int argc
,char *argv
[],int *i
);
258 /* Routine similar to the above, but working on strings. The pointer
259 * returned is a pointer to the argv field.
262 extern void vscan(int argc
,char *argv
[],int *i
,rvec
*vec
);
263 /* Routine similar to the above, but working on rvecs. */
265 extern int nenum(char *enumc
[]);
266 /* returns ordinal number of selected enum from args
267 * depends on enumc[0] pointing to one of the other elements
268 * array must be terminated by a NULL pointer
272 extern void gmx_gui(int *argc
,char *argv
[],
273 int nfile
,t_filenm fnm
[],int npargs
,t_pargs pa
[],
274 int ndesc
,char *desc
[],int nbugs
,char *bugs
[]);
275 /* This function plops up a Motif dialog box in which the command-line options
280 extern void parse_common_args(int *argc
,char *argv
[],unsigned long Flags
,
281 int nfile
,t_filenm fnm
[],int npargs
,t_pargs
*pa
,
282 int ndesc
,char **desc
,int nbugs
,char **bugs
);
283 /* Get arguments from the arg-list. The arguments extracted
284 * are removed from the list. If manual is NULL a default message is displayed
285 * when errors are encountered. The Flags argument, when non-0 enables
286 * some input checks. Using this routine also means that the arguments
287 * -b and -e will be used for begin and end time, whether this is
288 * appropriate or not!