Index: TOOLS/WATER_BUDGET/ATM_waterbudget.py
===================================================================
--- TOOLS/WATER_BUDGET/ATM_waterbudget.py	(revision 6647)
+++ TOOLS/WATER_BUDGET/ATM_waterbudget.py	(revision 6651)
@@ -68,5 +68,5 @@
 tar_restart_end_ATM=None ; tar_restart_end_DYN=None ; tar_restart_end_SRF=None
 tar_restart_end_RUN=None ; tar_restart_end_OCE=None ; tar_restart_end_ICE=None
-ContinueOnError=False ; ErrorCount=0 ; SortIco = False
+ContinueOnError=False ; ErrorCount=0 # ; SortIco = False
 
 ##
@@ -177,5 +177,5 @@
                       'OCE_rho_liq':str(OCE_rho_liq), 'ATM_rho':str(ATM_rho), 'SRF_rho':str(SRF_rho), 'RUN_rho':str(RUN_rho)}
 
-config['Config'] = { 'ContinueOnError':str(ContinueOnError), 'SortIco':str(SortIco), 'TestInterp':str(TestInterp), 'readPrec':str(readPrec) }
+config['Config'] = { 'ContinueOnError':str(ContinueOnError), 'TestInterp':str(TestInterp), 'readPrec':str(readPrec) }
 
 ## --------------------------
@@ -236,5 +236,5 @@
 if readPrec == float :
     def rprec (tab) : return tab
-else : 
+else                 :
     def rprec (tab) : return tab.astype(readPrec).astype(float)
     
@@ -270,5 +270,4 @@
 
 echo ( f'{ContinueOnError = }' )
-echo ( f'{SortIco         = }' )
 echo ( f'{readPrec        = }' )
 
@@ -624,32 +623,4 @@
 config_out.close ()
 
-if ICO :
-    if SortIco : 
-        # Creation d'une clef de tri pour les restarts (pour chaque restart !)
-        DYN_beg_keysort = np.lexsort ( (d_DYN_beg['lat_mesh'], d_DYN_beg['lon_mesh'] ) )
-        ATM_beg_keysort = np.lexsort ( (d_ATM_beg['latitude'], d_ATM_beg['longitude']) )
-        SRF_beg_keysort = np.lexsort ( (d_SRF_beg['nav_lat' ], d_SRF_beg['nav_lon']  ) )
-        DYN_end_keysort = np.lexsort ( (d_DYN_end['lat_mesh'], d_DYN_end['lon_mesh'] ) )
-        ATM_end_keysort = np.lexsort ( (d_ATM_end['latitude'], d_ATM_end['longitude']) )
-        SRF_end_keysort = np.lexsort ( (d_SRF_end['nav_lat' ], d_SRF_end['nav_lon']  ) )
-        
-        if ATM_HIS == 'ico' :
-            ATM_his_keysort = np.lexsort ( (d_ATM_his['lat'], d_ATM_his['lon'] ) )
-        if SRF_HIS == 'ico' :
-            SRF_his_keysort = np.lexsort ( (d_SRF_his['lat'], d_SRF_his['lon'] ) )
-            RUN_his_keysort = SRF_his_keysort
-    else : 
-        DYN_beg_keysort = np.arange ( len ( d_DYN_beg['lat_mesh'] ) )
-        ATM_beg_keysort = DYN_beg_keysort
-        SRF_beg_keysort = DYN_beg_keysort
-
-        DYN_end_keysort = DYN_beg_keysort
-        ATM_end_keysort = DYN_beg_keysort
-        SRF_end_keysort = DYN_beg_keysort
-    
-        ATM_his_keysort = DYN_beg_keysort
-        SRF_his_keysort = DYN_beg_keysort
-        RUN_his_keysort = SRF_his_keysort
-        
 # ATM grid with cell surfaces
 if LMDZ :
@@ -657,5 +628,5 @@
     ATM_lat       = lmdz.geo2point (   rprec (d_ATM_his ['lat'])+0*rprec (d_ATM_his ['lon']), dim1D='cell' )
     ATM_lon       = lmdz.geo2point ( 0*rprec (d_ATM_his ['lat'])+  rprec (d_ATM_his ['lon']), dim1D='cell' )
-    ATM_aire      = lmdz.geo2point ( rprec (d_ATM_his ['aire'] )    [0], cumulPoles=True, dim1D='cell' )
+    ATM_aire      = lmdz.geo2point ( rprec (d_ATM_his ['aire']     [0]), cumulPoles=True, dim1D='cell' )
     ATM_fter      = lmdz.geo2point ( rprec (d_ATM_his ['fract_ter'][0]), dim1D='cell' )
     ATM_foce      = lmdz.geo2point ( rprec (d_ATM_his ['fract_oce'][0]), dim1D='cell' )
@@ -685,11 +656,11 @@
     if ATM_HIS == 'ico' :
         echo ( 'ATM areas and fractions on ICO grid' )
-        ATM_aire =  rprec (d_ATM_his ['aire']     [0])[ATM_his_keysort].squeeze()
-        ATM_lat  =  rprec (d_ATM_his ['lat']         )[ATM_his_keysort]
-        ATM_lon  =  rprec (d_ATM_his ['lon']         )[ATM_his_keysort]
-        ATM_fter =  rprec (d_ATM_his ['fract_ter'][0])[ATM_his_keysort]
-        ATM_foce =  rprec (d_ATM_his ['fract_oce'][0])[ATM_his_keysort]
-        ATM_fsic =  rprec (d_ATM_his ['fract_sic'][0])[ATM_his_keysort]
-        ATM_flic =  rprec (d_ATM_his ['fract_lic'][0])[ATM_his_keysort]
+        ATM_aire =  rprec (d_ATM_his ['aire']     [0]).squeeze()
+        ATM_lat  =  rprec (d_ATM_his ['lat']         )
+        ATM_lon  =  rprec (d_ATM_his ['lon']         )
+        ATM_fter =  rprec (d_ATM_his ['fract_ter'][0])
+        ATM_foce =  rprec (d_ATM_his ['fract_oce'][0])
+        ATM_fsic =  rprec (d_ATM_his ['fract_sic'][0])
+        ATM_flic =  rprec (d_ATM_his ['fract_lic'][0])
 
     if SRF_HIS == 'latlon' :
