Reading NAMD coor files in CHARMM -> Fail for 64Bit

From: Bjoern Olausson (namdlist_at_googlemail.com)
Date: Wed Aug 11 2010 - 06:57:27 CDT

Hi,

Just in case someone is willing to fix the CHARMM part of reading NAMD coor
files. I figured out that the code is not portabele between 32/64Bit more then
to figure out the problem is beyond may lacking C skills.

Everything I found out so far is documented in the CHARMM-Forum:
http://www.charmm.org/ubbthreads-7-5-5/ubbthreads.php?ubb=showflat&Number=24987
http://www.charmm.org/ubbthreads-7-5-5/ubbthreads.php?ubb=showflat&Number=25078

It looks as if the CHARMM Devs are not very eager to fix this bug.
I don't know how much work it is to fix the variable declaration (I guess it
is some INT <-> LONG Problem) but if has the time, will and guts to mess with
this code I would appreciate it very much since I occasionately would like to
read a coor file instead of reding the coordinate set from a whole DCD.

I'll shortly summarize my findings:

The following check fails compiled for 64Bit:
  /* checking if the number of atoms is the same
  printf("checking if the number of atoms is the same\n");
  if ( n != (*ptr_natom)) {
    printf("number of atoms does not match; in psf %d, in file %d ; exiting...
\n", n, *ptr_natom);
    free(filename);
    *ptr_ier = -1;
    return;
  }*/

--->
number of atoms does not match; in psf 68120, in file 68120 ; exiting..
<---

Commenting out the above check, makes the following loop infinite:

  printf("read in coordinates\n");
  for (i = 0; i < n; i++) {
    printf("read in coordinates. Atom %d of %d \n", i, n);
    fread(x++,sizeof(double),1,fp);
    fread(y++,sizeof(double),1,fp);
    fread(z++,sizeof(double),1,fp);
  }
  printf("done reading coordinates\n");

---->
[...]
read in coordinates. Atom 10961940 of 68120
read in coordinates. Atom 10961941 of 68120
[...]
<----

What is weird:
i,n and ptr_natom ar all declared as LONG:

#ifdef i8
#define INT long
#else
#define INT int
#endif

I know it is some extraordinary request... fixing some code of a competitive
program ;-)

Cheers
Bjoern

-- 
Bjoern Olausson
Martin-Luther-Universität Halle-Wittenberg 
Fachbereich Biochemie/Biotechnologie
Kurt-Mothes-Str. 3
06120 Halle/Saale
Phone: +49-345-55-24942

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:56:01 CST