Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision dd8cf8a8462703ebe06c909e9115df444b75404d)
+++ src/config.cpp	(revision 7e27e738a38b76dacb4576347f33afc94b7933dc)
@@ -635,117 +635,121 @@
   if (!ParseForParameter(verbose,file,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional))
     config::StructOpt = 0;
-  // prescan number of ions per type
-  cout << Verbose(0) << "Prescanning ions per type: " << endl;
-  for (int i=0; i < config::MaxTypes; i++) {
-    sprintf(name,"Ion_Type%i",i+1);
-    ParseForParameter(verbose,file, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical);
-    ParseForParameter(verbose,file, name, 0, 2, 1, int_type, &Z, 1, critical);
-    elementhash[i] = periode->FindElement(Z);
-    cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; 
-  }
-  int repetition = 0; // which repeated keyword shall be read
-
-  map<int, atom *> AtomList[config::MaxTypes];
-  if (!FastParsing) {
-    // parse in trajectories
-    bool status = true;
-    atom *neues = NULL;
-    while (status) {
-      cout << "Currently parsing MD step " << repetition << "." << endl;
+  if (MaxTypes == 0) {
+    cerr << "There are no atoms according to MaxTypes in this config file." << endl;
+  } else {
+    // prescan number of ions per type
+    cout << Verbose(0) << "Prescanning ions per type: " << endl;
+    for (int i=0; i < config::MaxTypes; i++) {
+      sprintf(name,"Ion_Type%i",i+1);
+      ParseForParameter(verbose,file, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical);
+      ParseForParameter(verbose,file, name, 0, 2, 1, int_type, &Z, 1, critical);
+      elementhash[i] = periode->FindElement(Z);
+      cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; 
+    }
+    int repetition = 0; // which repeated keyword shall be read
+  
+    map<int, atom *> AtomList[config::MaxTypes];
+    if (!FastParsing) {
+      // parse in trajectories
+      bool status = true;
+      atom *neues = NULL;
+      while (status) {
+        cout << "Currently parsing MD step " << repetition << "." << endl;
+        for (int i=0; i < config::MaxTypes; i++) {
+          sprintf(name,"Ion_Type%i",i+1);
+          for(int j=0;j<No[i];j++) {
+            sprintf(keyword,"%s_%i",name, j+1);
+            if (repetition == 0) {
+              neues = new atom();
+              AtomList[i][j] = neues;
+              neues->type = elementhash[i]; // find element type
+              mol->AddAtom(neues);
+            } else
+              neues = AtomList[i][j];
+            status = (status && 
+                    ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], 1, (repetition == 0) ? critical : optional) &&
+                    ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], 1, (repetition == 0) ? critical : optional) &&
+                    ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], 1, (repetition == 0) ? critical : optional) &&
+                    ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional));
+            if (!status) break;
+    
+            // check size of vectors
+            if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition)) {
+              //cout << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl;
+              mol->Trajectories[neues].R.resize(repetition+10);
+              mol->Trajectories[neues].U.resize(repetition+10);
+              mol->Trajectories[neues].F.resize(repetition+10);
+            }
+          
+            // put into trajectories list
+            for (int d=0;d<NDIM;d++)
+              mol->Trajectories[neues].R.at(repetition).x[d] = neues->x.x[d];
+            
+            // parse velocities if present
+            if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], 1,optional))
+              neues->v.x[0] = 0.;
+            if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], 1,optional))
+              neues->v.x[1] = 0.;
+            if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], 1,optional))
+              neues->v.x[2] = 0.;
+            for (int d=0;d<NDIM;d++)
+              mol->Trajectories[neues].U.at(repetition).x[d] = neues->v.x[d];
+      
+            // parse forces if present
+            if(!ParseForParameter(verbose,file, keyword, 0, 8, 1, double_type, &value[0], 1,optional))
+              value[0] = 0.;
+            if(!ParseForParameter(verbose,file, keyword, 0, 9, 1, double_type, &value[1], 1,optional))
+              value[1] = 0.;
+            if(!ParseForParameter(verbose,file, keyword, 1, 10, 1, double_type, &value[2], 1,optional))
+              value[2] = 0.;
+            for (int d=0;d<NDIM;d++)
+              mol->Trajectories[neues].F.at(repetition).x[d] = value[d];
+  
+  //            cout << "Parsed position of step " << (repetition) << ": ("; 
+  //            for (int d=0;d<NDIM;d++)
+  //              cout << mol->Trajectories[neues].R.at(repetition).x[d] << " ";          // next step
+  //            cout << ")\t(";
+  //            for (int d=0;d<NDIM;d++)
+  //              cout << mol->Trajectories[neues].U.at(repetition).x[d] << " ";          // next step
+  //            cout << ")\t(";
+  //            for (int d=0;d<NDIM;d++)
+  //              cout << mol->Trajectories[neues].F.at(repetition).x[d] << " ";          // next step
+  //            cout << ")" << endl;
+          }
+        }
+        repetition++;
+      }
+      repetition--;
+      cout << "Found " << repetition << " trajectory steps." << endl;
+      mol->MDSteps = repetition;
+    } else {
+      // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom)
+      repetition = 0;
+      while ( ParseForParameter(verbose,file, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) &&
+              ParseForParameter(verbose,file, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) &&
+              ParseForParameter(verbose,file, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional))
+        repetition++;
+      cout << "I found " << repetition << " times the keyword Ion_Type1_1." << endl;
+      // parse in molecule coordinates
       for (int i=0; i < config::MaxTypes; i++) {
         sprintf(name,"Ion_Type%i",i+1);
         for(int j=0;j<No[i];j++) {
           sprintf(keyword,"%s_%i",name, j+1);
-          if (repetition == 0) {
-            neues = new atom();
-            AtomList[i][j] = neues;
-            neues->type = elementhash[i]; // find element type
-            mol->AddAtom(neues);
-          } else
-            neues = AtomList[i][j];
-          status = (status && 
-                  ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], 1, (repetition == 0) ? critical : optional) &&
-                  ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], 1, (repetition == 0) ? critical : optional) &&
-                  ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], 1, (repetition == 0) ? critical : optional) &&
-                  ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional));
-          if (!status) break;
-  
-          // check size of vectors
-          if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition)) {
-            //cout << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl;
-            mol->Trajectories[neues].R.resize(repetition+10);
-            mol->Trajectories[neues].U.resize(repetition+10);
-            mol->Trajectories[neues].F.resize(repetition+10);
-          }
-        
-          // put into trajectories list
-          for (int d=0;d<NDIM;d++)
-            mol->Trajectories[neues].R.at(repetition).x[d] = neues->x.x[d];
-          
-          // parse velocities if present
-          if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], 1,optional))
+          atom *neues = new atom();
+          // then parse for each atom the coordinates as often as present
+          ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical);
+          ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical);
+          ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition,critical);
+          ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical);
+          if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], repetition,optional))
             neues->v.x[0] = 0.;
