Index: /TOOLS/CPLRESTART/FillOceRestart.py
===================================================================
--- /TOOLS/CPLRESTART/FillOceRestart.py	(revision 3740)
+++ /TOOLS/CPLRESTART/FillOceRestart.py	(revision 3741)
@@ -32,5 +32,5 @@
     From https://stackoverflow.com/questions/5551286/filling-gaps-in-a-numpy-array
     
-    Input:  InputData : numpy masked array of any dimension.
+    Input:  InputData : numpy.ma array of any dimension.
 
     Output: Return a filled array. 
@@ -44,14 +44,17 @@
 
 def usage () :
-    texte = """%(prog)s usage :
-python %(prog)s [-d] [-i <orca grid file>] [-n <perio>]
+    __help__ = """%(prog)s usage :
+python %(prog)s [-d] -i <sstoce file> [-n <perio>] [-v variables] [-o <output file>]
  -d           | --debug                : debug
  -i <file>    | --input=<file>         : input file  (default: none)
- -v <varlist> | --variable=<variables> : list of variable to fill (defautl: none)
+ -o <file>    | --output=<file>        : output file (default : build a name form input file)
+ -r           | --replace              : replace input file by new file with filled variables
+ -v <varlist> | --variable=<variables> : list of variable to fill (defautlt: all variable in file)
+ -x           | --exclude              : fills all variable in files, except those given in -v|--variable
  -n <perio>   | --perio=<perio> : periodicity type (default: try to guess)
-    #   1, 4, 6 : Cyclic on i dimension (generaly longitudes)
-    #   2       : Obsolete (was symmetric condition at southern boundary ?)
-    #   3, 4    : North fold T-point pivot (legacy ORCA2)
-    #   5, 6    : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo)
+    1, 4, 6 : Cyclic on i dimension (generaly longitudes)
+    2       : Obsolete (was symmetric condition at southern boundary ?)
+    3, 4    : North fold T-point pivot (legacy ORCA2)
+    5, 6    : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo)
     If <perio> is not specified, %(prog)s will try to guess it from the grid dimensions
 example :