@@ -713,8 +684,8 @@
     if SRF_HIS == 'ico' :
         echo ( 'SRF areas and fractions on latlon grid' )
-        SRF_lat       =  rprec (d_SRF_his ['lat']     ) [SRF_his_keysort]
-        SRF_lon       =  rprec (d_SRF_his ['lon']     ) [SRF_his_keysort]
-        SRF_areas     =  rprec (d_SRF_his ['Areas']   ) [SRF_his_keysort] 
-        SRF_contfrac  =  rprec (d_SRF_his ['Contfrac']) [SRF_his_keysort]
+        SRF_lat       =  rprec (d_SRF_his ['lat']     )
+        SRF_lon       =  rprec (d_SRF_his ['lon']     )
+        SRF_areas     =  rprec (d_SRF_his ['Areas']   ) 
+        SRF_contfrac  =  rprec (d_SRF_his ['Contfrac'])
         SRF_aire      =  SRF_areas * SRF_contfrac
 
@@ -745,12 +716,12 @@
         DYN_aire_keysort = np.arange ( len ( d_DYN_aire['lat'] ) )
             
-    DYN_lat = d_DYN_aire['lat'][DYN_aire_keysort]
-    DYN_lon = d_DYN_aire['lon'][DYN_aire_keysort]
-
-    DYN_aire = d_DYN_aire['aire'][DYN_aire_keysort]
-    DYN_fsea = d_DYN_aire['fract_oce'][DYN_aire_keysort] + d_DYN_aire['fract_sic'][DYN_aire_keysort]
+    DYN_lat = d_DYN_aire['lat']
+    DYN_lon = d_DYN_aire['lon']
+
+    DYN_aire = d_DYN_aire['aire']
+    DYN_fsea = d_DYN_aire['fract_oce'] + d_DYN_aire['fract_sic']
     DYN_flnd = 1.0 - DYN_fsea
-    DYN_fter = d_ATM_beg['FTER'][ATM_beg_keysort]
-    DYN_flic = d_ATM_beg['FLIC'][ATM_beg_keysort]
+    DYN_fter = d_ATM_beg['FTER']
+    DYN_flic = d_ATM_beg['FLIC']
     DYN_aire_fter = DYN_aire * DYN_fter
     
@@ -782,5 +753,4 @@
 def SRF_stock_int (stock) :
     '''Integrate (* surface) stock on land grid'''
-    #SRF_stock_int  = wu.Ksum (  ( (stock * DYN_aire_fter).to_masked_array().ravel()) ) # Marche avec ICO et lon/lat na
     SRF_stock_int  = wu.Ksum (  ( (stock * DYN_aire_fter).to_masked_array().ravel()) )
     return SRF_stock_int
@@ -845,6 +815,6 @@
 echo ( 'Surface pressure' )
 if ICO :
-    DYN_psol_beg = d_DYN_beg['ps'][DYN_beg_keysort]
-    DYN_psol_end = d_DYN_end['ps'][DYN_end_keysort]
+    DYN_psol_beg = d_DYN_beg['ps']
+    DYN_psol_end = d_DYN_end['ps']
 if LMDZ : 
     DYN_psol_beg = lmdz.geo2point ( d_DYN_beg['ps'].isel(rlonv=slice(0,-1)), dim1D='cell' )
@@ -911,14 +881,14 @@
     if 'H2Ov_g' in d_DYN_beg.variables :
         echo ('reading ICO : H2O_g, H2O_l, H2O_s' )
-        DYN_wat_beg = (d_DYN_beg['H2O_g'] + d_DYN_beg['H2O_l'] + d_DYN_beg['H2O_s'])[..., DYN_beg_keysort]
-        DYN_wat_end = (d_DYN_end['H2O_g'] + d_DYN_end['H2O_l'] + d_DYN_end['H2O_s'])[..., DYN_beg_keysort]
+        DYN_wat_beg = (d_DYN_beg['H2O_g'] + d_DYN_beg['H2O_l'] + d_DYN_beg['H2O_s'])
+        DYN_wat_end = (d_DYN_end['H2O_g'] + d_DYN_end['H2O_l'] + d_DYN_end['H2O_s'])
     elif 'H2O_g' in d_DYN_beg.variables :
         echo ('reading ICO : H2O_g, H2O_l, H2O_s' )
-        DYN_wat_beg = (d_DYN_beg['H2O_g'] + d_DYN_beg['H2O_l'] + d_DYN_beg['H2O_s'])[..., DYN_beg_keysort]
-        DYN_wat_end = (d_DYN_end['H2O_g'] + d_DYN_end['H2O_l'] + d_DYN_end['H2O_s'])[..., DYN_beg_keysort]
+        DYN_wat_beg = (d_DYN_beg['H2O_g'] + d_DYN_beg['H2O_l'] + d_DYN_beg['H2O_s'])
+        DYN_wat_end = (d_DYN_end['H2O_g'] + d_DYN_end['H2O_l'] + d_DYN_end['H2O_s'])
     elif 'q' in d_DYN_beg.variables :
         echo ('reading ICO : q' )