-          if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], 1,optional))
+          if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional))
             neues->v.x[1] = 0.;
-          if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], 1,optional))
+          if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional))
             neues->v.x[2] = 0.;
-          for (int d=0;d<NDIM;d++)
-            mol->Trajectories[neues].U.at(repetition).x[d] = neues->v.x[d];
-    
-          // parse forces if present
-          if(!ParseForParameter(verbose,file, keyword, 0, 8, 1, double_type, &value[0], 1,optional))
-            value[0] = 0.;
-          if(!ParseForParameter(verbose,file, keyword, 0, 9, 1, double_type, &value[1], 1,optional))
-            value[1] = 0.;
-          if(!ParseForParameter(verbose,file, keyword, 1, 10, 1, double_type, &value[2], 1,optional))
-            value[2] = 0.;
-          for (int d=0;d<NDIM;d++)
-            mol->Trajectories[neues].F.at(repetition).x[d] = value[d];
-
-//            cout << "Parsed position of step " << (repetition) << ": ("; 
-//            for (int d=0;d<NDIM;d++)
-//              cout << mol->Trajectories[neues].R.at(repetition).x[d] << " ";          // next step
-//            cout << ")\t(";
-//            for (int d=0;d<NDIM;d++)
-//              cout << mol->Trajectories[neues].U.at(repetition).x[d] << " ";          // next step
-//            cout << ")\t(";
-//            for (int d=0;d<NDIM;d++)
-//              cout << mol->Trajectories[neues].F.at(repetition).x[d] << " ";          // next step
-//            cout << ")" << endl;
+          // here we don't care if forces are present (last in trajectories is always equal to current position)
+          neues->type = elementhash[i]; // find element type
+          mol->AddAtom(neues);
         }
-      }
-      repetition++;
-    }
-    repetition--;
-    cout << "Found " << repetition << " trajectory steps." << endl;
-    mol->MDSteps = repetition;
-  } else {
-    // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom)
-    repetition = 0;
-    while ( ParseForParameter(verbose,file, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) &&
-            ParseForParameter(verbose,file, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) &&
-            ParseForParameter(verbose,file, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional))
-      repetition++;
-    cout << "I found " << repetition << " times the keyword Ion_Type1_1." << endl;
-    // parse in molecule coordinates
-    for (int i=0; i < config::MaxTypes; i++) {
-      sprintf(name,"Ion_Type%i",i+1);
-      for(int j=0;j<No[i];j++) {
-        sprintf(keyword,"%s_%i",name, j+1);
-        atom *neues = new atom();
-        // then parse for each atom the coordinates as often as present
-        ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical);
-        ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical);
-        ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition,critical);
-        ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical);
-        if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], repetition,optional))
-          neues->v.x[0] = 0.;
-        if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional))
-          neues->v.x[1] = 0.;
-        if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional))
-          neues->v.x[2] = 0.;
-        // here we don't care if forces are present (last in trajectories is always equal to current position)
-        neues->type = elementhash[i]; // find element type
-        mol->AddAtom(neues);
       }
     }
@@ -1155,5 +1159,5 @@
           Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
           //Error(InitReading, name);
-          //fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
+          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
           exit(255);
         } else {
