Index: pcp/src/data.h
===================================================================
--- pcp/src/data.h	(revision 57a69b2d95f7a1ae3c65de0466254bdf74967b68)
+++ pcp/src/data.h	(revision cc46b056e24de9a2576b5d53ea4b6ad1a4a40240)
@@ -238,5 +238,5 @@
   char *default_path;    //!< path to default parameter file
   char *pseudopot_path;  //!< path ot pseudopotential files
-  int OutVisStep;       //!< Currently so and so often has visual data output occurred
+  int *OutVisStep;       //!< Currently so and so often has visual data output occurred
   int MeOutVis;         //!< 1 - visual data are written to files, 0 - no output (for this process)
   int MeOutCurr;        //!< 1 - visual data of current density written to file, 0 - no output, no calculation (for this process)
Index: pcp/src/output.c
===================================================================
--- pcp/src/output.c	(revision 57a69b2d95f7a1ae3c65de0466254bdf74967b68)
+++ pcp/src/output.c	(revision cc46b056e24de9a2576b5d53ea4b6ad1a4a40240)
@@ -798,5 +798,5 @@
  * Opens \ref suffixdensdoc, fills (pos&data file name, byte order, max mesh points, matrix alignment, steps)
  * and closes it.
- * Opens \ref suffixdensdx, then for every FileData::OutVisStep a describing structure for DX is written and
+ * Opens \ref suffixdensdx, then for every FileData::*OutVisStep a describing structure for DX is written and
  * the file closed again.
  * \param *P Problem at hand
@@ -831,5 +831,5 @@
   fprintf(DensityDoc,"points = %i\n", MaxPoints);
   fprintf(DensityDoc,"majority = row\n");
-  fprintf(DensityDoc,"TimeSeries = %i\n",P->Files.OutVisStep+1);
+  fprintf(DensityDoc,"TimeSeries = %i\n",P->Files.OutVisStep[Lev->LevelNo]+1);
   fclose(DensityDoc);
   Free(suffix, "CreateDensityOutputGeneral: suffix");
@@ -839,5 +839,5 @@
   sprintf(suffix, ".L%i%s", Lev->LevelNo, suffixdensdx);
   OpenFile(P, &DensityDx, suffix, "w",P->Call.out[ReadOut]);
