Index: /TOOLS/MOSAIX/Utils/CreateLMDgrid.bash
===================================================================
--- /TOOLS/MOSAIX/Utils/CreateLMDgrid.bash	(revision 4168)
+++ /TOOLS/MOSAIX/Utils/CreateLMDgrid.bash	(revision 4168)
@@ -0,0 +1,102 @@
+#!/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}
+AtmFile=${1:-/ccc/scratch/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/TEST/pdControl/TEST-CM617-MR-pd-5DBLE/ATM/Output/DA/TEST-CM617-MR-pd-5DBLE_18500101_18500105_1D_grid_p8.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=LMD${dim_lon}${dim_lat}_grid.nc
+
+ncks --overwrite -h -d time_counter,0,1 -v lon,lat,aire_p8,fract_oce_p8,fract_sic_p8 ${AtmFile}   ${GridFile}
+#ncwa --overwrite -h -a time_counter                     ${GridFile}  tmp_${GridFile} ; mv tmp_${GridFile} ${GridFile}
+ncrename -v aire_p8,aire           ${GridFile}
+ncrename -v fract_oce_p8,fract_oce ${GridFile}
+ncrename -v fract_sic_p8,fract_sic ${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
+defdim("time_counter",1) ;
+defdim("axis_nbounds",2) ;
+time_centered        [time_counter]               = {  43200.0 } ;
+time_centered_bounds [time_counter, axis_nbounds] = { 0.0, 86400.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"             \
+	${GridFile}
+
+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 !!!
+###
+### ===========================================================================
+