-        DYN_wat_beg = (d_DYN_beg['q'].isel(nq=0) + d_DYN_beg['q'].isel(nq=1) + d_DYN_beg['q'].isel(nq=2) )[..., DYN_beg_keysort]
-        DYN_wat_end = (d_DYN_end['q'].isel(nq=0) + d_DYN_end['q'].isel(nq=1) + d_DYN_end['q'].isel(nq=2) )[..., DYN_beg_keysort]
+        DYN_wat_beg = (d_DYN_beg['q'].isel(nq=0) + d_DYN_beg['q'].isel(nq=1) + d_DYN_beg['q'].isel(nq=2) )
+        DYN_wat_end = (d_DYN_end['q'].isel(nq=0) + d_DYN_end['q'].isel(nq=1) + d_DYN_end['q'].isel(nq=2) )
 
 if 'lev' in DYN_wat_beg.dims : 
@@ -973,22 +943,22 @@
 
 if ICO :
-     ATM_sno_beg     = ATM_sno_beg    [ATM_beg_keysort]
-     ATM_sno_end     = ATM_sno_end    [ATM_end_keysort]
-     ATM_qs_beg      = ATM_qs_beg     [ATM_beg_keysort]
-     ATM_qs_end      = ATM_qs_end     [ATM_end_keysort]
-     ATM_qsol_beg    = ATM_qsol_beg   [ATM_beg_keysort]
-     ATM_qs01_beg    = ATM_qs01_beg   [ATM_beg_keysort]
-     ATM_qs02_beg    = ATM_qs02_beg   [ATM_beg_keysort]
-     ATM_qs03_beg    = ATM_qs03_beg   [ATM_beg_keysort]
-     ATM_qs04_beg    = ATM_qs04_beg   [ATM_beg_keysort]
-     ATM_qsol_end    = ATM_qsol_end   [ATM_end_keysort]
-     ATM_qs01_end    = ATM_qs01_end   [ATM_end_keysort]
-     ATM_qs02_end    = ATM_qs02_end   [ATM_end_keysort]
-     ATM_qs03_end    = ATM_qs03_end   [ATM_end_keysort]
-     ATM_qs04_end    = ATM_qs04_end   [ATM_end_keysort]
-     LIC_sno_beg     = LIC_sno_beg    [ATM_beg_keysort]
-     LIC_sno_end     = LIC_sno_end    [ATM_end_keysort]
-     LIC_runlic0_beg = LIC_runlic0_beg[ATM_beg_keysort]
-     LIC_runlic0_end = LIC_runlic0_end[ATM_end_keysort]
+     ATM_sno_beg     = ATM_sno_beg    
+     ATM_sno_end     = ATM_sno_end    
+     ATM_qs_beg      = ATM_qs_beg     
+     ATM_qs_end      = ATM_qs_end     
+     ATM_qsol_beg    = ATM_qsol_beg   
+     ATM_qs01_beg    = ATM_qs01_beg   
+     ATM_qs02_beg    = ATM_qs02_beg   
+     ATM_qs03_beg    = ATM_qs03_beg   
+     ATM_qs04_beg    = ATM_qs04_beg   
+     ATM_qsol_end    = ATM_qsol_end   
+     ATM_qs01_end    = ATM_qs01_end   
+     ATM_qs02_end    = ATM_qs02_end   
+     ATM_qs03_end    = ATM_qs03_end   
+     ATM_qs04_end    = ATM_qs04_end   
+     LIC_sno_beg     = LIC_sno_beg    
+     LIC_sno_end     = LIC_sno_end    
+     LIC_runlic0_beg = LIC_runlic0_beg
+     LIC_runlic0_end = LIC_runlic0_end
    
 LIC_qs_beg = ATM_qs02_beg
@@ -1146,14 +1116,5 @@
     SRF_snow_end        = lmdz.geo2point (SRF_snow_end       , dim1D='cell')
     SRF_lakeres_end     = lmdz.geo2point (SRF_lakeres_end    , dim1D='cell')
-  
-if ICO :
-    SRF_tot_watveg_beg  = SRF_tot_watveg_beg  [SRF_beg_keysort]
-    SRF_tot_watsoil_beg = SRF_tot_watsoil_beg [SRF_beg_keysort]
-    SRF_snow_beg        = SRF_snow_beg        [SRF_beg_keysort]
-    SRF_lakeres_beg     = SRF_lakeres_beg     [SRF_beg_keysort]
-    SRF_tot_watveg_end  = SRF_tot_watveg_end  [SRF_end_keysort]
-    SRF_tot_watsoil_end = SRF_tot_watsoil_end [SRF_end_keysort]
-    SRF_snow_end        = SRF_snow_end        [SRF_end_keysort]
-    SRF_lakeres_end     = SRF_lakeres_end     [SRF_end_keysort]
+
 
 # Stock dSoilHum dInterce dSWE dStream dFastR dSlowR dLake dPond dFlood
@@ -1252,31 +1213,31 @@
 if ATM_HIS == 'ico' :
     echo (' ico case')
