From: Charles McAnany (vmdnamd_at_charlesmcanany.com)
Date: Thu Jun 01 2017 - 12:39:48 CDT

This is mostly a question for John Stone, but I figure maybe someone in the
future can find it of use, because I'm trying to figure out the DCD format.

First, I really appreciate how nice the code in dcdplugin.c is. The
comments are helpful and the control flow is actually about as
straightforward as it can be. After reading programs that are written by
chemists, it's a relief to come across something without a kajillion
one-letter global variables. =)

Okay, questions:
On line 237 in dcdplugin.c (revision 1.77, 2013/06/04):
if (*((int *) (hdrbuf + 44)) == 1)
 This seems to interpret a 4-byte value as an int *without endianness
swap*. Is this correct? Or would this produce incorrect behavior in a dcd
file of opposite endianness that contains a 4th dimension?

Question 2:
Lines 334-337:
 334 for (i=0; i<NTITLE; i++) {
 335 fio_fseek(fd, 80, FIO_SEEK_CUR);
 336 CHECK_FEOF(ret_val, "reading TITLE");
 337 }

Is there some side effect that I'm missing that reassigns ret_val each call
to fio_fseek? Or should line 335 start with "ret_val = fio_fseek...."?

Question 3:
Is the order of the extrablock really A, gamma, B, beta, alpha, C? Am I
reading that right?

And now, for the people of the future, here's what I've worked out about
dcd files. I hope this will be useful, since most of the dcd documentation
I've been able to find is "Go read the source." Please check for any
replies to this thread to see if I got anything wrong. I'd hate to mislead
you!
Each block of the dcd is surrounded by ints specifying its size. These ints
can be 32 or 64 bits, though apparently vmd only writes 32-bit sizes.
The overall layout of a dcd is:

Header Size
Header (84 bytes)
Header Size
Title Block Size
NTITLE (4 bytes)
Title block (multiple of 80 bytes long)
Title Block Size
NATOMS size
NATOMS (4 bytes)
NATOMS size
Index Array (for fixed atoms)
Timesteps

Okay,
1. *Header Size. *
Will always be the integer 84. The first eight bytes of a DCD will be:
84 'CORD' if 32-bit, native endianness.
X Y such that X+Y = 84 if 64-bit, native endianness.
X 'CORD' where swap(X) = 84 if 32-bit, opposite endainness
X Y where swap(X)+swap(Y) = 84 if 64-bit, opposite endianness--001a113f7bb03249a10550e987f2--