Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision e9b8bbc350d26b202af7d90b4200003a5a492355)
+++ src/config.cpp	(revision 5e0d1f1c85a9ade010b400eb5a691b8c94a48949)
@@ -461,4 +461,5 @@
   int Z, No[MAX_ELEMENTS];
   int verbose = 0;
+  int MinSteps = -1;
   
   /* Namen einlesen */
@@ -652,9 +653,49 @@
         while (ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition, (repetition == 1) ? critical : optional) &&
           ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition, (repetition == 1) ? critical : optional) &&
-          ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition, (repetition == 1) ? critical : optional))
+          ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition, (repetition == 1) ? critical : optional)) {
+          // check size of vectors
+          if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition-1)) {
+            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-1).x[d] = neues->x.x[d];
+          
+          // parse velocities if present
+          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.;
+          for (int d=0;d<NDIM;d++)
+            mol->Trajectories[neues].U[repetition-1].x[d] = neues->v.x[d];
+          
+          // parse forces if present
+          if(!ParseForParameter(verbose,file, keyword, 0, 8, 1, double_type, &neues->v.x[0], repetition,optional))
+            neues->v.x[0] = 0.;
+          if(!ParseForParameter(verbose,file, keyword, 0, 9, 1, double_type, &neues->v.x[1], repetition,optional))
+            neues->v.x[1] = 0.;
+          if(!ParseForParameter(verbose,file, keyword, 0, 10, 1, double_type, &neues->v.x[2], repetition,optional))
+            neues->v.x[2] = 0.;
+          for (int d=0;d<NDIM;d++)
+            mol->Trajectories[neues].F[repetition-1].x[d] = neues->v.x[d];
+          
+          cout << "Parsed position of step " << (repetition-1) << " "; 
+          for (int d=0;d<NDIM;d++)
+            cout << mol->Trajectories[neues].R.at(repetition-1).x[d] << "  ";          // next step
+          cout << endl;
+          
           repetition++;
+        }
         repetition--;
-        //cout << "Found " << repetition << " times of the keyword " << keyword << "." << endl;
+        cout << "Found " << repetition << " times of the keyword " << keyword << "." << endl;
       }
+      if ((repetition < MinSteps) || (MinSteps == -1))
+        MinSteps = repetition;
       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);
@@ -667,8 +708,10 @@
       if(!ParseForParameter(verbose,file, keyword, (int)FastParsing, 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);
     }
   }
+  mol->MDSteps = MinSteps;    // set equal to smallest number of parsed steps
   file->close();
   delete(file);
@@ -972,5 +1015,5 @@
     *output << endl;
     result = result && mol->Checkout(output);
-    result = result && mol->Output(output);
+    result = result && mol->OutputTrajectories(output);
     return result;
   } else
Index: src/molecules.cpp
===================================================================
--- src/molecules.cpp	(revision e9b8bbc350d26b202af7d90b4200003a5a492355)
+++ src/molecules.cpp	(revision 5e0d1f1c85a9ade010b400eb5a691b8c94a48949)
@@ -47,4 +47,5 @@
   link(first,last);
   // other stuff 
+  MDSteps = 0;
   last_atom = 0; 
   elemente = teil;
@@ -983,4 +984,5 @@
   int i, Ion[2];
   double a, IonMass;
+  unsigned int size;
 
   CountElements();  // make sure ElementsInMolecule is up to date
@@ -1044,4 +1046,12 @@
             
             
+            // check size of vectors
+            size = Trajectories[walker].R.size(); 
+            if (size <= (unsigned int)(MDSteps)) {
+              cout << "Increasing size for trajectory array of " << *walker << " to " << (size+10) << "." << endl;
+              Trajectories[walker].R.resize(size+10);
+              Trajectories[walker].U.resize(size+10);
+              Trajectories[walker].F.resize(size+10);
+            }
             // add trajectory point
 