-    ATM_wbilo_oce   = rprec (d_ATM_his ['wbilo_oce'])[..., ATM_his_keysort]
-    ATM_wbilo_sic   = rprec (d_ATM_his ['wbilo_sic'])[..., ATM_his_keysort]
-    ATM_wbilo_ter   = rprec (d_ATM_his ['wbilo_ter'])[..., ATM_his_keysort]
-    ATM_wbilo_lic   = rprec (d_ATM_his ['wbilo_lic'])[..., ATM_his_keysort]
-    ATM_runofflic   = rprec (d_ATM_his ['runofflic'])[..., ATM_his_keysort]
-    ATM_fqcalving   = rprec (d_ATM_his ['fqcalving'])[..., ATM_his_keysort]
-    ATM_fqfonte     = rprec (d_ATM_his ['fqfonte']  )[..., ATM_his_keysort]
-    ATM_precip      = rprec (d_ATM_his ['precip']   )[..., ATM_his_keysort]
-    ATM_snowf       = rprec (d_ATM_his ['snow']     )[..., ATM_his_keysort]
-    ATM_evap        = rprec (d_ATM_his ['evap']     )[..., ATM_his_keysort]
-    ATM_wevap_ter   = rprec (d_ATM_his ['wevap_ter'])[..., ATM_his_keysort]
-    ATM_wevap_oce   = rprec (d_ATM_his ['wevap_oce'])[..., ATM_his_keysort]
-    ATM_wevap_lic   = rprec (d_ATM_his ['wevap_lic'])[..., ATM_his_keysort]
-    ATM_wevap_sic   = rprec (d_ATM_his ['wevap_sic'])[..., ATM_his_keysort]
-    ATM_runofflic   = rprec (d_ATM_his ['runofflic'])[..., ATM_his_keysort]
-    ATM_wevap_ter   = rprec (d_ATM_his ['wevap_ter'])[..., ATM_his_keysort]
-    ATM_wevap_oce   = rprec (d_ATM_his ['wevap_oce'])[..., ATM_his_keysort]
-    ATM_wevap_lic   = rprec (d_ATM_his ['wevap_lic'])[..., ATM_his_keysort]
-    ATM_wevap_sic   = rprec (d_ATM_his ['wevap_sic'])[..., ATM_his_keysort]
-    ATM_wrain_ter   = rprec (d_ATM_his ['wrain_ter'])[..., ATM_his_keysort]
-    ATM_wrain_oce   = rprec (d_ATM_his ['wrain_oce'])[..., ATM_his_keysort]
-    ATM_wrain_lic   = rprec (d_ATM_his ['wrain_lic'])[..., ATM_his_keysort]
-    ATM_wrain_sic   = rprec (d_ATM_his ['wrain_sic'])[..., ATM_his_keysort]
-    ATM_wsnow_ter   = rprec (d_ATM_his ['wsnow_ter'])[..., ATM_his_keysort]
-    ATM_wsnow_oce   = rprec (d_ATM_his ['wsnow_oce'])[..., ATM_his_keysort]
-    ATM_wsnow_lic   = rprec (d_ATM_his ['wsnow_lic'])[..., ATM_his_keysort]
-    ATM_wsnow_sic   = rprec (d_ATM_his ['wsnow_sic'])[..., ATM_his_keysort]
+    ATM_wbilo_oce   = rprec (d_ATM_his ['wbilo_oce'])
+    ATM_wbilo_sic   = rprec (d_ATM_his ['wbilo_sic'])
+    ATM_wbilo_ter   = rprec (d_ATM_his ['wbilo_ter'])
+    ATM_wbilo_lic   = rprec (d_ATM_his ['wbilo_lic'])
+    ATM_runofflic   = rprec (d_ATM_his ['runofflic'])
+    ATM_fqcalving   = rprec (d_ATM_his ['fqcalving'])
+    ATM_fqfonte     = rprec (d_ATM_his ['fqfonte']  )
+    ATM_precip      = rprec (d_ATM_his ['precip']   )
+    ATM_snowf       = rprec (d_ATM_his ['snow']     )
+    ATM_evap        = rprec (d_ATM_his ['evap']     )
+    ATM_wevap_ter   = rprec (d_ATM_his ['wevap_ter'])
+    ATM_wevap_oce   = rprec (d_ATM_his ['wevap_oce'])
+    ATM_wevap_lic   = rprec (d_ATM_his ['wevap_lic'])
+    ATM_wevap_sic   = rprec (d_ATM_his ['wevap_sic'])
+    ATM_runofflic   = rprec (d_ATM_his ['runofflic'])
+    ATM_wevap_ter   = rprec (d_ATM_his ['wevap_ter'])
+    ATM_wevap_oce   = rprec (d_ATM_his ['wevap_oce'])
+    ATM_wevap_lic   = rprec (d_ATM_his ['wevap_lic'])
+    ATM_wevap_sic   = rprec (d_ATM_his ['wevap_sic'])
+    ATM_wrain_ter   = rprec (d_ATM_his ['wrain_ter'])
+    ATM_wrain_oce   = rprec (d_ATM_his ['wrain_oce'])
+    ATM_wrain_lic   = rprec (d_ATM_his ['wrain_lic'])
+    ATM_wrain_sic   = rprec (d_ATM_his ['wrain_sic'])
+    ATM_wsnow_ter   = rprec (d_ATM_his ['wsnow_ter'])
+    ATM_wsnow_oce   = rprec (d_ATM_his ['wsnow_oce'])
+    ATM_wsnow_lic   = rprec (d_ATM_his ['wsnow_lic'])
+    ATM_wsnow_sic   = rprec (d_ATM_his ['wsnow_sic'])
     echo ( f'End of ico case ')
 
@@ -1326,12 +1287,12 @@
 if RUN_HIS == 'ico' :
     echo ( f'RUN costalflow Grille ICO' )
