From: Leandro Martínez (leandromartinez98_at_gmail.com)
Date: Sun Apr 06 2008 - 02:25:45 CDT

I think you cannot go directly to the end of an unformatted file, at least
in fortran. You could eventually read the file once and write the
coordinates again in direct access mode. However, one quite simple solution
is to read nothing a lot of times, this
probably does not take too long:

open(10,file=dcdfile)
do i = 1, frameyouwant - 1
    read(10) ! read nothing for x in this frame
    read(10) ! read nothing for y in this frame
    read(10) ! read nothing for z in this frame
end do
do i = 1, numberofframesyouwant
    read(10) (x(i),i=1,natoms)
    read(10) (y(i),i=1,natoms)
    read(10) (z(i),i=1,natoms)
end do
close(10)

Using this, I tested here in my laptop, you can jump 1000 frames of the DCD
file in about 10 seconds.

Leandro.

On Sun, Apr 6, 2008 at 1:08 AM, Axel Kohlmeyer <akohlmey_at_cmm.chem.upenn.edu>
wrote:

> On Sat, 5 Apr 2008, Yinglong Miao wrote:
>
> YM> Hi,
>
> dear long,
>
>
> apart from the other suggestions, which are good, the simples solution
> to your problem is to chop your run into parts and name
> your .dcd files for each part differently. this also is in general
> considered good practice as this reduces the impact of any file
> corruption on scratch disks.
>
> cheers,
> axel.
>
>
> YM>
> YM> I have a question about reading big binary DCD files in FORTRAN. In my
> YM> simulations with NAMD, there are cycles in which I want to read two
> frames
> YM> at the end of the DCD output trajectory for analysis and go back to
> NAMD to
> YM> continue. The problem is that the size of the DCD file keeps
> increasing as
> YM> the simulation goes on, and so does the time needed for reading. I am
> YM> wondering whether their are ways to read the last several frames of a
> DCD
> YM> file directly without going through the big file from the beginning in
> YM> FORTRAN.
> YM>
> YM> I have tried to open the DCD file with position put at the end of the
> file
> YM> (append for position) and use "backspace" to read the lines I want,
> but it
> YM> turned out that the backspace doesn't work for unformatted files. I
> also
> YM> tried reading DCD lines using "direct access", but it seemed that only
> 1
> YM> record can be accessed. So my question is whether the DCD file
> supports
> YM> "direct access" reading. Or are there any other ways you know for my
> YM> purpose? I will appreciate it if you can share your experiences with
> me.
> YM>
> YM> Thanks,
> YM> Long
> YM>
> YM>
>
> --
> =======================================================================
> Axel Kohlmeyer akohlmey_at_cmm.chem.upenn.edu http://www.cmm.upenn.edu
> Center for Molecular Modeling -- University of Pennsylvania
> Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
> tel: 1-215-898-1582, fax: 1-215-573-6233, office-tel: 1-215-898-5425
> =======================================================================
> If you make something idiot-proof, the universe creates a better idiot.
>