@@ -1294,5 +1304,5 @@
 bool molecule::Output(ofstream *out)
 {
-  element *runner = elemente->start;
+  element *runner;
   atom *walker = NULL;
   int ElementNo, AtomNo;
@@ -1304,4 +1314,5 @@
     *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
     ElementNo = 0;
+    runner = elemente->start;
     while (runner->next != elemente->end) { // go through every element
   		runner = runner->next;
@@ -1314,5 +1325,53 @@
           if (walker->type == runner) { // if this atom fits to element
             AtomNo++;
-            walker->Output(ElementNo, AtomNo, out);
+            walker->Output(ElementNo, AtomNo, out); // removed due to trajectories
+          }
+        }
+      }
+    }
+    return true;
+  }
+};
+
+/** Prints molecule with all atomic trajectory positions to *out.
+ * \param *out output stream
+ */
+bool molecule::OutputTrajectories(ofstream *out)
+{
+  element *runner = NULL;
+  atom *walker = NULL;
+  int ElementNo, AtomNo;
+  CountElements();
+  
+  if (out == NULL) {
+    return false;
+  } else {
+    for (int step = 0; step < MDSteps; step++) {
+      if (step == 0) {
+        *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
+      } else {
+        *out << "# ====== MD step " << step << " =========" << endl;
+      }
+      ElementNo = 0;
+      runner = elemente->start;
+      while (runner->next != elemente->end) { // go through every element
+        runner = runner->next;
+        if (ElementsInMolecule[runner->Z]) { // if this element got atoms
+          ElementNo++;
+          AtomNo = 0;
+          walker = start;
+          while (walker->next != end) { // go through every atom of this element
+            walker = walker->next;
+            if (walker->type == runner) { // if this atom fits to element
+              AtomNo++;
+              *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
+              *out << Trajectories[walker].R.at(step).x[0] << "\t" << Trajectories[walker].R.at(step).x[1] << "\t" << Trajectories[walker].R.at(step).x[2];
+              *out << "\t" << walker->FixedIon;
+              if (Trajectories[walker].U.at(step).Norm() > MYEPSILON)
+                *out << "\t" << scientific << setprecision(6) << Trajectories[walker].U.at(step).x[0] << "\t" << Trajectories[walker].U.at(step).x[1] << "\t" << Trajectories[walker].U.at(step).x[2] << "\t";
+              if (Trajectories[walker].F.at(step).Norm() > MYEPSILON)
+                *out << "\t" << scientific << setprecision(6) << Trajectories[walker].F.at(step).x[0] << "\t" << Trajectories[walker].F.at(step).x[1] << "\t" << Trajectories[walker].F.at(step).x[2] << "\t";
+              *out << " # Number in molecule " << walker->nr << endl;
+            }
           }
         }
Index: src/molecules.hpp
===================================================================
--- src/molecules.hpp	(revision e9b8bbc350d26b202af7d90b4200003a5a492355)
+++ src/molecules.hpp	(revision 5e0d1f1c85a9ade010b400eb5a691b8c94a48949)
@@ -21,4 +21,5 @@
 #include <deque>
 #include <list>
+#include <vector>
 
 #include "helpers.hpp"
@@ -51,7 +52,8 @@
 struct Trajectory
 {
-  double R[3];  //!< position vector
-  double U[3];    //!< velocity vector
-  double F[3];    //!< last force vector
+  vector<Vector> R;  //!< position vector
+  vector<Vector> U;  //!< velocity vector
+  vector<Vector> F;  //!< last force vector
+  atom *ptr;         //!< pointer to atom whose trajectory we contain
 };
 
@@ -178,4 +180,6 @@
     bond *last;         //!< end of bond list
     bond ***ListOfBondsPerAtom; //!< pointer list for each atom and each bond it has
+    map<atom *, struct Trajectory> Trajectories; //!< contains old trajectory points
+    int MDSteps;        //!< The number of MD steps in Trajectories
     int *NumberOfBondsPerAtom;  //!< Number of Bonds each atom has
     int AtomCount;					//!< number of atoms, brought up-to-date by CountAtoms()
@@ -279,4 +283,5 @@
   // Output routines.
   bool Output(ofstream *out);
+  bool OutputTrajectories(ofstream *out);
   void OutputListOfBonds(ofstream *out) const;
   bool OutputXYZ(ofstream *out) const;