-    RUN_coastalflow =  rprec (d_RUN_his ['coastalflow'])[..., RUN_his_keysort]
-    RUN_riverflow   =  rprec (d_RUN_his ['riverflow']  )[..., RUN_his_keysort]
-    RUN_runoff      =  rprec (d_RUN_his ['runoff']     )[..., RUN_his_keysort]
-    RUN_drainage    =  rprec (d_RUN_his ['drainage']   )[..., RUN_his_keysort]
-    RUN_riversret   =  rprec (d_RUN_his ['riversret']  )[..., RUN_his_keysort]
-    
-    RUN_coastalflow_cpl = rprec (d_RUN_his ['coastalflow_cpl'])[..., RUN_his_keysort]
-    RUN_riverflow_cpl   = rprec (d_RUN_his ['riverflow_cpl']  )[..., RUN_his_keysort]
+    RUN_coastalflow =  rprec (d_RUN_his ['coastalflow'])
+    RUN_riverflow   =  rprec (d_RUN_his ['riverflow']  )
+    RUN_runoff      =  rprec (d_RUN_his ['runoff']     )
+    RUN_drainage    =  rprec (d_RUN_his ['drainage']   )
+    RUN_riversret   =  rprec (d_RUN_his ['riversret']  )
+    
+    RUN_coastalflow_cpl = rprec (d_RUN_his ['coastalflow_cpl'])
+    RUN_riverflow_cpl   = rprec (d_RUN_his ['riverflow_cpl']  )
 
 Step = 0
@@ -1345,9 +1306,9 @@
          SRF_subli    = lmdz.geo2point ( rprec (d_SRF_his ['subli_contfrac_interp']), dim1D='cell')
          SRF_transpir = lmdz.geo2point ( rprec (d_SRF_his ['transpir_contfrac_interp']).sum(dim='veget'), dim1D='cell' )
-         SRF_rain.attrs     = d_SRF_his ['rain_contfrac_interp'].attrs
-         SRF_evap.attrs     = d_SRF_his ['evap_contfrac_interp'].attrs
-         SRF_snowf.attrs    = d_SRF_his ['snow_contfrac_interp'].attrs
-         SRF_subli.attrs    = d_SRF_his ['subli_contfrac_interp'].attrs
-         SRF_transpir.attrs = d_SRF_his ['transpir_contfrac_interp'].attrs
+         #SRF_rain.attrs.update     ( d_SRF_his ['rain_contfrac_interp'].attrs )
+         #SRF_evap.attrs.update     ( d_SRF_his ['evap_contfrac_interp'].attrs )
+         #SRF_snowf.attrs.update    ( d_SRF_his ['snow_contfrac_interp'].attrs )
+         #SRF_subli.attrs.update    ( d_SRF_his ['subli_contfrac_interp'].attrs )
+         #SRF_transpir.attrs.update ( d_SRF_his ['transpir_contfrac_interp'].attrs )
     else : 
         echo ( f'SRF rain' )
@@ -1360,9 +1321,9 @@
 if SRF_HIS == 'ico' :
     echo ( f'SRF rain')
-    SRF_rain     = rprec (d_SRF_his ['rain'] )[..., SRF_his_keysort]
-    SRF_evap     = rprec (d_SRF_his ['evap'] )[..., SRF_his_keysort]
-    SRF_snowf    = rprec (d_SRF_his ['snowf'])[..., SRF_his_keysort]
-    SRF_subli    = rprec (d_SRF_his ['subli'])[..., SRF_his_keysort]
-    SRF_transpir = rprec (d_SRF_his ['transpir']).sum(dim='veget')[..., SRF_his_keysort]
+    SRF_rain     = rprec (d_SRF_his ['rain'] )
+    SRF_evap     = rprec (d_SRF_his ['evap'] )
+    SRF_snowf    = rprec (d_SRF_his ['snowf'])
+    SRF_subli    = rprec (d_SRF_his ['subli'])
+    SRF_transpir = rprec (d_SRF_his ['transpir']).sum(dim='veget')
 
 echo ( f'SRF emp' )
Index: TOOLS/WATER_BUDGET/CPL_waterbudget.py
===================================================================
--- TOOLS/WATER_BUDGET/CPL_waterbudget.py	(revision 6647)
+++ TOOLS/WATER_BUDGET/CPL_waterbudget.py	(revision 6651)
@@ -81,5 +81,5 @@
 tar_restart_end_ATM=None ; tar_restart_end_DYN=None ; tar_restart_end_SRF=None
 tar_restart_end_RUN=None ; tar_restart_end_OCE=None ; tar_restart_end_ICE=None
-ContinueOnError=False ; ErrorCount=0 ; SortIco = False
+ContinueOnError=False ; ErrorCount=0
 
 ##
@@ -191,5 +191,5 @@
                       'OCE_rho_liq':str(OCE_rho_liq), 'ATM_rho':str(ATM_rho), 'SRF_rho':str(SRF_rho), 'RUN_rho':str(RUN_rho)}
 
-config['Config'] = { 'ContinueOnError':str(ContinueOnError), 'SortIco':str(SortIco), 'TestInterp':str(TestInterp), 'readPrec':str(readPrec) }
+config['Config'] = { 'ContinueOnError':str(ContinueOnError), 'TestInterp':str(TestInterp), 'readPrec':str(readPrec) }
 
 ## --------------------------
@@ -284,5 +284,4 @@
 
 echo ( f'{ContinueOnError = }' )
-echo ( f'{SortIco         = }' )
 echo ( f'{readPrec        = }' )
 
@@ -605,15 +604,15 @@
 def ONE_stock_int (stock) :
     '''Sum stock'''
-    ONE_stock_int = np.sum (  np.sort ( (stock ).to_masked_array().ravel()) )
+    ONE_stock_int =  wu.Psum ( stock.to_masked_array().ravel() )
     return ONE_stock_int
 
 def OCE_flux_int (flux) :
     '''Integrate flux on oce grid'''
-    OCE_flux_int = np.sum (  np.sort ( (flux * OCE_aire * dtime_per_sec).to_masked_array().ravel()) )
+    OCE_flux_int = wu.Psum ( (flux * OCE_aire * dtime_per_sec).to_masked_array().ravel() )
     return OCE_flux_int
 
 def ONE_flux_int (flux) :
     '''Integrate flux on oce grid'''
