Skip to content

Commit

Permalink
remarks handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kain88-de committed Sep 1, 2016
1 parent 379a00a commit 66ec493
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions package/MDAnalysis/lib/formats/libdcd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ _whence_vals = {"FIO_SEEK_SET": SEEK_SET,
"FIO_SEEK_CUR": SEEK_CUR,
"FIO_SEEK_END": SEEK_END}

from libc.stdint cimport uintptr_t
from libc.stdlib cimport free

cdef enum:
FIO_READ = 0x01
FIO_WRITE = 0x02
Expand Down Expand Up @@ -65,8 +68,6 @@ cdef class DCDFile:
cdef float *fixedcoords
cdef int reverse
cdef int charmm
cdef char *remarks
cdef int len_remarks

def __cinit__(self, fname, mode='r'):
self.fname = fname.encode('utf-8')
Expand Down Expand Up @@ -101,9 +102,7 @@ cdef class DCDFile:

def close(self):
if self.is_open:
print("closing", self.freeind == NULL, self.fixedcoords == NULL)
if self.freeind != NULL:
print("freeing memory")
close_dcd_read(self.freeind, self.fixedcoords);

ok = fio_fclose(self.fp)
Expand All @@ -116,11 +115,18 @@ cdef class DCDFile:
if not self.is_open:
raise RuntimeError("No file open")

cdef char *remarks
cdef int len_remarks

print("reading", <uintptr_t>self.freeind, self.fixedcoords == NULL)
ok = read_dcdheader(self.fp, &self.natoms, &self.nsets, &self.istart,
&self.nsavc, &self.delta, &self.nfixed, &self.freeind,
&self.fixedcoords, &self.reverse,
&self.charmm, &self.remarks, &self.len_remarks)
&self.charmm, &remarks, &len_remarks)
print("reading", <uintptr_t>self.freeind, self.fixedcoords == NULL)
if ok != 0:
raise IOError("Reading DCD header failed: {}".format(DCD_ERRORS[ok]))
if remarks != NULL:
free(remarks)

print(self.natoms)

0 comments on commit 66ec493

Please sign in to comment.