changed reading hint
[gromacs/adressmacs.git] / include / statutil.h
blob6e256a8161720b7b2ed78f7e9e57064409c7af79
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Green Red Orange Magenta Azure Cyan Skyblue
30 #ifndef _statutil_h
31 #define _statutil_h
33 static char *SRCID_statutil_h = "$Id$";
35 #ifdef CPLUSPLUS
36 extern "C" {
37 #endif
39 #include <stdio.h>
40 #include "typedefs.h"
41 #include "filenm.h"
42 #include "readinp.h"
43 #include "wman.h"
45 typedef int t_first_x(int *status,char *fn,real *t,rvec **x,matrix box);
46 typedef bool t_next_x(int status,real *t,int natoms,rvec x[],matrix box);
48 /* I/O function types */
50 extern char *Program(void);
51 /* Return the name of the program */
52 extern char *ShortProgram(void);
53 /* Id. without leading directory */
55 /************************************************
56 * Trajectory functions
57 ************************************************/
59 extern int nframes_read(void);
60 /* Returns the number of frames read from the trajectory */
62 int write_trx(int fnum,int nind,atom_id *ind,t_atoms *atoms,
63 int step,real time,matrix box,rvec x[],rvec *v);
64 /* write an indexed frame to a TRX file */
66 int close_trx(int fnum);
67 /* Close a TRX file */
69 int open_trx(char *outfile,char *filemode);
70 /* Open a TRX file and return the file number */
72 extern int check_times(real t);
73 /* This routine checkes if the read-in time is correct or not;
74 * returns -1 if t<tbegin,
75 * 0 if tbegin <= t <=tend,
76 * 1 if t>tend
79 extern int read_first_x(int *status,char *fn,
80 real *t,rvec **x,matrix box);
81 /* These routines read first coordinates and box, and allocates
82 * memory for the coordinates, for a trajectory file.
83 * The routine returns the number of atoms, or 0 when something is wrong.
84 * The integer in status should be passed to calls of read_next_x
87 extern bool read_next_x(int status,real *t,int natoms,rvec x[],matrix box);
88 /* Read coordinates and box from a trajectory file. Return TRUE when all well,
89 * or FALSE when end of file (or last frame requested by user).
90 * status is the integer set in read_first_x.
93 extern void close_trj(int status);
94 /* Close trj file as opened with read_first_x */
96 extern void rewind_trj(int status);
97 /* Rewind trj file as opened with read_first_x */
99 extern int read_first_v(int *status,char *fn,real *t,rvec **v,matrix box);
100 /* Same as above, but for velocities */
102 extern bool read_next_v(int status,real *t,int natoms,rvec v[],matrix box);
103 /* Idem */
105 extern int read_first_x_v(int *status,char *fn,real *t,rvec **x,rvec **v,matrix box);
106 /* Same as above, but for coordinates and velocities */
108 extern bool read_next_x_v(int status,real *t,int natoms,rvec x[],rvec v[],matrix box);
109 /* Idem */
111 extern bool read_next_x_or_v(int status,real *t,int natoms,rvec x[],rvec v[],matrix box);
112 /* Same as above, but for coordinates *AND/OR* velocities */
114 extern bool read_first_x_or_v(int *status,char *fn,real *t,rvec **x,rvec **v,matrix box);
115 /* Idem */
117 extern bool next_e(FILE *status, real *t, t_energy e[]);
118 /* Read energy terms from trajectory file */
120 extern t_topology *read_top(char *fn);
121 /* Extract a topology data structure from a topology file */
123 extern void mk_single_top(t_topology *top);
124 /* Make the topology file single processor ready */
126 extern char *status_title(FILE *status);
127 /* Return a title from a topology file */
129 extern bool bDoView(void);
130 /* Return TRUE when user requested viewing of the file */
132 /*****************************************************
133 * Some command line parsing routines
134 *****************************************************/
136 #define PCA_CAN_VIEW (1<<5)
137 /* add option -w to view output files (must be implemented in program) */
138 #define PCA_CAN_BEGIN (1<<6)
139 #define PCA_CAN_END (1<<7)
140 #define PCA_CAN_TIME (PCA_CAN_BEGIN | PCA_CAN_END)
141 /* adds options -b and -e for begin and end time for reading trajectories */
142 #define PCA_KEEP_ARGS (1<<8)
143 /* keep parsed args in argv (doesn't make sense without NOEXIT_ON_ARGS) */
144 #define PCA_SILENT (1<<9)
145 /* don't print options by default */
146 #define PCA_CAN_SET_DEFFNM (1<<10)
147 /* does something for non-master mdrun processes */
148 #define PCA_NOEXIT_ON_ARGS (1<<11)
149 /* no fatal_error when invalid options are encountered */
150 #define PCA_QUIET (1<<12)
151 /* does something for non-master mdrun processes */
152 #define PCA_SET_NPRI (1<<13)
153 /* set weightless prioriy by default */
155 extern int iscan(int argc,char *argv[],int *i);
156 /* Scan an int from the argument at *i. If the argument length
157 * is > 2, the int is assumed to be in the remainder of the arg,
158 * eg: -p32, else the int is assumed to be in the next argument
159 * eg: -p 32. If neither is the case the routine exits with an error,
160 * otherwise it returns the value found. If the value is in the next
161 * argument *i is incremented. You typically would want to pass
162 * a loop variable to this routine.
165 extern double dscan(int argc,char *argv[],int *i);
166 /* Routine similar to the above, but working on doubles. */
168 extern char *sscan(int argc,char *argv[],int *i);
169 /* Routine similar to the above, but working on strings. The pointer
170 * returned is a pointer to the argv field.
173 extern void vscan(int argc,char *argv[],int *i,rvec *vec);
174 /* Routine similar to the above, but working on rvecs. */
176 #ifdef HAVE_MOTIF
177 extern void gmx_gui(int *argc,char *argv[],
178 int nfile,t_filenm fnm[],int npargs,t_pargs pa[],
179 int ndesc,char *desc[],int nbugs,char *bugs[]);
180 /* This function plops up a Motif dialog box in which the command-line options
181 * can be changed.
183 #endif
185 extern void parse_common_args(int *argc,char *argv[],unsigned long Flags,bool bNice,
186 int nfile,t_filenm fnm[],int npargs,t_pargs *pa,
187 int ndesc,char **desc,int nbugs,char **bugs);
188 /* Get arguments from the arg-list. The arguments extracted
189 * are removed from the list. If manual is NULL a default message is displayed
190 * when errors are encountered. The Flags argument, when non-0 enables
191 * some input checks. Using this routine also means that the arguments
192 * -b and -e will be used for begin and end time, whether this is
193 * appropriate or not!
196 #ifdef CPLUSPLUS
198 #endif
200 #endif