Index: TOOLS/MOSAIX/Utils/CreateBounds.bash
===================================================================
--- TOOLS/MOSAIX/Utils/CreateBounds.bash	(revision 3621)
+++ TOOLS/MOSAIX/Utils/CreateBounds.bash	(revision 3621)
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+cp  essai_grid.nc   essai1.nc
+
+cat <<EOF > add_bound.nco
+defdim ("nvertex_lmd", 4) ;
+delta_x = alon(0,1) - alon(0,0) ;
+delta_y = alat(1,0) - alat(0,0) ;
+//
+bounds_alon[nvertex_lmd,lat,lon] = 0.0 ;
+bounds_alat[nvertex_lmd,lat,lon] = 0.0 ;
+//
+bounds_alon (0,:,:) = alon + delta_x*0.5 ;
+bounds_alat (0,:,:) = alat + delta_y*0.5 ;
+bounds_alon (1,:,:) = alon + delta_x*0.5 ;
+bounds_alat (1,:,:) = alat - delta_y*0.5 ;
+bounds_alon (2,:,:) = alon - delta_x*0.5 ;
+bounds_alat (2,:,:) = alat - delta_y*0.5 ;
+bounds_alon (3,:,:) = alon - delta_x*0.5 ;
+bounds_alat (3,:,:) = alat + delta_y*0.5 ;
+//
+where (bounds_alat >  90.0 ) bounds_alat =  90.0 ;;
+where (bounds_alat < -90.0 ) bounds_alat = -90.0 ;;
+//
+EOF
+ 
+ncap2 -S add_bound.nco -O -h essai1.nc essai2.nc
Index: TOOLS/MOSAIX/Utils/CreateDynamico450grid.bash
===================================================================
--- TOOLS/MOSAIX/Utils/CreateDynamico450grid.bash	(revision 3621)
+++ TOOLS/MOSAIX/Utils/CreateDynamico450grid.bash	(revision 3621)
@@ -0,0 +1,83 @@
+#!/bin/bash
+set -e
+set -x
+
+
+InDir=/ccc/work/cont003/gencmip6/bedidil/InterpolToy/DATA/GRIDS
+
+
+ncks -4 -h -O -v icoh.lon,icoh.lat,icoh.clo,icoh.cla ${InDir}/grids.nc dynamico450_grid.nc
+ncrename -h -v icoh.lon,lon        dynamico450_grid.nc
+ncrename -h -v icoh.lat,lat        dynamico450_grid.nc
+ncrename -h -v icoh.clo,bounds_lon dynamico450_grid.nc
+ncrename -h -v icoh.cla,bounds_lat dynamico450_grid.nc
+
+ncatted -h\
+	-a history,global,d,c,c,""      \
+	-a Comment,global,d,c,c,""      \
+	-a source,global,d,c,c,""       \
+	-a group,global,d,c,c,""        \
+	-a production,global,d,c,c,""   \
+	-a cr,global,d,c,c,""           \
+	-a grid,global,d,c,c,""         \
+	-a Institution,global,d,c,c,""  \
+	-a Model,global,d,c,c,""        \
+	-a HOSTNAME,global,d,c,c,""     \
+	-a LOGNAME,global,d,c,c,""      \
+	-a name,global,d,c,c,""         \
+	-a title,global,d,c,c,""        \
+	-a timeStamp,global,d,c,c,""    \
+	-a uuid,global,d,c,c,""         \
+	-a bounds,lon,c,c,"bounds_lon"  \
+	-a bounds,lat,c,c,"bounds_lat"       \
+	-a units,lon,c,c,"degrees_east"      \
+	-a standard_name,lon,c,c,"Longitude" \
+	-a long_name,lon,c,c,"Longitude"     \
+	-a units,lat,c,c,"degrees_north"     \
+	-a standard_name,lat,c,c,"Latitude"  \
+	-a long_name,lat,c,c,"Latitude"      \
+	dynamico450_grid.nc
+
+ncwa -h -a y_icoh       dynamico450_grid.nc tmp_dynamico450_grid.nc ; mv tmp_dynamico450_grid.nc dynamico450_grid.nc
+ncatted -h \
+	-a cell_methods,lon,d,c,""         \
+	-a cell_methods,lat,d,c,""         \
+	-a cell_methods,bounds_lon,d,c,""  \
+	-a cell_methods,bounds_lat,d,c,""  \
+	dynamico450_grid.nc
+
+ncrename -h -d x_icoh,cell     dynamico450_grid.nc
+ncrename -h -d crn_icoh,nvertex dynamico450_grid.nc
+
+ncpdq -h --permute cell,nvertex  dynamico450_grid.nc tmp_dynamico450_grid.nc ; mv tmp_dynamico450_grid.nc dynamico450_grid.nc
+
+
+cat <<EOF > add_mask.nco
+defdim("time_counter", 2) ;
+defdim("axis_nbounds", 2) ;
+time_centered        [time_counter]               = {  43200.0, 129600.0 } ;
+time_centered_bounds [time_counter, axis_nbounds] = { 0.0, 86400.0,  86400.0, 172800.0 } ;
+aire                 [cell]                       = ( 3.14159*6400000)^2/2016012.0  ;
+OceMask              [time_counter,cell]          = 0.0d ;
+EOF
+
+ncap2 -h -S add_mask.nco dynamico450_grid.nc tmp_dynamico450_grid.nc ; mv tmp_dynamico450_grid.nc dynamico450_grid.nc
+
+ncatted -h \
+	-a coordinates,OceMask,c,c,"time_centered lat lon"             \
+	-a standard_name,time_centered,c,c,"time"                      \
+	-a long_name,time_centered,c,c,"Time axis"                     \
+	-a calendar,time_centered,c,c,"360_day"                        \
+	-a units,time_centered,c,c,"seconds since 2000-01-01 00:00:00" \
+	-a time_origin,time_centered,c,c,"2000-01-01 00:00:00"         \
+	-a bounds,time_centered,c,c,"time_centered_bounds"             \
+	dynamico450_grid.nc
+
+ncks -O --mk_rec time_counter dynamico450_grid.nc tmp_dynamico450_grid.nc ; mv tmp_dynamico450_grid.nc dynamico450_grid.nc
+
+ncatted -h \
+	-a long_name,aire,c,c,"Grid area"    \
+	-a units,aire,c,c,"m^2"              \
+	-a online_operation,aire,c,c,"once"  \
+	-a coordinates,aire,c,c,"lat lon"    \
+	dynamico450_grid.nc
Index: TOOLS/MOSAIX/Utils/CreateLMD9695grid.bash
===================================================================
--- TOOLS/MOSAIX/Utils/CreateLMD9695grid.bash	(revision 3621)
+++ TOOLS/MOSAIX/Utils/CreateLMD9695grid.bash	(revision 3621)
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+
+### ===========================================================================
+##
+## Default configuration
+## ===========================================================================
+
+### ===========================================================================
+###
+### You should not change anything below this line ....
+###
+### ===========================================================================
+
+##
+## Command line parameters
+## ===========================================================================
+set -o verbose
+set -o xtrace
+set -e
+
+
+while [[ ${1} = -* ]] ; do
+    case ${1} in
+	( -- ) shift ; break ;;
+	( -v | --verbose    ) set -o verbose   ;;
+	( -x | --xtrace     ) set -o xtrace    ;;
+	( -e                ) set -e           ;;
+	( -V | --noverbose  ) set +o verbose   ;;
+	( -X | --noxtrace   ) set +o xtrace    ;;
+	( -E                ) set +e           ;;
+	( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;;
+    esac
+    shift
+done
+
+##
+AtmFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc}
+
+dim_lat=$(ncdump -h ${AtmFile} | grep "lat *=" | awk '{print $3}' )
+dim_lon=$(ncdump -h ${AtmFile} | grep "lon *=" | awk '{print $3}' )
+(( dim_lat = dim_lat - 1 ))
+
+GridFile=lmdz${dim_lon}x${dim_lat}_grid.nc
+
+ncks --overwrite -h -d time_counter,0,1 -v lon,lat,aire,fract_oce,fract_sic ${AtmFile}   ${GridFile}
+#ncwa --overwrite -h -a time_counter                     ${GridFile}  tmp_${GridFile} ; mv tmp_${GridFile} ${GridFile}
+
+ncatted -h -a coordinates,aire,m,c,"lat lon"       ${GridFile}
+ncatted -h -a coordinates,fract_oce,m,c,"lat lon"  ${GridFile}
+ncatted -h -a coordinates,fract_sic,m,c,"lat lon"  ${GridFile}
+
+ncks --overwrite -h --xcl -v time_counter,time_centered,time_counter_bounds ${GridFile} tmp_${GridFile} ; mv tmp_${GridFile} ${GridFile}
+
+cat <<EOF >add_fields.nco
+time_centered        [time_counter]               = {  43200.0, 129600.0 } ;
+time_centered_bounds [time_counter, axis_nbounds] = { 0.0, 86400.0,  86400.0, 172800.0 } ;
+fract_oce_plus_sic = fract_oce + fract_sic ;
+where (fract_oce_plus_sic <   0.00001 )  fract_oce_plus_sic=0.0 ;
+where (fract_oce_plus_sic >   0.99999 )  fract_oce_plus_sic=1.0 ;
+// Fill masked values to land values
+OceMask[time_counter,lat,lon] = 0.0 ;
+where (fract_oce_plus_sic >  0.0 )  OceMask=1.0 ;
+EOF
+
+ncap2 -h --overwrite --script-file add_fields.nco ${GridFile} tmp_${GridFile}  ; mv tmp_${GridFile} ${GridFile}
+
+ncatted -h \
+	-a coordinates,OceMask,c,c,"time_centered lat lon"             \
+	-a standard_name,time_centered,c,c,"time"                      \
+	-a long_name,time_centered,c,c,"Time axis"                     \
+	-a calendar,time_centered,c,c,"360_day"                        \
+	-a units,time_centered,c,c,"seconds since 2000-01-01 00:00:00" \
+	-a time_origin,time_centered,c,c,"2000-01-01 00:00:00"         \
+	-a bounds,time_centered,c,c,"time_centered_bounds"             \
+	dynamico450_grid.nc
+
+ncks -O --mk_rec time_counter ${GridFile} tmp_${GridFile}  ; mv tmp_${GridFile} ${GridFile}
+
+ncatted -h \
+	-a long_name,aire,c,c,"Grid area"    \
+	-a units,aire,c,c,"m^2"              \
+	-a online_operation,aire,c,c,"once"  \
+	-a coordinates,aire,c,c,"lat lon"    \
+	${GridFile}
+
+### ===========================================================================
+rm -f add_fields.nco
+
+
+### ===========================================================================
+###
+###                               That's all folk's !!!
+###
+### ===========================================================================
+
Index: TOOLS/MOSAIX/Utils/CreateORCA025grid.bash
===================================================================
--- TOOLS/MOSAIX/Utils/CreateORCA025grid.bash	(revision 3621)
+++ TOOLS/MOSAIX/Utils/CreateORCA025grid.bash	(revision 3621)
@@ -0,0 +1,123 @@
+#!/bin/bash
+set -e
+set -x
+
+
+InFile=/ccc/work/cont003/igcmg/igcmg/IGCM/OCE/NEMO/ORCA025_LIM3_PISCES/v3.6_stable/mesh_mask_eORCA025.nc
+
+
+ncks -4 -h -O -v glamt,glamu,glamv,glamf,gphit,gphiu,gphiv,gphif,tmask,umask,vmask,fmask,tmaskutil,umaskutil,vmaskutil,fmaskutil,e1t,e2t,e1u,e1f,e2u,e1v,e2v,e2f,e2f ${InFile} ORCA025_coordinates_mask.nc
+ncrename -h -v glamt,nav_lon_grid_T -v gphit,nav_lat_grid_T ORCA025_coordinates_mask.nc
+ncrename -h -v glamu,nav_lon_grid_U -v gphiu,nav_lat_grid_U ORCA025_coordinates_mask.nc
+ncrename -h -v glamv,nav_lon_grid_V -v gphiv,nav_lat_grid_V ORCA025_coordinates_mask.nc
+ncrename -h -v glamf,nav_lon_grid_F -v gphif,nav_lat_grid_F ORCA025_coordinates_mask.nc
+
+ncatted -h\
+	-a history,global,d,c,c,""      \
+	-a Comment,global,d,c,c,""      \
+	-a source,global,d,c,c,""       \
+	-a group,global,d,c,c,""        \
+	-a production,global,d,c,c,""   \
+	-a cr,global,d,c,c,""           \
+	-a grid,global,d,c,c,""         \
+	-a Institution,global,d,c,c,""  \
+	-a Model,global,d,c,c,""        \
+	-a HOSTNAME,global,d,c,c,""     \
+	-a LOGNAME,global,d,c,c,""      \
+	-a name,global,d,c,c,""         \
+	-a title,global,d,c,c,""        \
+	-a timeStamp,global,d,c,c,""    \
+	-a uuid,global,d,c,c,""         \
+	-a units,nav_lon_grid_T,c,c,"degrees_east"      \
+	-a standard_name,nav_lon_grid_T,c,c,"Longitude" \
+	-a long_name,nav_lon_grid_T,c,c,"Longitude"     \
+	-a units,nav_lat_grid_T,c,c,"degrees_north"     \
+	-a standard_name,nav_lat_grid_T,c,c,"Latitude"  \
+	-a long_name,nav_lat_grid_T,c,c,"Latitude"      \
+	-a units,nav_lon_grid_U,c,c,"degrees_east"      \
+	-a standard_name,nav_lon_grid_U,c,c,"Longitude" \
+	-a long_name,nav_lon_grid_U,c,c,"Longitude"     \
+	-a units,nav_lat_grid_U,c,c,"degrees_north"     \
+	-a standard_name,nav_lat_grid_U,c,c,"Latitude"  \
+	-a long_name,nav_lat_grid_U,c,c,"Latitude"      \
+	-a units,nav_lon_grid_V,c,c,"degrees_east"      \
+	-a standard_name,nav_lon_grid_V,c,c,"Longitude" \
+	-a long_name,nav_lon_grid_V,c,c,"Longitude"     \
+	-a units,nav_lat_grid_V,c,c,"degrees_north"     \
+	-a standard_name,nav_lat_grid_V,c,c,"Latitude"  \
+	-a long_name,nav_lat_grid_V,c,c,"Latitude"      \
+	-a units,nav_lon_grid_F,c,c,"degrees_east"      \
+	-a standard_name,nav_lon_grid_F,c,c,"Longitude" \
+	-a long_name,nav_lon_grid_F,c,c,"Longitude"     \
+	-a units,nav_lat_grid_F,c,c,"degrees_north"     \
+	-a standard_name,nav_lat_grid_F,c,c,"Latitude"  \
+	-a long_name,nav_lat_grid_F,c,c,"Latitude"      \
+	ORCA025_coordinates_mask.nc
+
+ncwa -O -h -a t ORCA025_coordinates_mask.nc tmp_ORCA025_coordinates_mask.nc ; mv tmp_ORCA025_coordinates_mask.nc ORCA025_coordinates_mask.nc
+
+cat <<EOF > add_mask.nco
+area_grid_T [y,x] = e1t (:,:) * e2t (:,:)    ;
+area_grid_U [y,x] = e1u (:,:) * e2u (:,:)    ;
+area_grid_V [y,x] = e1v (:,:) * e2v (:,:)    ;
+area_grid_F [y,x] = e1f (:,:) * e2f (:,:)    ;
+mask_T      [y,x] = tmask     (0,:,:) * 1.0d ;
+mask_U      [y,x] = umask     (0,:,:) * 1.0d ;
+mask_V      [y,x] = vmask     (0,:,:) * 1.0d ;
+mask_F      [y,x] = fmask     (0,:,:) * 1.0d ;
+maskutil_T  [y,x] = tmaskutil   (:,:) * 1.0d ;
+maskutil_U  [y,x] = umaskutil   (:,:) * 1.0d ;
+maskutil_V  [y,x] = fmaskutil   (:,:) * 1.0d ;
+maskutil_F  [y,x] = fmaskutil   (:,:) * 1.0d ;
+//maskutil_T  [:,    0] = 0.0d ;
+//maskutil_T  [:, 1441] = 0.0d ;
+//maskutil_U  [:,    0] = 0.0d ;
+//maskutil_U  [:, 1441] = 0.0d ;
+//maskutil_V  [:,    0] = 0.0d ;
+//maskutil_V  [:, 1441] = 0.0d ;
+//maskutil_F  [:, 0   ] = 0.0d ;
+//maskutil_F  [:, 1441] = 0.0d ;
+EOF
+
+ncap2 -h -S add_mask.nco ORCA025_coordinates_mask.nc tmp_ORCA025_coordinates_mask.nc ; mv tmp_ORCA025_coordinates_mask.nc ORCA025_coordinates_mask.nc
+
+ncks -h -x --variable e1t,e2t,e1u,e2u,e1v,e2v,e1f,e2f,tmask,umask,vmask,fmask,tmaskutil,umaskutil,vmaskutil,fmaskutil ORCA025_coordinates_mask.nc tmp_ORCA025_coordinates_mask.nc ; 
+
+#python creates_nemo_bounds.py
+#mv tmp_ORCA025_coordinates_mask.nc ORCA025_coordinates_mask.nc
+
+ncatted -h \
+	-a coordinates,area_grid_T,c,c,"nav_lat_grid_T nav_lon_grid_T" \
+	-a coordinates,area_grid_U,c,c,"nav_lat_grid_U nav_lon_grid_U" \
+	-a coordinates,area_grid_V,c,c,"nav_lat_grid_V nav_lon_grid_V" \
+	-a coordinates,area_grid_F,c,c,"nav_lat_grid_F nav_lon_grid_F" \
+	-a units,area_grid_T,c,c,"m^2"                                 \
+	-a units,area_grid_U,c,c,"m^2"                                 \
+	-a units,area_grid_V,c,c,"m^2"                                 \
+	-a units,area_grid_F,c,c,"m^2"                                 \
+	-a coordinates,mask_T,c,c,"nav_lat_grid_T nav_lon_grid_T"      \
+	-a coordinates,mask_U,c,c,"nav_lat_grid_U nav_lon_grid_U"      \
+	-a coordinates,mask_V,c,c,"nav_lat_grid_V nav_lon_grid_V"      \
+	-a coordinates,mask_F,c,c,"nav_lat_grid_F nav_lon_grid_F"      \
+	-a coordinates,maskutil_T,c,c,"nav_lat_grid_T nav_lon_grid_T"  \
+	-a coordinates,maskutil_U,c,c,"nav_lat_grid_U nav_lon_grid_U"  \
+	-a coordinates,maskutil_V,c,c,"nav_lat_grid_V nav_lon_grid_V"  \
+	-a coordinates,maskutil_F,c,c,"nav_lat_grid_F nav_lon_grid_F"  \
+	-a cell_measures,mask_T,c,c,"area: area_grid_T"                \
+	-a cell_measures,mask_U,c,c,"area: area_grid_U"                \
+	-a cell_measures,mask_V,c,c,"area: area_grid_V"                \
+	-a cell_measures,mask_F,c,c,"area: area_grid_F"                \
+	-a cell_measures,maskutil_T,c,c,"area: area_grid_T"            \
+	-a cell_measures,maskutil_U,c,c,"area: area_grid_U"            \
+	-a cell_measures,maskutil_V,c,c,"area: area_grid_V"            \
+	-a cell_measures,maskutil_F,c,c,"area: area_grid_F"            \
+	-a bounds,nav_lon_grid_T,c,c,"bounds_lon_grid_T"               \
+	-a bounds,nav_lat_grid_T,c,c,"bounds_lat_grid_T"               \
+	-a bounds,nav_lon_grid_U,c,c,"bounds_lon_grid_U"               \
+	-a bounds,nav_lat_grid_U,c,c,"bounds_lat_grid_U"               \
+	-a bounds,nav_lon_grid_V,c,c,"bounds_lon_grid_V"               \
+	-a bounds,nav_lat_grid_V,c,c,"bounds_lat_grid_V"               \
+	-a bounds,nav_lon_grid_F,c,c,"bounds_lon_grid_F"               \
+	-a bounds,nav_lat_grid_F,c,c,"bounds_lat_grid_F"               \
+	ORCA025_coordinates_mask.nc
+
Index: TOOLS/MOSAIX/Utils/CreateORCA025grid_FromCerfacs.bash
===================================================================
--- TOOLS/MOSAIX/Utils/CreateORCA025grid_FromCerfacs.bash	(revision 3621)
+++ TOOLS/MOSAIX/Utils/CreateORCA025grid_FromCerfacs.bash	(revision 3621)
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -e
+set -x
+
+
+InDir=.
+
+ncks -h -O -4 ${InDir}/cerfacs_grids.nc cerfacs_grids_netcdf4.nc
+ncks -4 -h -O -v nogh.lon,nogh.lat,nogh.clo,nogh.cla cerfacs_grids_netcdf4.nc ORCA025_coordinates_mask.nc
+ncrename -h -v nogh.lon,nav_lon_grid_T    ORCA025_coordinates_mask.nc
+ncrename -h -v nogh.lat,nav_lat_grid_T    ORCA025_coordinates_mask.nc
+ncrename -h -v nogh.clo,bounds_lon_grid_T ORCA025_coordinates_mask.nc
+ncrename -h -v nogh.cla,bounds_lat_grid_T ORCA025_coordinates_mask.nc
+
+ncks -h -O -4 ${InDir}/cerfacs_masks.nc cerfacs_masks_netcdf4.nc
+ncks -4 -h -A -v nogh.msk cerfacs_masks_netcdf4.nc ORCA025_coordinates_mask.nc
+ncrename -h -v nogh.msk,mask_T    ORCA025_coordinates_mask.nc
+
+ncks -h -O -4 ${InDir}/cerfacs_areas.nc cerfacs_areas_netcdf4.nc
+ncks -4 -h -A -v nogh.srf cerfacs_areas_netcdf4.nc ORCA025_coordinates_mask.nc
+ncrename -h -v nogh.srf,area      ORCA025_coordinates_mask.nc
+
+ncatted -h \
+	-a history,global,d,c,"" \
+	-a history_of_appended_files,global,d,c,"" \
+	ORCA025_coordinates_mask.nc
+
+ncpdq -O -h --permute nj,ni,jpcr ORCA025_coordinates_mask.nc tmp_ORCA025_coordinates_mask.nc ; mv tmp_ORCA025_coordinates_mask.nc ORCA025_coordinates_mask.nc
+
+ncrename -d jpcr,nvertex_grid_T ORCA025_coordinates_mask.nc
+ncrename -d ni,x_grid_T         ORCA025_coordinates_mask.nc
+ncrename -d nj,y_grid_T         ORCA025_coordinates_mask.nc
+
+#ncks -4 -O -h ORCA025_coordinates_mask.nc tmp_ORCA025_coordinates_mask.nc ; mv tmp_ORCA025_coordinates_mask.nc ORCA025_coordinates_mask.nc
+
+ncatted -h \
+	-a bounds,nav_lon_grid_T,c,c,"bounds_lon_grid_T"  \
+	-a bounds,nav_lat_grid_T,c,c,"bounds_lat_grid_T"  \
+	-a units,nav_lon_grid_T,c,c,"degrees_east"        \
+	-a standard_name,nav_lon_grid_T,c,c,"Longitude"   \
+	-a long_name,nav_lon_grid_T,c,c,"Longitude"       \
+	-a units,nav_lat_grid_T,c,c,"degrees_north"       \
+	-a standard_name,nav_lat_grid_T,c,c,"Latitude"       \
+	-a long_name,nav_lat_grid_T,c,c,"Latitude"           \
+	-a long_name,area,c,c,"Grid area"                 \
+	-a units,area,c,c,"m^2"                           \
+	-a online_operation,area,c,c,"once"               \
+	-a coordinates,area,c,c,"nav_lat_grid_T nav_lon_grid_T"     \
+	ORCA025_coordinates_mask.nc
+
+cat <<EOF > add_mask.nco
+mask_T             = 1.0d - mask_T         ;
+maskutil_T [y_grid_T,x_grid_T] = mask_T(:,:)           ;
+maskutil_T  (   :  ,   0) = 0.0d           ;
+maskutil_T  (   : , 1441) = 0.0d           ;
+maskutil_T  ( 1049,  :  ) = 0.0d           ;
+maskutil_T  ( 1048, 740:1441) = 0.0d       ;
+EOF
+
+ncap2 -O -h -S add_mask.nco ORCA025_coordinates_mask.nc tmp_ORCA025_coordinates_mask.nc  ; mv tmp_ORCA025_coordinates_mask.nc ORCA025_coordinates_mask.nc
+ncatted -h \
+	-a coordinates,mask_T,c,c,"nav_lat_grid_T nav_lon_grid_T"        \
+	-a coordinates,maskutil_T,c,c,"nav_lat_grid_T nav_lon_grid_T"    \
+	ORCA025_coordinates_mask.nc
+
+
+
+
Index: TOOLS/MOSAIX/Utils/build_ORCA2.3_grid.bash
===================================================================
--- TOOLS/MOSAIX/Utils/build_ORCA2.3_grid.bash	(revision 3621)
+++ TOOLS/MOSAIX/Utils/build_ORCA2.3_grid.bash	(revision 3621)
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+
+
+# ncap2 --overwrite --script-file build.nco ORCA2_coordinates.nc ORCA2_coordinates_mask.nc
+
+cp ORCA2_coordinates.nc ORCA2.3_coordinates_mask.nc 
+
+ncks --overwrite -v maskper /ccc/work/cont003/dsm/p86mart/GRAF/DATA/orca2.3.nc ORCA2_maskutil.nc
+ncrename -v maskper,maskutil_T ORCA2_maskutil.nc
+ncrename -d x,x_grid_T ORCA2_maskutil.nc
+ncrename -d y,y_grid_T ORCA2_maskutil.nc
+
+ncks --append ORCA2_maskutil.nc ORCA2.3_coordinates_mask.nc
+
+
+
+ncatted -a cell_measures,maskutil_T,c,c,"area: area_grid_T"            ORCA2.3_coordinates_mask.nc
+ncatted -a coordinates,maskutil_T,c,c,"nav_lat_grid_T nav_lon_grid_T"  ORCA2.3_coordinates_mask.nc
+
+
+cat <<EOF > build.nco 
+mask_T = mask_T == 1 || maskutil_T == 1  ;
+EOF
+
+ncap2 --script-file build.nco --overwrite ORCA2.3_coordinates_mask.nc ORCA2.3_coordinates_mask_tmp.nc
+mv ORCA2.3_coordinates_mask_tmp.nc ORCA2.3_coordinates_mask.nc
Index: TOOLS/MOSAIX/Utils/creates_nemo_bounds.py
===================================================================
--- TOOLS/MOSAIX/Utils/creates_nemo_bounds.py	(revision 3621)
+++ TOOLS/MOSAIX/Utils/creates_nemo_bounds.py	(revision 3621)
@@ -0,0 +1,166 @@
+# -*- Mode: python -*-
+### -
+### - Computes polynomial fit
+### -
+## -
+## - Olivier Marti (olivier.marti@lsce.ipsl.fr)
+## - Institut Pierre Simon Laplace
+## - Laboratoire des Sciences du Climate et de L'environnment
+## -
+print 'Demarrage'
+## - Needed Python modules
+import cdms2, MV2, numpy as np
+import nemo
+
+def clo_lon (lon, lon_ref) : # Find closest longitude
+      z0 = lon
+      for nn in range (2) :
+         z0 = np.where ( z0 > lon_ref+180.0, z0-360.0, z0)
+         z0 = np.where ( z0 < lon_ref-180.0, z0+360.0, z0)
+
+      return z0
+
+## - NetCDF parameters
+# - If you want to turn that off or set different values of compression use the functions:
+cdms2.setNetcdfShuffleFlag     (0)
+cdms2.setNetcdfDeflateFlag     (0)
+cdms2.setNetcdfDeflateLevelFlag(0)
+
+print 'Ouverture fichier'
+f_grid = cdms2.open ( 'tmp_ORCA025_coordinates_mask.nc', 'r+' )
+
+print 'Lecture tmask'
+tmask = f_grid ( 'mask_T' )
+
+print 'Lecture des axes'
+yy      = tmask.getAxis(0) ; ny = len(yy)
+xx      = tmask.getAxis(1) ; nx = len(xx)
+
+print 'Creation axe'
+nvertex = cdms2.createAxis ( np.arange (4) )
+
+print 'Lecture lon lat'
+glamt =  f_grid ( 'nav_lon_grid_T' ).filled(0)
+gphit =  f_grid ( 'nav_lat_grid_T' ).filled(0)
+glamu =  f_grid ( 'nav_lon_grid_U' ).filled(0)
+gphiu =  f_grid ( 'nav_lat_grid_U' ).filled(0)
+glamv =  f_grid ( 'nav_lon_grid_V' ).filled(0)
+gphiv =  f_grid ( 'nav_lat_grid_V' ).filled(0)
+glamf =  f_grid ( 'nav_lon_grid_F' ).filled(0)
+gphif =  f_grid ( 'nav_lon_grid_F' ).filled(0)
+
+
+# Construction des limites
+#   1,2->3      2,2->2
+#   1,1->0      2,1->1
+
+# :, :, \([1,2]\), \([1,2]\)
+# \1, \2, :, :
+
+print 'Creation bounds_*_T'
+bounds_lon_grid_T = np.zeros ( (ny, nx, 4), dtype=np.float32 )
+bounds_lat_grid_T = np.zeros ( (ny, nx, 4), dtype=np.float32 )
+
+print 'Calcul bounds_*_T'
+bounds_lon_grid_T [ :, :, 0] = np.roll ( np.roll ( glamf [:,:], 1, axis=0), 1, axis=1) # EOSHIFT (CSHIFT (glamf(:,:), -1, dim = 1), -1, dim = 2 )
+bounds_lon_grid_T [ :, :, 1] = np.roll ( glamf [:,:], 1, axis=0) # CSHIFT  (glamf(:,:), -1, dim = 2 )
+bounds_lon_grid_T [ :, :, 3] = np.roll ( glamf [:,:], 1, axis=1) # CSHIFT  (glamf(:,:), -1, dim = 1 )
+bounds_lon_grid_T [ :, :, 2] =           glamf [:,:]
+
+bounds_lat_grid_T [ :, :, 0] = np.roll ( np.roll ( gphif [:,:], 1, axis=0), 1, axis=1)
+bounds_lat_grid_T [ :, :, 1] = np.roll ( gphif [:,:], 1, axis=0)
+bounds_lat_grid_T [ :, :, 3] = np.roll ( gphif [:,:], 1, axis=1)
+bounds_lat_grid_T [ :, :, 2] =           gphif [:,:]
+
+bounds_lon_grid_T = cdms2.createVariable ( bounds_lon_grid_T, axes=(yy, xx, nvertex), id='bounds_lon_grid_T', dtype=np.float32 )
+bounds_lat_grid_T = cdms2.createVariable ( bounds_lat_grid_T, axes=(yy, xx, nvertex), id='bounds_lat_grid_T', dtype=np.float32 )
+
+print 'Calcul bounds_*_U'
+bounds_lon_grid_U = np.zeros ( (ny, nx, 4), dtype=np.float32 )
+bounds_lat_grid_U = np.zeros ( (ny, nx, 4), dtype=np.float32 )
+
+bounds_lon_grid_U [ :, :, 0] = np.roll ( glamv [:,:], 1, axis=0) # CSHIFT  (glamv(:,:), -1, dim = 2 )
+bounds_lon_grid_U [ :, :, 1] = np.roll ( np.roll ( glamv [:,:], 1, axis=0), 1, axis=1) # EOSHIFT (CSHIFT (glamv(:,:),  1, dim = 1 ), -1, dim = 2)
+bounds_lon_grid_U [ :, :, 3] =           glamv [:,:]
+bounds_lon_grid_U [ :, :, 2] = np.roll ( glamv [:,:], 1, axis=1) # CSHIFT  (glamv(:,:),  1, dim = 1 )
+
+bounds_lat_grid_U [ :, :, 0] = np.roll ( gphiv [:,:], 1, axis=0)
+bounds_lat_grid_U [ :, :, 1] = np.roll ( np.roll ( gphiv [:,:], 1, axis=0), 1, axis=1)
+bounds_lat_grid_U [ :, :, 3] =           gphiv [:,:]
+bounds_lat_grid_U [ :, :, 2] = np.roll ( gphiv [:,:], 1, axis=1)
+
+bounds_lon_grid_U = cdms2.createVariable ( bounds_lon_grid_U, axes = ( yy, xx, nvertex ), id='bounds_lon_grid_U' )
+bounds_lat_grid_U = cdms2.createVariable ( bounds_lat_grid_U, axes = ( yy, xx, nvertex ), id='bounds_lon_grid_U' )
+
+print 'Calcul bounds_*_V'
+bounds_lon_grid_V = np.zeros ( (ny, nx, 4), dtype=np.float32 )
+bounds_lat_grid_V = np.zeros ( (ny, nx, 4), dtype=np.float32 )
+
+bounds_lon_grid_V [ :, :, 0] = np.roll (glamu [:,:], 1, axis=1) # CSHIFT  (glamu(:,:), -1, dim = 1 )
+bounds_lon_grid_V [ :, :, 1] =          glamu [:,:]
+bounds_lon_grid_V [ :, :, 3] = np.roll (np.roll (glamu [:,:], 1, axis=0), 1, axis=1) # EOSHIFT (CSHIFT (glamu(:,:), -1, dim = 1 ),  1, dim = 2)
+bounds_lon_grid_V [ :, :, 2] = np.roll (glamu [:,:], 1, axis=0) # EOSHIFT (glamu(:,:), 1, dim = 2 )
+
+bounds_lat_grid_V [ :, :, 0] = np.roll (gphiu [:,:], 1, axis=1)
+bounds_lat_grid_V [ :, :, 1] =          gphiu [:,:]
+bounds_lat_grid_V [ :, :, 3] = np.roll (np.roll (glamu [:,:], 1, axis=0), 1, axis=1)
+bounds_lat_grid_V [ :, :, 2] = np.roll (gphiu [:,:], 1, axis=0) 
+
+bounds_lon_grid_V = cdms2.createVariable ( bounds_lon_grid_V, axes = ( yy, xx, nvertex ), id='bounds_lon_grid_V' )
+bounds_lat_grid_V = cdms2.createVariable ( bounds_lat_grid_V, axes = ( yy, xx, nvertex ), id='bounds_lat_grid_V' )
+
+print 'Calcul bounds_*_F'
+bounds_lon_grid_F = np.zeros((ny, nx, 4), dtype=np.float32)
+bounds_lat_grid_F = np.zeros((ny, nx, 4), dtype=np.float32)
+
+bounds_lon_grid_F [ :, :, 0] =          glamt [:,:]
+bounds_lon_grid_F [ :, :, 1] = np.roll (glamt [:,:], 1, axis=1) # CSHIFT  (glamt(:,:), 1, dim = 1 )
+bounds_lon_grid_F [ :, :, 3] = np.roll (glamt [:,:], 1, axis=0) # EOSHIFT (glamt(:,:), 1, dim = 2 )
+bounds_lon_grid_F [ :, :, 2] = np.roll (np.roll (glamt [:,:], 1, axis=0), 1, axis=1) # EOSHIFT (CSHIFT (glamt(:,:),  1, dim = 1),  1, dim = 2)
+
+bounds_lat_grid_F [ :, :, 0] =          gphit [:,:]
+bounds_lat_grid_F [ :, :, 1] = np.roll (gphit [:,:], 1, axis=1) # CSHIFT  (glamt(:,:), 1, dim = 1 )
+bounds_lat_grid_F [ :, :, 3] = np.roll (gphit [:,:], 1, axis=0) # EOSHIFT (glamt(:,:), 1, dim = 2 )
+bounds_lat_grid_F [ :, :, 2] = np.roll (np.roll (gphit [:,:], 1, axis=0), 1, axis=1) # EOSHIFT (CSHIFT (glamt(:,:),  1, dim = 1),  1, dim = 2)
+
+bounds_lon_grid_F = cdms2.createVariable ( bounds_lon_grid_F, axes = ( yy, xx, nvertex ), id='bounds_lon_grid_F' )
+bounds_lat_grid_F = cdms2.createVariable ( bounds_lat_grid_F, axes = ( yy, xx, nvertex ), id='bounds_lat_grid_F' )
+
+print 'Trucage au sud'
+
+#bounds_lat_grid_T [ 0, :, 0:1] = -90.0
+#bounds_lat_grid_U [ 0, :, 0:1] = -90.0
+#bounds_lat_grid_V [ 0, :, 0:1] = -90.0
+#bounds_lat_grid_F [ 0, :, 0:1] = -90.0
+
+#bounds_lon_grid_T [ 0, :, 0:1] = bounds_lon_grid_T  [ 0, :, 2:3 ]
+#bounds_lon_grid_U [ 0, :, 0:1] = bounds_lon_grid_U  [ 0, :, 2:3 ]
+#bounds_lon_grid_V [ 0, :, 0:1] = bounds_lon_grid_V  [ 0, :, 2:3 ]
+#bounds_lon_grid_F [ 0, :, 0:1] = bounds_lon_grid_F  [ 0, :, 2:3 ]
+
+print 'lbc'
+for nn in range (4) :
+    print 'nn : ', nn
+    bounds_lon_grid_T [:,:,nn] = nemo.lbc (bounds_lon_grid_T [:,:,nn], npolj=6, cd_type='T', psgn=1.0)
+    bounds_lat_grid_T [:,:,nn] = nemo.lbc (bounds_lat_grid_T [:,:,nn], npolj=6, cd_type='T', psgn=1.0)
+    bounds_lon_grid_U [:,:,nn] = nemo.lbc (bounds_lon_grid_U [:,:,nn], npolj=6, cd_type='U', psgn=1.0)
+    bounds_lat_grid_U [:,:,nn] = nemo.lbc (bounds_lat_grid_U [:,:,nn], npolj=6, cd_type='U', psgn=1.0)
+    bounds_lon_grid_V [:,:,nn] = nemo.lbc (bounds_lon_grid_V [:,:,nn], npolj=6, cd_type='V', psgn=1.0)
+    bounds_lat_grid_V [:,:,nn] = nemo.lbc (bounds_lat_grid_V [:,:,nn], npolj=6, cd_type='V', psgn=1.0)
+    bounds_lon_grid_F [:,:,nn] = nemo.lbc (bounds_lon_grid_F [:,:,nn], npolj=6, cd_type='F', psgn=1.0)
+    bounds_lat_grid_F [:,:,nn] = nemo.lbc (bounds_lat_grid_F [:,:,nn], npolj=6, cd_type='F', psgn=1.0)
+
+    bounds_lon_grid_T[:,:,nn] = clo_lon ( bounds_lon_grid_T[:,:,nn], lon_ref=glamt )
+    bounds_lon_grid_U[:,:,nn] = clo_lon ( bounds_lon_grid_U[:,:,nn], lon_ref=glamu )
+    bounds_lon_grid_V[:,:,nn] = clo_lon ( bounds_lon_grid_V[:,:,nn], lon_ref=glamv )
+    bounds_lon_grid_F[:,:,nn] = clo_lon ( bounds_lon_grid_F[:,:,nn], lon_ref=glamf )
+    
+
+f_grid.write ( bounds_lon_grid_T )
+f_grid.write ( bounds_lat_grid_T )
+f_grid.write ( bounds_lon_grid_U )
+f_grid.write ( bounds_lat_grid_U )
+f_grid.write ( bounds_lon_grid_V )
+f_grid.write ( bounds_lat_grid_V )
+f_grid.write ( bounds_lon_grid_F )
+f_grid.write ( bounds_lat_grid_F )
Index: TOOLS/MOSAIX/Utils/nemo.py
===================================================================
--- TOOLS/MOSAIX/Utils/nemo.py	(revision 3621)
+++ TOOLS/MOSAIX/Utils/nemo.py	(revision 3621)
@@ -0,0 +1,92 @@
+### ===========================================================================
+### Periodicity of NEMO/ORCA fields
+##
+##  Warning, to install, configure, run, use any of Olivier Marti's
+##  software or to read the associated documentation you'll need at least
+##  one (1) brain in a reasonably working order. Lack of this implement
+##  will void any warranties (either express or implied).
+##  O. Marti assumes no responsability for errors, omissions,
+##  data loss, or any other consequences caused directly or indirectly by
+##  the usage of his software by incorrectly or partially configured
+##  personal.
+##
+###
+###    O. Marti - 2015
+###
+### ===========================================================================
+
+def lbc (ptab, npolj=6, cd_type='T', psgn=1.0) :
+    # npolj    : 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)
+    # ptab     : Input array
+    #   rank 2 at least : patb[...., lat, lon]
+    # cd_type  : Grid specification : T, U, V or F
+    # psgn     : For change of sign for vector components
+    #
+    # Adapted from NEMO fortran code lbc.F90.
+    # See NEMO documentation for further details
+    
+    jpi = ptab.shape[-1] #> i dimension of NEMO field
+    
+    #
+    #> East-West boundary conditions
+    # --------------------------------
+
+    if npolj in [1, 4, 6] :
+        # ... cyclic
+        ptab [...,:,  0] = ptab [...,:,-2]
+        ptab [...,:, -1] = ptab [...,:, 1]
+   
+    #
+    #> North-South boundary conditions
+    # ----------------------------------
+    if npolj 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 npolj 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
+
+### ===========================================================================
+###
+###                               That's all folk's !!!
+###
+### ===========================================================================