-  for (i=0; i < (unsigned int)P->Files.OutVisStep+1; i++) { // for every OutVis step
+  for (i=0; i < (unsigned int)P->Files.OutVisStep[Lev->LevelNo]+1; i++) { // for every OutVis step
     if (i==0) { 
       fprintf(DensityDx,"object \"gridcon\" class gridconnections counts %i %i %i\n\n",(N[0]+1),(N[1]+1),(N[2]+1));
@@ -871,5 +871,5 @@
     }
   fprintf(DensityDx,"\nobject \"series\" class series\n");
-  for (i=0; i < (unsigned int)P->Files.OutVisStep+1; i++) 
+  for (i=0; i < (unsigned int)P->Files.OutVisStep[Lev->LevelNo]+1; i++) 
     fprintf(DensityDx,"member %i \"obj.%04u\" position %f\n",i,i,(float)i);
   fprintf(DensityDx,"end\n");
@@ -1035,5 +1035,5 @@
   struct Lattice *Lat = &P->Lat;
   struct LatticeLevel *Lev0 = &Lat->Lev[0];
-  float step = P->Files.OutVisStep;
+  float step = P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo];
   int No=0, destpos;
   char suffix[255];
@@ -1255,5 +1255,5 @@
  * If this is process 0 (and OutVis desired), allocate memory for FileData::PosTemp, FileData::work,
  * set the entries of FileData all to their corresponding values from RiemannTensor,
- * FileData::OutVisStep to zero.
+ * FileData::*OutVisStep to zero.
  * \param *P Problem at hand
  */
@@ -1264,7 +1264,11 @@
   struct RiemannTensor *RT = &Lat->RT;
   struct LatticeLevel *Lev0 = &Lat->Lev[0];
+  int i;
   F->OutputPosType = NULL;
   if (!F->MeOutVis) return;
-  F->OutVisStep = 0;
+
+  F->OutVisStep = Malloc(sizeof(int)*Lat->MaxLevel,"InitOutVisArray: OutVisStep");
+  for (i=0;i<Lat->MaxLevel;i++)
+    F->OutVisStep[i] = 0;
   F->PosTemp = (fftw_complex *)
     Malloc(sizeof(float)*(Lev0->Plan0.plan->N[1]+1)*(Lev0->Plan0.plan->N[2]+1)*
@@ -1459,7 +1463,7 @@
  * If this is process 0,
  * open, fill and close IonDoc file suffixiondoc,
- * open, fill for each FileData::OutVisStep and close IonDX file suffixiondx
+ * open, fill for each FileData::*OutVisStep and close IonDX file suffixiondx
  * for every
- * open suffixionfor, suffixionpos (and suffixionZ in case of only FileData::OutVisStep), fill
+ * open suffixionfor, suffixionpos (and suffixionZ in case of only FileData::*OutVisStep), fill
  * them with the ion forces IonType::FIon and positions IonType::R of each type and each ion per type,
  * close them all.
@@ -1498,5 +1502,5 @@
     fprintf(IonsDoc,"points = %i\n", I->Max_TotalIons);
     fprintf(IonsDoc,"majority = row\n");
-    fprintf(IonsDoc,"TimeSeries = %i\n",F->OutVisStep+1);
+    fprintf(IonsDoc,"TimeSeries = %i\n",F->OutVisStep[Lev->LevelNo]+1);
     fclose(IonsDoc);
   }
@@ -1504,5 +1508,5 @@
   sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixiondx);
   if (OpenFile(P, &IonsDx, suffix, "w",P->Call.out[ReadOut])) {
-    for (i=0; i < F->OutVisStep+1; i++) {
+    for (i=0; i < F->OutVisStep[Lev->LevelNo]+1; i++) {
       if (i==0) {
         /*      fprintf(IonsDx,"object \"ioncon\" class array type int rank 1 shape 2 items 0 data follows\nattribute \"element type\" string \"lines\"\nattribute \"ref\" string \"positions\"\n\n"); */
@@ -1530,8 +1534,8 @@
     }
     fprintf(IonsDx,"\nobject \"ionseriesF\" class series\n");
-    for (i=0; i < F->OutVisStep+1; i++) 
+    for (i=0; i < F->OutVisStep[Lev->LevelNo]+1; i++) 
       fprintf(IonsDx,"member %i \"ionobjF.%04i\" position %f\n",i,i,(float)i);
     fprintf(IonsDx,"\nobject \"ionseriesZ\" class series\n");
-    for (i=0; i < F->OutVisStep+1; i++) 
+    for (i=0; i < F->OutVisStep[Lev->LevelNo]+1; i++) 
       fprintf(IonsDx,"member %i \"ionobjZ.%04i\" position %f\n",i,i,(float)i);
     fprintf(IonsDx,"end\n");
@@ -1543,11 +1547,11 @@
   // open IonForces, IonZ and IonPosition file, write forces respectively positions for each ion of each type, close them
   sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixionfor);
-  if (OpenFileNo(P, &IonsDataF, suffix, F->OutVisStep, "wb",P->Call.out[ReadOut])) {
-    if (F->OutVisStep == 0) { 
+  if (OpenFileNo(P, &IonsDataF, suffix, F->OutVisStep[Lev->LevelNo], "wb",P->Call.out[ReadOut])) {
+    if (F->OutVisStep[Lev->LevelNo] == 0) { 
       sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixionZ);
       OpenFile(P, &IonsDataZ, suffix, "wb",P->Call.out[ReadOut]);
     }
     sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixionpos);
-    if (OpenFileNo(P, &IonsPos, suffix, F->OutVisStep, "wb",P->Call.out[ReadOut])) {
+    if (OpenFileNo(P, &IonsPos, suffix, F->OutVisStep[Lev->LevelNo], "wb",P->Call.out[ReadOut])) {
       for (is=0; is < I->Max_Types; is++) {
         for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) {
@@ -1561,5 +1565,5 @@
           if (fwrite(&data[0],sizeof(float), (size_t)(3),IonsPos) != 3)
             Error(FileOpenParams, "Error writing ion positions!");
-          if (F->OutVisStep == 0) (void)fwrite(&Z,sizeof(int), (size_t)(1),IonsDataZ);
+          if (F->OutVisStep[Lev->LevelNo] == 0) (void)fwrite(&Z,sizeof(int), (size_t)(1),IonsDataZ);
           if (fwrite(&data[3],sizeof(float), (size_t)(3),IonsDataF) != 3)
             Error(FileOpenParams, "Error writing ionic forces!");
@@ -1568,5 +1572,5 @@
       fclose(IonsPos);
     }
-    if (F->OutVisStep == 0) 
+    if (F->OutVisStep[Lev->LevelNo] == 0) 
       fclose(IonsDataZ);
     fclose(IonsDataF);
@@ -1589,16 +1593,16 @@
   // if (!P->Files.MeOutVis) return;
   // P->Files.OutputPosType = 
-  //   Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep+1),"OutputVis");
-  // P->Files.OutputPosType[P->Files.OutVisStep] = P->Lat.RT.ActualUse;
+  //   Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]+1),"OutputVis");
+  // P->Files.OutputPosType[P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]] = P->Lat.RT.ActualUse;
   // CreateDensityOutputGeneral(P, P->Par.me_comm_ST_Psi);
   // OutVisDensity(P);
   // OutVisIons(P);
-  // if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep);
-  // /* P->Files.OutVisStep++; Genau ebend nicht hochzaehlen - wird immer ueberschrieben */
+  // if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]);
+  // /* P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]++; Genau ebend nicht hochzaehlen - wird immer ueberschrieben */
 }
 
 /** Main output total electronic density and ion data for OpenDX.
  * Calls subsequently preparing CreateDensityOutputGeneral(), then output of electronic
- * densities OutVisDensity() and ion data OutVisIons(), increasing finally FileData::OutVisStep.
+ * densities OutVisDensity() and ion data OutVisIons(), increasing finally FileData::*OutVisStep.
  * \param *P Problem at hand
   * \param *srcdens Pointer to DensityArray which is to be displayed
@@ -1608,12 +1612,12 @@
 {
   if (!P->Files.MeOutVis) return;
-  P->Files.OutputPosType = (enum ModeType *) Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep+1),"OutputVis");
-  P->Files.OutputPosType[P->Files.OutVisStep] = P->Lat.RT.ActualUse;
+  P->Files.OutputPosType = (enum ModeType *) Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]+1),"OutputVis");
+  P->Files.OutputPosType[P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]] = P->Lat.RT.ActualUse;
   
   CreateDensityOutputGeneral(P, P->Par.me_comm_ST_Psi);
   OutVisDensity(P, srcdens);
   OutVisIons(P);
-  if(P->Call.out[MinOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep);
-  P->Files.OutVisStep++;
+  if(P->Call.out[MinOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]);
+  P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]++;
 }
 
@@ -1631,8 +1635,8 @@
   if(P->Call.out[NormalOut]) fprintf(stderr,"(%i)Output of Current Density (Vis)\n", P->Par.me);
 
-  P->Files.OutputPosType = (enum ModeType *) Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep+(1)*NDIM),"OutputVis");
+  P->Files.OutputPosType = (enum ModeType *) Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]+(1)*NDIM),"OutputVis");
   for (i=0;i<(1)*NDIM;i++)
-    P->Files.OutputPosType[P->Files.OutVisStep+i] = P->Lat.RT.ActualUse;
-  if(P->Call.out[PsiOut]) fprintf(stderr,"(%i) OutVisStep %i, OutputPosType %p\n",P->Par.me, P->Files.OutVisStep, P->Files.OutputPosType);
+    P->Files.OutputPosType[P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]+i] = P->Lat.RT.ActualUse;
+  if(P->Call.out[PsiOut]) fprintf(stderr,"(%i) OutVisStep %i, OutputPosType %p\n",P->Par.me, P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo], P->Files.OutputPosType);
   
   // due to preprocessor values we can't put the following stuff into a loop
@@ -1660,6 +1664,6 @@
     OutVisDensity(P, density);
     OutVisIons(P);
-    if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep);
-    P->Files.OutVisStep++;
+    if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]);
+    P->Files.OutVisStep[P->Lat.Lev[STANDARTLEVEL].LevelNo]++;
   }
 }
@@ -1676,4 +1680,5 @@
   struct RunStruct *R = &P->R;
   struct LatticeLevel *LevS = R->LevS;
+  struct LatticeLevel *Lev = &P->Lat.Lev[STANDARTLEVEL];
   struct LatticeLevel *Lev0 = R->Lev0;
   struct Density *Dens0 = Lev0->Dens;
@@ -1687,8 +1692,9 @@
   if (!P->Files.MeOutVis) return;
 
-  P->Files.OutputPosType = (enum ModeType *) Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep+(Num)),"OutputVis");
-  
-  P->Files.OutVisStep += offset;
-  P->Files.OutputPosType[P->Files.OutVisStep] = P->Lat.RT.ActualUse;  
+  fprintf(stderr,"(%i) Realloc OutputPosType: %li to %i\n",P->Par.me,sizeof(P->Files.OutputPosType), P->Files.OutVisStep[Lev->LevelNo]+(Num));
+  P->Files.OutputPosType = (enum ModeType *) Realloc(P->Files.OutputPosType,sizeof(enum ModeType)*(P->Files.OutVisStep[Lev->LevelNo]+(Num)),"OutputVis");
+  
+  P->Files.OutVisStep[Lev->LevelNo] += offset;
+  //P->Files.OutputPosType[P->Files.OutVisStep[Lev->LevelNo]] = P->Lat.RT.ActualUse;  
   for (i=0; i < Psi->MaxPsiOfType+P->Par.Max_me_comm_ST_PsiT; i++) {  // go through all wave functions (plus the extra one for each process)
     OnePsiA = &Psi->AllPsiStatus[i];    // grab the desired OnePsiA
@@ -1709,5 +1715,5 @@
       } // LPsiDatA is now set to the coefficients of OnePsi either stored or MPI_Received
 
-      P->Files.OutputPosType[P->Files.OutVisStep] = P->Lat.RT.ActualUse;
+      P->Files.OutputPosType[P->Files.OutVisStep[Lev->LevelNo]] = P->Lat.RT.ActualUse;
       // recalculate density for the specific wave function ...
       CalculateOneDensityR(Lat, LevS, Dens0, LPsiDatA, Dens0->DensityArray[ActualDensity], R->FactorDensityR, 0);
@@ -1717,7 +1723,7 @@
       OutVisDensity(P, Dens0->DensityArray[ActualDensity]);
       OutVisIons(P);
-      if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep);
-      P->Files.OutVisStep+=increment;
-      P->Files.OutputPosType[P->Files.OutVisStep] = P->Lat.RT.ActualUse;  
+      if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) Written OutVisStep %i to disk\n", P->Par.me, P->Files.OutVisStep[Lev->LevelNo]);
+      P->Files.OutVisStep[Lev->LevelNo]+=increment;
+      //P->Files.OutputPosType[P->Files.OutVisStep[Lev->LevelNo]] = P->Lat.RT.ActualUse;  
     }
   }
