Re: vmd-l: How to read specific DCD frames directly in Fortran?

From: Yinglong Miao (yimiao_at_indiana.edu)
Date: Sun Apr 06 2008 - 10:51:40 CDT

Leandro, thanks for your reply! And thank Peter, John and Axel for all your
very good suggestions.

The way Leandro suggested is actually what I have tried successfully, but
it's not efficient. It may take less time to read nothing for those lines
not needed, but it's not like moving the file position pointer directly. The
accumulated time for reading becomes significant as the DCD file keeps
increasing. I learned that using BACKSPACE in Fortran can move the file
position pointer to one line back in sequential access mode, but
unfortunately it's a bug reported online that it doesn't work for
unformatted files.

For Axel's suggestion, I actually tried the following in a NAMD simulation:

  DCDfile ${outputname}_1.dcd
  run 200
  DCDfile ${outputname}_2.dcd
  run 200

But it turned out that I cannot name different DCD files for the two run
parts in NAMD like this:

TCL: Setting parameter DCDfile to 1cwp-vmd-H-out_2
FATAL ERROR: Setting parameter DCDfile from script failed!

It would be the easiest approach for my problem if it worked. And I wish
somebody could tell me I did something wrong for my purpose and make it
work.

I may move on to try using the skip_dcdstep function provided in the VMD
dcdplugin via Axel's Fortran binder. If it works, it would be nice. Or I
will just read the restart files as Peter suggested. It's easy to implement
even though the PDB file for large systems is quite big compared with a
binary DCD frame for reading. Let me see how will things work out.

Thanks,
Long

On Sun, Apr 6, 2008 at 3:25 AM, Leandro Martínez <
leandromartinez98_at_gmail.com> wrote:

>
> 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.
> >
>
>

-- 
Yinglong Miao
Ph.D. Candidate
Center for Cell and Virus Theory
Chemistry Department, Indiana University
800 E Kirkwood Ave Room C203A, Bloomington, IN 47405
Tel: 1-812-856-0981

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:49:21 CST