Index: TOOLS/MOSAIX/CreateNemoAtmWeightsMask.bash
===================================================================
--- TOOLS/MOSAIX/CreateNemoAtmWeightsMask.bash	(revision 3620)
+++ TOOLS/MOSAIX/CreateNemoAtmWeightsMask.bash	(revision 3620)
@@ -0,0 +1,330 @@
+#!/bin/bash
+#MSUB -r NemoAtm        # nom de la requete
+#MSUB -o NemoAtm.out    # nom du fichier de sortie
+#MSUB -e NemoAtm.out    # nom du fichier de sortie
+#MSUB -eo
+#MSUB -n 16             # Reservation des processeurs pour le job
+#MSUB -T 1800           # Limite temps (en secondes)
+#MSUB -q standard
+#MSUB -Q test
+#MSUB -p devcmip6
+
+### ===========================================================================
+###
+### Creates interpolation weights between ORCA and DYNAMICO grids
+### Interpolates ORCA mask to DYNAMICO grid
+###
+### ===========================================================================
+##
+##  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.
+##
+
+##
+## Configuration
+## ===========================================================================
+
+#
+# Defines models
+# ==============
+OCE=ORCA2.3
+OCE=eORCA1.2
+#OCE=ORCA025
+
+ATM=dynamico30
+#ATM=dynamico40
+#ATM=dynamico450
+#ATM=LMD9695
+#ATM=LMD144X142
+
+
+
+#
+# Defines OCE grids to handle
+# ===========================
+
+OCEGRIDS="T" # " UV
+
+### ===========================================================================
+###
+### You should not change anything below this line ....
+###
+### ===========================================================================
+SUBMIT_DIR=$(pwd)
+
+# Defines computer
+# ================
+[[ $(hostname) = curie* ]] && arch=curie
+
+case ${arch} in
+    ( curie | irene ) 
+    module load netcdf/4.3.3.1_hdf5_parallel
+    module load nco/4.4.8
+    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
+    TMPDIR=${SCRATCHDIR}/TMP/${OCE}x${ATM}
+    ;;
+    ( * )
+    exit -1
+    ;;
+esac
+
+
+set -vx ; set -e
+
+mkdir -p ${TMPDIR}/${OCE}x${ATM} || exit 1
+cd       ${TMPDIR}/${OCE}x${ATM} || exit 1
+rm -f *
+
+#
+# Suffixes
+# ---------------------------------------------------------------------------
+ocegrids=${OCEGRIDS~}
+
+case ${OCE} in
+    ( *ORC*) oce=orc ;;
+esac
+case ${ATM} in
+    ( *dynamico*    ) atm=ico ;;
+    ( *lmd* | *LMD* ) atm=lmd ;;
+esac
+
+#
+# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
+# ---------------------------------------------------------------------------
+FL_FMT=64bit
+
+##
+## NEMO T point towards ATM - 1st order
+## ===========================================================================
+cp ${SUBMIT_DIR}/bin/interpol.exe                 .
+cp ${SUBMIT_DIR}/iodef_t${oce}_to_t${atm}_1storder.xml   iodef.xml
+
+cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  .
+cp ${R_IN}/ATM/${ATM}/${ATM}_grid.nc .
+
+ln -s ${OCE}_coordinates_mask.nc  oce_grid.nc
+ln -s ${ATM}_grid.nc              atm_grid.nc
+
+sed --in-place -e 's/"mask_[TUV]"/"mask_T"/g' -e "s/[tuv]${oce}/t${oce}/" -e 's/_...order/_1storder/g' -e 's/order="."/order="1"/' iodef.xml
+time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=no
+
+##
+## Correct spurious values (extremes)
+## ===========================================================================
+cat <<EOF > correction_masque.nco
+where (OceFrac <   0.00001 )  OceFrac=OceFrac.get_miss() ;
+where (OceFrac >   0.99999 )  OceFrac=1.0 ;
+OceFrac.delete_miss() ;
+// Fill masked values to land values
+where (OceFrac >  1.0 )  OceFrac=0.0 ;
+where (OceFrac <  0.0 )  OceFrac=0.0 ; 
+EOF
+ncap2 -h --overwrite --script-file correction_masque.nco t${oce}_to_t${atm}_1storder.nc tmp_t${oce}_to_t${atm}_1storder.nc ; mv tmp_t${oce}_to_t${atm}_1storder.nc t${oce}_to_t${atm}_1storder.nc
+ncatted -h -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" t${oce}_to_t${atm}_1storder.nc
+
+##
+##  Creates mask on ATM grid
+## ===========================================================================
+cp t${oce}_to_t${atm}_1storder.nc  t${oce}_to_t${atm}_1storder_mask.nc
+ncks -h --overwrite                      -v OceFrac               t${oce}_to_t${atm}_1storder_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc
+ncks -h --append                         -v aire                  atm_grid.nc                          ${ATM}_grid_maskFrom_${OCE}.nc
+[[ ${atm} = *ico* ]] && ncks -h --append -v bounds_lon,bounds_lat atm_grid.nc                          ${ATM}_grid_maskFrom_${OCE}.nc
+
+cat <<EOF > creation_masque.nco
+where (OceFrac >  0.0 )  OceFrac=1 ;
+where (OceFrac <= 0.0 )  OceFrac=0 ;
+EOF
+ncap2 -h --overwrite --script-file creation_masque.nco t${oce}_to_t${atm}_1storder_mask.nc tmp_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_t${oce}_to_t${atm}_1storder_mask.nc t${oce}_to_t${atm}_1storder_mask.nc
+ncrename -h -v OceFrac,OceMask t${oce}_to_t${atm}_1storder_mask.nc
+
+ncks -h --append  -v OceMask t${oce}_to_t${atm}_1storder_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc
+
+##
+## NEMO T point towards ATM - 2nd order
+## ===========================================================================
+sed --in-place -e 's/"mask_[TUV]"/"mask_T"/g' -e "s/[tuv]${oce}/t${oce}/" -e 's/_...order/_2ndorder/g' -e 's/order="."/order="2"/' iodef.xml
+#time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+ 
+##
+## ATM towards NEMO T point - 1st order
+## ===========================================================================
+cp ${SUBMIT_DIR}/iodef_t${atm}_to_t${oce}_1storder.xml           iodef.xml
+sed --in-place -e 's/"mask_[TUV]"/"mask_T"/g' -e "s/[tuv]${oce}/t${oce}/" -e 's/_...order/_1storder/g' -e 's/order="."/order="1"/' iodef.xml
+time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+
+##
+## ATM towards NEMO U Point - 1st order
+## ===========================================================================
+sed --in-place -e 's/"mask_[TUV]"/"mask_U"/g' -e "s/[tuv]${oce}/u${oce}/" -e 's/_...order/_1storder/g' -e 's/order="."/order="1"/' iodef.xml
+#time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+
+##
+## ATM towards NEMO V Point - 1st order
+## ===========================================================================
+sed --in-place -e 's/"mask_[TUV]"/"mask_V"/g' -e "s/[tuv]${oce}/v${oce}/" -e 's/_...order/_1storder/g' -e 's/order="."/order="1"/' iodef.xml
+#time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+
+##
+## ATM verstowards NEMO T point - 2nd order
+## ===========================================================================
+sed --in-place -e 's/"mask_[TUV]"/"mask_T"/g' -e "s/[tuv]${oce}/t${oce}/" -e 's/_...order/_2ndorder/g' -e 's/order="."/order="2"/' iodef.xml
+#/usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+
+
+##
+## Change all NetCDF files to NetCDF 3 format (needed for OASIS)
+## ===========================================================================
+for InFile in *.nc ; do
+    if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then
+	mv ${InFile} tmp_${InFile}
+	ncks --fl_fmt=${FL_FMT} -h  tmp_${InFile}  ${InFile}
+    fi
+done
+
+
+##
+## Add time axis and coordinates information
+## (needed if files need to be read by XIOS)
+## ===========================================================================
+if [[ ${atm} = ico ]] ; then
+    cat <<EOF > add_time.nco
+defdim("time_counter",1) ;
+OceFrac [time_counter,cell] = OceFrac (:) ;
+OceMask [time_counter,cell] = OceMask (:) ;
+EOF
+    ncap2 -O -h -S add_time.nco     ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncks -O --mk_rec time_counter   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncatted -h \
+	    -a coordinates,OceFrac,c,c,"time_counter cell" \
+            -a coordinates,OceMask,c,c,"time_counter cell" \
+            -a coordinates,aire,c,c,"time_counter cell"    ${ATM}_grid_maskFrom_${OCE}.nc
+fi
+if [[ ${atm} = lmd ]] ; then
+    cat <<EOF > add_time.nco
+defdim("time_counter",1) ;
+OceFrac [time_counter,lat,lon] = OceFrac (:,:) ;
+OceMask [time_counter,lat,lon] = OceMask (:,:) ;
+EOF
+    ncap2 -O -h -S add_time.nco     ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc  ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncks -O --mk_rec time_counter   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc  ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncatted -h \
+	    -a coordinates,OceFrac,c,c,"time_counter lat lon" \
+            -a coordinates,OceMask,c,c,"time_counter lat lon" \
+            -a coordinates,aire,c,c,"time_counter lat lon"    ${ATM}_grid_maskFrom_${OCE}.nc
+fi
+
+##
+## Add some information in file headers
+## ===========================================================================
+
+UUID=$(uuid)
+NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
+for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do
+    ncatted -h \
+	    --attribute uuid,global,d,,                                           \
+	    --attribute LongName,global,d,,                                       \
+	    --attribute nco_openmp_thread_number,global,d,,                       \
+	    --attribute Conventions,global,o,c,"CF-1.6"                           \
+	    --attribute source,global,o,c,"IPSL Earth system model"               \
+	    --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
+	    --attribute Institution,global,o,c,"IPSL"                             \
+	    --attribute Ocean,global,o,c,"${OCE}"                                 \
+	    --attribute Atmosphere,global,o,c,"${ATM}"                            \
+	    --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \
+	    --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc"      \
+	    --attribute associatedFiles,global,o,c,"grids_${OCE}x${ATM}.nc areas_${OCE}x${ATM}.nc masks_${OCE}x${ATM}.nc" \
+	    --attribute directory,global,o,c,"$(pwd)"                             \
+	    --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
+	    --attribute title,global,o,c,"${type}_${OCE}x${ATM}.nc"               \
+	    --attribute timeStamp,global,o,c,"$(date)"                            \
+	    --attribute uuid,global,o,c,"${UUID}"                                 \
+	    --attribute HOSTNAME,global,o,c,"$(hostname)"                         \
+	    --attribute LOGNAME,global,o,c,"$(whoami)"                            \
+	    --attribute NCO,global,o,c,"NCO ${NCO}"                               \
+	    --attribute OS,global,o,c,"$(uname -o)"                               \
+	    --attribute release,global,o,c,"$(uname -r)"                          \
+	    --attribute hardware,global,o,c,"$(uname -i)"                         \
+	    --attribute directory,global,o,c,"$(pwd)"                             \
+	    --attribute description,global,o,c,"Generated with XIOS"              \
+	    --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \
+	    ${InFile}
+done
+
+
+##
+## Update and complete weights file to fit OASIS requested format
+## ===========================================================================
+cat <<EOF > add_dim.nco
+defdim("num_wgts",1) ;
+weight[n_weight, num_wgts] = weight ;
+EOF
+
+for file in rmp_*${oce}_to_*${atm}_*.nc rmp_*${atm}_to_*${oce}_*.nc ; do
+    mv ${file} xios_${file}
+    ncap2 --fl_fmt=${FL_FMT} -h --script-file add_dim.nco xios_${file} ${file}
+    
+    ncrename -h --dimension n_weight,num_links   ${file}
+    ncrename -h --variable  src_idx,src_address  ${file}
+    ncrename -h --variable  dst_idx,dst_address  ${file}
+    ncrename -h --variable  weight,remap_matrix  ${file}
+    case ${file} in
+	( *1storder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${file} ;;
+	( *2ndorder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${file} ;;
+    esac
+    ncatted -h --attribute conventions,global,o,c,"SCRIP"                            ${file}
+    ncatted -h --attribute normalization,global,o,c,"none"                           ${file}
+    
+    case ${file} in
+	( rmp_*${oce}_to_t${atm}_* )
+	ncatted -h \
+		--attribute title,global,o,c,"Weights ${OCE} to ${ATM}"           \
+		--attribute source_grid,global,o,c,"curvilinear"                  \
+		--attribute dest_grid,global,o,c,"unstructured"                   \
+		${file}	
+	;;
+	( rmp_*${atm}_to_*${oce}_* )
+	ncatted -h \
+		--attribute title,global,o,c,"Weights ${ATM} to ${OCE}"           \
+		--attribute source_grid,global,o,c,"unstructured"                 \
+		--attribute dest_grid,global,o,c,"curvilinear"                    \
+		${file}
+	;;
+    esac
+done
+
+##
+## Save results
+## ===========================================================================
+cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR}
+for order in 1st # 2nd
+do
+    cp t${oce}_to_t${atm}_${order}order.nc     ${SUBMIT_DIR}/t${OCE}_to_t${ATM}_${order}order.nc
+    cp rmp_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/rmp_t${OCE}_to_t${ATM}_${order}order.nc
+    for grid in ${ocegrids} ; do
+	cp rmp_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_t${ATM}_to_${grid}${OCE}_${order}order.nc
+	cp t${atm}_to_${grid}${oce}_${order}order.nc     ${SUBMIT_DIR}/t${ATM}_to_${grid}${OCE}_${order}order.nc
+    done
+done
+
+##
+## Creates and save auxiliary files for OASIS
+## ===========================================================================
+bash ${SUBMIT_DIR}/GenerateOasisGrids.bash --oce ${OCE} --atm ${ATM}
+
+cp areas_${OCE}_${ATM}.nc ${SUBMIT_DIR}
+cp grids_${OCE}_${ATM}.nc ${SUBMIT_DIR}
+cp masks_${OCE}_${ATM}.nc ${SUBMIT_DIR}
+
+
+### ===========================================================================
+###
+###                               That's all folk's !!!
+###
+### ===========================================================================
+
Index: TOOLS/MOSAIX/CreateOasisGrids.bash
===================================================================
--- TOOLS/MOSAIX/CreateOasisGrids.bash	(revision 3620)
+++ TOOLS/MOSAIX/CreateOasisGrids.bash	(revision 3620)
@@ -0,0 +1,386 @@
+#!/bin/bash
+### ===========================================================================
+###
+### Creates grids.nc, masks.nc and areas.nc for OASIS-MCT
+###
+### ===========================================================================
+##
+##  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.
+##
+
+##
+## Default configuration (may be overrided by command line parameters)
+## ===========================================================================
+OCE=ORCA2.3
+# OCE=eORCA1.2
+ATM=ICO30
+#ATM=ICO40
+# ATM=ICO450
+# ATM=LMD144142
+# ATM=LMD9695
+
+## ===========================================================================
+##
+## You should not change anything below this line ....
+##
+## ===========================================================================
+
+# Defines computer
+# ================
+if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
+if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
+PROGRAM=$(basename ${0})
+
+case ${arch} in
+    ( curie | irene )
+    set +vx
+    module unload cdo nco ferret
+    module unload netcdf hdf5
+    module load python # /2.7.12
+    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
+    module load nco
+    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
+    TMPDIR=${SCRATCHDIR}/TMP
+    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
+    ;;
+    ( * )
+    exit -1
+    ;;
+esac
+##
+## Command line parameters
+## ===========================================================================
+set -o verbose
+set -o xtrace
+
+while [[ ${1} = -* ]] ; do
+    case ${1} in
+	( -- ) shift ; break ;;
+	( -o=* | --oce=*    ) OCE=${1##*=}     ; echo OCE:${OCE}    ;;
+	( -o   | --oce      ) shift ; OCE=${1} ; echo OCE:${OCE}    ;;
+	( -a=* | --atm=*    ) ATM=${1##*=}     ; echo ATM:${ATM}    ;;
+	( -a   | --atm      ) shift ; ATM=${1} ; echo ATM:${ATM}    ;;
+	( -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
+
+##
+## Short names (grid names in Oasis) 
+## ===========================================================================
+case ${OCE} in
+    ( *ORC*) oce=orc ;;
+esac
+case ${ATM} in
+    ( *ICO*         ) atm=ico ;;
+    ( *dynamico*    ) atm=ico ;;
+    ( *lmd* | *LMD* ) atm=lmd ;;
+esac
+
+CplModel=${OCE}x${ATM}
+
+##
+## Get input files
+## ===========================================================================
+[[ -f ${OCE}_coordinates_mask.nc ]] || cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  .
+[[ -f ${ATM}_grid.nc             ]] || cp ${R_IN}/ATM/${ATM}/${ATM}_grid.nc                   .
+
+#
+# Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits
+# ---------------------------------------------------------------------------
+FL_FMT=64bit
+
+#
+# Cleaning
+# ----------------------------------------------------------------------------
+rm -f grids_${CplModel}.nc masks_${CplModel}.nc areas_${CplModel}.nc
+rm  -f *_tmp.nc
+
+#
+# Creates NetCDF3 version of input files
+# ----------------------------------------------------------------------------
+ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc      ${OCE}_coordinates_mask_${FL_FMT}.nc
+ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc  ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc
+#
+# Creates ocean fields
+# ----------------------------------------------------------------------------
+
+for OCEGRID in T U V ; do
+    ncks --fl_fmt=${FL_FMT} -C --history --append -v nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc grids_${CplModel}.nc
+    ncks --fl_fmt=${FL_FMT} -C --history --append -v area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc areas_${CplModel}.nc
+    # Inverts mask values and switch to integer
+    ncks --fl_fmt=${FL_FMT} --history -C -v mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc
+    ncatted --history \
+	    --attribute coordinates,mask_${OCEGRID},d,,         \
+	    --attribute online_operation,mask_${OCEGRID},d,,    \
+	    --attribute cell_measures,mask_${OCEGRID},d,,       \
+    mask_${OCEGRID}_tmp.nc
+    
+    ncap2 --fl_fmt=${FL_FMT} --history --append -s "mask_${OCEGRID}=int(1-mask_${OCEGRID});"    mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc
+    ncatted --history \
+	    --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \
+	    --attribute units,mask_${OCEGRID},o,c,"Land:1, Ocean:0"    masks_${CplModel}.nc
+    # Change order of dimensions
+    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc
+    ncpdq --permute nvertex_grid_${OCEGRID},y_grid_${OCEGRID},x_grid_${OCEGRID} grids_${CplModel}_tmp.nc grids_${CplModel}.nc
+done
+
+ncks --history --append -v lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc
+
+#
+# We need to have different names for dimensions and variables
+# ----------------------------------------------------------------------------
+ncrename --history -v lon,alon   grids_${CplModel}.nc
+ncrename --history -v lat,alat   grids_${CplModel}.nc
+
+if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then 
+    ncks --fl_fmt=${FL_FMT} --history --append -v bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc
+fi
+
+ncks --fl_fmt=${FL_FMT} --history -C --append -v aire   ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc
+ncatted --history --attribute coordinates,aire,d,,     \
+	--attribute _FillValue,aire,d,,                \
+	--attribute missing_value,aire,d,,             \
+	--attribute online_operation,aire,d,,          \
+	--attribute units,aire,o,c,"m2"                \
+	--attribute standard_name,aire,o,c,"cell_area" \
+	areas_${CplModel}.nc
+
+ncks --fl_fmt=${FL_FMT} --history -C -v OceMask         ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc
+ncatted --history \
+	--attribute coordinates,OceMask,d,,         \
+	--attribute online_operation,OceMask,d,,    \
+	--attribute _FillValue,OceMask,d,,          \
+	--attribute missing_value,OceMask,d,,       \
+	OceMask_tmp.nc
+ncap2 --fl_fmt=${FL_FMT} --history --append -s "OceMask=int(1-OceMask)"            OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1
+ncatted --history \
+	--attribute long_name,OceMask,o,c,"Land-sea mask"   \
+	--attribute units,OceMask,o,c,"Land:1, Ocean:0"  masks_${CplModel}.nc
+
+ncatted --history --attribute history,global,d,, grids_${CplModel}.nc
+ncatted --history --attribute history,global,d,, masks_${CplModel}.nc
+ncatted --history --attribute history,global,d,, areas_${CplModel}.nc
+
+if [[ ${atm} = *dynamico* || ${atm} = ico* ]] ; then
+    ncrename --history -d cell,ycell grids_${CplModel}.nc
+    ncrename --history -d cell,ycell areas_${CplModel}.nc
+    ncrename --history -d cell,ycell masks_${CplModel}.nc
+fi
+# if [[ ${atm} = *lmd* ]] ; then
+#     ncrename -d lon,tlmdlon  grids_${CplModel}.nc
+#     ncrename -d lat,tlmdlat  grids_${CplModel}.nc
+#     ncrename -d lon,tlmdlon  masks_${CplModel}.nc
+#     ncrename -d lat,tlmdlat  masks_${CplModel}.nc
+#     ncrename -d lon,tlmdlon  areas_${CplModel}.nc
+#     ncrename -d lat,tlmdlat  areas_${CplModel}.nc
+# fi
+
+#
+# DYNAMICO grids :
+#  - Set correct order of dimensions
+#  - Add a dimension
+# ----------------------------------------------------------------------------
+if [[ ${atm} = dynamico* || ${atm} = ico* ]] ; then
+    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc
+    ncpdq --permute nvertex,ycell,xcell  grids_${CplModel}_tmp.nc grids_${CplModel}.nc
+    
+    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc
+    cat <<EOF >add_dim.nco
+//
+defdim("xcell",1) ;
+alat               [ycell,xcell] = alat       ;
+alon               [ycell,xcell] = alon       ;
+bounds_lat [nvertex,ycell,xcell] = bounds_lat ;
+bounds_lon [nvertex,ycell,xcell] = bounds_lon ;
+//
+EOF
+    
+    ncap2 --fl_fmt=${FL_FMT} --history --append -S add_dim.nco  grids_${CplModel}_tmp.nc grids_${CplModel}.nc
+    
+    mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc
+    ncap2 --fl_fmt=${FL_FMT} --history --append -s 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)'  masks_${CplModel}_tmp.nc masks_${CplModel}.nc
+
+    mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc
+    ncap2 --fl_fmt=${FL_FMT} --history --append -s 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; '                       areas_${CplModel}_tmp.nc areas_${CplModel}.nc
+fi
+
+#
+# Some changes specific to LMDZ lon/lat grid
+# ----------------------------------------------------------------------------
+if [[ ${atm} = lmd* ]] ; then
+    # Spreads lon and lat to get 2D fields
+    # -----------------------------------------------------------------------
+    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc
+    ncap2 --fl_fmt=${FL_FMT} --history --append -s "alon[lat,lon]=alon; alat[lat,lon]=alat"  grids_${CplModel}_tmp.nc grids_${CplModel}.nc
+    ncatted --history \
+	    --attribute long_name,alon,o,c,"Longitude"    \
+	    --attribute long_name,alat,o,c,"Latitude"     \
+	    --attribute units,alon,o,c,"degrees_east"     \
+	    --attribute units,alat,o,c,"degrees_north"    \
+	    --attribute grid_type,alon,o,c,"P"            \
+	    --attribute grid_type,alat,o,c,"P"            \
+	    --attribute overlap,alon,o,i,0                \
+	    --attribute overlap,alat,o,i,0                grids_${CplModel}.nc
+    
+    # Generates cell corners
+    # -----------------------------------------------------------------------
+cat <<EOF > add_bounds.nco
+defdim ("nvertex_lmd", 4) ;
+*delta_x = alon(0,1) - alon(0,0) ;
+*delta_y = alat(1,0) - alat(0,0) ;
+//
+bounds_lon[nvertex_lmd,lat,lon] = 0.0 ;
+bounds_lat[nvertex_lmd,lat,lon] = 0.0 ;
+//
+bounds_lon (0,:,:) = alon + delta_x*0.5 ;
+bounds_lat (0,:,:) = alat + delta_y*0.5 ;
+bounds_lon (1,:,:) = alon + delta_x*0.5 ;
+bounds_lat (1,:,:) = alat - delta_y*0.5 ;
+bounds_lon (2,:,:) = alon - delta_x*0.5 ;
+bounds_lat (2,:,:) = alat - delta_y*0.5 ;
+bounds_lon (3,:,:) = alon - delta_x*0.5 ;
+bounds_lat (3,:,:) = alat + delta_y*0.5 ;
+//
+where (bounds_lat >  90.0 ) bounds_lat =  90.0 ;;
+where (bounds_lat < -90.0 ) bounds_lat = -90.0 ;;
+//
+EOF
+    mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc
+    ncap2 --fl_fmt=${FL_FMT} --history -S add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc
+fi
+
+#
+# Generates grid "aone" : same as t-ocean grid, with surfaces set to 1
+# This grid is used when field are quantities instead of fluxes (i.e river flow)
+# ----------------------------------------------------------------------------
+mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc
+ncap2 --fl_fmt=${FL_FMT} --history -s "aone_lon=alon; aone_lat=alat; bounds_aone_lon=bounds_lon; bounds_aone_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc
+
+mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc
+ncap2 --fl_fmt=${FL_FMT} --history -s "aone_aire=aire*0+1; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc
+
+mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc
+ncap2 --fl_fmt=${FL_FMT} --history -s "aone_mask=int(OceMask); " masks_${CplModel}_tmp.nc masks_${CplModel}.nc
+
+#
+# Final renaming
+# ----------------------------------------------------------------------------
+for OCEGRID in T U V
+do
+    ocegrid=${OCEGRID~} # To lowercase
+    ncrename --history -v nav_lon_grid_${OCEGRID},${ocegrid}${oce}.lon     grids_${CplModel}.nc
+    ncrename --history -v nav_lat_grid_${OCEGRID},${ocegrid}${oce}.lat     grids_${CplModel}.nc
+    ncrename --history -v bounds_lon_grid_${OCEGRID},${ocegrid}${oce}.clo  grids_${CplModel}.nc
+    ncrename --history -v bounds_lat_grid_${OCEGRID},${ocegrid}${oce}.cla  grids_${CplModel}.nc
+    ncrename --history -v mask_${OCEGRID},${ocegrid}${oce}.msk             masks_${CplModel}.nc
+    ncrename --history -v area_grid_${OCEGRID},${ocegrid}${oce}.srf        areas_${CplModel}.nc
+    
+    ncatted --history \
+	    --attribute bounds,${ocegrid}${oce}.lon,m,c,"${ocegrid}${oce}.clo"  \
+	    --attribute bounds,${ocegrid}${oce}.lat,m,c,"${ocegrid}${oce}.cla"  \
+	    --attribute units,${ocegrid}${oce}.clo,o,c,"degrees_east"        \
+	    --attribute units,${ocegrid}${oce}.clo,o,c,"degrees_north" grids_${CplModel}.nc
+done
+
+ncrename --history -v alon,t${atm}.lon           grids_${CplModel}.nc
+ncrename --history -v alat,t${atm}.lat           grids_${CplModel}.nc
+ncrename --history -v aone_lon,o${atm}.lon       grids_${CplModel}.nc
+ncrename --history -v aone_lat,o${atm}.lat       grids_${CplModel}.nc
+ncrename --history -v OceMask,t${atm}.msk        masks_${CplModel}.nc
+ncrename --history -v aone_mask,o${atm}.msk      masks_${CplModel}.nc
+ncrename --history -v aire,t${atm}.srf           areas_${CplModel}.nc
+ncrename --history -v aone_aire,o${atm}.srf      areas_${CplModel}.nc
+
+ncrename --history -v bounds_lon,t${atm}.clo        grids_${CplModel}.nc
+ncrename --history -v bounds_lat,t${atm}.cla        grids_${CplModel}.nc
+ncrename --history -v bounds_aone_lon,o${atm}.clo   grids_${CplModel}.nc
+ncrename --history -v bounds_aone_lat,o${atm}.cla   grids_${CplModel}.nc
+
+for atmgrid in t o ; do
+    ncatted --history \
+	    --attribute bounds,${atmgrid}${atm}.lon,c,c,"${atmgrid}${atm}.clo"   \
+	    --attribute bounds,${atmgrid}${atm}.lat,c,c,"${atmgrid}${atm}.cla"   \
+	    --attribute units,${atmgrid}${atm}.clo,o,c,"degrees_east"         \
+	    --attribute units,${atmgrid}${atm}.cla,o,c,"degrees_north"        grids_${CplModel}.nc
+done
+
+##
+## Change all NetCDF files to NetCDF 3 format
+## ===========================================================================
+for InFile in areas_${CplModel}.nc grids_${CplModel}.nc masks_${CplModel}.nc ; do
+    if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then
+	mv ${InFile} tmp_${InFile}
+	ncks --fl_fmt=${FL_FMT} --history  tmp_${InFile}  ${InFile}
+    fi
+done
+
+##
+## Add some useful information in NetCDF headers
+## ===========================================================================
+UUID=$(uuid)
+NCO=$(ncks --version |& tail -1|sed 's/ncks //')
+for type in areas masks grids ; do
+    ncatted --history \
+	    --attribute nco_openmp_thread_number,global,d,,            \
+	    --attribute uuid,global,d,,                                \
+	    --attribute LongName,global,d,,                            \
+	    --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
+	    --attribute Conventions,global,o,c,"CF-1.6"                \
+	    --attribute source,global,o,c,"IPSL Earth system model"    \
+	    --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center" \
+	    --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \
+	    --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr" \
+	    --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu"  \
+	    --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \
+	    --attribute HOSTNAME,global,o,c,"$(hostname)"              \
+	    --attribute LOGNAME,global,o,c,"$(whoami)"                 \
+	    --attribute Program,global,o,c,"Generated by ${0}"         \
+	    --attribute name,global,o,c,"${type}_${CplModel}.nc"     \
+	    --attribute directory,global,o,c,"$(pwd)"                  \
+	    --attribute description,global,o,c,"Fields needed by OASIS-MCT" \
+	    --attribute title,global,o,c,"${type}_${CplModel}.nc"    \
+	    --attribute timeStamp,global,o,c,"$(date)"                 \
+	    --attribute associatedFiles,global,o,c,"grids_${CplModel}.nc areas_${CplModel}.nc masks_${CplModel}.nc" \
+	    --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc"\
+	    --attribute uuid,global,o,c,"${UUID}"                      \
+	    --attribute OS,global,o,c,"$(uname -o)"                    \
+	    --attribute release,global,o,c,"$(uname -r)"               \
+	    --attribute hardware,global,o,c,"$(uname -i)"              \
+	    ${type}_${CplModel}.nc
+done
+
+##
+## Cleaning
+## ===========================================================================
+#rm  *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc *.nco
+
+exit
+#
+# Name of the dimensions ? 
+# ----------------------------------------------------------------------------
+for OCEGRID in T U V ; do
+    ocegrid=${OCEGRID~} # Downcase name of grids
+    ncrename --history -d  x_grid_${OCEGRID},x${ocegrid}${oce}         grids_${CplModel}.nc
+    ncrename --history -d  y_grid_${OCEGRID},y${ocegrid}${oce}         grids_${CplModel}.nc
+    ncrename --history -d  nvertex_grid_${OCEGRID},crn${ocegrid}${oce} grids_${CplModel}.nc
+done
+
+## ===========================================================================
+##
+##                               That's all folk's !!!
+##
+## ===========================================================================
Index: TOOLS/MOSAIX/CreateRestartAtm4Oasis.bash
===================================================================
--- TOOLS/MOSAIX/CreateRestartAtm4Oasis.bash	(revision 3620)
+++ TOOLS/MOSAIX/CreateRestartAtm4Oasis.bash	(revision 3620)
@@ -0,0 +1,262 @@
+#!/bin/bash
+### ===========================================================================
+###
+### Creates initial state for coupler, atmosphere side
+### Takes state from atmospheric hist file
+###
+### ===========================================================================
+##
+##  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.
+##
+
+# Usage exemples :
+# CreateRestartAtm4Oasis.bash --oce ORCA2.3 /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
+# CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc
+# CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc
+
+## ===========================================================================
+##
+## You should not change anything below this line ....
+##
+## ===========================================================================
+
+##
+## Command line parameters
+## ===========================================================================
+# Default values
+Comment="Preliminary attempt - Do not trust !"
+OCE="Unknown"
+
+#
+# Defines computer
+# ================
+if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
+if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
+
+case ${arch} in
+    ( curie | irene )
+    set +vx
+    module unload cdo nco ferret
+    module unload netcdf hdf5
+    module load python # /2.7.12
+    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
+    module load nco
+    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
+    TMPDIR=${SCRATCHDIR}/TMP
+    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
+    ;;
+    ( * )
+    exit -1
+    ;;
+esac
+set -o verbose
+set -o xtrace
+set -e
+
+while [[ ${1} = -* ]] ; do
+    case ${1} in
+	( -- ) shift ; break ;;
+	( -o   | --oce      ) shift ; OCE=${1}     ;; # Just needed to add information in the file and file name
+	( -c   | --comment  ) shift ; Comment=${1} ;; # Just needed to add information in the file
+	( -v | --verbose    ) set -o verbose         ;;
+	( -x | --xtrace     ) set -o xtrace          ;;
+	( -xv | -vx         ) set -o xtrace verbose  ;;
+	( -e                ) set -e                 ;;
+	( -V | --noverbose  ) set +o verbose         ;;
+	( -X | --noxtrace   ) set +o xtrace          ;;
+	( -XV | -VX         ) set +o xtrace verbose  ;;
+	( -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/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc}
+AtmFile=${1:-/ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc}
+
+#
+# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
+# ---------------------------------------------------------------------------
+FL_FMT=64bit
+
+##
+## Extract variables
+## ===========================================================================
+ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 -v lon,lat,sols,soll,fract_oce,fract_sic,precip,snow,evap_sic,evap_oce,wind10m,taux_oce,tauy_oce,taux_sic,tauy_sic ${AtmFile} flxat_fields.nc
+ncwa --overwrite --fl_fmt=${FL_FMT} --history -a time_counter flxat_fields.nc flxat_fields_notime.nc # remove time dimension 
+ncatted --history --attribute history,global,d,c,""  flxat_fields_notime.nc          # cleaning of history attributes
+
+##
+## Determines if the file is unstructured (Dynamico) or lon/lat (LMDZ)
+## Set atmosphere name
+## ===========================================================================
+Count=$(ncdump -h flxat_fields_notime.nc | grep nvertex | wc -l)
+if [[ ${Count} -gt 0 ]] ; then
+    IsUnstructured=yes
+    dim_cell=$(ncdump -h flxat_fields_notime.nc |& grep "cell *=" | awk '{print $3}' ) # Get nominal DYNAMICO resolution (nbp parameter)
+    ico_nbp=$( echo "sqrt(($dim_cell-2)/10)+1" | bc -l | sed 's/\..*//' )
+    ATM=ICO${ico_nbp}
+    ncrename --history -d cell,y flxat_fields_notime.nc
+cat <<EOF > add_dim.nco
+defdim("x",1) ;
+lon      [y,x] = lon       ;
+lat      [y,x] = lat       ;
+sols     [y,x] = sols      ;
+soll     [y,x] = soll      ;
+fract_oce[y,x] = fract_oce ;
+fract_sic[y,x] = fract_sic ;
+precip   [y,x] = precip    ;
+snow     [y,x] = snow      ;
+evap_sic [y,x] = evap_sic  ;
+evap_oce [y,x] = evap_oce  ;
+wind10m  [y,x] = wind10m   ;
+taux_oce [y,x] = taux_oce  ;
+tauy_oce [y,x] = tauy_oce  ;
+taux_sic [y,x] = taux_sic  ;
+tauy_sic [y,x] = tauy_sic  ;
+EOF
+    ncap2 --history --overwrite --fl_fmt=${FL_FMT} -S add_dim.nco flxat_fields_notime.nc tmp_flxat_fields_notime.nc
+    mv tmp_flxat_fields_notime.nc flxat_fields_notime.nc
+
+cat<<EOF > lonlat2xyz.nco
+// Value at North Pole for DYNAMICO grid 
+where ( lat(:,:) >= 90.0d ) COTAUXXU = double(-tau_y) ;
+where ( lat(:,:) >= 90.0d ) COTAUYYU = double( tau_x) ;
+// Value at South Pole for DYNAMICO grid ?
+EOF
+else
+    # lat/lon
+    IsUnstructured=no
+    dim_lat=$(ncdump -h flxat_fields_notime.nc | grep "lat *=" | awk '{print $3}' )
+    dim_lon=$(ncdump -h flxat_fields_notime.nc | grep "lon *=" | awk '{print $3}' )
+    ncrename --history -d lon,x flxat_fields_notime.nc
+    ncrename --history -d lat,y flxat_fields_notime.nc
+cat <<EOF > add_dim.nco
+lon[y,x] = lon ;
+lat[y,x] = lat ;
+EOF
+    ncap2 --history --overwrite --fl_fmt=${FL_FMT} -S add_dim.nco flxat_fields_notime.nc tmp_flxat_fields_notime.nc
+    mv tmp_flxat_fields_notime.nc flxat_fields_notime.nc
+    (( dim_lat = dim_lat - 1 ))
+    #ATM=lmdz${dim_lon}x${dim_lat}
+    ATM=LMD${dim_lon}${dim_lat}
+    (( n_lat = dim_lat-1 ))
+cat<<EOF > lonlat2xyz.nco
+// Value at North Pole for LMDZ lon/lat grid
+COTAUXXU(0,:) = double( -tau_x (0, 0) ) ;
+COTAUYYU(0,:) = double( -tau_y (0, 0) ) ;
+COTAUZZU(0,:) =  0.0d ; 
+// Value at south Pole for LMDZ lon/lat grid ?
+COTAUXXU(${n_lat},:) = double( -tau_x (${n_lat}, 0) ) ;
+COTAUYYU(${n_lat},:) = double( -tau_y (${n_lat}, 0) ) ;
+COTAUZZU(${n_lat},:) =  0.0d ; 
+EOF
+
+fi
+
+echo "Version atmosphere : " ${ATM}
+
+
+##
+## Creates flxat file
+## ===========================================================================
+
+cat <<EOF > create_flxat.nco
+//
+*fract_oce_plus_sic  = double(fract_oce + fract_sic) ; // ocean fraction
+*fract_oce_norm[y,x] = 0.0d ; fract_sic_norm[y,x] = 0.0d ; 
+where (fract_oce_plus_sic >  0.0d ) *fract_oce_norm = double(fract_oce)/fract_oce_plus_sic ; // free ocean vs. total ocen fraction
+where (fract_oce_plus_sic >  0.0d ) *fract_sic_norm = double(fract_sic)/fract_oce_plus_sic ; // sea ice vs. total ocean fraction
+//
+COTOTRAI[y,x] = double(precip-snow)    ;  //  Liquid precip
+COTOTSNO[y,x] = double(snow)           ;  //  Solid precipitation
+COTOTEVA[y,x] = double(evap_oce*fract_oce_norm + evap_sic*fract_sic_norm) ;
+COICEVAP[y,x] = double(evap_sic(:,:))  ; // Evaporation on sea ice
+COQSRMIX[y,x] = double(sols(:,:))      ; // Heat flux short wave
+COQNSMIX[y,x] = double(soll(:,:))      ; // Heat flux minus short wave
+COSHFICE[y,x] = double(sols(:,:))      ; // Heat flux short wave over sea ice
+CONSFICE[y,x] = double(soll(:,:))      ; // Heat flux minus short wave over sea ice
+CODFLXDT[y,x] = -20.0d       ; // W/m2 - dQ/dt
+COCALVIN[y,x] =   0.0d       ; // Calving of icebergs, solid
+COLIQRUN[y,x] =   0.0d       ; // River run-off , liquid
+COWINDSP[y,x] = double( wind10m(:,:) ) ; // Wind speed at 10m high
+COTAUMOD[y,x] =   0.0d                 ; // Wind stress modulus
+// Wind stress
+*tau_x[y,x] = double(taux_oce*fract_oce_norm + taux_sic*fract_sic_norm) ; 
+*tau_y[y,x] = double(tauy_oce*fract_oce_norm + tauy_sic*fract_sic_norm) ;
+COTAUMOD[y,x] = sqrt ( double(tau_x*tau_x + tau_y*tau_y) )  ; 
+// Wind stress, from east/north components to geocentric
+*rpi = acos (-1.0d) ;  *rad = rpi / 180.0d  ; 
+COTAUXXU[y,x] = double( -tau_x(:,:) * sin(rad * lon(:,:)) - tau_y(:,:) * sin(rad * lat(:,:)) * cos(rad * lon(:,:)) ); 
+COTAUYYU[y,x] = double(  tau_x(:,:) * cos(rad * lon(:,:)) - tau_y(:,:) * sin(rad * lat(:,:)) * sin(rad * lon(:,:)) );
+COTAUZZU[y,x] = double(  tau_y(:,:) * cos(rad * lat(:,:)) ) ;
+// Value at North Pole
+#include "lonlat2xyz.nco"
+//
+COTAUXXV[y,x] = COTAUXXU(:,:) ;
+COTAUYYV[y,x] = COTAUYYU(:,:) ;
+COTAUZZV[y,x] = COTAUZZU(:,:) ;
+//
+EOF
+ncap2 --overwrite --fl_fmt=${FL_FMT} -h -S create_flxat.nco flxat_fields_notime.nc tmp_flxat.nc
+ 
+ncks --fl_fmt=${FL_FMT} --overwrite -h -v lon,lat tmp_flxat.nc flxat.nc
+[[ ${IsUnstructured} = yes ]] && ncks --fl_fmt=${FL_FMT} --append -v bounds_lon,bounds_lat tmp_flxat.nc flxat.nc
+ncks --fl_fmt=${FL_FMT} --append  -h -v COTAUXXU,COTAUYYU,COTAUZZU,COTAUXXV,COTAUYYV,COTAUZZV,COTOTRAI,COTOTSNO,COTOTEVA,COICEVAP,COQSRMIX,COQNSMIX,COSHFICE,CONSFICE,CODFLXDT,COCALVIN,COLIQRUN,COWINDSP,COTAUMOD tmp_flxat.nc flxat.nc
+
+##
+## Add some information in file headers
+## ===========================================================================
+
+UUID=$(uuid)
+NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
+ncatted --history \
+	--attribute nco_openmp_thread_number,global,d,,                       \
+	--attribute source,global,o,c,"IPSL Earth system model"               \
+	--attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
+	--attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \
+	--attribute Model,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr"      \
+	--attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \
+	--attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \
+	--attribute originalFiles,global,o,c,"${AtmFile}"                     \
+	--attribute directory,global,o,c,"$(pwd)"                             \
+	--attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
+	--attribute timeStamp,global,o,c,"$(date)"                            \
+	--attribute Program,global,o,c,"Generated by ${0}"                    \
+	--attribute uuid,global,o,c,"${UUID}"                                 \
+	--attribute HOSTNAME,global,o,c,"$(hostname)"                         \
+	--attribute LOGNAME,global,o,c,"$(whoami)"                            \
+	--attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
+	--attribute OS,global,o,c,"$(uname -o)"                               \
+	--attribute release,global,o,c,"$(uname -r)"                          \
+	--attribute hardware,global,o,c,"$(uname -i)"                         \
+	--attribute directory,global,o,c,"$(pwd)"                             \
+	--attribute Comment,global,o,c,"${Comment}"                \
+	flxat.nc
+
+
+##
+## Creates other files
+## ===========================================================================
+mv flxat.nc flxat_${ATM}_maskFrom_${OCE}.nc
+ncks -v COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icbrg_${ATM}_maskFrom_${OCE}.nc
+ncks -v COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icshf_${ATM}_maskFrom_${OCE}.nc
+
+##
+## Cleaning
+## ===========================================================================
+rm -f flxat_fields.nc flxat_fields_notime.nc tmp_flxat.nc
+
+## ===========================================================================
+##
+##                               That's all folk's !!!
+##
+## ===========================================================================
Index: TOOLS/MOSAIX/CreateRestartOce4Oasis.bash
===================================================================
--- TOOLS/MOSAIX/CreateRestartOce4Oasis.bash	(revision 3620)
+++ TOOLS/MOSAIX/CreateRestartOce4Oasis.bash	(revision 3620)
@@ -0,0 +1,179 @@
+#!/bin/bash
+### ===========================================================================
+###
+### Creates initial state for coupler, ocean side
+### Take data from NEMO grid_T and icemod files
+###
+### ===========================================================================
+##
+##  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.
+##
+
+# Usage exemples :
+# CreateRestartOce4Oasis.bash /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc/ccc/store/c# CreateRestartOce4Oasis.bash /ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc
+## ===========================================================================
+##
+## You should not change anything below this line ....
+##
+## ===========================================================================
+
+##
+## Command line parameters
+## ===========================================================================
+# Default values
+Comment="Preliminary attempt - Do not trust !"
+IceVar=ice_pres # siconc #> Variable containing sea ice fraction [0-1]
+
+#
+# Defines computer
+# ================
+if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
+if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
+
+case ${arch} in
+    ( curie | irene )
+    set +vx
+    module unload cdo nco ferret
+    module unload netcdf hdf5
+    module load python # /2.7.12
+    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
+    module load nco
+    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
+    TMPDIR=${SCRATCHDIR}/TMP
+    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
+    ;;
+    ( * )
+    exit -1
+    ;;
+esac
+set -o verbose
+set -o xtrace
+set -e
+
+while [[ ${1} = -* ]] ; do
+    case ${1} in
+	( -- ) shift ; break ;;
+	( -c   | --comment  ) shift ; Comment=${1} ;;
+	( -i   | --ice      ) shift ; IceVar=${1}  ;;
+	( -a   | --alb      ) shift ; AlbVar=${1}  ;;
+	( -v | --verbose    ) set -o verbose   ;;
+	( -x | --xtrace     ) set -o xtrace    ;;
+	( -xv | -vx         ) set -o xtrace verbose  ;;
+	( -e                ) set -e           ;;
+	( -V | --noverbose  ) set +o verbose   ;;
+	( -X | --noxtrace   ) set +o xtrace    ;;
+	( -XV | -VX         ) set +o xtrace verbose    ;;
+	( -E                ) set +e           ;;
+	( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;;
+    esac
+    shift
+done
+
+OceFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc}
+
+#OceFile=${1:-/ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc}
+#
+
+#
+# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
+# ---------------------------------------------------------------------------
+FL_FMT=64bit
+
+##
+## Defines associated sea ice file
+## ===========================================================================
+IceFile=$(echo ${OceFile} | sed 's=/OCE/=/ICE/=' | sed 's=grid_T=icemod=')
+
+##
+## Extract variables
+## ===========================================================================
+ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 -v ${IceVar} ${IceFile} sstoce_fields.nc
+ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 -v tos       ${OceFile} oce_fields.nc
+ncks --append --fl_fmt=${FL_FMT} --history oce_fields.nc   sstoce_fields.nc
+ncwa --overwrite --fl_fmt=${FL_FMT} --history -a time_counter sstoce_fields.nc sstoce_fields_notime.nc # Remove time dimension
+ncatted --history --attribute history,global,d,c,""  sstoce_fields_notime.nc           # Clean attributes
+
+##
+## Find ocean name
+## ===========================================================================
+dim_y=$(ncdump -h sstoce_fields_notime.nc | grep "y *=" | awk '{print $3}' )
+dim_x=$(ncdump -h sstoce_fields_notime.nc | grep "x *=" | awk '{print $3}' )
+echo ${dim_x} ${dim_y}
+
+[[ ${dim_x} = 182 && ${dim_y} = 149 ]] && OCE=ORCA2.3
+[[ ${dim_x} = 362 && ${dim_y} = 332 ]] && OCE=eORCA2.1
+
+
+##
+## Creates sstoce file
+## ===========================================================================
+
+cat <<EOF > create_sstoce.nco
+OIceFrac       = double ( ${IceVar}(:,:) ) ; 
+//tos.simple_fill_miss(tos)               ;
+O_SSTSST[y,x]  = double ( (tos   (:,:) + 273.15d) * (1.0d-OIceFrac) ) ;
+//O_AlbIce[y,x]  = double ( ialb   (:,:)            * OIceFrac(:,:)   ) ;
+//O_TepIce[y,x]  = double ( (tsice (:,:) + 273.15d) * OIceFrac(:,:)   ) ;
+O_AlbIce[y,x]  = double (   0.65d            * OIceFrac(:,:)   ) ;
+O_TepIce[y,x]  = double ( (-20.0d + 273.15d) * OIceFrac(:,:)   ) ;
+O_OCurx1[y,x]  = 0.0d ;
+O_OCury1[y,x]  = 0.0d ;
+O_OCurz1[y,x]  = 0.0d ;
+EOF
+
+ncap2 --overwrite --fl_fmt=${FL_FMT} --history -S create_sstoce.nco sstoce_fields_notime.nc tmp_sstoc.nc
+
+ncks --fl_fmt=${FL_FMT} --overwrite --history -v OIceFrac,O_SSTSST,O_AlbIce,O_TepIce,O_OCurx1,O_OCury1,O_OCurz1 tmp_sstoc.nc sstoc.nc
+
+ncatted --history --attribute comment,O_SSTSST,o,c,"SST weighted by fraction of open ocean"          sstoc.nc
+ncatted --history --attribute comment,O_SSTSST,o,c,"Albedo weighted by fraction of sea ice"          sstoc.nc
+ncatted --history --attribute comment,O_SSTSST,o,c,"Ice temperature weighted by fraction of sea ice" sstoc.nc
+
+##
+## Add some information in file headers
+## ===========================================================================
+
+UUID=$(uuid)
+NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
+ncatted --history \
+	--attribute nco_openmp_thread_number,global,d,,                       \
+	--attribute source,global,o,c,"IPSL Earth system model"               \
+	--attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
+	--attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \
+	--attribute Model,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \
+	--attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \
+	--attribute originalFiles,global,o,c,"${OceFile} ${IceFile}"          \
+	--attribute directory,global,o,c,"$(pwd)"                             \
+	--attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
+	--attribute timeStamp,global,o,c,"$(date)"                            \
+	--attribute uuid,global,o,c,"${UUID}"                                 \
+	--attribute Program,global,o,c,"Generated by ${0}"                    \
+	--attribute HOSTNAME,global,o,c,"$(hostname)"                         \
+	--attribute LOGNAME,global,o,c,"$(whoami)"                            \
+	--attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
+	--attribute OS,global,o,c,"$(uname -o)"                               \
+	--attribute release,global,o,c,"$(uname -r)"                          \
+	--attribute hardware,global,o,c,"$(uname -i)"                         \
+	--attribute directory,global,o,c,"$(pwd)"                             \
+	--attribute Comment,global,o,c,"${Comment}"                           \
+	sstoc.nc
+
+##
+## Cleaning
+## ===========================================================================
+rm -f sstoce_fields.nc sstoce_fields_notime.nc tmp_flxat.nc oce_fields.nc
+
+mv sstoc.nc sstoc_${OCE}.nc
+
+## ===========================================================================
+##
+##                               That's all folk's !!!
+##
+## ===========================================================================
Index: TOOLS/MOSAIX/CreateWeightsMask.bash
===================================================================
--- TOOLS/MOSAIX/CreateWeightsMask.bash	(revision 3620)
+++ TOOLS/MOSAIX/CreateWeightsMask.bash	(revision 3620)
@@ -0,0 +1,402 @@
+#!/bin/bash
+#MSUB -r WeightsMask        # nom de la requete
+#MSUB -o Out_WeightsMask    # nom du fichier de sortie
+#MSUB -e Out_WeightsMask    # nom du fichier de sortie
+#MSUB -eo
+#MSUB -n 4              # Reservation des processeurs pour le job
+#MSUB -T 1800           # Limite temps (en secondes)
+#MSUB -q standard
+#MSUB -Q test
+#MSUB -p devcmip6
+
+### ===========================================================================
+###
+### Creates interpolation weights between ORCA and atmospher grids.
+### Interpolates ORCA mask to atmosphere grid.
+### Weight files are at OASIS-MCT format.
+###
+### Atmosphere grid may be lon/lat LMDZ or DYNAMICO icosahedron
+### ===========================================================================
+##
+##  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.
+##
+
+##
+## Configuration
+## ===========================================================================
+
+#
+# Defines models
+# ==============
+OCE=ORCA2.3
+#OCE=eORCA1.2
+#OCE=ORCA025
+
+ATM=ICO30
+#ATM=ICO40
+#ATM=ICO450
+#ATM=LMD9695
+#ATM=LMD144X142
+
+#
+# Defines OCE grids to handle
+# ===========================
+ListOCEGRID="T U V"
+Listorder="1st" # " 2nd
+
+## ===========================================================================
+##
+## You should not change anything below this line ....
+##
+## ===========================================================================
+SUBMIT_DIR=$(pwd)
+
+#
+# Defines computer
+# ================
+if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
+if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
+PROGRAM=$(basename ${0})
+
+case ${arch} in
+    ( curie | irene )
+    set +vx
+    module unload cdo nco ferret
+    module unload netcdf hdf5
+    module load python # /2.7.12
+    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
+    module load nco
+    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
+    TMPDIR=${SCRATCHDIR}/TMP
+    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
+    PROGRAM=${BRIDGE_MSUB_REQNAME}
+    ;;
+    ( * )
+    exit -1
+    ;;
+esac
+
+set -x ; set -e
+
+mkdir -p ${TMPDIR}/${OCE}x${ATM} || exit 1
+cd       ${TMPDIR}/${OCE}x${ATM} || exit 1
+rm -f *
+
+#
+# Suffixes
+# ---------------------------------------------------------------------------
+Listocegrid=${ListOCEGRID~}
+
+case ${OCE} in
+    ( *ORC* )         oce=orc ; oce_domain_type=curvilinear   ;;
+esac
+case ${ATM} in
+    ( *dynamico*    ) atm=ico ; atm_domain_type=unstructured  ;;
+    ( *ICO*         ) atm=ico ; atm_domain_type=unstructured  ;;
+    ( *lmd* | *LMD* ) atm=lmd ; atm_domain_type=rectilinear   ;;
+esac
+
+#
+# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
+# ---------------------------------------------------------------------------
+FL_FMT=64bit
+
+
+cp ${SUBMIT_DIR}/bin/interpol.exe                 .
+cp ${SUBMIT_DIR}/update_xml.py                    .
+
+##
+## NEMO T point towards ATM - 1st order
+## ===========================================================================
+cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  .
+cp ${R_IN}/ATM/${ATM}/${ATM}_grid.nc .
+
+ln -s ${OCE}_coordinates_mask.nc  oce_grid.nc
+ln -s ${ATM}_grid.nc              atm_grid.nc
+
+echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm}
+cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   iodef.xml
+
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]'   -k name  -v maskutil_T
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${oce_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${atm_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name  -v maskutil_T
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_t${oce}_to_t${atm}_1storder
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${OCE} mask interpolated to ${ATM}"
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${atm_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${oce_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${atm_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_t${oce}_to_t${atm}_1storder.nc
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1
+
+cp iodef.xml iodef_t${oce}_to_t${atm}_1storder.xml
+
+time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=no
+
+##
+## Correct spurious values (extremes)
+## ===========================================================================
+cat <<EOF > correction_masque.nco
+where (OceFrac <   0.00001 )  OceFrac=OceFrac.get_miss() ;
+where (OceFrac >   0.99999 )  OceFrac=1.0 ;
+OceFrac.delete_miss() ;
+// Fill masked values to land values
+where (OceFrac >  1.0 )  OceFrac=0.0 ;
+where (OceFrac <  0.0 )  OceFrac=0.0 ; 
+EOF
+ncap2 -h --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder.nc tmp_dia_t${oce}_to_t${atm}_1storder.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder.nc
+ncatted -h -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc
+
+##
+##  Creates mask on ATM grid
+## ===========================================================================
+cp dia_t${oce}_to_t${atm}_1storder.nc  dia_t${oce}_to_t${atm}_1storder_mask.nc
+ncks -h --overwrite -v OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc
+ncks -h --append    -v aire    atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc
+[[ ${atm} = *ico* ]] && ncks -h --append -v bounds_lon,bounds_lat atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc
+
+cat <<EOF > creation_masque.nco
+where (OceFrac >  0.0 )  OceFrac=1 ;
+where (OceFrac <= 0.0 )  OceFrac=0 ;
+EOF
+ncap2 -h --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc dia_t${oce}_to_t${atm}_1storder_mask.nc
+ncrename -h -v OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc
+
+ncks -h --append  -v OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc
+
+
+##
+## NEMO, other case, towards ATM 
+## ===========================================================================
+for order in ${Listorder} ; do
+    case ${order} in
+	( 1st ) num_order=1 ;;
+	( 2nd ) num_order=2 ;;
+    esac
+    
+    for OCEGRID in ${ListOCEGRID} ; do
+	ocegrid=${OCEGRID~}
+
+	if [[ !( ${order} = 1st && ${OCEGRID} = T ) ]] ; then
+
+	    echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}order"${Norm}
+
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]'   -k name  -v maskutil_${OCEGRID}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${oce_domain_type}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${atm_domain_type}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name  -v maskutil_${OCEGRID}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${ocegrid}${oce}_to_t${atm}_${order}order
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${OCE} mask interpolated to ${ATM}"
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${atm_domain_type}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t ${num_order}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${oce_domain_type}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${atm_domain_type}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${num_order}
+	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${ocegrid}${oce}_to_t${atm}_${order}order.nc
+	    cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order.xml
+	    
+	    time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+	fi
+	
+    done
+done
+
+##
+## ATM towards NEMO points
+## ===========================================================================
+cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml
+
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${ATM} mask interpolated to ${OCE}"
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${atm_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${oce_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type}
+	    
+for order in ${Listorder} ; do
+    case ${order} in
+	( 1st ) num_order=1 ;;
+	( 2nd ) num_order=2 ;;
+    esac
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${num_order}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t ${num_order}   
+    
+    for OCEGRID in ${ListOCEGRID} ; do
+	ocegrid=${OCEGRID~}
+
+	echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}order"${Norm}
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]'   -k name  -v mask_${OCEGRID}
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]'   -k name  -v mask_${OCEGRID}
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_t${atm}_to_${ocegrid}${oce}_${order}order
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_t${atm}_to_${ocegrid}${oce}_${order}order.nc
+	cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order.xml
+	
+	time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes
+	
+    done
+done
+
+##
+## Change all NetCDF files to NetCDF 3 format (needed for OASIS)
+## ===========================================================================
+for InFile in *.nc ; do
+    if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then
+	mv ${InFile} tmp_${InFile}
+	ncks --fl_fmt=${FL_FMT} -h  tmp_${InFile}  ${InFile}
+    fi
+done
+
+##
+## Add time axis and coordinates information
+## (needed if files need to be read by XIOS)
+## ===========================================================================
+if [[ ${atm} = ico ]] ; then
+    cat <<EOF > add_time.nco
+defdim("time_counter",1) ;
+OceFrac [time_counter,cell] = OceFrac (:) ;
+OceMask [time_counter,cell] = OceMask (:) ;
+EOF
+    ncap2 -O -h -S add_time.nco   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncks -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncatted -h \
+	    -a coordinates,OceFrac,c,c,"time_counter cell" \
+            -a coordinates,OceMask,c,c,"time_counter cell" \
+            -a coordinates,aire,c,c,"time_counter cell"    ${ATM}_grid_maskFrom_${OCE}.nc
+fi
+if [[ ${atm} = lmd ]] ; then
+    cat <<EOF > add_time.nco
+defdim("time_counter",1) ;
+OceFrac [time_counter,lat,lon] = OceFrac (:,:) ;
+OceMask [time_counter,lat,lon] = OceMask (:,:) ;
+EOF
+    ncap2 -O -h -S add_time.nco   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncks -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc
+    ncatted -h \
+	    -a coordinates,OceFrac,c,c,"time_counter lat lon" \
+            -a coordinates,OceMask,c,c,"time_counter lat lon" \
+            -a coordinates,aire,c,c,"time_counter lat lon"    ${ATM}_grid_maskFrom_${OCE}.nc
+fi
+
+##
+## Add some information in file headers
+## ===========================================================================
+
+UUID=$(uuid)
+NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
+PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" )
+for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do
+    ncatted -h \
+	    --attribute uuid,global,d,,                                           \
+	    --attribute LongName,global,d,,                                       \
+	    --attribute nco_openmp_thread_number,global,d,,                       \
+	    --attribute Conventions,global,o,c,"CF-1.6"                           \
+	    --attribute source,global,o,c,"IPSL Earth system model"               \
+	    --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
+	    --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \
+	    --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \
+	    --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \
+	    --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \
+	    --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc"      \
+	    --attribute associatedFiles,global,o,c,"grids_${OCE}x${ATM}.nc areas_${OCE}x${ATM}.nc masks_${OCE}x${ATM}.nc" \
+	    --attribute directory,global,o,c,"$(pwd)"                             \
+	    --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
+	    --attribute title,global,o,c,"${InFile}.nc"                           \
+	    --attribute Program,global,o,c,"Generated by ${PROGRAM}"              \
+	    --attribute timeStamp,global,o,c,"$(date)"                            \
+	    --attribute uuid,global,o,c,"${UUID}"                                 \
+	    --attribute HOSTNAME,global,o,c,"$(hostname)"                         \
+	    --attribute LOGNAME,global,o,c,"$(whoami)"                            \
+	    --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
+	    --attribute Python,global,o,c,"Python version ${PYTHON_VER}"          \
+	    --attribute OS,global,o,c,"$(uname -o)"                               \
+	    --attribute release,global,o,c,"$(uname -r)"                          \
+	    --attribute hardware,global,o,c,"$(uname -i)"                         \
+	    --attribute directory,global,o,c,"$(pwd)"                             \
+	    --attribute description,global,o,c,"Generated with XIOS http://forge.ipsl.jussieu.fr/ioserver" \
+	    --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \
+	    ${InFile}
+done
+
+
+##
+## Update and complete weights file to fit OASIS requested format
+## ===========================================================================
+cat <<EOF > add_dim.nco
+defdim("num_wgts",1) ;
+weight[n_weight, num_wgts] = weight ;
+EOF
+
+for file in rmp_*${oce}_to_*${atm}_*.nc rmp_*${atm}_to_*${oce}_*.nc ; do
+    mv ${file} xios_${file}
+    ncap2 --fl_fmt=${FL_FMT} -h --script-file add_dim.nco xios_${file} ${file}
+    
+    ncrename -h --dimension n_weight,num_links   ${file}
+    ncrename -h --variable  src_idx,src_address  ${file}
+    ncrename -h --variable  dst_idx,dst_address  ${file}
+    ncrename -h --variable  weight,remap_matrix  ${file}
+    case ${file} in
+	( *1storder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${file} ;;
+	( *2ndorder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${file} ;;
+    esac
+    ncatted -h --attribute conventions,global,o,c,"SCRIP"   ${file}
+    ncatted -h --attribute normalization,global,o,c,"none"  ${file}
+    
+    case ${file} in
+	( rmp_*${oce}_to_t${atm}_* )
+	ncatted -h \
+		--attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \
+		--attribute source_grid,global,o,c,"${oce_domain_type}" \
+		--attribute dest_grid,global,o,c,"${atm_domain_type}"   \
+		${file}	
+	;;
+	( rmp_*${atm}_to_*${oce}_* )
+	ncatted -h \
+		--attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \
+		--attribute source_grid,global,o,c,"${atm_domain_type}" \
+		--attribute dest_grid,global,o,c,"${oce_domain_type}"   \
+		${file}
+	;;
+    esac
+done
+
+##
+## Save results
+## ===========================================================================
+cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR}
+for order in ${Listorder}
+do
+    cp dia_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/dia_t${OCE}_to_t${ATM}_${order}order.nc
+    cp rmp_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/rmp_t${OCE}_to_t${ATM}_${order}order.nc
+    for grid in ${Listocegrid} ; do
+	cp rmp_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_t${ATM}_to_${grid}${OCE}_${order}order.nc
+	cp dia_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/dia_t${ATM}_to_${grid}${OCE}_${order}order.nc
+    done
+done
+
+##
+## Creates and save auxiliary files for OASIS
+## ===========================================================================
+bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM}
+
+cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR}
+cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR}
+cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR}
+
+
+## ===========================================================================
+##
+##                               That's all folk's !!!
+##
+## ===========================================================================
+
Index: TOOLS/MOSAIX/README.txt
===================================================================
--- TOOLS/MOSAIX/README.txt	(revision 3620)
+++ TOOLS/MOSAIX/README.txt	(revision 3620)
@@ -0,0 +1,21 @@
+
+
+CreateWeightsMask.bash
+======================
+Creates the weights to interpolate between atmospheric and ocean grid. Weight file are suitable for OASIS-MCT.
+Creates the fraction of ocean in atmospherci grid cells.
+
+
+CreateOasisGrids.bash
+=====================
+Creates files grids.nc, areas.nc and masks.nc with information from both models, suitable for OASIS-MCT.
+
+
+CreateRestartOce4Oasis.bash
+===========================
+
+CreateRestartAtm4Oasis.bash
+===========================
+
+
+rangement.bash*
Index: TOOLS/MOSAIX/Setup.bash
===================================================================
--- TOOLS/MOSAIX/Setup.bash	(revision 3620)
+++ TOOLS/MOSAIX/Setup.bash	(revision 3620)
@@ -0,0 +1,42 @@
+export Bold=$(    tput bold   ) 
+export Unde=$(    tput smul   ) ; export OffUnde=$( tput rmul )
+export Stou=$(    tput smso   ) ; export OffStou=$( tput rmso )
+export Reve=$(    tput rev    ) 
+
+export Black=$(   tput setf 0 )
+export Blue=$(    tput setf 1 )
+export Green=$(   tput setf 2 )
+export Cyan=$(    tput setf 3 )
+export Red=$(     tput setf 4 )
+export Magenta=$( tput setf 5 )
+export Yellow=$(  tput setf 6 )
+export White=$(   tput setf 7 )
+
+export Norm=$(    tput sgr0 )
+
+
+#
+# Defines computer
+# ================
+if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
+if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
+PROGRAM=$(basename ${0})
+
+case ${arch} in
+    ( curie | irene )
+    set +vx
+    module unload cdo nco ferret
+    module unload netcdf hdf5
+    module load python # /2.7.12
+    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
+    module load nco
+    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
+    TMPDIR=${SCRATCHDIR}/TMP
+    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
+    PROGRAM=${BRIDGE_MSUB_REQNAME}
+    ;;
+    ( * )
+    exit -1
+    ;;
+esac
+
Index: TOOLS/MOSAIX/bld.cfg
===================================================================
--- TOOLS/MOSAIX/bld.cfg	(revision 3620)
+++ TOOLS/MOSAIX/bld.cfg	(revision 3620)
@@ -0,0 +1,43 @@
+# --
+
+cfg::type     bld                           
+cfg::version  1.0                           
+
+bld::tool::shell /bin/bash
+
+
+# ---------- User section -----------
+
+%XIOS_DIR /ccc/cont003/home/gencmip6/p86mart/XIOS
+
+%ROOT    ${PWD}
+%F90	 mpif90 -r8
+#%FFLAGS  -O3 -ip -no-prec-div
+#%FFLAGS	 -g -check all -check noarg_temp_created -debug all -debug-parameters all -ftrapuv -traceback
+#%FFLAGS	 -g -check arg_temp_created -check bounds -check format -check output_conversion -check pointers -check uninit -ftrapuv -traceback
+%FFLAGS	 -g -traceback -check all
+#%FFLAGS	 -g -check all -check noarg_temp_created -debug all -debug-parameters all -ftrapuv -traceback
+
+# ---------- Do no touch -----------
+
+dir::root     %{ROOT}
+bld::target  interpol.exe # interpol_nemo_to_lmdz.exe interpol_lmdz_to_nemo.exe
+
+search_src    1
+
+# -- Compiler, etc ...
+bld::tool::fc       %{F90}                    
+bld::tool::fflags   %{FFLAGS} -I%{XIOS_DIR}/inc -I${NETCDF_INC_DIR}
+bld::tool::ld       %{F90} %{FFLAGS} -L%{XIOS_DIR}/lib -L${NETCDF_LIB_DIR}
+bld::tool::ldflags  -lxios -lnetcdff -lnetcdf -lstdc++
+bld::tool::ar       ar
+
+# -- Ignore the following dependencies
+bld::excl_dep        use::netcdf
+bld::excl_dep        use::mpi
+bld::excl_dep        inc::mpif.h
+bld::excl_dep        use::xios
+bld::excl_dep        use::mod_wait
+
+# -- Dont generate interface files 
+bld::tool::geninterface none
Index: TOOLS/MOSAIX/iodef.xml
===================================================================
--- TOOLS/MOSAIX/iodef.xml	(revision 3620)
+++ TOOLS/MOSAIX/iodef.xml	(revision 3620)
@@ -0,0 +1,128 @@
+<?xml version="1.0"?>
+<simulation>
+
+  <context id="interpol_read">
+    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" timestep="3600s" />
+    
+    <file_definition type="one_file" >
+
+      <file id="file_src" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_src"  name="maskutil_T" operation="instant" domain_ref="domain_src" /> 
+      </file>
+
+      <file id="file_dst" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_dst"  name="OceMask" operation="instant" domain_ref="domain_dst" /> 
+      </file>
+      
+    </file_definition>
+
+    <domain_definition>
+
+      <domain id="domain_src" type="curvilinear" >
+	<generate_rectilinear_domain/>
+      </domain>
+
+      <domain id="domain_dst" type="unstructured" >
+	<generate_rectilinear_domain/>
+      </domain>
+
+    </domain_definition>
+
+  </context >   
+
+  <context id="interpol_run">
+    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" timestep="3600s" />
+
+    <field_definition level="1" enabled=".TRUE." default_value="1e20" detect_missing_value="true">
+      <field id="mask_src"  domain_ref="domain_src" />
+      
+      <field id="field01_src"  domain_ref="domain_src" />
+      <field id="field02_src"  domain_ref="domain_src" />
+      <field id="field03_src"  domain_ref="domain_src" />
+      <field id="field04_src"  domain_ref="domain_src" />
+      <field id="field05_src"  domain_ref="domain_src" />
+      <field id="field06_src"  domain_ref="domain_src" />
+      <field id="field07_src"  domain_ref="domain_src" />
+      <field id="field08_src"  domain_ref="domain_src" />
+      <field id="field09_src"  domain_ref="domain_src" />
+      <field id="field10_src"  domain_ref="domain_src" />
+      <field id="field11_src"  domain_ref="domain_src" />
+      <field id="field12_src"  domain_ref="domain_src" />
+      <field id="field13_src"  domain_ref="domain_src" />
+      <field id="field14_src"  domain_ref="domain_src" />
+      <field id="field15_src"  domain_ref="domain_src" />
+      <field id="field16_src"  domain_ref="domain_src" />
+    </field_definition>
+
+    <file_definition type="one_file" >
+
+      <file id="file_src" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_source"  name="maskutil_T" operation="instant" domain_ref="domain_src" /> 
+      </file>
+
+      <file id="file_dst" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
+	<field id="aire"  name="aire" operation="instant" domain_ref="domain_dst" />
+      </file>
+
+      <file id="dia" name="dia_toce_to_tatm_1storder.nc" output_freq="1ts" enabled=".TRUE."  >
+	<variable name="description"   type="string">Generated with XIOS</variable>
+        <variable name="title"         type="string">OCEAN mask interpolated to ATMOSPHERE</variable>
+	<variable name="Comment"       type="string">Preliminary attempt - Do not trust !</variable>
+	<variable name="map_method"    type="string">Conservative Remapping</variable>
+	<variable name="order"         type="string">1</variable>
+	<variable name="conventions"   type="string">SCRIP</variable>
+	<variable name="normalization" type="string">none</variable>
+	<variable name="source_grid"   type="string">curvilinear</variable>
+	<variable name="dest_grid"     type="string">unstructured</variable>
+	<variable name="Institution"   type="string">IPSL</variable>
+	<variable name="Model"         type="string">IPSL CM6</variable>
+	
+	<field name="OceFrac"     field_ref="mask_src"    domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field01_dst" field_ref="field01_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field02_dst" field_ref="field02_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field03_dst" field_ref="field03_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field04_dst" field_ref="field04_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field05_dst" field_ref="field05_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field06_dst" field_ref="field06_src" domain_ref="domain_dst" operation="once" prec="8" />
+	
+      </file>
+      
+    </file_definition>
+
+    <domain_definition>
+      <domain id="domain_src" type="curvilinear" >
+	<generate_rectilinear_domain/>
+      </domain>
+      
+      <domain id="domain_dst" type="unstructured" prec="8" >
+	<generate_rectilinear_domain/>
+	<interpolate_domain order="1" renormalize="false" write_weight="true" weight_filename="rmp_toce_to_tatm_1storder.nc"/>
+      </domain>
+    </domain_definition>
+
+    
+  </context>
+
+  <context id="xios">
+    <variable_definition>
+      <variable_group id="server">
+        <variable id="using_server2" type="bool">false</variable>
+        <variable id="ratio_server2" type="int">50</variable>
+      </variable_group>
+
+      <variable_group id="buffer">
+        <variable id="optimal_buffer_size" type="string">performance</variable>
+        <variable id="min_buffer_size" type="string">10000000</variable>
+        <variable id="buffer_size_factor" type="double">1.0</variable>
+      </variable_group>
+
+      <variable_group id="parameters" >
+        <variable id="using_server" type="bool">false</variable>
+        <variable id="info_level" type="int">50</variable>
+        <variable id="print_file" type="bool">true</variable>
+      </variable_group>
+    </variable_definition>
+  </context>
+
+</simulation>
+
Index: TOOLS/MOSAIX/iodef_atm_to_oce.xml
===================================================================
--- TOOLS/MOSAIX/iodef_atm_to_oce.xml	(revision 3620)
+++ TOOLS/MOSAIX/iodef_atm_to_oce.xml	(revision 3620)
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<simulation>
+
+  <context id="interpol_read">
+    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" timestep="3600s" />
+    
+    <file_definition type="one_file" >
+
+      <file id="file_src" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_src" name="OceMask" operation="instant" domain_ref="domain_src" /> 
+      </file>
+
+      <file id="file_dst" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+	<field id="mask_dst" name="mask_T" operation="instant" domain_ref="domain_dst" /> 
+      </file>
+      
+    </file_definition>
+
+    <domain_definition>
+      
+      <domain id="domain_src" type="unstructured" >
+	<generate_rectilinear_domain/>
+      </domain>
+
+      <domain id="domain_dst" type="curvilinear" >
+	<generate_rectilinear_domain/>
+      </domain>
+
+    </domain_definition>
+
+  </context >   
+
+  <context id="interpol_run">
+    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" timestep="3600s" />
+
+    <field_definition level="1" enabled=".TRUE." default_value="1e20" detect_missing_value="true">
+      <field id="mask_src"  domain_ref="domain_src" />
+      
+      <field id="field01_src"  domain_ref="domain_src" />
+      <field id="field02_src"  domain_ref="domain_src" />
+      <field id="field03_src"  domain_ref="domain_src" />
+      <field id="field04_src"  domain_ref="domain_src" />
+      <field id="field05_src"  domain_ref="domain_src" />
+      <field id="field06_src"  domain_ref="domain_src" />
+      <field id="field07_src"  domain_ref="domain_src" />
+      <field id="field08_src"  domain_ref="domain_src" />
+      <field id="field09_src"  domain_ref="domain_src" />
+      <field id="field10_src"  domain_ref="domain_src" />
+      <field id="field11_src"  domain_ref="domain_src" />
+      <field id="field12_src"  domain_ref="domain_src" />
+      <field id="field13_src"  domain_ref="domain_src" />
+      <field id="field14_src"  domain_ref="domain_src" />
+      <field id="field15_src"  domain_ref="domain_src" />
+      <field id="field16_src"  domain_ref="domain_src" />
+    </field_definition>
+
+    <file_definition type="one_file" >
+
+      <file id="file_src" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+	<field id="mask_source"  name="OceMask" operation="instant" domain_ref="domain_src" /> 
+      </file>
+
+      <file id="file_dst" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
+	<field id="mask_dest"  name="mask_T" operation="instant" domain_ref="domain_dst" />
+      </file>
+
+      <file id="dia" name="dia_tatm_to_toce_1storder" output_freq="1ts" enabled=".TRUE.">
+	<variable name="description"   type="string">Generated with XIOS</variable>
+        <variable name="title"         type="string">ATMOSPHERE mask interpolated to OCEAN</variable>
+	<variable name="Comment"       type="string">Preliminary attempt - Do not trust !</variable>
+	<variable name="map_method"    type="string">Conservative Remapping</variable>
+	<variable name="order"         type="string">1</variable>
+	<variable name="conventions"   type="string">SCRIP</variable>
+	<variable name="normalization" type="string">none</variable>
+	<variable name="source_grid"   type="string">curvilinear</variable>
+	<variable name="dest_grid"     type="string">unstructured</variable>
+	<variable name="Institution"   type="string">IPSL</variable>
+	<variable name="Model"         type="string">IPSL CM6</variable>
+
+	<field name="field01_dst" field_ref="field01_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field02_dst" field_ref="field02_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field03_dst" field_ref="field03_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field04_dst" field_ref="field04_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field05_dst" field_ref="field05_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field06_dst" field_ref="field06_src" domain_ref="domain_dst" operation="once" prec="8" />
+      </file>
+      
+    </file_definition>
+
+    <domain_definition>
+      <domain id="domain_src" type="unstructured" >
+	<generate_rectilinear_domain/>
+      </domain>
+      
+      <domain id="domain_dst" type="curvilinear" prec="8" >
+	<generate_rectilinear_domain/>
+	<interpolate_domain order="1" renormalize="false" write_weight="true" weight_filename="rmp_tatm_to_toce_1storder.nc"/>
+      </domain>
+    </domain_definition>
+
+    
+  </context>
+
+  <context id="xios">
+    <variable_definition>
+      <variable_group id="server">
+        <variable id="using_server2" type="bool">false</variable>
+        <variable id="ratio_server2" type="int">50</variable>
+      </variable_group>
+
+      <variable_group id="buffer">
+        <variable id="optimal_buffer_size" type="string">performance</variable>
+        <variable id="min_buffer_size" type="string">10000000</variable>
+        <variable id="buffer_size_factor" type="double">1.0</variable>
+      </variable_group>
+
+      <variable_group id="parameters" >
+        <variable id="using_server" type="bool">false</variable>
+        <variable id="info_level" type="int">50</variable>
+        <variable id="print_file" type="bool">true</variable>
+      </variable_group>
+    </variable_definition>
+  </context>
+
+</simulation>
Index: TOOLS/MOSAIX/iodef_oce_to_atm.xml
===================================================================
--- TOOLS/MOSAIX/iodef_oce_to_atm.xml	(revision 3620)
+++ TOOLS/MOSAIX/iodef_oce_to_atm.xml	(revision 3620)
@@ -0,0 +1,128 @@
+<?xml version="1.0"?>
+<simulation>
+
+  <context id="interpol_read">
+    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" timestep="3600s" />
+    
+    <file_definition type="one_file" >
+
+      <file id="file_src" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_src"  name="maskutil_T" operation="instant" domain_ref="domain_src" /> 
+      </file>
+
+      <file id="file_dst" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_dst"  name="OceMask" operation="instant" domain_ref="domain_dst" /> 
+      </file>
+      
+    </file_definition>
+
+    <domain_definition>
+
+      <domain id="domain_src" type="curvilinear" >
+	<generate_rectilinear_domain/>
+      </domain>
+
+      <domain id="domain_dst" type="unstructured" >
+	<generate_rectilinear_domain/>
+      </domain>
+
+    </domain_definition>
+
+  </context >   
+
+  <context id="interpol_run">
+    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" timestep="3600s" />
+
+    <field_definition level="1" enabled=".TRUE." default_value="1e20" detect_missing_value="true">
+      <field id="mask_src"  domain_ref="domain_src" />
+      
+      <field id="field01_src"  domain_ref="domain_src" />
+      <field id="field02_src"  domain_ref="domain_src" />
+      <field id="field03_src"  domain_ref="domain_src" />
+      <field id="field04_src"  domain_ref="domain_src" />
+      <field id="field05_src"  domain_ref="domain_src" />
+      <field id="field06_src"  domain_ref="domain_src" />
+      <field id="field07_src"  domain_ref="domain_src" />
+      <field id="field08_src"  domain_ref="domain_src" />
+      <field id="field09_src"  domain_ref="domain_src" />
+      <field id="field10_src"  domain_ref="domain_src" />
+      <field id="field11_src"  domain_ref="domain_src" />
+      <field id="field12_src"  domain_ref="domain_src" />
+      <field id="field13_src"  domain_ref="domain_src" />
+      <field id="field14_src"  domain_ref="domain_src" />
+      <field id="field15_src"  domain_ref="domain_src" />
+      <field id="field16_src"  domain_ref="domain_src" />
+    </field_definition>
+
+    <file_definition type="one_file" >
+
+      <file id="file_src" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE.">
+        <field id="mask_source"  name="maskutil_T" operation="instant" domain_ref="domain_src" /> 
+      </file>
+
+      <file id="file_dst" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
+	<field id="aire"  name="aire" operation="instant" domain_ref="domain_dst" />
+      </file>
+
+      <file id="dia" name="dia_toce_to_tatm_1storder" output_freq="1ts" enabled=".TRUE."  >
+	<variable name="description"   type="string">Generated with XIOS</variable>
+        <variable name="title"         type="string">OCEAN mask interpolated to ATMOSPHERE</variable>
+	<variable name="Comment"       type="string">Preliminary attempt - Do not trust !</variable>
+	<variable name="map_method"    type="string">Conservative Remapping</variable>
+	<variable name="order"         type="string">1</variable>
+	<variable name="conventions"   type="string">SCRIP</variable>
+	<variable name="normalization" type="string">none</variable>
+	<variable name="source_grid"   type="string">curvilinear</variable>
+	<variable name="dest_grid"     type="string">unstructured</variable>
+	<variable name="Institution"   type="string">IPSL</variable>
+	<variable name="Model"         type="string">IPSL CM6</variable>
+	
+	<field name="OceFrac"     field_ref="mask_src"    domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field01_dst" field_ref="field01_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field02_dst" field_ref="field02_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field03_dst" field_ref="field03_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field04_dst" field_ref="field04_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field05_dst" field_ref="field05_src" domain_ref="domain_dst" operation="once" prec="8" />
+	<field name="field06_dst" field_ref="field06_src" domain_ref="domain_dst" operation="once" prec="8" />
+	
+      </file>
+      
+    </file_definition>
+
+    <domain_definition>
+      <domain id="domain_src" type="curvilinear" >
+	<generate_rectilinear_domain/>
+      </domain>
+      
+      <domain id="domain_dst" type="unstructured" prec="8" >
+	<generate_rectilinear_domain/>
+	<interpolate_domain order="1" renormalize="false" write_weight="true" weight_filename="rmp_toce_to_tatm_1storder.nc"/>
+      </domain>
+    </domain_definition>
+
+    
+  </context>
+
+  <context id="xios">
+    <variable_definition>
+      <variable_group id="server">
+        <variable id="using_server2" type="bool">false</variable>
+        <variable id="ratio_server2" type="int">50</variable>
+      </variable_group>
+
+      <variable_group id="buffer">
+        <variable id="optimal_buffer_size" type="string">performance</variable>
+        <variable id="min_buffer_size" type="string">10000000</variable>
+        <variable id="buffer_size_factor" type="double">1.0</variable>
+      </variable_group>
+
+      <variable_group id="parameters" >
+        <variable id="using_server" type="bool">false</variable>
+        <variable id="info_level" type="int">50</variable>
+        <variable id="print_file" type="bool">true</variable>
+      </variable_group>
+    </variable_definition>
+  </context>
+
+</simulation>
+
Index: TOOLS/MOSAIX/rangement.bash
===================================================================
--- TOOLS/MOSAIX/rangement.bash	(revision 3620)
+++ TOOLS/MOSAIX/rangement.bash	(revision 3620)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+source ./Setup.bash
+
+
+# ============================================================
+
+for ATM in LMD9695 LMD144142 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450
+do
+    for OCE in ORCA2.3 eORCA1.2 ORCA025
+    do
+	Liste=$(ls *${ATM}*_*${OCE}*.nc *${OCE}*_*${ATM}*.nc  *${ATM}x${OCE}*.nc *${OCE}x${ATM}*.nc 2> /dev/null  )
+
+	if [[ -z ${Liste} ]] ; then
+	    echo "${ATM} : ${OCE} : Vide "
+	else
+	    echo "${ATM} : ${OCE} : ${Liste}"
+	    mkdir -p ${OCE}x${ATM}
+	    mv ${Liste} ${OCE}x${ATM}
+
+	fi
+	
+    done
+done
Index: TOOLS/MOSAIX/update_xml.py
===================================================================
--- TOOLS/MOSAIX/update_xml.py	(revision 3620)
+++ TOOLS/MOSAIX/update_xml.py	(revision 3620)
@@ -0,0 +1,147 @@
+### ===========================================================================
+###
+### Modifies or add an element in an XML file
+###
+### ===========================================================================
+##
+##  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.
+##
+#
+__version__ = "0.1"
+# 
+# Tested with python/2.7.12 and python/3.6.4
+#
+import xml.etree.ElementTree
+import getopt, sys
+
+##
+def usage () :
+    texte = """%(prog)s usage :
+python %(prog)s [-d] [-i iodef.xml] [-o iodef_new.xml] -n [node in Xpath syntax] -k <key>  -v <value>
+python %(prog)s [-d] [-i iodef.xml] [-o iodef_new.xml] -n [node in Xpath syntax] -t <value>
+ -d         | --debug         : debug
+ -i <file>  | --input=<file>  : input file  (default iodef.xml)
+ -o <file>  | --output=<file> : output file (default: overwrite input file)
+ -n <file>  | --node=<file>   : node in Xpath syntax
+ -f <field> | --field=<field> : xml field to update
+ -t <text>  | --text=<text>   : will replace the 'text' part of the Xpath by <text>
+ -v <value> | --value=<value> : new value for xml field
+example :  
+    python %(prog)s -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name  -v maskutil_T
+    """
+    #print ( texte % ( sys.argv[0], sys.argv[0], sys.argv[0], sys.argv[0] ) )
+    #print ( texte %   ( 6*[sys.argv[0]] ))
+    print ( texte % { 'prog':sys.argv[0] } )
+    
+# Check version
+if sys.version_info<(2,7,0):
+  sys.stderr.write ( "You need python 2.7 or later to run this script\n" )
+  sys.exit (1)
+  
+## Input parameters
+FileIn   = 'iodef.xml'
+FileOut  = None
+Node     = None 
+Key      = None
+Text     = None
+Value    = None
+Debug    = False
+
+## Command line options
+try:
+    myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:o:n:k:v:t:dh', [ 'input=', 'output=', 'node=', 'key=', 'value=', 'text=', 'debug=', '--help' ] )
+except getopt.GetoptError as cmdle :
+    print ( "Command line error :", cmdle, "\n" )
+    usage ()
+    sys.exit(1)
+
+for myopt, myval in myopts :
+    if myopt in [ '-h', '--help'   ] : usage () ; sys.exit (0) ; 
+    if myopt in [ '-i', '--input'  ] : FileIn   = myval
+    if myopt in [ '-o', '--output' ] : FileOut  = myval
+    if myopt in [ '-n', '--node'   ] : Node     = myval
+    if myopt in [ '-k', '--key'    ] : Key      = myval
+    if myopt in [ '-t', '--text'   ] : Text     = myval
+    if myopt in [ '-v', '--value'  ] : Value    = myval
+    if myopt in [ '-d', '--debug'  ] : Debug    = True
+
+## Some coherency checking of command line parameters
+if FileOut == None : FileOut = FileIn
+
+if Node == None :
+    print ( "Error : please specify -n <node>", "\n" )
+    usage ()
+    sys.exit (1)
+    
+if Key == None and Text == None :
+    print ( "Error : please specify either -t <text> or -k <key> -v <value> ", "\n" )
+    usage ()
+    sys.exit (1)
+
+if Key != None and Text != None :
+    print ( "Error : please specify only one option between -t", Text, "and -k", Key, "\n" )
+    usage ()
+    sys.exit (1)
+
+if Key != None and Value == None :
+    print ( "Error : please specify -v <value> when -k", Key, "is given", "\n")
+    usage ()
+    sys.exit (1)
+    
+## Get XML tree from input file
+iodef = xml.etree.ElementTree.parse ( FileIn )
+
+## Find node
+nodeList = iodef.findall ( Node )
+
+## Check that only one node is found
+if len(nodeList) == 0 :
+    print ( "Error : node not found" )
+    print ( "Node  :", Node )
+    sys.exit(1)
+    
+if len(nodeList) > 1 :
+    print ( "Error :", len(nodeList), "occurences of node found" )
+    print ( "Node  :", Node )
+    sys.exit(1)
+
+## Update element
+elem = nodeList[0]
+
+if Debug :
+    print ( 'Node  :', Node  )
+    print ( 'Key   :', Key   )
+    print ( 'Value :', Value )
+
+if Text != None :
+    if Debug :
+        print ( 'Attributes of node:', elem.attrib )
+        print ( 'Text       :', elem.text   )
+    elem.text = Text
+
+if Key != None :
+    # To do : check that Key exist (it is added if not : do we want that ?)
+    if Debug :
+        print ( 'Attributes of node:', elem.attrib )
+    elem.attrib.update ( { Key:Value } )
+    
+
+## Writes XML tree to file
+iodef.write ( FileOut )
+
+## This is the end
+sys.exit(0)
+    
+### ===========================================================================
+###
+###                               That's all folk's !!!
+###
+### ===========================================================================
+