-    OCE_flux_int = np.sum (  np.sort ( (flux * dtime_per_sec).to_masked_array().ravel()) )
+    OCE_flux_int = wu.Psum ( (flux * dtime_per_sec).to_masked_array().ravel() )
     return OCE_flux_int
 
Index: TOOLS/WATER_BUDGET/OCE_waterbudget.py
===================================================================
--- TOOLS/WATER_BUDGET/OCE_waterbudget.py	(revision 6647)
+++ TOOLS/WATER_BUDGET/OCE_waterbudget.py	(revision 6651)
@@ -68,5 +68,5 @@
 tar_restart_end_ATM=None ; tar_restart_end_DYN=None ; tar_restart_end_SRF=None
 tar_restart_end_RUN=None ; tar_restart_end_OCE=None ; tar_restart_end_ICE=None
-ContinueOnError=False ; ErrorCount=0 ; SortIco = False
+ContinueOnError=False ; ErrorCount=0
 
 ##
@@ -144,5 +144,4 @@
             exec ( f'wu.{VarName} = {VarName}' )
             print ( f'    {VarName:21} set to : {locals()[VarName]}' )
-            #exec ( f'del {VarName}' )
 
 print ( f'\nConfig file readed : {IniFile} ' )
@@ -177,5 +176,5 @@
                       'OCE_rho_liq':str(OCE_rho_liq), 'ATM_rho':str(ATM_rho), 'SRF_rho':str(SRF_rho), 'RUN_rho':str(RUN_rho)}
 
-config['Config'] = { 'ContinueOnError':ContinueOnError, 'SortIco':SortIco, 'TestInterp':str(TestInterp), 'readPrec':str(readPrec) }
+config['Config'] = { 'ContinueOnError':ContinueOnError, 'TestInterp':str(TestInterp), 'readPrec':str(readPrec) }
 
 ## --------------------------
@@ -528,5 +527,4 @@
 config.write (config_out )
 config_out.close ()
-
     
 # Get mask and surfaces
@@ -543,20 +541,20 @@
 def OCE_stock_int (stock) :
     '''Integrate stock on ocean grid'''
-    OCE_stock_int = np.sum (  np.sort ( (stock * OCE_aire ).to_masked_array().ravel()) )
+    OCE_stock_int = wu.Psum (  (stock * OCE_aire ).to_masked_array().ravel() )
     return OCE_stock_int
 
 def ONE_stock_int (stock) :
     '''Sum stock'''
-    ONE_stock_int = np.sum (  np.sort ( (stock ).to_masked_array().ravel()) )
+    ONE_stock_int =  wu.Psum ( stock.to_masked_array().ravel() )
     return ONE_stock_int
 
 def OCE_flux_int (flux) :
     '''Integrate flux on oce grid'''
-    OCE_flux_int = np.sum (  np.sort ( (flux * OCE_aire * dtime_per_sec).to_masked_array().ravel()) )
+    OCE_flux_int =  wu.Psum  ( (flux * OCE_aire * dtime_per_sec).to_masked_array().ravel() )
     return OCE_flux_int
 
 def ONE_flux_int (flux) :
     '''Integrate flux on oce grid'''
-    OCE_flux_int = np.sum (  np.sort ( (flux * dtime_per_sec).to_masked_array().ravel()) )
+    OCE_flux_int =  wu.Psum ( (flux * dtime_per_sec).to_masked_array().ravel() )
     return OCE_flux_int
 
Index: TOOLS/WATER_BUDGET/README.md
===================================================================
--- TOOLS/WATER_BUDGET/README.md	(revision 6647)
+++ TOOLS/WATER_BUDGET/README.md	(revision 6651)
@@ -16,9 +16,17 @@
 
 With the simple input file, the scripts will uses the information to
-constructs the needed file names, according to the libIGCM DRS
+constructs the needed file names, according to the libIGCM DRS.
 
-It will extract the restarts from the tar files, and rebuild NEMO restarts
+On Irene, Jean-Zay and Spip, you need to specifiy the group and user
+to locate the files.
+
+It will extract the restarts from the tar files, and rebuild NEMO restarts.
 
 ```config
+OCE_waterbudget.py
+[Config]
+ContinueOnError = True
+SortIco         = False
+
 [Experiment]
 libIGCM        = True
@@ -28,96 +36,109 @@
 ExperimentName = piControl
 User           = p86caub
-Project        = gencmip6
+Group          = gencmip6
 Freq           = MO
 YearBegin      = 1850
 YearEnd        = 1859
 PackFrequency  = 10
-ATM            = ICO40
-Routing        = SIMPLE
-ORCA           = eORCA1.2
-NEMO           = 3.6
-Coupled        = True
+ATM             = ICO40
+Routing         = SIMPLE
+ORCA            = eORCA1.4.2
+NEMO            = 4.2
+Coupled         = True
+ATM_HIS         = ico
+SRF_HIS         = ${ATM_HIS}
+RUN_HIS         = ${ATM_HIS}
 ```
+
 ## Example of full input file
 
 All the file names computed by the scripts will be writen back
-additional sections
+in additional sections.
 
-You can add a `[libIGCM]` section to overcome part or all compouted
-libIGCM directories by pre-determined directory names
+You can add a `[libIGCM]` section to override part or all computed
+libIGCM directories by pre-determined directory names.
 
-You can add a `[Files]` section to overcome part or all compouted file
+You can add a `[Files]` section to override part or all computed file
 names by pre-determined file names
 