@@ -59,5 +62,5 @@
     python %(prog)s -n 4 -i sstoce_ORCA2.3.nc -v O_SSTSST,OIceFrc
     """
-    print ( texte % { 'prog':sys.argv[0] } )
+    print ( __help__ % { 'prog':sys.argv[0] } )
 
 ## Default input parameters
@@ -72,5 +75,6 @@
 ## Command line options
 try:
-    myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:o:rv:xp:hd', [ 'input=', 'output=', 'replace', 'exclude', 'variable=', 'perio=', 'debug', 'help' ] )
+    myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:o:rv:xp:hd',
+                                         [ 'input=', 'output=', 'replace', 'exclude', 'variable=', 'variables=', 'perio=', 'debug', 'help' ] )
 except getopt.GetoptError as cmdle :
     print ( "Command line error : "+str(cmdle)+"\n" )
@@ -97,11 +101,9 @@
         else :
             if Debug : print ("Out file set to input file")
-            OuFile   = InFile ; s 
+            OuFile   = InFile ;
     elif myopt in [ '-p', '--perio'     ] : nperio = int(myval) ;
-    elif myopt in [ '-v', '--variable'  ] :
-        if Exclude :
-            ListExclude = myval.split(',')          
-        else :
-            ListVarName = myval.split(',')
+    elif myopt in [ '-v', '--variable', '--variables'  ] :
+        if Exclude : ListExclude = myval.split(',')          
+        else :       ListVarName = myval.split(',')
     elif myopt in [ '-x', '--exclude'  ] :
         Exclude = True
@@ -124,22 +126,30 @@
 # Try to guess periodicity type
 if nperio == None :
-    print ("Trying to guess nperio parameter")
+    print ( "Trying to guess nperio parameter" )
     jpoi = OuFile.dimensions["x"].size
     jpoj = OuFile.dimensions["y"].size
     print ("Grid dimensions: ("+str(jpoj)+", "+str(jpoi)+")")
-    if (jpoj, jpoi) == (149, 182) :
-        print ("ORCA 2 grid found: nperio may vary for this configuration")
+    if   'ORCA2' in InFile :
+        print ("ORCA 2 grid found from file name: nperio may vary for this configuration")
+        print ("Choosen nperio=4")
+    elif 'ORCA1' in InFile :
+        if 'eORCA1' in InFile : 
+            print ("eORCA 1 grid found from file name, nperio=6")
+        else :
+            print ("ORCA 1 grid found from file name, nperio=6")
+    elif (jpoj, jpoi) == (149, 182) :
+        print ("ORCA 2 grid found from dimension: nperio may vary for this configuration")
         print ("Choosen nperio=4")
         nperio = 4
-    if (jpoj, jpoi) == (332, 292) :
+    elif (jpoj, jpoi) == (332, 292) :
         nperio = 6
-        print ("ORCA1 grid found, nperio=6" )
-    if (jpoj, jpoi) == (332, 362) :
+        print ("ORCA1 grid found from dimensions, nperio=6" )
+    elif (jpoj, jpoi) == (332, 362) :
         nperio = 6
-        print ("eORCA1 grid found, nperio=6" )
-
+        print ("eORCA1 grid found from dimensions, nperio=6" )
+        
 if nperio == None :
-    print ("%(prog)s could not guess the periodicity type of your file")
-    print ("Please specify -n|--nperio")
+    print ("%(prog)s couldn't guess the periodicity type of your file")
+    print ("Please specify -p|--perio")
     usage ()
     sys.exit(1)
@@ -149,5 +159,5 @@
 
 # Exclude some var if needed
-if Exclude :
+if Exclude : 
     for Var in ListExclude : 
         if Var in ListVarName : ListVarName.remove(Var)
@@ -155,9 +165,8 @@
 # Loop on variables
 for VarName in ListVarName :
-
     Var    = OuFile.variables[VarName]
-    if 'mask' in dir(Var[:,...]) :
+    if 'mask' in dir(Var[...]) :
         print ( "Working on " + VarName )
-        NewVar = MyFill ( InputData = Var[:,:] )
+        NewVar = MyFill ( InputData = Var[...] )
         NewVar = nemo.lbc (NewVar, nperio=nperio, cd_type='T', psgn=1.0)
         OuFile.variables[VarName][:,:] = NewVar[:,:]
@@ -166,5 +175,5 @@
         
 # Close file : writes update variables.    
-#OuFile.close()
+OuFile.close()
 
 ## ===========================================================================
Index: /TOOLS/CPLRESTART/nemo.py
===================================================================
--- /TOOLS/CPLRESTART/nemo.py	(revision 3740)
+++ /TOOLS/CPLRESTART/nemo.py	(revision 3741)
@@ -22,74 +22,73 @@
 
 def lbc (ptab, nperio=6, cd_type='T', psgn=1.0) :
-    """
-    ptab      : Input array
+      """
+      ptab      : Input array
       rank 2 at least : patb[...., lat, lon]
-    nperio    : Type of periodicity
-      1, 4, 6 : Cyclic on i dimension (generaly longitudes)
-      2       : Obsolete (was symmetric condition at southern boundary ?)
-      3, 4    : North fold T-point pivot (legacy ORCA2)
-      5, 6    : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo)
-    cd_type   : Grid specification : T, U, V or F
-    psgn      : For change of sign for vector components
+      nperio    : Type of periodicity
+         1, 4, 6   : Cyclic on i dimension (generaly longitudes)
+         2         : Obsolete (was symmetric condition at southern boundary ?)
+         3, 4      : North fold T-point pivot (legacy ORCA2)
+         5, 6      : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo)
+      cd_type   : Grid specification : T, U, V or F
+      psgn      : For change of sign for vector components
+      
+      See NEMO documentation for further details
+      """
+      jpi = ptab.shape[-1]
     
