1 <title>xtc file format
</title>
3 The xtc format is a
<b>portable
</b> format for trajectories.
4 It uses the
<i>xdr
</i> routines for writing and reading
5 data which was created for the Unix NFS system. The trajectories
6 are written using a reduced precision algorithm which works
7 in the following way: the coordinates (in nm) are multiplied by a scale
8 factor, typically
1000, so that you have coordinates in pm.
9 These are rounded to integer values. Then several other tricks are
10 performed, for instance making use of the fact that atoms close
11 in sequence are usually close in space too (e.g. a water molecule).
12 To this end, the
<i>xdr
</i> library is extended with a special routine
13 to write
3-D float coordinates.
<!-- link is broken--><!-- This routine was written by Frans van Hoesel
14 as part of an Europort project, and can be obtained through <a href="http://hpcv100.rc.rug.nl/xdrf.html">this link</a>.-->
16 All the data is stored using calls to
<i>xdr
</i> routines.
20 <dd>A magic number, for the current file version its value is
1995.
22 <dd>The number of atoms in the trajectory.
24 <dd>The simulation step.
26 <dd>The simulation time.
27 <dt><b>float
</b> box[
3][
3]
28 <dd>The computational box which is stored as a set of three basis
29 vectors, to allow for triclinic PBC. For a rectangular box the
30 box edges are stored on the diagonal of the matrix.
31 <dt><b>3dfcoord
</b> x[natoms]
32 <dd>The coordinates themselves stored in reduced precision.
33 Please note that when the number of atoms is smaller than
9
34 no reduced precision is used.
37 <h3>Using xtc in your
"C" programs
</h3>
38 To read and write these files the following
"C" routines are available:
40 /* All functions return
1 if successful,
0 otherwise */
42 extern int open_xtc(XDR *xd,char *filename,char *mode);
43 /* Open a file for xdr I/O */
45 extern void close_xtc(XDR *xd);
46 /* Close the file for xdr I/O */
48 extern int read_first_xtc(XDR *xd,char *filename,
49 int *natoms,int *step,real *time,
50 matrix box,rvec **x,real *prec);
51 /* Open xtc file, read xtc file first time, allocate memory for x */
53 extern int read_next_xtc(XDR *xd,
54 int *natoms,int *step,real *time,
55 matrix box,rvec *x,real *prec);
56 /* Read subsequent frames */
58 extern int write_xtc(XDR *xd,
59 int natoms,int step,real time,
60 matrix box,rvec *x,real prec);
61 /* Write a frame to xtc file */
63 To use the library function include
<tt>"gromacs/fileio/xtcio.h"</tt>
64 in your file and link with
<tt>-lgmx.$(CPU)
</tt>
67 <h3>Using xtc in your FORTRAN programs
</h3>
68 To read and write these in a FORTRAN program use the calls to
69 <tt>readxtc
</tt> and
<tt>writextc
</tt> as in the following sample program
70 which reads and xtc file and copies it to a new one:
74 parameter (maxatom=
10000,maxx=
3*maxatom)
75 integer xd,xd2,natoms,step,ret,i
76 real time,box(
9),x(maxx)
78 call xdrfopen(xd,
"test.xtc",
"r",ret)
79 print *,'opened test.xtc, ret=',ret
80 call xdrfopen(xd2,
"testout.xtc",
"w",ret)
81 print *,'opened testout.xtc, ret=',ret
83 10 call readxtc(xd,natoms,step,time,box,x,prec,ret)
85 if ( ret .eq.
1 ) then
86 call writextc(xd2,natoms,step,time,box,x,prec,ret)
88 print *,'Error reading xtc'
94 To link your program use
<tt>-L$(GMXHOME)/lib/$(CPU) -lxtcf
</tt>
95 on your linker command line.
96 The source for this test can be found in file
97 <tt>$(GMXHOME)/src/gmxlib/testxtcf.f
</ff>.