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 * Gyas ROwers Mature At Cryogenic Speed
36 static char *SRCID_template_c = "$Id$";
46 int main(int argc,char *argv[])
48 static char *desc[] = {
49 "this is a small test program meant to serve as a template ",
50 "when writing your own analysis tools. The advantage of ",
51 "using gromacs for this is that you have access to all ",
52 "information in the topology, and your program will be ",
53 "able to handle all types of coordinates and trajectory ",
54 "files supported by gromacs. Go ahead and try it! ",
55 "This test version just writes the coordinates of an ",
56 "arbitrary atom to standard out for each frame. You can ",
57 "select which atom you want to examine with the -n argument."
62 /* Extra arguments - but note how you always get the begin/end
63 * options when running the program, without mentioning them here!
67 { "-n", FALSE, etINT, {&n},
68 "Plot data for atom number n (starting on 1)"
80 { efTPS, NULL, NULL, ffREAD }, /* this is for the topology */
81 { efTRX, "-f", NULL, ffREAD } /* and this for the trajectory */
84 #define NFILE asize(fnm)
86 CopyRight(stderr,argv[0]);
88 /* This is the routine responsible for adding default options,
89 * calling the X/motif interface, etc. */
90 parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW,TRUE,
91 NFILE,fnm,asize(pa),pa,asize(desc),desc,0,NULL);
93 /* We don't need any topology information to write the coordinates,
94 * but to show how it works we start by writing the name and
95 * charge of the selected atom. It returns a boolean telling us
96 * whether the topology was found and could be read
99 read_tps_conf(ftp2fn(efTPS,NFILE,fnm),title,&top,&xtop,NULL,box,TRUE);
102 n=n-1; /* Our enumeration started on 1, but C starts from 0 */
103 /* check that this atom exists */
104 if(n<0 || n>(top.atoms.nr))
106 printf("Error: Atom number %d is out of range.\n",n);
110 printf("Atom name: %s\n",*(top.atoms.atomname[n]));
111 printf("Atom charge: %f\n",top.atoms.atom[n].q);
113 /* The first time we read data is a little special */
114 read_first_frame(&status,ftp2fn(efTRX,NFILE,fnm),&fr,flags);
116 /* This is the main loop over frames */
118 /* coordinates are available in the vector fr.x
119 * you can find this and all other structures in
120 * the types directory under the gromacs include dir.
122 printf("Coordinates at t=%8.3f : %8.5f %8.5f %8.5f\n",fr.time,fr.x[n][XX],fr.x[n][YY],fr.x[n][ZZ]);
123 } while(read_next_frame(status,&fr));