|
Joined: Feb 2009
Posts: 83
Forum Member
|
OP
Forum Member
Joined: Feb 2009
Posts: 83 |
First I'll cite myself: 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: 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. It does not make any difference if I read "memb30.coor" or "memb30.restart.coor". Any suggestions? Here's my test script: 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: /* 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): 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 #ifdef i8
#define INT long
#else
#define INT int
#endif and later: #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: 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!
|
|
|
|
Joined: Feb 2009
Posts: 83
Forum Member
|
OP
Forum Member
Joined: Feb 2009
Posts: 83 |
Well, at least the NAMD reader works... CHARMM> !read NAMD FILE "memb30.coor" CHARMM> read NAMD FILE "memb30.restart.coor" opening file memb30.restart.coor CHARMM> CHARMM> coor stat STATISTICS FOR 68120 SELECTED ATOMS: XMIN = -53.300504 XMAX = 55.834633 XAVE = -0.056126 YMIN = -55.419478 YMAX = 53.734237 YAVE = -0.268634 ZMIN = -37.261740 ZMAX = 45.160107 ZAVE = 1.756780 WMIN = 0.000000 WMAX = 0.000000 WAVE = 0.000000 CHARMM> energy
NONBOND OPTION FLAGS: ELEC VDW ATOMs CDIElec SHIFt VATOm VSWItch BYGRoup NOEXtnd NOEWald CUTNB = 14.000 CTEXNB =999.000 CTONNB = 10.000 CTOFNB = 12.000 WMIN = 1.500 WRNMXD = 0.500 E14FAC = 1.000 EPS = 1.000 NBXMOD = 5 There are 0 atom pairs and 0 atom exclusions. There are 0 group pairs and 0 group exclusions. <MAKINB> with mode 5 found 146290 exclusions and 111112 interactions(1-4) <MAKGRP> found 33970 group exclusions. Generating nonbond list with Exclusion mode = 5 VEHEAP> Expanding heap size by 20709376 words. Segmentation fault
|
|
|
|
Joined: May 2009
Posts: 125
Forum Member
|
Forum Member
Joined: May 2009
Posts: 125 |
I agree with Kenno: the #ifdef stuff is bogus. This is what Fortran 2003's iso_c_binding module is for. Try int32_t on the C side and integer(c_int32_t) on the Fortran side. If you're using gfortran, it needs to be version 4.3 or later.
|
|
|
|
Joined: Sep 2003
Posts: 8,660 Likes: 26
Forum Member
|
Forum Member
Joined: Sep 2003
Posts: 8,660 Likes: 26 |
There had also been some Makefile errors where instead of '-Di8', the bogus '-i8' flag was being used for the C compiler, which I suspect would break that #ifdef declaration on 64-bit machines.
Rick Venable computational chemist
|
|
|
|
Joined: Sep 2003
Posts: 4,883 Likes: 12
Forum Member
|
Forum Member
Joined: Sep 2003
Posts: 4,883 Likes: 12 |
Why bother with binary file problems instead of using a PDB file from NAMD?
Another issue may be the reading of "n" from the file: fread(&n, sizeof(INT), 1, fp);
This may differ for 32- and 64-bit CHARMM installations, but presumably NAMD has already made a decision here?
IMHO: The simple solution is to just use CHARMM - your time is certainly much more valuable than computer time (at about $100/core/year)! Not only is CHARMM orders of magnitude more versatile than all other codes (combined?), but it is also significantly faster in serial mode, which is very important since enhanced sampling is most efficiently obtained by running multiple independent simulations, be it REMD or just 20x 50 ns instead of a single 1µs simulation.
Lennart Nilsson Karolinska Institutet Stockholm, Sweden
|
|
|
|
Joined: Feb 2009
Posts: 83
Forum Member
|
OP
Forum Member
Joined: Feb 2009
Posts: 83 |
There had also been some Makefile errors where instead of '-Di8', the bogus '-i8' flag was being used for the C compiler, which I suspect would break that #ifdef declaration on 64-bit machines. No, thats not the case: (I only added -Wall -pedantic for testing purpose) gcc -O -Dgnu -DLINUX -Di8 -Wall -pedantic -c /home/blub/.soft/usr/local/charmm/c34b2/source/machdep/cstuff.c
|
|
|
|
Joined: Sep 2003
Posts: 4,883 Likes: 12
Forum Member
|
Forum Member
Joined: Sep 2003
Posts: 4,883 Likes: 12 |
routine readnamd in source/machdep/cstuff.c has to be changed: 1537c1537,1538 < INT n, i; --- > INT i; > int n; 1564c1565 < fread(&n, sizeof(INT), 1, fp); --- > fread(&n, sizeof(int), 1, fp); 1567c1568 < if (n != (*ptr_natom)) { --- > if ((INT)n != (*ptr_natom)) {
Lennart Nilsson Karolinska Institutet Stockholm, Sweden
|
|
|
|
Joined: Sep 2003
Posts: 8,660 Likes: 26
Forum Member
|
Forum Member
Joined: Sep 2003
Posts: 8,660 Likes: 26 |
It looks like most of the problems with -Di8 have been related to CC definitions in Makefile_em64t
Rick Venable computational chemist
|
|
|
|
Joined: Dec 2005
Posts: 1,535
Forum Member
|
Forum Member
Joined: Dec 2005
Posts: 1,535 |
All these changes involving i8 versus "no i8" and INT versus int may fix the problem for one compiler/architecture, but are prone to break it in another one. As mgarraha mentioned, the only portable way to do these things is to use Fortran 2003's iso_c_binding module.
Here's my original post he's referring to.
|
|
|
|
|