-You can add a `[Physics]` section to overcome some or all default parameters
+You can add a `[Physics]` section to override some or all default parameters.
 
 ```
+[Config]
+ContinueOnError = True
+SortIco = False
+
 [Experiment]
-libIGCM    = True
-JobName    = TEST-CM72-SIMPLE-ROUTING.12
-TagName    = IPSLCM7
-SpaceName  = DEVT
-ExperimentName = piControl
-User       = p86caub
-Project    = gencmip6
-Freq       = MO
-YearBegin  = 1970
-YearEnd    = 1979
-PackFrequency = 10
-ATM        = ICO40
-Routing    = SIMPLE
-ORCA       = eORCA1.2
-NEMO       = 3.6
-Coupled    = True
+JobName = CM71v420-LR-pd-02-out-ico-reg
+ConfigCard = /ccc/cont003/home/gencmip6/p86caub/IPSLCM7_TUNING_MODIF_ORCHIDEE/config/IPSLCM7/${JobName}/config.card
+libIGCM = True
+User = p86caub
+Group = gencmip6
+Freq = MO
+YearBegin = 1870
+YearEnd = 1870
+ATM = ICO40
+Routing = SIMPLE
+ORCA = eORCA1.4.2
+NEMO = 4.2
+Coupled = True
+ATM_HIS = latlon
+SRF_HIS = ${ATM_HIS}
+RUN_HIS = ${ATM_HIS}
+DateBegin = 18700101
+DateEnd = 18701231
 
 [Files]
-TmpDir        = /ccc/scratch/cont003/gencmip6/p86mart/WATER_TEST-CM72-SIMPLE-ROUTING.12_1970_1979
-FileOut       = ATM_waterbudget_TEST-CM72-SIMPLE-ROUTING.12_1970_1979.out
-dir_ATM_his   = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/ATM/Output/MO
-dir_SRF_his   = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/SRF/Output/MO
-Period        = 19700101_19791231_1M
-FileCommon    = TEST-CM72-SIMPLE-ROUTING.12_19700101_19791231_1M
-Title         = TEST-CM72-SIMPLE-ROUTING.12 : MO : 1970-01-01 - 1979-12-31
-file_ATM_his  = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/ATM/Output/MO/TEST-CM72-SIMPLE-ROUTING.12_19700101_19791231_1M_histmth.nc
-file_SRF_his  = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/SRF/Output/MO/TEST-CM72-SIMPLE-ROUTING.12_19700101_19791231_1M_sechiba_history.nc
-file_RUN_his  = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/SRF/Output/MO/TEST-CM72-SIMPLE-ROUTING.12_19700101_19791231_1M_sechiba_history.nc
-TarRestartPeriod_beg = 19600101_19691231
-TarRestartPeriod_end = 19700101_19791231
-file_restart_beg = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/RESTART/TEST-CM72-SIMPLE-ROUTING.12_${TarRestartPeriod_beg}_restart.tar
-file_restart_end = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/piControl/TEST-CM72-SIMPLE-ROUTING.12/RESTART/TEST-CM72-SIMPLE-ROUTING.12_${TarRestartPeriod_end}_restart.tar
-file_ATM_beg     = ${TmpDir}/ATM_TEST-CM72-SIMPLE-ROUTING.12_19691231_restartphy.nc
-file_ATM_end     = ${TmpDir}/ATM_TEST-CM72-SIMPLE-ROUTING.12_19791231_restartphy.nc
-file_DYN_beg     = ${TmpDir}/ICO_TEST-CM72-SIMPLE-ROUTING.12_19691231_restart.nc
-file_DYN_end     = ${TmpDir}/ICO_TEST-CM72-SIMPLE-ROUTING.12_19791231_restart.nc
-file_SRF_beg     = ${TmpDir}/SRF_TEST-CM72-SIMPLE-ROUTING.12_19691231_sechiba_rest.nc
-file_SRF_end     = ${TmpDir}/SRF_TEST-CM72-SIMPLE-ROUTING.12_19791231_sechiba_rest.nc
-file_RUN_beg     = ${TmpDir}/SRF_TEST-CM72-SIMPLE-ROUTING.12_19691231_routing_restart.nc
-file_RUN_end     = ${TmpDir}/SRF_TEST-CM72-SIMPLE-ROUTING.12_19791231_routing_restart.nc
+FileOut = ATM_waterbudget_CM71v420-LR-pd-02-out-ico-reg_1870_1870_LATLON.out
+TmpDir = /ccc/scratch/cont003/gencmip6/p86mart
+RunDir = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231
+dir_ATM_his = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/ATM/Output/MO
+dir_SRF_his = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/SRF/Output/MO
+Period = 18700101_18701231_1M
+DateBegin = 18701231
+FileCommon = CM71v420-LR-pd-02-out-ico-reg_18700101_18701231_1M
+Title = CM71v420-LR-pd-02-out-ico-reg : MO : 18700101 - 18701231
+file_ATM_his = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/ATM/Output/MO/CM71v420-LR-pd-02-out-ico-reg_18700101_18701231_1M_histmth.nc
+file_SRF_his = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/SRF/Output/MO/CM71v420-LR-pd-02-out-ico-reg_18700101_18701231_1M_sechiba_history.nc
+file_RUN_his = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/SRF/Output/MO/CM71v420-LR-pd-02-out-ico-reg_18700101_18701231_1M_sechiba_history.nc
+TarRestartPeriod_beg = 18690101_18691231
+TarRestartPeriod_end = 18700101_18701231
+tar_restart_beg = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/RESTART/CM71v420-LR-pd-02-out-ico-reg_18690101_18691231_restart.tar
+tar_restart_end = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/RESTART/CM71v420-LR-pd-02-out-ico-reg_18700101_18701231_restart.tar
+file_ATM_beg = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/ATM_CM71v420-LR-pd-02-out-ico-reg_18691231_restartphy.nc
+file_ATM_end = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/ATM_CM71v420-LR-pd-02-out-ico-reg_18701231_restartphy.nc
+file_DYN_beg = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/ICO_CM71v420-LR-pd-02-out-ico-reg_18691231_restart.nc
+file_DYN_end = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/ICO_CM71v420-LR-pd-02-out-ico-reg_18701231_restart.nc
+file_SRF_beg = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/SRF_CM71v420-LR-pd-02-out-ico-reg_18691231_sechiba_rest.nc
+file_SRF_end = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/SRF_CM71v420-LR-pd-02-out-ico-reg_18701231_sechiba_rest.nc
+file_DYN_aire = /ccc/work/cont003/igcmg/igcmg/IGCM/ATM/GRID/ICO40_grid.nc
+file_RUN_beg = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/SRF_CM71v420-LR-pd-02-out-ico-reg_18691231_routing_restart.nc
+file_RUN_end = /ccc/scratch/cont003/gencmip6/p86mart/WATER_CM71v420-LR-pd-02-out-ico-reg_18700101_18701231/SRF_CM71v420-LR-pd-02-out-ico-reg_18701231_routing_restart.nc
+file_ATM_aire = /ccc/work/cont003/igcmg/igcmg/IGCM/ATM/GRID/aire_ICO40_to_144x143.nc
 
 [Physics]
-# Earth Radius (m)
 Ra = 6366197.7236758135
-# Gravity (m^2/s) in LMDZ or ICO
 Grav = 9.81
-# Ice volumic mass (kg/m^3) in NEMO
 ICE_rho_ice = 917.0
-# Snow volumic mass (kg/m3) in NEMO
-ICE_rho_sno = 330.0
-# Ocean water volumic mass (kg/m3) in NEMO
+CE_rho_sno = 330.0
 OCE_rho_liq = 1026.0
-# Water volumic mass in atmosphere (kg/m^3)
 ATM_rho = 1000.0
-# Water volumic mass in surface reservoir (kg/m^3)
 SRF_rho = 1000.0
-# Water volumic mass of rivers (kg/m^3)
 RUN_rho = 1000.0
 
 [libIGCM]
-ARCHIVE    = /ccc/store/cont003/gencmip6/p86caub
-STORAGE    = /ccc/work/cont003/gencmip6/p86caub
-SCRATCHDIR = /ccc/scratch/cont003/gencmip6/p86caub
-R_IN       = /ccc/work/cont003/igcmg/igcmg/IGCM
-rebuild    = /ccc/cont003/home/igcmg/igcmg/Tools/irene-amd/rebuild_nemo/bin/rebuild_nemo
-
+ARCHIVE = /ccc/store/cont003/gencmip6/p86caub
+STORAGE = /ccc/work/cont003/gencmip6/p86caub
+TmpDir = /ccc/scratch/cont003/gencmip6/p86mart
+R_IN = /ccc/work/cont003/igcmg/igcmg/IGCM
+rebuild = /ccc/cont003/home/igcmg/igcmg/Tools/x86_64/rebuild_nemo/bin/rebuild_nemo
+R_OUT = /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT
+R_BUF = /ccc/scratch/cont003/gencmip6/p86caub/IGCM_OUT
+L_EXP = IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg
+R_BUFR = /ccc/scratch/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg
+POST_DIR = /ccc/scratch/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/Out
+REBUILD_DIR = /ccc/scratch/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/REBUILD
+R_BUF_KSH = /ccc/scratch/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg/Out
+R_FIGR = /ccc/work/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM7/DEVT/pdControl/CM71v420-LR-pd-02-out-ico-reg
 ```
 
