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

dumpdcd.c File Reference

#include "largefiles.h"
#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 17 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 23 of file dumpdcd.c.

Referenced by ComputeNonbondedCUDA::build_exclusions(), ComputeNonbondedCUDA::build_force_table(), Molecule::build_gridforce_params(), OptPmeRealSpace::compute_forces(), ComputeConsTorque::doForce(), ComputeConsForce::doForce(), OptPmeRealSpace::fill_charges(), 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(), TholeElem::getMoleculePointers(), ExclElem::getMoleculePointers(), ImproperElem::getMoleculePointers(), DihedralElem::getMoleculePointers(), CrosstermElem::getMoleculePointers(), BondElem::getMoleculePointers(), AnisoElem::getMoleculePointers(), AngleElem::getMoleculePointers(), imd_htonl(), imd_ntohl(), imd_readn(), imd_recv_handshake(), imd_send_energies(), imd_send_fcoords(), imd_send_mdcomm(), imd_writen(), ComputeHomeTuples< TholeElem, Thole, TholeValue >::loadTuples(), main(), my_imd_connect(), read_binary_file(), Molecule::receive_Molecule(), ComputeMgr::recvComputeConsForceMsg(), and SELF().


Function Documentation

int main int  argc,
char *  argv[]
 

Definition at line 26 of file dumpdcd.c.

References int32, j, and MAP_FILE.

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


Generated on Sun Feb 12 04:07:58 2012 for NAMD by  doxygen 1.3.9.1