Re: dcd binary file format

From: Jeffrey A Tibbitt (JTibbitt_at_odu.edu)
Date: Tue May 01 2007 - 16:57:47 CDT

Jianhui,

Here is some fortran code that works for me. A couple of things:
1. Code assumes no fixed atoms
     You need to modify it with an if........then type statement
if you have fixed atoms.
2. The dimension of x( ) y( ) z( ) need to be set to the number of
atoms before running.

What I do when I don't want to set the dimensions is to place the code
inside of a shell script and read in both a dcd and a psf. The script
reads the number of atoms from the psf and sets it to a variable then uses
that variable as it reads the dcd file. I attached the file for doing
that. It uses the code below. Try running it in a directory where you
have a dcd and its corresponding psf.

Jeff

ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
      program readdcd

      character*4 header
      integer control(20),i,ntitle,natom
      character*80 title(4)
      real*4 x( )
      real*4 y( )
      real*4 z( )

c OPEN TRAJECTORY FILE
      open(unit=56,file="tmp.dcd",status='old',form='unformatted')

c READ IN HEADER AND CONTROL INFO
      read(56) header,control
      write (*,*) "Type:
",header
      write (*,*) "Number of Frames:
",control(1)
      write (*,*) "Number of Previous Dynamic Steps: ",control(2)
      write (*,*) "Skip Frequency:
",control(3)
      write (*,*) "Number of Dynamics Steps: ",control(4)

c READ IN THE TITLE LINES
      read(56) ntitle,(title(j),j=1,ntitle)

c READ IN NUMBER OF ATOMS
      read(56) natom
      write (*,*) "Number of Atoms: ",natom

c READ IN COORDINATES AND CONVERT TO DOUBLE PRECISION
      do i=1,control(1)
        read(56) x
        read(56) y
        read(56) z
      enddo
      close(56)
      end program
c
c
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:46:14 CST