Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

dumpdcd.c File Reference

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <limits.h>

Go to the source code of this file.

Defines

#define MAP_FILE   0
#define SKIPFOUR   {d+=4;n-=4;}
#define SKIP(X)   {d+=(X);n-=(X);}
#define READINT(X)

Typedefs

typedef short int32

Functions

int main (int argc, char *argv[])


Define Documentation

#define MAP_FILE   0
 

Definition at line 15 of file dumpdcd.c.

Referenced by main().

#define READINT  ) 
 

Value:

{ X=0; if (isbig) { for(j=0;j<4;++j,X<<8) X+=d[j]; } \
        else { for(j=3;j>=0;--j,X<<8) X+=d[j]; } }

Referenced by main().

#define SKIP  )     {d+=(X);n-=(X);}
 

Referenced by main().

#define SKIPFOUR   {d+=4;n-=4;}
 


Typedef Documentation

typedef short int32
 

Definition at line 21 of file dumpdcd.c.

Referenced by Molecule::build_constant_forces(), Molecule::build_constorque_params(), Molecule::build_constraint_params(), Molecule::build_exPressure_atoms(), Molecule::build_fixed_atoms(), Molecule::build_gridforce_params(), Molecule::build_movdrag_params(), Molecule::build_rotdrag_params(), Molecule::build_stirred_atoms(), ComputeConsTorque::doForce(), ComputeConsForce::doForce(), fill_header(), Molecule::get_angles_for_atom(), Molecule::get_bonds_for_atom(), Molecule::get_crossterms_for_atom(), Molecule::get_dihedrals_for_atom(), Molecule::get_exclusions_for_atom(), Molecule::get_full_exclusions_for_atom(), Molecule::get_impropers_for_atom(), Molecule::get_mod_exclusions_for_atom(), GlobalMasterIMD::get_vmd_forces(), ImproperElem::getMoleculePointers(), DihedralElem::getMoleculePointers(), CrosstermElem::getMoleculePointers(), BondElem::getMoleculePointers(), AngleElem::getMoleculePointers(), imd_htonl(), imd_ntohl(), imd_readn(), imd_recv_handshake(), imd_send_energies(), imd_send_fcoords(), imd_send_mdcomm(), imd_writen(), ComputeHomeTuples< BondElem, Bond, BondValue >::loadTuples(), main(), my_imd_connect(), read_binary_file(), Molecule::receive_Molecule(), ComputeMgr::recvComputeConsForceMsg(), SELF(), and Molecule::send_Molecule().


Function Documentation

int main int  argc,
char *  argv[]
 

Definition at line 24 of file dumpdcd.c.

References int32, and MAP_FILE.

00024                                  {
00025 
00026 int fd;
00027 struct stat statbuf;
00028 int i, j, n, isbig, itmp;
00029 double delta;
00030 float delta4;
00031 int32 icntrl[20];
00032 char *ccntrl;
00033 char b[8];
00034 char *d;
00035 
00036 if ( argc != 2 ) {
00037   fprintf(stderr,"This program reads the ICNTRL array from DCD files.\n");
00038   fprintf(stderr,"Usage: %s <filename> > <data>\n",argv[0]);
00039   exit(-1);
00040 }
00041 
00042 if ( ( fd = open(argv[1], O_RDONLY) ) < 0 ) {
00043   fprintf(stderr,"Can't open %s for reading.\n",argv[1]);
00044   exit(-1);
00045 }
00046 
00047 if ( fstat(fd,&statbuf) < 0 ) {
00048   fprintf(stderr,"Can't stat %s.\n",argv[1]);
00049   exit(-1);
00050 }
00051 
00052 n = statbuf.st_size;
00053 
00054 if ( n <= 104 ) {
00055   fprintf(stderr,"%s is not in DCD format.\n",argv[1]);
00056   exit(-1);
00057 }
00058 
00059 if ( n % 4 ) {
00060   fprintf(stderr,"%s is not in DCD format.\n",argv[1]);
00061   exit(-1);
00062 }
00063 
00064 if ( ( d = mmap(0,n,PROT_READ,MAP_FILE|MAP_SHARED,fd,0) )
00065                                                         == (caddr_t) -1 ) {
00066   fprintf(stderr,"Can't mmap %s.\n",argv[1]);
00067   exit(-1);
00068 }
00069 
00070 #define SKIPFOUR {d+=4;n-=4;}
00071 #define SKIP(X) {d+=(X);n-=(X);}
00072 #define READINT(X) { X=0; if (isbig) { for(j=0;j<4;++j,X<<8) X+=d[j]; } \
00073         else { for(j=3;j>=0;--j,X<<8) X+=d[j]; } }
00074 
00075 SKIPFOUR;  /* 84 */
00076 SKIPFOUR;  /* "CORD" */
00077 
00078 ccntrl = (char*)(&(icntrl[0]));
00079 
00080 for(j=0;j<80;++j) {
00081   ccntrl[j] = d[j];
00082 }
00083 
00084 for(j=0;j<9;++j) {
00085   itmp = icntrl[j];
00086   printf("%d\n",itmp);
00087 }
00088 
00089 printf("%f\n",*((float*)(icntrl+9)));
00090 
00091 for(j=10;j<20;++j) {
00092   itmp = icntrl[j];
00093   printf("%d\n",itmp);
00094 }
00095 
00096 }


Generated on Sat Aug 30 04:07:41 2008 for NAMD by  doxygen 1.3.9.1