The truth is rarely pure and never simple

Unrecognized DCD header in CP2K

DCD files are quite versatile but suffer from nearly non-existing documentation except for some quite dated code that gets copied around between open source projects. They can hold atomic coordinates, velocities and forces – all designated by a different DCD file header: CORD, VEL, FRC. CP2K allows the user to write out all the aforementioned information for a trajectory, but many software packages have limited support for reading forces and velocities from DCD files, mostly, because they use the original source from VMD which only reads coordinates. The ones I tested are VMD/catdcd, mdtraj, and MDAnalysis.

The typical error message would be:

CatDCD 4.0
dcdplugin) unrecognized DCD header:
dcdplugin)   [0]: 1409286144  [1]:  541282886
dcdplugin)   [0]: 0x54000000  [1]: 0x20435246
dcdplugin) read_dcdheader: corruption or unrecognized file structure
Error: could not open file 'for-frc-1.dcd' for reading.

If the header is “wrong” in the sense that the bytes read “FRC” instead of “CORD”, you can either change this in a hex editor (make sure you do not insert bytes to the file) or you can use the dumpdcd tool in CP2K.

Update, 04.02.2016
Please use the updated version of dumpdcd.f90. The author of the tool, Matthias Krack, has updated the code such that no patching is necessary. Thank you!

Only if you happen to be stuck with former versions (CP2K svn revision < 16559) for whatever reason, feel free to follow this approach: It is in the cp2k/tools folder and needs a bit of patching first: open dumpdcd.f90, and find line 443:

ELSE IF (TRIM(ADJUSTL(id_dcd)) == "CORD" THEN

and exchange “CORD” for “FRC”. Then add the following line in the IF branch.

id_dcd = "CORD"

Now compile and you can write new DCD files from them:

./dumpdcd -i -o output.dcd -of dcd input.dcd

The resulting DCD file has the “CORD” header and can be read by any of the tools mentioned above.

Leave a comment

Your email address will not be published.

2 thoughts on “Unrecognized DCD header in CP2K”