@@ -130,34 +151,5 @@
 - Grille LMDZ et routage SIMPLE : pb sur runoff
 - Grille ICO avec sorties interpolÃ©es : 
+  - OK pour LMD
+  - A finaliser pour SECHIBA
 
-# Erreurs relatives
-
-### VALID-CM622-LR.01 - LMDZ : OK ? Sauf LIC
-- LIC : 1.e-2
-- SRF : 4.e-6
-- SRF/ATM : 2e-10
-- RUNOFF : 1.5e-4
-
-### VALID-CM622-SIMPLE-ROUTING - LMDZ : Erreur RUNOFF, LIC
-- LIC : 1.6
-- SRF : 1e-6
-- SRF/ATM : 1.e-10
-- RUNOFF : -7
-
-### TEST-CM72-SIMPLE-ROUTING.13 - ICO : Erreur SRF, RUNOFF, LIC
-- LIC : 150
-- SRF : 0.5
-- SRF/ATM : 4e-2
-- RUNOFF : 700
-
-### CM71v420-LR-pd-02.ini - ICO interpolÃ© : Erreur SRF, RUNOFF, LIC
-- LIC : 15
-- SRF : 0.7
-- SRF/ATM : -5.e-2
-- ROUTING : 3e3
-
-### CM71v420-LR-pd-02.ini - ICO natif : Erreurs faibles RUNOFF, LIC
-- LIC : 0.3
-- SRF : 7.e-6
-- SRF/ATM : -6.e-9
-- ROUTING : 5.e-2
Index: TOOLS/WATER_BUDGET/waterbudget.sh
===================================================================
--- TOOLS/WATER_BUDGET/waterbudget.sh	(revision 6647)
+++ TOOLS/WATER_BUDGET/waterbudget.sh	(revision 6651)
@@ -17,8 +17,8 @@
 #--for a good precision consider at least a period of 50 or 100 years
 
-direxp="/ccc/store/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/DEVT/pdControl/"
-exp="CM6014-pd-split-D-01"
-yearbeg=1910
-yearend=1949
+direxp="/ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM6/DEVT/piControl/"
+exp="VALID-CM622-LR.01"
+yearbeg=1890
+yearend=1899
 yearinc=10
 
