diff --git a/DiffractionGratings/grating3D.pro b/DiffractionGratings/grating3D.pro
index 44d7b27b96db6ff66661e049011fbf190a57ccf9..d48a5325b26dd80d5316edb86fe493bdc027a83a 100644
--- a/DiffractionGratings/grating3D.pro
+++ b/DiffractionGratings/grating3D.pro
@@ -178,13 +178,13 @@ Function{
 	dephY[] = Exp[I[]*CompY[k1[]]*period_y];
 
 	// Fourier coefficients variables
-  Nb_ordre = 2*N_d_order+1;
+  Nb_ordre = 2*Nmax+1;
   For i In {0:Nb_ordre-1}
-    alpha~{i}[]      = -CompX[k1[]] + 2*Pi/period_x * (i-N_d_order);
+    alpha~{i}[]      = -CompX[k1[]] + 2*Pi/period_x * (i-Nmax);
     expialphax~{i}[] = Exp[I[]*alpha~{i}[]*X[]];
   EndFor
   For j In {0:Nb_ordre-1}
-    beta~{j}[]      = -CompY[k1[]]  + 2*Pi/period_y * (j-N_d_order);
+    beta~{j}[]      = -CompY[k1[]]  + 2*Pi/period_y * (j-Nmax);
     expibetay~{j}[] = Exp[I[]*beta~{j}[]*Y[]];
   EndFor
   For i In {0:Nb_ordre-1}
@@ -338,7 +338,7 @@ PostProcessing {
                  1/(gammar~{i}~{j}[]*-CompZ[k1[]])*((gammar~{i}~{j}[]^2+alpha~{i}[]^2)*SquNorm[$int_x_r~{i}~{j}]+
                                                       (gammar~{i}~{j}[]^2+ beta~{j}[]^2)*SquNorm[$int_y_r~{i}~{j}]+
                                                       2*alpha~{i}[]*beta~{j}[]*Re[$int_x_r~{i}~{j}*Conj[$int_y_r~{i}~{j}]]) ] ; In SurfIntTop ; } } }
-          { Name numbering_ij~{i}~{j}   ; Value { Term{Type Global; [Vector[i-Nb_ordre,j-Nb_ordre,0]] ; In SurfIntBot ; } } }
+          { Name numbering_ij~{i}~{j}   ; Value { Term{Type Global; [Vector[i-Nmax,j-Nmax,0]] ; In SurfIntBot ; } } }
         EndFor
       EndFor
 
@@ -422,7 +422,7 @@ PostOperation {
       EndFor
       For i In {0:Nb_ordre-1}
         For j In {0:Nb_ordre-1}
-          Print[ numbering_ij~{i}~{j}[SurfIntBot], OnRegion SurfIntBot, File StrCat[myDir,"numbering_ij.txt"], Format Table ];
+          Print[ numbering_ij~{i}~{j}[SurfIntBot], OnRegion SurfIntBot, File > StrCat[myDir,"numbering_ij.txt"], Format Table ];
         EndFor
       EndFor
     }
diff --git a/DiffractionGratings/grating3D_data_torus.geo b/DiffractionGratings/grating3D_data_torus.geo
index 466c31365729315b7638ff2d8f3c20de87c07ef5..69f8f8e9ef38500b611824038682355ff5bce91e 100644
--- a/DiffractionGratings/grating3D_data_torus.geo
+++ b/DiffractionGratings/grating3D_data_torus.geo
@@ -50,7 +50,7 @@ DefineConstant[
     scat_lc       = {20         , Name StrCat[pp5,"/2Scatterer absolute mesh size [nm]"]},
     PML_top       = {lambda0*1.5, Name StrCat[pp5,"/4PML top thickness [nm]"]},
     PML_bot       = {lambda0*1.5, Name StrCat[pp5,"/5PML bot thickness [nm]"]},
-    N_d_order     = {1          , Name StrCat[pp5,"/6Number of non specular order to output [-]"]},
+    Nmax          = {1          , Name StrCat[pp5,"/6Max number of non specular order to output [-]"]},
     refine_mesh_L1= {1          , Name StrCat[pp5,"/7refine layers/1refine mesh layer 1 [-]"]},
     refine_mesh_L2= {1          , Name StrCat[pp5,"/7refine layers/2refine mesh layer 2 [-]"]},
     refine_mesh_L3= {1          , Name StrCat[pp5,"/7refine layers/3refine mesh layer 3 [-]"]},