Re: [AMBER] Reading NetCDF file

From: Jason Swails <>
Date: Fri, 4 Oct 2013 09:18:12 -0400

On Fri, Oct 4, 2013 at 8:46 AM, Uday Midya <> wrote:

> Hi all
> I have spent few days to find out a simple fortran code for read a amber12
> binary trajectory file. Though there are few examples, none of them work
> for me.
> I have tried to read a dcd file generated from the mdcrd file by ptraj
> module. The code that I used works fine with the NAMD generated dcd file.
> But it fails to read the ptraj generated one.
> Can any one give me a fortran code or some tips for the reading of amber12
> binary trajectory file or the ptraj generated dcd file with/without box
> information.

For the DCD file, I would suggest looking at "catdcd" from VMD. There are
issues with endianness in dcd files which makes reading those files
platform-dependent in general (unless you do byte-swapping, like catdcd and
ptraj/cpptraj do). I've never had problems using ptraj-generated DCD

As for the amber12 NetCDF file, do you have to use Fortran? The
Python-NetCDF bindings make reading NetCDF files in Python (with numpy)
much easier. The file $AMBERHOME/doc/nctraj.pdf is the NetCDF
specification for Amber trajectories which will tell you what dimensions
and variables are present in the file.

As far as an example using the Fortran API to read an Amber-generated
NetCDF file, I would suggest looking at the subroutines that sander itself
uses to read trajectories: $AMBERHOME/src/sander/bintraj.F90. The NetCDF
API documentation itself may be more helpful:

For an example reading NetCDF files in Python:


Jason M. Swails
Rutgers University
Postdoctoral Researcher
AMBER mailing list
Received on Fri Oct 04 2013 - 06:30:03 PDT
Custom Search