-    See NEMO documentation for further details
-    """
-        
-    jpi = ptab.shape[-1]
-    
-    #
-    #> East-West boundary conditions
-    # --------------------------------
-
-    if nperio in [1, 4, 6] :
-        # ... cyclic
-        ptab [...,:,  0] = ptab [...,:,-2]
-        ptab [...,:, -1] = ptab [...,:, 1]
-   
-    #
-    #> North-South boundary conditions
-    # ----------------------------------
-    if nperio in [3, 4] :  # North fold T-point pivot     
-        if cd_type in [ 'T', 'W' ] : # T-, W-point
-            ptab[..., -1, 1:       ] = psgn * ptab[..., -3, -1:0:-1      ]      
-            ptab[..., -1, 0        ] = psgn * ptab[..., -3, 2            ]
-            ptab[..., -2, jpi//2:  ] = psgn * ptab[..., -2, jpi//2:0:-1  ]
-                      
-        if cd_type == 'U' :
-            ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ]       
-            ptab[..., -1,  0       ] = psgn * ptab[..., -3,  1           ]
-            ptab[..., -1, -1       ] = psgn * ptab[..., -3, -2           ] 
-            ptab[..., -2, jpi//2-1:] = psgn * ptab[..., -2, jpi//2+1:0:-1]
+      #
+      #> East-West boundary conditions
+      # --------------------------------
+      
+      if nperio in [1, 4, 6] :
+            # ... cyclic
+            ptab [...,:,  0] = ptab [...,:,-2]
+            ptab [...,:, -1] = ptab [...,:, 1]
+      
+      #
+      #> North-South boundary conditions
+      # ----------------------------------
+      if nperio in [3, 4] :  # North fold T-point pivot     
+            if cd_type in [ 'T', 'W' ] : # T-, W-point
+                  ptab[..., -1, 1:       ] = psgn * ptab[..., -3, -1:0:-1      ]      
+                  ptab[..., -1, 0        ] = psgn * ptab[..., -3, 2            ]
+                  ptab[..., -2, jpi//2:  ] = psgn * ptab[..., -2, jpi//2:0:-1  ]
+                  
+            if cd_type == 'U' :
+                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ]       
+                  ptab[..., -1,  0       ] = psgn * ptab[..., -3,  1           ]
+                  ptab[..., -1, -1       ] = psgn * ptab[..., -3, -2           ] 
+                  ptab[..., -2, jpi//2-1:] = psgn * ptab[..., -2, jpi//2+1:0:-1]
+                  
+            if cd_type == 'V' : 
+                  ptab[..., -2, 1:       ] = psgn * ptab[..., -3, jpi-1:0:-1   ]
+                  ptab[..., -1, 1:       ] = psgn * ptab[..., -4, -1:0:-1      ]   
+                  ptab[..., -1, 0        ] = psgn * ptab[..., -4, 2            ]
+              
+            if cd_type == 'F' :
+                  ptab[..., -2, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ]
+                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -4, -1:0:-1      ]
+                  ptab[..., -1,  0       ] = psgn * ptab[..., -4,  1           ]
+                  ptab[..., -1, -1       ] = psgn * ptab[..., -4, -2           ] 
+                  
+      if nperio in [5, 6] :            #  North fold F-point pivot  
+            if cd_type in ['T', 'W']  :
+                  ptab[..., -1, 0:       ] = psgn * ptab[..., -2, -1::-1       ]
             
-        if cd_type == 'V' : 
-            ptab[..., -2, 1:       ] = psgn * ptab[..., -3, jpi-1:0:-1   ]
-            ptab[..., -1, 1:       ] = psgn * ptab[..., -4, -1:0:-1      ]   
-            ptab[..., -1, 0        ] = psgn * ptab[..., -4, 2            ]
-            
-        if cd_type == 'F' :
-            ptab[..., -2, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ]
-            ptab[..., -1, 0:-1     ] = psgn * ptab[..., -4, -1:0:-1      ]
-            ptab[..., -1,  0       ] = psgn * ptab[..., -4,  1           ]
-            ptab[..., -1, -1       ] = psgn * ptab[..., -4, -2           ] 
-      
-    if nperio in [5, 6] :            #  North fold F-point pivot  
-        if cd_type in ['T', 'W']  :
-            ptab[..., -1, 0:       ] = psgn * ptab[..., -2, -1::-1       ]
-                
-        if cd_type == 'U' :
-            ptab[..., -1, 0:-1     ] = psgn * ptab[..., -2, -2::-1       ]       
-            ptab[..., -1, -1       ] = psgn * ptab[..., -2, 0            ]
-             
-        if cd_type == 'V' :
-            ptab[..., -1, 0:       ] = psgn * ptab[..., -3, -1::-1       ]
-            ptab[..., -2, jpi/2:   ] = psgn * ptab[..., -2, jpi/2-1::-1  ]
-                             
-        if cd_type == 'F' :
-            ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -2::-1       ]
-            ptab[..., -1, -1       ] = psgn * ptab[..., -3, 0            ]
-            ptab[..., -2, jpi//2:-1] = psgn * ptab[..., -2, jpi//2-2::-1 ]
-
-    return ptab
-        
+            if cd_type == 'U' :
+                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -2, -2::-1       ]       
+                  ptab[..., -1, -1       ] = psgn * ptab[..., -2, 0            ]
+              
+            if cd_type == 'V' :
+                  ptab[..., -1, 0:       ] = psgn * ptab[..., -3, -1::-1       ]
+                  ptab[..., -2, jpi/2:   ] = psgn * ptab[..., -2, jpi/2-1::-1  ]
+              
+            if cd_type == 'F' :
+                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -2::-1       ]
+                  ptab[..., -1, -1       ] = psgn * ptab[..., -3, 0            ]
+                  ptab[..., -2, jpi//2:-1] = psgn * ptab[..., -2, jpi//2-2::-1 ]
+              
+      return ptab
+  
 ## ===========================================================================
 ##
