GLYLIB  0.3.0b
add_trajcrds_to_prmtop_assembly.c
Go to the documentation of this file.
00001 /** \file add_trajcrds_to_prmtop_assembly.c 
00002 Function for adding the contents of an AMBER coordinate trajectory to an 
00003 existing assembly.
00004 
00005 Please read the following carefully if this is your first use.
00006 
00007 Usage: 
00008 void add_trajcrds_to_prmtop_assembly(
00009         fileset F, ///< The file containing the data *Must* be open
00010         assembly *A, ///< Assembly to which the crds should be added
00011         char ftype, ///< 'c'=coordinate; 'v'=velocity; 'r'=restart
00012         int offset ///< read in the offset-th trajectory -- zero=current
00013         )
00014 
00015 
00016 *** Storage of Coordinates ***
00017 
00018 This function only adds *one* set of coordinates at a time.  If the file
00019 pointer is not altered between calls, each time this function is called it
00020 will read in the next set of coordinates.
00021 
00022 The coordinates are stored via the assembly's atom double-pointers.  The 
00023 **atom pointers must be set correctly because the the coordinates will be 
00024 added in the order dictated by the **atom locations.  
00025 
00026 The coordinates are added into an 'xa' location in the incoming assembly. 
00027 Regarding the 'xa' locations:  The program will check through the "nalt" for 
00028 each atom.  It will reallocate them all to the same size if they differ.  
00029 The new coordinates will be added starting in the lowest xa array location 
00030 that is empty for all atoms.
00031 
00032 You can figure out where they were added because the function will only
00033 add one set of coordinates, and the value stored in "nalt" tells you where.
00034 Alternately, you can set nalt=0 and free(xa) between each call.
00035 
00036 If the file is a velocity trajectory, substitute velocity locations for
00037 alternate coordinate locations in the last two paragraphs.
00038 
00039 If the file is specified as a restart file, and if velocities are found, 
00040 velocities will be added into array locations to match the xa locations.  
00041 Any unused velocity locations will be cleared to equal zero.
00042 
00043 
00044 *** The input file pointer status ***
00045 
00046 The calling function *must* open the file.  In most cases, the file pointer 
00047 should not be altered between calls to this function.  This is because the
00048 function will begin reading coordinates from the current position pointed to
00049 by the file pointer.  At the end of each read, it will be pointing to the
00050 next set of coordinates.  Unless the calling program wants to change this
00051 behavior, it should not alter the file pointer.
00052 
00053 
00054 *** Regarding BOX information ***
00055 
00056 This assembly *MUST* have nBOX set correctly.  If nBOX is less than or equal
00057 to zero, this function will assume there is no box information contained in 
00058 the coordinate file.  If nBOX is greater than or equal to one, it will assume
00059 there is box information.  This distinction can have a significant impact on
00060 the sanity of structures defined by the coordinate sets.  
00061 
00062 LOCATION OF BOX INFO:  It is assumed most folks will ignore the box info, so
00063 it will be put in a slightly annoying location.  In the assembly's nBOX-long
00064 BOX array, the box info will be offset in the BOX array by an index of +1 from 
00065 the locations of the coordinate and velocity information.  The zeroth and first
00066 locations will be the box info originally contained in the TOP file.
00067 
00068 To reiterate:  BOX INFO IS CONTAINED STARTING AT INDEX +1
00069 
00070 ...but, the three coordinates are in the first coordinate slot, unlike the 
00071 prmtop info, which also contains an angle... confused yet?
00072 
00073 
00074 *** An example for coordinate and box information location ***
00075 
00076 For example, if there are 5 sets of alternative coordinates saved in the 
00077 incoming assembly, and this function is reading in a coordinate trajectory
00078 containing box info, the function will save new coordinates into the sixth
00079 coordinate location (.xa[5]), and box info into the seventh (.BOX[6]).
00080 
00081 Begun on 20080811 by BLFoley.  Significantly altered starting 20090803 BLF.
00082 */
00083 #include <mylib.h>
00084 #include <molecules.h>
00085 #include <AMBER/amber.h>
00086 
00087 void add_trajcrds_to_prmtop_assembly(
00088         fileset F, ///< The trajectory file containing the data *Must* be open
00089         assembly *A, ///< Assembly ("incoming") to which the crds should be added
00090         char ftype, ///< 'c' if coordinate ; 'v' if velocity ; 'r' if restart (might have both)
00091         int offset ///< read in the offset-th trajectory -- starts with zero=current
00092         ){
00093 char tmpc,readnum[13]; ///< temporary char holders
00094 int allocated_xa=0, ///< alternate coords or vectors allocated outgoing
00095     nalt_here=0, ///< alternate coords or vectors allocated incoming
00096     scan_tst=0, ///< for testing [f,s]scanf results
00097     ai=0, ///< atom index
00098     xi=0, ///< dummy coordinate index
00099     newline=0; ///< counter to test if there should be a newline
00100 long foffset;
00101 fpos_t here,here2;
00102 
00103 for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00104 
00105 /// DO NOT RE/OPEN the file 
00106 // But do check to see that it is already open
00107 if(F.F==NULL){mywhine("add_trajcrds_to_prmtop_assembly: called file is not already open.");}
00108 // check other sanity
00109 if(A[0].na<=0){mywhine("add_trajcrds_to_prmtop_assembly: Incoming assembly contains no atom pointers.");}
00110 if((ftype!='c')&&(ftype!='v')&&(ftype!='r')){mywhine("add_trajcrds_to_prmtop_assembly: unknown input file type.");}
00111 if(offset<0){mywhine("add_trajcrds_to_prmtop_assembly: Negative coordinate offset/skip values are not supported.");}
00112 if((ftype=='r')&&(offset>0)){
00113         printf("add_trajcrds_to_prmtop_assembly: WARNING! asked for non-zero offset in a restart file.\n");
00114         printf("\t\tA restart file should contain precisely one data set.  Ignoring the offset request.\n");}
00115 if((A[0].nBOX>0)&&(A[0].BOX[0].nC!=2)&&(A[0].BOX[0].C[1].nD!=3)){
00116         mywhine("add_trajcrds_to_prmtop_assembly: non-prmtop BOXINFO not supported.");}
00117 
00118 /// See if we are at the start of the file or not
00119 foffset=ftell(F.F);
00120 if(foffset==0){ // we are at the start of the file
00121 // Ignore any titles -- let the calling program read them if it wants to
00122         tmpc=fgetc(F.F); // read and ignore the first line
00123         while((tmpc!='\n')&&(tmpc!='\r')&&(tmpc!=EOF)){ 
00124                 tmpc=fgetc(F.F); 
00125                 //printf("%c",tmpc);
00126                 }
00127         //printf("\n");
00128         if (ftype=='r'){ // if restart, also read and ignore the second line
00129                 tmpc=fgetc(F.F);
00130                 while((tmpc!='\n')&&(tmpc!='\r')&&(tmpc!=EOF)){ tmpc=fgetc(F.F);
00131                 //printf("%c",tmpc);
00132                 }
00133         //printf("\n");
00134                 }
00135         if(tmpc==EOF){printf("add_trajcrds_to_prmtop_assembly: WARNING: EOF found at top of file.\n");}
00136         }
00137 
00138 /// Don't make lots of silly checks -- just add coordinates to atom structures...
00139 
00140 /// First, allocate space as needed, and clear any unused middle-space
00141 if(ftype=='v'){
00142         for(ai=0;ai<A[0].na;ai++){ if(A[0].a[ai][0].nvec) allocated_xa=A[0].a[ai][0].nvec; }
00143         if(allocated_xa==0){
00144                 for(ai=0;ai<A[0].na;ai++){
00145                         A[0].a[ai][0].nvec=allocated_xa=1;
00146                         A[0].a[ai][0].v=(vectormag_3D*)calloc(1,sizeof(vectormag_3D));
00147                         }
00148                 }
00149         else{   
00150                 allocated_xa++;
00151                 for(ai=0;ai<A[0].na;ai++){
00152                         if(A[0].a[ai][0].nvec==0){
00153                                 A[0].a[ai][0].nvec=allocated_xa;
00154                                 A[0].a[ai][0].v=(vectormag_3D*)calloc(allocated_xa,sizeof(vectormag_3D));
00155                                 }
00156                         else{
00157                                 nalt_here=A[0].a[ai][0].nvec;
00158                                 A[0].a[ai][0].nvec=allocated_xa;
00159                                 A[0].a[ai][0].v=(vectormag_3D*)realloc(A[0].a[ai][0].v,allocated_xa*sizeof(vectormag_3D));
00160                                 for(xi=nalt_here;xi<allocated_xa;xi++){
00161                                         A[0].a[ai][0].v[xi].i=A[0].a[ai][0].v[xi].j=0;
00162                                         A[0].a[ai][0].v[xi].k=A[0].a[ai][0].v[xi].d=0;
00163                                         }
00164                                 }
00165                         }
00166                 }
00167         }
00168 else{
00169         for(ai=0;ai<A[0].na;ai++){ if(A[0].a[ai][0].nalt>allocated_xa) allocated_xa=A[0].a[ai][0].nalt; }
00170         if(allocated_xa==0){
00171                 for(ai=0;ai<A[0].na;ai++){
00172                         A[0].a[ai][0].nalt=allocated_xa=1;
00173                         A[0].a[ai][0].xa=(coord_3D*)calloc(1,sizeof(coord_3D));
00174                         }
00175                 }
00176         else{   
00177                 allocated_xa++;
00178                 for(ai=0;ai<A[0].na;ai++){
00179                         if(A[0].a[ai][0].nalt==0){
00180                                 A[0].a[ai][0].nalt=allocated_xa;
00181                                 A[0].a[ai][0].xa=(coord_3D*)calloc(allocated_xa,sizeof(coord_3D));
00182                                 }
00183                         else{
00184                                 nalt_here=A[0].a[ai][0].nalt;
00185                                 A[0].a[ai][0].nalt=allocated_xa;
00186                                 A[0].a[ai][0].xa=(coord_3D*)realloc(A[0].a[ai][0].xa,allocated_xa*sizeof(coord_3D));
00187                                 for(xi=nalt_here;xi<allocated_xa;xi++){
00188                                         A[0].a[ai][0].xa[xi].i=A[0].a[ai][0].xa[xi].j=A[0].a[ai][0].xa[xi].k=0;
00189                                         }
00190                                 }
00191                         }
00192                 }
00193         }
00194 
00195 /// Now scan through and add info to the structure
00196 xi=allocated_xa-1;
00197 if(ftype=='r') newline=1;
00198 else newline=0;
00199 for(ai=0;ai<A[0].na;ai++){
00200         //if(ftype=='v') scan_tst=fscanf(F.F,"%lf",&A[0].a[ai][0].v[xi].i);
00201         //else scan_tst=fscanf(F.F,"%lf",&A[0].a[ai][0].xa[xi].i);
00202         //if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass 1-i.");}
00203         //if(ftype=='v') scan_tst=fscanf(F.F,"%lf",&A[0].a[ai][0].v[xi].j);
00204         //else scan_tst=fscanf(F.F,"%lf",&A[0].a[ai][0].xa[xi].j);
00205         //if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass 1-j.");}
00206         //if(ftype=='v') scan_tst=fscanf(F.F,"%lf",&A[0].a[ai][0].v[xi].k);
00207         //else scan_tst=fscanf(F.F,"%lf",&A[0].a[ai][0].xa[xi].k);
00208         
00209         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00210         if(ftype=='r') scan_tst=fscanf(F.F,"%12c",readnum);
00211         else {
00212                 scan_tst=fscanf(F.F,"%8c",readnum);
00213                 newline++;
00214                 }
00215         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass 1-i.");}
00216 
00217 //printf("readnum (i) is >>>%s<<< newline is %d\n",readnum,newline);
00218         if( ((ftype!='r')&&(newline==10)) ) 
00219                 {
00220                 scan_tst=fgetc(F.F);
00221 //printf("  newline is %d (10, we hope), scan_tst is >>>%c<<<\n",newline, scan_tst);
00222                 if(scan_tst!='\n') {mywhine("i: newline expected but not found during first read-set");}
00223                 if(ftype!='r') newline=0;       
00224                 } 
00225 
00226         if(ftype=='v') scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].v[xi].i);
00227         else scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].xa[xi].i);
00228 
00229 //printf("A[0].a[ai][0].xa[xi].i is %f\n",A[0].a[ai][0].xa[xi].i);
00230 
00231         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00232         if(ftype=='r') scan_tst=fscanf(F.F,"%12c",readnum);
00233         else {
00234                 scan_tst=fscanf(F.F,"%8c",readnum);
00235                 newline++;
00236                 }
00237         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass 1-j.");}
00238 
00239 //printf("readnum (j) is >>>%s<<< newline is %d\n",readnum,newline);
00240         if( ((ftype!='r')&&(newline==10)) ) 
00241                 {
00242                 scan_tst=fgetc(F.F);
00243 //printf("  newline is %d (10, we hope), scan_tst is >>>%c<<<\n",newline, scan_tst);
00244                 if(scan_tst!='\n') {mywhine("j: newline expected but not found during first read-set");}
00245                 if(ftype!='r') newline=0;       
00246                 } 
00247 
00248         if(ftype=='v') scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].v[xi].j);
00249         else scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].xa[xi].j);
00250 
00251 //printf("A[0].a[ai][0].xa[xi].j is %f\n",A[0].a[ai][0].xa[xi].j);
00252 
00253         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00254         if(ftype=='r') {
00255                 scan_tst=fscanf(F.F,"%12c",readnum);
00256                 newline*=-1;
00257                 }
00258         else {
00259                 scan_tst=fscanf(F.F,"%8c",readnum);
00260                 newline++;
00261                 }
00262         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass 1-k.");}
00263 
00264 //printf("readnum (k) is >>>%s<<< newline is %d\n",readnum,newline);
00265 
00266         if(ftype=='v') scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].v[xi].k);
00267         else scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].xa[xi].k);
00268 
00269 //printf("A[0].a[ai][0].xa[xi].k is %f\n",A[0].a[ai][0].xa[xi].k);
00270 
00271         if( ((ftype=='r')&&(newline==1)) || ((ftype!='r')&&(newline==10)) ) 
00272                 {
00273                 scan_tst=fgetc(F.F);
00274 //printf("  newline is %d (10, we hope), scan_tst is >>>%c<<<\n",newline, scan_tst);
00275                 if(scan_tst!='\n') {mywhine("1. newline not found during first read-set");}
00276                 if(ftype!='r') newline=0;       
00277                 } 
00278 
00279         if(ftype=='v'){
00280                 A[0].a[ai][0].v[xi].d=sqrt(A[0].a[ai][0].v[xi].i*A[0].a[ai][0].v[xi].i+\
00281                         A[0].a[ai][0].v[xi].j*A[0].a[ai][0].v[xi].j+\
00282                         A[0].a[ai][0].v[xi].k*A[0].a[ai][0].v[xi].k);}
00283         }
00284 
00285 
00286 if( ((ftype=='r')&&(newline!=1)) || ((ftype!='r')&&(newline!=0)) ) { 
00287         scan_tst=fgetc(F.F);
00288 //printf("newline is %d, scan_tst is >>>%c<<<\n",newline, scan_tst);
00289         if(scan_tst!='\n') {mywhine("2. newline not found during first read-set");}
00290         }
00291 
00292 if(fgetpos(F.F,&here)!=0){mywhine("problem getting file position -- before first BOX read");};
00293 //printf("before first BOX read and xallocted_xa=%d\n",allocated_xa);
00294 // Do BOX info, too, if appropriate:
00295 if(A[0].nBOX>0){
00296         nalt_here=A[0].nBOX;
00297         A[0].nBOX=allocated_xa+1;
00298         A[0].BOX=(boxinfo*)realloc(A[0].BOX,(allocated_xa+1)*sizeof(boxinfo));
00299         for(xi=nalt_here;xi<(allocated_xa+1);xi++){
00300                 A[0].BOX[xi].nC=1;
00301                 A[0].BOX[xi].C=(coord_nD*)calloc(1,sizeof(coord_nD));
00302                 A[0].BOX[xi].C[0].nD=3;
00303                 A[0].BOX[xi].C[0].D=(double*)calloc(3,sizeof(double));
00304                 }
00305         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00306         if(ftype=='r') scan_tst=fscanf(F.F,"%12c",readnum);
00307         else scan_tst=fscanf(F.F,"%8c",readnum); 
00308         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass BOX 1-0.");}
00309         scan_tst=sscanf(readnum,"%lf",&A[0].BOX[allocated_xa].C[0].D[0]);
00310 
00311         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00312         if(ftype=='r') scan_tst=fscanf(F.F,"%12c",readnum);
00313         else scan_tst=fscanf(F.F,"%8c",readnum); 
00314         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass BOX 1-1.");}
00315         scan_tst=sscanf(readnum,"%lf",&A[0].BOX[allocated_xa].C[0].D[1]);
00316 
00317         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00318         if(ftype=='r') scan_tst=fscanf(F.F,"%12c",readnum);
00319         else scan_tst=fscanf(F.F,"%8c",readnum); 
00320         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass BOX 1-2.");}
00321         scan_tst=sscanf(readnum,"%lf",&A[0].BOX[allocated_xa].C[0].D[2]);
00322         if(ftype=='r'){
00323                 scan_tst=fscanf(F.F,"%12c",readnum);
00324                 //printf("readnum is >>>%s<<<\n",readnum);
00325                 scan_tst=fscanf(F.F,"%12c",readnum);
00326                 //printf("readnum is >>>%s<<<\n",readnum);
00327                 scan_tst=fscanf(F.F,"%12c",readnum);
00328                 //printf("readnum is >>>%s<<<\n",readnum);
00329                 }
00330         scan_tst=fgetc(F.F);
00331         if(scan_tst!='\n') {ungetc(scan_tst,F.F);}
00332         }
00333 // START HERE -- one day there might be non-square box info in these files...
00334 // as of now, though, there isn't...
00335 if(ftype!='r'){return;}
00336 
00337 /// If this is type 'r', see if there is any more info in the file
00338 if(fgetpos(F.F,&here2)!=0){mywhine("problem getting file position -- before check for extra-r read");};
00339 scan_tst=fscanf(F.F,"%12s",readnum);
00340 //printf("readnum is >>>%s<<< scan_tst is %d\n",readnum,scan_tst);
00341 if(scan_tst!=1){return;} // no more info in file
00342 
00343 // Still here? Assume there are velocities in the file, but don't do any more fancy checks --
00344 //      just assume the calling program has a clue...  :-)
00345 if(fsetpos(F.F,&here)!=0){mywhine("problem setting file position -- before restart velocities read");};
00346 
00347 // allocate velocity space 
00348 if(allocated_xa==1){
00349         for(ai=0;ai<A[0].na;ai++){
00350                 A[0].a[ai][0].nvec=allocated_xa;
00351                 A[0].a[ai][0].v=(vectormag_3D*)calloc(1,sizeof(vectormag_3D));
00352                 }
00353         }
00354 else{   
00355         for(ai=0;ai<A[0].na;ai++){
00356                 if(A[0].a[ai][0].nvec==0){
00357                         A[0].a[ai][0].nvec=allocated_xa;
00358                         A[0].a[ai][0].v=(vectormag_3D*)calloc(allocated_xa,sizeof(vectormag_3D));
00359                         }
00360                 else{
00361                         nalt_here=A[0].a[ai][0].nvec;
00362                         A[0].a[ai][0].nvec=allocated_xa;
00363                         A[0].a[ai][0].v=(vectormag_3D*)realloc(A[0].a[ai][0].v,allocated_xa*sizeof(vectormag_3D));
00364                         for(xi=nalt_here;xi<allocated_xa;xi++){
00365                                 A[0].a[ai][0].v[xi].i=A[0].a[ai][0].v[xi].j=0;
00366                                 A[0].a[ai][0].v[xi].k=A[0].a[ai][0].v[xi].d=0;
00367                                 }
00368                         }
00369                 }
00370         }
00371 
00372 // read in velocities 
00373 xi=allocated_xa-1;
00374 newline=1;
00375 for(ai=0;ai<A[0].na;ai++){
00376         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00377         scan_tst=fscanf(F.F,"%12c",readnum);
00378 //printf("readnum, v-i is %12s\n",readnum);
00379         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass r-v-i.");}
00380         scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].v[xi].i);
00381 //printf("the value saved is  %12.7f\n",A[0].a[ai][0].v[xi].i);
00382 
00383         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00384         scan_tst=fscanf(F.F,"%12c",readnum);
00385 //printf("readnum, v-i is %12s\n",readnum);
00386         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass r-v-i.");}
00387         scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].v[xi].j);
00388 //printf("the value saved is  %12.7f\n",A[0].a[ai][0].v[xi].j);
00389         
00390         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00391         scan_tst=fscanf(F.F,"%12c",readnum);
00392 //printf("readnum, v-i is %12s\n",readnum);
00393         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass r-v-i.");}
00394         scan_tst=sscanf(readnum,"%lf",&A[0].a[ai][0].v[xi].k);
00395 //printf("the value saved is  %12.7f\n",A[0].a[ai][0].v[xi].k);
00396 
00397         newline*=-1;
00398         if(newline==1)
00399                 {
00400                 scan_tst=fgetc(F.F);
00401                 if(scan_tst!='\n')
00402                         {
00403                         printf("ai is %d and newline is %d\n",ai,newline);
00404                         printf("the velocities are:\n");
00405                         printf("%12.7f%12.7f%12.7f\n",A[0].a[ai][0].v[xi].i,A[0].a[ai][0].v[xi].j,A[0].a[ai][0].v[xi].k);
00406                         mywhine("expected newline not found during velocity read in restart file");
00407                         }
00408                 }
00409 
00410         A[0].a[ai][0].v[xi].d=sqrt(A[0].a[ai][0].v[xi].i*A[0].a[ai][0].v[xi].i+\
00411                 A[0].a[ai][0].v[xi].j*A[0].a[ai][0].v[xi].j+\
00412                 A[0].a[ai][0].v[xi].k*A[0].a[ai][0].v[xi].k);
00413         }
00414 
00415 if(newline==-1)
00416         {
00417         scan_tst=fgetc(F.F);
00418         if(scan_tst!='\n')
00419                 {
00420                 printf("ai is %d and newline is %d\n",ai,newline);
00421                 printf("the velocities are:\n");
00422                 printf("%12.7f%12.7f%12.7f\n",A[0].a[ai][0].v[xi].i,A[0].a[ai][0].v[xi].j,A[0].a[ai][0].v[xi].k);
00423                 mywhine("expected newline not found during velocity read in restart file");
00424                 }
00425         }
00426 //for(ai=0;ai<A[0].na;ai++){
00427 //printf("The coords are: %12.7f%12.7f%12.7f\n",A[0].a[ai][0].v[xi].i,A[0].a[ai][0].v[xi].j,A[0].a[ai][0].v[xi].k); }
00428 
00429 // Do BOX info, too, if appropriate:
00430 // Was already allocated -- just need to read it in
00431 //printf("before rst box read and allocated_xa is %d\n",allocated_xa);
00432 if(A[0].nBOX>0){
00433         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00434         scan_tst=fscanf(F.F,"%12c",readnum);
00435 //printf("readnum, v-i is %12s\n",readnum);
00436         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass BOX r-v-1.");}
00437         scan_tst=sscanf(readnum,"%lf",&A[0].BOX[allocated_xa].C[0].D[0]);
00438 //printf("the value saved is  %12.7f\n",A[0].BOX[allocated_xa].C[0].D[0]);
00439 
00440         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00441         scan_tst=fscanf(F.F,"%12c",readnum);
00442 //printf("readnum, v-i is %12s\n",readnum);
00443         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass BOX r-v-1.");}
00444         scan_tst=sscanf(readnum,"%lf",&A[0].BOX[allocated_xa].C[0].D[1]);
00445 //printf("the value saved is  %12.7f\n",A[0].BOX[allocated_xa].C[0].D[1]);
00446 
00447         for(scan_tst=0;scan_tst<13;scan_tst++) readnum[scan_tst]='\0';
00448         scan_tst=fscanf(F.F,"%12c",readnum);
00449 //printf("readnum, v-i is %12s\n",readnum);
00450         if(scan_tst!=1){mywhine("add_trajcrds_to_prmtop_assembly: File read error, pass BOX r-v-1.");}
00451         scan_tst=sscanf(readnum,"%lf",&A[0].BOX[allocated_xa].C[0].D[2]);
00452 //printf("the value saved is  %12.7f\n",A[0].BOX[allocated_xa].C[0].D[2]);
00453         }
00454 //printf("After rst box read and BOX is %12.7f%12.7f%12.7f\n",A[0].BOX[allocated_xa].C[0].D[0],A[0].BOX[allocated_xa].C[0].D[1],A[0].BOX[allocated_xa].C[0].D[2]);
00455 //for(ai=0;ai<A[0].na;ai++){
00456 //printf("The coords are now: %12.7f%12.7f%12.7f\n",A[0].a[ai][0].v[xi].i,A[0].a[ai][0].v[xi].j,A[0].a[ai][0].v[xi].k); }
00457 return;
00458 } 
 All Classes Files Functions Variables Typedefs Defines