First I'll cite myself:
Originally Posted By: blubbi

Hi again.

I know handling NAMD stuff is not one of the top priorities of CHARMM, but since the io.doc suggests that it should work, I dare to ask.

While I tried to read a binary coordinate file from NAMD (with the original PSF/EXPLOR.PSF created with CHARMM) I get the following weird error:

Code:
 CHARMM>    read NAMD FILE "../../run400/memb30.restart.coor"
Reading as namd binary file"../../run400/memb30.restart.coor"                                              
opening file ../../run400/memb30.restart.coor
number of atoms does not match; in psf 68120, in file 68120 ; exiting...

      ***** LEVEL -5 WARNING FROM <MAINIO> *****
      ***** Error reading binary file
      ******************************************


68120 Atoms in the PSF looks very equal to 68120 Atoms in the "file". And yes, there are exactly 68120 Atoms in my setup. crazy

It does not make any difference if I read "memb30.coor" or "memb30.restart.coor".

Any suggestions?

Here's my test script:
Code:
open read card unit 10 name ../../top_all27_prot_lipid.rtf
read  rtf card unit 10

open read card unit 20 name ../../par_all27_prot_lipid.prm
read para card unit 20

stream ../../toppar_all27_lipid_cholesterol.str

open read card unit 10 name ../../step5_assembly.psf
read psf unit 10 card

!read NAMD FILE "../../run400/memb30.coor"
read NAMD FILE "../../run400/memb30.restart.coor"

coor stat
!energy

stop



I played a bit with the code (keep in mind I have no clue of C) and what I could figure out was, that the code does not seem to be portabe (32bit <-> 64bit). Compiling it to 32Bit code works!!!!
Either the variables are borked somehow (int vs. long int) or the stack is shredded somewhere. But This is way beyond my lacking C skills.

I commented out the following code and added some print statements to see what happens:
Code:
  /* 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;   
  }*/


and it stumbled upon the next comparison (prinf added by me):
Code:
  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");



The result was
[...]
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
Code:
#ifdef i8
#define INT long
#else 
#define INT int
#endif


and later:
Code:
#if ibmrs || hpux
void readnamd(double *x, double *y, double *z, INT *ptr_natom, char *fname, INT *ptr_flen, INT *ptr_ier)
#else
void readnamd_(double *x, double *y, double *z, INT *ptr_natom, char *fname, INT *ptr_flen, INT *ptr_ier)
#endif
{
  FILE *fp;
  INT n, i;


So where's the problem?

If I try to compile this chunk of code I get the following warnings:

Quote:
gcc -O -Dgnu -DLINUX -Di8 -Wall -pedantic -c /home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘fmalloc_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:104: warning: conflicting types for built-in function ‘malloc’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘ffree_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:115: warning: implicit declaration of function ‘free’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:115: warning: incompatible implicit declaration of built-in function ‘free’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:115: warning: passing argument 1 of ‘free’ makes pointer from integer without a cast
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘fsystem_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:145: warning: implicit declaration of function ‘exit’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:145: warning: incompatible implicit declaration of built-in function ‘exit’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘gethdir_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:177: warning: implicit declaration of function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:177: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:183: warning: implicit declaration of function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:183: warning: incompatible implicit declaration of built-in function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:188: warning: implicit declaration of function ‘strcpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:188: warning: incompatible implicit declaration of built-in function ‘strcpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:188: warning: incompatible implicit declaration of built-in function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘fgetenv_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:232: warning: incompatible implicit declaration of built-in function ‘strcpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:233: warning: incompatible implicit declaration of built-in function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘fputenv_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:272: warning: incompatible implicit declaration of built-in function ‘strcpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:273: warning: implicit declaration of function ‘putenv’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:277: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long int’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:278: warning: incompatible implicit declaration of built-in function ‘exit’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘frealloc_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:288: warning: conflicting types for built-in function ‘realloc’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘filcpy_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:317: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:337: warning: incompatible implicit declaration of built-in function ‘free’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘getunamef_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:375: warning: incompatible implicit declaration of built-in function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:380: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘fdate_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:692: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘chngbuf_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:736: warning: unused variable ‘bufptr’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘uninf_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:988: warning: incompatible implicit declaration of built-in function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:990: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘binarytesthdrr_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1185: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1187: warning: incompatible implicit declaration of built-in function ‘strlen’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1187: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1205: warning: implicit declaration of function ‘strcmp’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘binaryreadhdrr_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1271: warning: unused variable ‘hrev’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1271: warning: unused variable ‘input’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘binaryrdtitl_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1318: warning: unused variable ‘ntitl8’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1315: warning: unused variable ‘input’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘readnamd_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1554: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1559: warning: incompatible implicit declaration of built-in function ‘free’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1537: warning: unused variable ‘i’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1564: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: At top level:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1575: error: expected declaration specifiers or ‘...’ before string constant
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1575: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1575: warning: type defaults to ‘int’ in declaration of ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1575: error: conflicting types for ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1575: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1576: error: expected identifier or ‘(’ before ‘for’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1576: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1576: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘++’ token
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1582: error: expected declaration specifiers or ‘...’ before string constant
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1582: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1582: warning: type defaults to ‘int’ in declaration of ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1582: error: conflicting types for ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1582: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1583: error: expected declaration specifiers or ‘...’ before string constant
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1583: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1583: warning: type defaults to ‘int’ in declaration of ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1583: error: conflicting types for ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1583: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1584: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1584: warning: type defaults to ‘int’ in declaration of ‘fclose’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1584: warning: parameter names (without types) in function declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1585: error: expected declaration specifiers or ‘...’ before string constant
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1585: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1585: warning: type defaults to ‘int’ in declaration of ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1585: error: conflicting types for ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1585: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1586: error: expected declaration specifiers or ‘...’ before string constant
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1586: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1586: warning: type defaults to ‘int’ in declaration of ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1586: error: conflicting types for ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1586: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1587: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1587: warning: type defaults to ‘int’ in declaration of ‘free’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1587: warning: parameter names (without types) in function declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1587: warning: conflicting types for built-in function ‘free’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1588: error: expected declaration specifiers or ‘...’ before string constant
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1588: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1588: warning: type defaults to ‘int’ in declaration of ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1588: error: conflicting types for ‘printf’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1588: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1589: warning: data definition has no type or storage class
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1589: warning: type defaults to ‘int’ in declaration of ‘ptr_ier’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1591: error: expected identifier or ‘(’ before ‘}’ token
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘writenamd_’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1617: warning: incompatible implicit declaration of built-in function ‘strncpy’
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1629: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1633: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1634: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1635: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘osx_g95_getpointer__’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1650: warning: cast from pointer to integer of different size
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c: In function ‘openpty’:
/home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c:1657: warning: ‘return’ with no value, in function returning non-void


So finally:
Code works for 32Bit but is borked for 64Bit. I guess it is related to some INT, LONG variable declaration... but keep in mind I have no clue of C!