<br>Hi<br>Following are <br>1. template.c<br>
2. README<br>
3. Makefile.x86_64-unknown-linux-gnu<br><br><br>In the template.c => it includes several GROMACS headers.<br>#include "statutil.h"<br>
#include "typedefs.h"<br>
#include "smalloc.h"<br>
#include "vec.h"<br>
#include "copyrite.h"<br>
#include "statutil.h"<br>
#include "tpxio.h"<br>
<br><br><br>If I put the GROMACS headers with template.c in the same directory, should I still need the Makefile for my architecture, intended to compile template.c and link to the GROMACS libraries correctly ???<br><br>
<br>Thank you<br>Lin<br>
<br>
<br><br><br><br>============= [ TEMPLATE.C ]<br>
==============================<div id=":1w3" class="ii gt">=====================================<br>
/*<br>
* $Id: template.c,v 1.5 2008/05/29 08:36:53 hess Exp $<br>
*<br>
* This source code is part of<br>
*<br>
* G R O M A C S<br>
*<br>
* GROningen MAchine for Chemical Simulations<br>
*<br>
* VERSION 3.0<br>
*<br>
* Copyright (c) 1991-2001<br>
* BIOSON Research Institute, Dept. of Biophysical Chemistry<br>
* University of Groningen, The Netherlands<br>
*<br>
* This program is free software; you can redistribute it and/or<br>
* modify it under the terms of the GNU General Public License<br>
* as published by the Free Software Foundation; either version 2<br>
* of the License, or (at your option) any later version.<br>
*<br>
* If you want to redistribute modifications, please consider that<br>
* scientific software is very special. Version control is crucial -<br>
* bugs must be traceable. We will be happy to consider code for<br>
* inclusion in the official distribution, but derived work must not<br>
* be called official GROMACS. Details are found in the README & COPYING<br>
* files - if they are missing, get the official version at <a href="http://www.gromacs.org/" target="_blank">www.gromacs.org</a>.<br>
*<br>
* To help us fund GROMACS development, we humbly ask that you cite<br>
* the papers on the package - you can find them in the top README file.<br>
*<br>
* Do check out <a href="http://www.gromacs.org/" target="_blank">http://www.gromacs.org</a> , or mail us at <a href="mailto:gromacs@gromacs.org">gromacs@gromacs.org</a> .<br>
*<br>
* And Hey:<br>
* Gyas ROwers Mature At Cryogenic Speed<br>
*/<br>
<br>
/* This line is only for CVS version info */<br>
static char *SRCID_template_c = "$Id: template.c,v 1.5 2008/05/29 08:36:53 hess<br>
Exp $";<br>
<br>
#include "statutil.h"<br>
#include "typedefs.h"<br>
#include "smalloc.h"<br>
#include "vec.h"<br>
#include "copyrite.h"<br>
#include "statutil.h"<br>
#include "tpxio.h"<br>
<br>
<br>
int main(int argc,char *argv[])<br>
{<br>
static char *desc[] = {<br>
"this is a small test program meant to serve as a template ",<br>
"when writing your own analysis tools. The advantage of ",<br>
"using gromacs for this is that you have access to all ",<br>
"information in the topology, and your program will be ",<br>
"able to handle all types of coordinates and trajectory ",<br>
"files supported by gromacs. Go ahead and try it! ",<br>
"This test version just writes the coordinates of an ",<br>
"arbitrary atom to standard out for each frame. You can ",<br>
"select which atom you want to examine with the -n argument."<br>
};<br>
<br>
static int n=1;<br>
<br>
/* Extra arguments - but note how you always get the begin/end<br>
* options when running the program, without mentioning them here!<br>
*/<br>
<br>
t_pargs pa[] = {<br>
{ "-n", FALSE, etINT, {&n},<br>
"Plot data for atom number n (starting on 1)"<br>
}<br>
};<br>
<br>
t_topology top;<br>
int ePBC;<br>
char title[STRLEN];<br>
t_trxframe fr;<br>
rvec *xtop;<br>
matrix box;<br>
int status;<br>
int flags = TRX_READ_X;<br>
<br>
t_filenm fnm[] = {<br>
{ efTPS, NULL, NULL, ffREAD }, /* this is for the topology */<br>
{ efTRX, "-f", NULL, ffREAD } /* and this for the trajectory */<br>
};<br>
<br>
#define NFILE asize(fnm)<br>
<br>
CopyRight(stderr,argv[0]);<br>
<br>
/* This is the routine responsible for adding default options,<br>
* calling the X/motif interface, etc. */<br>
parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW,<br>
NFILE,fnm,asize(pa),pa,asize(desc),desc,0,NULL);<br>
<br>
/* We don't need any topology information to write the coordinates,<br>
* but to show how it works we start by writing the name and<br>
* charge of the selected atom. It returns a boolean telling us<br>
* whether the topology was found and could be read<br>
*/<br>
<br>
read_tps_conf(ftp2fn(efTPS,NFILE,fnm),title,&top,&ePBC,&xtop,NULL,box,TRUE);<br>
sfree(xtop);<br>
<br>
n=n-1; /* Our enumeration started on 1, but C starts from 0 */<br>
/* check that this atom exists */<br>
if(n<0 || n>(<a href="http://top.atoms.nr/" target="_blank">top.atoms.nr</a>))<br>
{<br>
printf("Error: Atom number %d is out of range.\n",n);<br>
exit(1);<br>
}<br>
<br>
printf("Atom name: %s\n",*(top.atoms.atomname[n]));<br>
printf("Atom charge: %f\n",top.atoms.atom[n].q);<br>
<br>
/* The first time we read data is a little special */<br>
read_first_frame(&status,ftp2fn(efTRX,NFILE,fnm),&fr,flags);<br>
<br>
/* This is the main loop over frames */<br>
do {<br>
/* coordinates are available in the vector fr.x<br>
* you can find this and all other structures in<br>
* the types directory under the gromacs include dir.<br>
* Note how flags determines wheter to read x/v/f!<br>
*/<br>
printf("Coordinates at t=%8.3f : %8.5f %8.5f %8.5f\n",fr.time,fr.x[n][XX],fr<br>
.x[n][YY],fr.x[n][ZZ]);<br>
} while(read_next_frame(status,&fr));<br>
<br>
thanx(stderr);<br>
<br>
return 0;<br>
}<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
======================= [ README ]<br>
=================================================================<br>
<br>
[chihying@hpc-login2 template]$ more README<br>
Once installed, this directory contains a Makefile and<br>
a small program that you could use as a template when<br>
writing your own analysis software.<br>
<br>
A Makefile.arch is created for each architecture you install<br>
with the correct paths and libraries. You will have to link<br>
(or copy) the correct makefile to "Makefile" or use the -f<br>
option to gmake in order to select a makefile.<br>
<br>
----------------------------------------------------------<br>
<br>
If you are reading this in the distribution directory,<br>
there will be a Makefile.am which automake uses to<br>
create a Makefile.in which in turn is converted to<br>
a Makefile by the configure script. Note that this is<br>
NOT the template makefile - it is called Template.mak,<br>
and used to create Makefile.arch at build time.<br>
<br>
You should NOT touch or copy Makefile.in unless you<br>
really know what you are doing - it is a template file<br>
used by the configure script to create the real Makefile.<br>
<br>
If you want to use automake and autoconf yourself, look<br>
in the contrib directory of the distribution.<br>
<br>
<br>
<br>
<br>
<br>
<br>
=================== [ Makefile.x86_64-unknown-linux-gnu ]<br>
=======================================================<br>
<br>
[chihying@hpc-login2 template]$ more Makefile.x86_64-unknown-linux-gnu<br>
# Generated automatically from Makefile.in by configure.<br>
#<br>
# This is a Gromacs 3.0 template makefile for your own utility programs.<br>
#<br>
# Copy this file to whatever directory you are using for your own<br>
# software and add more targets like the template one below.<br>
#<br>
# If you are using gmake it is relatively straightforward to add<br>
# an include based on environment variables (like previous Gromacs versions)<br>
# to select compiler flags and stuff automatically, but below it is static:<br>
#<br>
<br>
# Variables set by the configuration script:<br>
LIBS = -lmd_mpi -lgmx_mpi -L/usr/lib64 -lnsl -lsrfftw -lsfftw<br>
-lm -lSM -lICE -<br>
lX11<br>
LDFLAGS = -L/usr/usc/gromacs/4.0.5//lib<br>
CFLAGS = -O3 -fomit-frame-pointer -finline-functions -Wall<br>
-Wno-unused -funroll-all<br>
-loops -std=gnu99 -I/usr/usc/gromacs/4.0.5//include<br>
-I/usr/usc/gromacs/4.0.5//include/g<br>
romacs<br>
CC = mpicc<br>
LD = $(CC)<br>
<br>
# The real make targets - note that most make programs support<br>
# the shortcut $^ instead of listing all object files a second<br>
# time, but we cannot count on it...<br>
<br>
template: template.o<br>
$(LD) $(LDFLAGS) -o $@ template.o $(LIBS)<br>
<br><br><br><br><br><br><br>
</div><br>