Esempio n. 1
0
Mol *read_atomic_coordinates(const char *file)
{
   long fpos;
   float x, y, z;
   int ord, natoms;

   free_dyna();

   if(find_string("Standard orientation")) {
      do {
         fpos = ftell(fp);
         natoms = addTrajectoryStep();
         } while(find_string("Standard orientation"));
   }
   else {
      rewind(fp);
      if(find_string("Z-Matrix orientation")) {
         do {
            fpos = ftell(fp);
            natoms = addTrajectoryStep();
         } while(find_string("Z-Matrix orientation"));
      }
      else {
           rewind(fp);
           if(find_string("Input orientation")) {
                do {
                 fpos = ftell(fp);
                 natoms = addTrajectoryStep();
                } while(find_string("Input orientation"));
           }
      }
   }

   Mol *mol = add_mol(file);
   dynamics.molecule = mol;
   dynamics.current = dynamics.ntotalsteps - 1;

   fseek(fp, fpos, SEEK_SET);

   if(!find_string("Coordinates (Angstroms)")) return 0;
   if(!find_string("-----")) return 0;

   fgets(line, 255, fp);
   do {
      if(flagG9803) {
      if(sscanf(line, "%*d %d %*d %f %f %f", &ord, &x, &y, &z) != 4) return 0;
      }
      else {
      if(sscanf(line, "%*d %d %f %f %f", &ord, &x, &y, &z) != 4) return 0;
      }
      if(ord >= 0) mol->AddNewAtom(ord, x, y, z);
      fgets(line, 255, fp);
   } while(!strstr(line, "------"));



   return mol;
}