[gmx-users] open_xtc() returns zero

Erik Lindahl lindahl at sbc.su.se
Mon Mar 27 23:48:03 CEST 2006


Hi Chris,

Have a look at the template.c program in share/template.

In most cases it's a bad idea to use the XTC routines directly, since  
they will (obviously) only work for XTC files. Gromacs provides high- 
level routines that can read/write any type of trajectory or  
coordinates, with or without velocities. If you use those your code  
will be more useful :-)

Cheers,

Erik


On Mar 27, 2006, at 11:32 PM, chris.neale at utoronto.ca wrote:

> I am trying to manipulate my XTC trajectory using a C program. I am  
> having
> difficulty getting open_xtc() to work. Specifically, fxtc=open_xtc 
> (args[1],"r")
> returns 0 (mentioned as an error in the online manual).
>
> I am using gromacs-3.3 on intel linux.
>
> I have attached my code.
> I compile with:
> gcc -o xtc_getmaxd xtc_getmaxd.c -I/home/cneale/gromacs-3.3/exec/ 
> include/gromacs
> -L/home/cneale/gromacs-3.3/exec/lib -lgmx -lm
>
> #include <stdio.h>
> #include <stdlib.h>
> #include "/home/cneale/gromacs-3.3/include/xtcio.h"
>
> int main(int argn, char *args[]){
>   int natoms,step,k,fxtc;
>   real time,prec;
>   matrix box;
>   rvec **x;
>   bool bOK;
>   int k;
>   if (argn!=2){
>     exit(1);
>   }
>
>   if((fxtc=open_xtc(args[1],"r"))!=1){
>     printf("error (main): unable to open xtc file %s for reading 
> \n",args[1]);
>     printf("              open_xtc() returned %d\n",fxtc);
>     exit(1);
>   }
>   k=read_first_xtc(fxtc,&natoms,&step,&time,box,x,&prec,&bOK);
>   if(k!=1){
>     printf("error (main): read_first_xtc() returned error value (%d) 
> \n",k);
>     close_xtc(fxtc);
>     exit(1);
>   }
>
>   close_xtc(fxtc);
> }
>
> ************************
>
> I have also tried with the following includes:
> #ifdef HAVE_CONFIG_H
> #include <config.h>
> #endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include "typedefs.h"
> #include "xdrf.h"
> #include "gmxfio.h"
> #include "xtcio.h"
> #include "smalloc.h"
> #include "vec.h"
> #include "futil.h"
> #include "fatal.h"
>
> Thanks,
> Chris Neale.
>
> _______________________________________________
> gmx-users mailing list    gmx-users at gromacs.org
> http://www.gromacs.org/mailman/listinfo/gmx-users
> 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
>




More information about the gromacs.org_gmx-users mailing list