[gmx-users] template.c => put the GROMACS headers in the same file ?
Justin A. Lemkul
jalemkul at vt.edu
Fri Sep 11 21:33:03 CEST 2009
Chih-Ying Lin wrote:
>
> Hi
> Following are
> 1. template.c
> 2. README
> 3. Makefile.x86_64-unknown-linux-gnu
>
>
> In the template.c => it includes several GROMACS headers.
> #include "statutil.h"
> #include "typedefs.h"
> #include "smalloc.h"
> #include "vec.h"
> #include "copyrite.h"
> #include "statutil.h"
> #include "tpxio.h"
>
>
>
> 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 ???
>
You don't need to move anything. The Makefile present in the /template
subdirectory is sufficient to include these headers in their normal location and
to compile the code. This is explained in the README file.
-Justin
>
> Thank you
> Lin
>
>
>
>
>
> ============= [ TEMPLATE.C ]
> ==============================
> =====================================
> /*
> * $Id: template.c,v 1.5 2008/05/29 08:36:53 hess 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 <http://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 <http://www.gromacs.org/> , or
> mail us at gromacs at gromacs.org <mailto: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.5 2008/05/29
> 08:36:53 hess
> 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;
> int ePBC;
> 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)
>
> CopyRight(stderr,argv[0]);
>
> /* 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,
> NFILE,fnm,asize(pa),pa,asize(desc),desc,0,NULL);
>
> /* 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
> */
>
> read_tps_conf(ftp2fn(efTPS,NFILE,fnm),title,&top,&ePBC,&xtop,NULL,box,TRUE);
> sfree(xtop);
>
> 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 <http://top.atoms.nr/>))
> {
> printf("Error: Atom number %d is out of range.\n",n);
> exit(1);
> }
>
> 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 */
> read_first_frame(&status,ftp2fn(efTRX,NFILE,fnm),&fr,flags);
>
> /* 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
> .x[n][YY],fr.x[n][ZZ]);
> } while(read_next_frame(status,&fr));
>
> thanx(stderr);
>
> return 0;
> }
>
>
>
>
>
>
>
> ======================= [ README ]
> =================================================================
>
> [chihying at hpc-login2 template]$ more README
> Once installed, this directory contains a Makefile and
> a small program that you could use as a template when
> writing your own analysis software.
>
> A Makefile.arch is created for each architecture you install
> with the correct paths and libraries. You will have to link
> (or copy) the correct makefile to "Makefile" or use the -f
> option to gmake in order to select a makefile.
>
> ----------------------------------------------------------
>
> If you are reading this in the distribution directory,
> there will be a Makefile.am which automake uses to
> create a Makefile.in which in turn is converted to
> a Makefile by the configure script. Note that this is
> NOT the template makefile - it is called Template.mak,
> and used to create Makefile.arch at build time.
>
> You should NOT touch or copy Makefile.in unless you
> really know what you are doing - it is a template file
> used by the configure script to create the real Makefile.
>
> If you want to use automake and autoconf yourself, look
> in the contrib directory of the distribution.
>
>
>
>
>
>
> =================== [ Makefile.x86_64-unknown-linux-gnu ]
> =======================================================
>
> [chihying at hpc-login2 template]$ more Makefile.x86_64-unknown-linux-gnu
> # Generated automatically from Makefile.in by configure.
> #
> # This is a Gromacs 3.0 template makefile for your own utility programs.
> #
> # Copy this file to whatever directory you are using for your own
> # software and add more targets like the template one below.
> #
> # If you are using gmake it is relatively straightforward to add
> # an include based on environment variables (like previous Gromacs versions)
> # to select compiler flags and stuff automatically, but below it is static:
> #
>
> # Variables set by the configuration script:
> LIBS = -lmd_mpi -lgmx_mpi -L/usr/lib64 -lnsl -lsrfftw -lsfftw
> -lm -lSM -lICE -
> lX11
> LDFLAGS = -L/usr/usc/gromacs/4.0.5//lib
> CFLAGS = -O3 -fomit-frame-pointer -finline-functions -Wall
> -Wno-unused -funroll-all
> -loops -std=gnu99 -I/usr/usc/gromacs/4.0.5//include
> -I/usr/usc/gromacs/4.0.5//include/g
> romacs
> CC = mpicc
> LD = $(CC)
>
> # The real make targets - note that most make programs support
> # the shortcut $^ instead of listing all object files a second
> # time, but we cannot count on it...
>
> template: template.o
> $(LD) $(LDFLAGS) -o $@ template.o $(LIBS)
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gmx-users mailing list gmx-users at gromacs.org
> http://lists.gromacs.org/mailman/listinfo/gmx-users
> Please search the archive at http://www.gromacs.org/search before posting!
> Please don't post (un)subscribe requests to the list. Use the
> www interface or send it to gmx-users-request at gromacs.org.
> Can't post? Read http://www.gromacs.org/mailing_lists/users.php
--
========================================
Justin A. Lemkul
Ph.D. Candidate
ICTAS Doctoral Scholar
Department of Biochemistry
Virginia Tech
Blacksburg, VA
jalemkul[at]vt.edu | (540) 231-9080
http://www.bevanlab.biochem.vt.edu/Pages/Personal/justin
========================================
More information about the gromacs.org_gmx-users
mailing list