[gmx-users] about template.c?

Chih-Ying Lin chihying2008 at gmail.com
Tue Jul 7 09:35:17 CEST 2009


inside template.c =>

#include "statutil.h"
#include "typedefs.h"
#include "smalloc.h"
#include "vec.h"
#include "copyrite.h"
#include "statutil.h"
#include "tpxio.h"

what are they?
and, where are they?

thank you

 * $Id: template.c,v 1.4 2001/07/23 15:28:29 lindahl Exp $
 *                This source code is part of
 *                 G   R   O   M   A   C   S
 *          GROningen MAchine for Chemical Simulations
 *                        VERSION 3.0
 * Copyright (c) 1991-2001
 * BIOSON Research Institute, Dept. of Biophysical Chemistry
 * University of Groningen, The Netherlands
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * If you want to redistribute modifications, please consider that
 * scientific software is very special. Version control is crucial -
 * bugs must be traceable. We will be happy to consider code for
 * inclusion in the official distribution, but derived work must not
 * be called official GROMACS. Details are found in the README & COPYING
 * files - if they are missing, get the official version at www.gromacs.org.
 * To help us fund GROMACS development, we humbly ask that you cite
 * the papers on the package - you can find them in the top README file.
 * Do check out http://www.gromacs.org , or mail us at gromacs at gromacs.org .
 * And Hey:
 * Gyas ROwers Mature At Cryogenic Speed

/* This line is only for CVS version info */
static char *SRCID_template_c = "$Id: template.c,v 1.4 2001/07/23 15:28:29 linda
hl Exp $";

#include "statutil.h"
#include "typedefs.h"
#include "smalloc.h"
#include "vec.h"
#include "copyrite.h"
#include "statutil.h"
#include "tpxio.h"

int main(int argc,char *argv[])
 static char *desc[] = {
   "this is a small test program meant to serve as a template ",
   "when writing your own analysis tools. The advantage of ",
   "using gromacs for this is that you have access to all ",
   "information in the topology, and your program will be ",
   "able to handle all types of coordinates and trajectory ",
   "files supported by gromacs. Go ahead and try it! ",
   "This test version just writes the coordinates of an ",
   "arbitrary atom to standard out for each frame. You can ",
   "select which atom you want to examine with the -n argument."

 static int n=1;

 /* Extra arguments - but note how you always get the begin/end
  * options when running the program, without mentioning them here!

 t_pargs pa[] = {
   { "-n", FALSE, etINT, {&n},
     "Plot data for atom number n (starting on 1)"

 t_topology top;
 char       title[STRLEN];
 t_trxframe fr;
 rvec       *xtop;
 matrix     box;
 int        status;
 int        flags = TRX_READ_X;

 t_filenm fnm[] = {
   { efTPS,  NULL,  NULL, ffREAD },   /* this is for the topology */
   { efTRX, "-f", NULL, ffREAD }      /* and this for the trajectory */

#define NFILE asize(fnm)


 /* This is the routine responsible for adding default options,
  * calling the X/motif interface, etc. */
 parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW,

 /* We don't need any topology information to write the coordinates,
  * but to show how it works we start by writing the name and
  * charge of the selected atom. It returns a boolean telling us
  * whether the topology was found and could be read


 n=n-1; /* Our enumeration started on 1, but C starts from 0 */
 /* check that this atom exists */
 if(n<0 || n>(top.atoms.nr))
   printf("Error: Atom number %d is out of range.\n",n);

 printf("Atom name: %s\n",*(top.atoms.atomname[n]));
 printf("Atom charge: %f\n",top.atoms.atom[n].q);

 /* The first time we read data is a little special */

 /* This is the main loop over frames */
 do {
   /* coordinates are available in the vector fr.x
    * you can find this and all other structures in
    * the types directory under the gromacs include dir.
    * Note how flags determines wheter to read x/v/f!
   printf("Coordinates at t=%8.3f : %8.5f %8.5f %8.5f\n",fr.time,fr.x[n][XX],fr
 } while(read_next_frame(status,&fr));


 return 0;

More information about the gromacs.org_gmx-users mailing list