Index: pcp/src/perturbed.c
===================================================================
--- pcp/src/perturbed.c	(revision cc9c36527731f3b1b508bb1c90f78f8775a7ee1b)
+++ pcp/src/perturbed.c	(revision 9bdd866eca950981175d4eb672952e1c119b1d98)
@@ -999,5 +999,5 @@
         //else fprintf(stderr,"(%i) WCentre[%i] = %e \n",P->Par.me, index_r, Wcentre[index_r]);
         MinImageConv(Lat,x, Wcentre, X);
-        vector = sawtooth(Lat,X[index_r],index_r);
+        vector = sawtooth(Lat,X,index_r);
         //vector = 1.;//sin((double)(n[index_r])/(double)((N[index_r]))*2*PI);      
          PsiCR[iS] = vector * TempPsiR[i0];
@@ -1272,6 +1272,6 @@
         MinImageConv(Lat, x, Wcentre, X);
          PsiCR[iS] = //vector * TempPsiR[i0]; 
-          sawtooth(Lat,X[index[0]],index[0]) * TempPsiR [i0]
-         -sawtooth(Lat,X[index[2]],index[2]) * TempPsi2R[i0];
+          sawtooth(Lat,X,index[0]) * TempPsiR [i0]
+         -sawtooth(Lat,X,index[2]) * TempPsi2R[i0];
 //          ShiftGaugeOrigin(P,X,index[0]) * TempPsiR [i0]
 //         -ShiftGaugeOrigin(P,X,index[2]) * TempPsi2R[i0];
@@ -1616,5 +1616,5 @@
  * \param index component index for Lattice#RealBasisSQ
  */
-inline double sawtooth(struct Lattice *Lat, double L, const int index)
+inline double sawtooth(struct Lattice *Lat, double L[NDIM], const int index)
 {
   double axis = sqrt(Lat->RealBasisSQ[index]);
@@ -1626,10 +1626,10 @@
   //fprintf(stderr, "sawstart: %e\tsawend: %e\tsawfactor: %e\tL: %e\n", sawstart, sawend, sawfactor, L);
   // transform and return (sawtooth profile checked, 04.08.06)
-  L += axis/2.; // transform to 0 ... L
-  if (L < (sawstart*axis)) return (-axis/(2*sawfactor)*sin(L/(sawstart*axis)*PI/2.));  // first smooth transition from 0 ... -L/2
-  if (L > (sawend*axis)) return ( axis/(2*sawfactor)*cos((L-sawend*axis)/(sawstart*axis)*PI/2.));  // second smooth transition from +L/2 ... 0
+  L[index] += axis/2.; // transform to 0 ... L
+  if (L[index] < (sawstart*axis)) return (-axis/(2*sawfactor)*sin(L[index]/(sawstart*axis)*PI/2.));  // first smooth transition from 0 ... -L/2
+  if (L[index] > (sawend*axis)) return ( axis/(2*sawfactor)*cos((L[index]-sawend*axis)/(sawstart*axis)*PI/2.));  // second smooth transition from +L/2 ... 0
   //fprintf(stderr,"L %e\t sawstart %e\t sawend %e\t sawfactor %e\t axis%e\n", L, sawstart, sawend, sawfactor, axis);
   //return ((L - sawstart*axis) - axis/(2*sawfactor));  // area in between scale to -L/2 ... +L/2
-  return (L - axis/2);  // area in between return as it was 
+  return (L[index] - axis/2);  // area in between return as it was 
 }
 
@@ -1663,5 +1663,5 @@
       }
   
-  return(sawtooth(Lat,x[index],index));  // still use sawtooth due to the numerical instability around the border region of the cell
+  return(sawtooth(Lat,x,index));  // still use sawtooth due to the numerical instability around the border region of the cell
 }
 
@@ -1687,5 +1687,5 @@
     //fprintf(stderr,"(%i) x %e\t Axis/2 %e\n",P->Par.me, x, sqrt(Lat->RealBasisSQ[index])/2. );     
 	  MinImageConv(Lat, n, Lat->RealBasisCenter, x);
-  	fprintf(stderr,"%e\t%e\n", n[index], sawtooth(Lat,n[index],index));  
+  	fprintf(stderr,"%e\t%e\n", n[index], sawtooth(Lat,n,index));  
   }
 }
@@ -2265,5 +2265,5 @@
                 MinImageConv(Lat, x, Psi->AddData[k].WannierCentre, X);
                 for (i=0;i<NDIM;i++) // build gauge-translated r_bar evaluation point
-                  r_bar[i] = sawtooth(Lat,X[i],i);
+                  r_bar[i] = sawtooth(Lat,X,i);
 //                    ShiftGaugeOrigin(P,X,i);
                     //X[i];
Index: pcp/src/perturbed.h
===================================================================
--- pcp/src/perturbed.h	(revision cc9c36527731f3b1b508bb1c90f78f8775a7ee1b)
+++ pcp/src/perturbed.h	(revision 9bdd866eca950981175d4eb672952e1c119b1d98)
@@ -43,5 +43,5 @@
 void ReadSrcPerturbedPsis(struct Problem *P, enum PsiTypeTag type);
 inline double ShiftGaugeOrigin(struct Problem *P, double r[NDIM], const int index);
-inline double sawtooth(struct Lattice *Lat, const double L, const int index);
+inline double sawtooth(struct Lattice *Lat, double L[NDIM], const int index);
 inline void MinImageConv(struct Lattice *Lat, const double R[NDIM], const double r[NDIM], double *result);
 void test_fft_symmetry(struct Problem *P, const int l);
