Index: /TOOLS/MOSAIX/CreateWeightsMask.bash
===================================================================
--- /TOOLS/MOSAIX/CreateWeightsMask.bash	(revision 4152)
+++ /TOOLS/MOSAIX/CreateWeightsMask.bash	(revision 4153)
@@ -53,6 +53,6 @@
 # Defines models
 # ==============
-OCE=ORCA2.3
-#OCE=eORCA1.2
+#OCE=ORCA2.3
+OCE=eORCA1.2
 #OCE=ORCA025
 
@@ -60,14 +60,18 @@
 #ATM=ICO40
 #ATM=ICO450
-ATM=LMD9695
-#ATM=LMD144X142
-
-#
-# Defines OCE grids to handle
-# ===========================
-ListOCEGRID="T" # U V
-ListOrder="1st" # 2nd
-ListNormalize="false true"
-ListQuantity="false true"
+#ATM=LMD9695
+ATM=LMD144142
+
+# Default values, used to create ocean fraction on atmospheric grid 
+DefaultValues=( Direction=o2a,ocegrid=t,atmgrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false )
+
+# List of weights to build
+CommandList=( \
+    Direction=o2a,Order=1st,Quantity=false,Renormalize=true,ocegrid=t,atmgrid=t,useArea=false,maskSrc=true,maskDst=true  \
+    Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmgrid=t,ocegrid=t,useArea=true,maskSrc=true,maskDst=true  \
+    Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmgrid=t,ocegrid=u,useArea=true,maskSrc=true,maskDst=true  \
+    Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmgrid=t,ocegrid=v,useArea=true,maskSrc=true,maskDst=true  \
+    Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmgrid=c,ocegrid=t,useArea=true,maskSrc=true,maskDst=true   \
+   )
 
 ## ===========================================================================
@@ -77,21 +81,72 @@
 ## ===========================================================================
 SUBMIT_DIR=$(pwd)
-
+# Function to handle command parameters
+function read_Command {
+    # Decipher the command line to set bash variables 
+    local l_Debug="no" l_Element
+    while [[ ${1} = -* ]] ; do
+	case ${1} in
+	    ( -- ) shift ; break ;;
+	    ( -d | --debug ) l_Debug="true" ; shift ;;
+	esac
+    done
+    local l_Command=${1}
+    for l_Element in $(echo ${l_Command} | tr "," "\n" )
+    do
+	[[ "X${l_Debug}" = "Xtrue" ]] && echo ${l_Element}
+	eval export ${l_Element}
+    done
+}
+
+function setValues {
+    #
+    ocegrid=${ocegrid,,}
+    atmgrid=${atmgrid,,}
+    OCEGRID=${ocegrid^^}
+    ATMGRID=${atmgrid^^}
+
+    case ${Order} in
+	( 1st ) numOrder=1 ;;
+	( 2nd ) numOrder=2 ;;
+    esac
+    case ${Renormalize} in
+	( true )  NormName=Normalized   ;;
+	( false ) NormName=UnNormalized ;;
+    esac
+    case ${Quantity} in
+	( true )  QuantName=Integrated ;;
+	( false ) QuantName=Surfacic   ;;
+    esac
+    case ${useArea} in
+	( true )  AreaName=Area   ;;
+	( false ) AreaName=NoArea ;;
+    esac
+    
+    Suffix=${Order}Order_${NormName}_${QuantName}_${AreaName}
+
+    case ${Direction} in
+	( o2a )
+	src=${oce} ; SRC=${OCE} ; srcGrid=${ocegrid} ; srcDomainType=${oceDomainType} ; SRCGRID=${OCEGRID} ; srcArea=area_grid_${OCEGRID}
+	dst=${atm} ; DST=${ATM} ; dstGrid=${atmgrid} ; dstDomainType=${atmDomainType} ; DSTGRID=${ATMGRID} ; dstArea=aire
+	;; 
+	( a2o )
+	src=${atm} ; SRC=${ATM} ; srcGrid=${atmgrid} ; srcDomainType=${atmDomainType} ; SRCGRID=${ATMGRID} ; srcArea=aire
+	dst=${oce} ; DST=${OCE} ; dstGrid=${ocegrid} ; dstDomainType=${oceDomainType} ; DSTGRID=${OCEGRID} ; dstArea=area_grid_${OCEGRID}
+	;;
+    esac
+    echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName}  "${Norm}	     
+}
+    
 #
 # Defines computer
 # ================
-if [[ $(hostname) = curie*    ]] ; then arch=curie ; center=tgcc ; fi
 if [[ $(hostname) = irene*    ]] ; then arch=irene ; center=tgcc ; fi
-if [[ $(hostname) = lsce3005* ]] ; then arch=spip  ; center=spip ; fi
+if [[ $(hostname) = lsce*     ]] ; then arch=spip  ; center=spip ; fi
 
 PROGRAM=$(basename ${0})
 
 case ${arch} in
-     ( irene )
+    ( irene )
     set +vx
-    module purge
-    source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene
-    module load python/2.7.8
-    module load datadir/igcmg
     R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
     TMPDIR=${CCCWORKDIR}/TMP
@@ -99,4 +154,10 @@
     PROGRAM=${BRIDGE_MSUB_REQNAME}
     MPIRUN=ccc_mprun
+    source ${SUBMIT_DIR}/arch.env
+    module load nco
+    module load cdo
+    #source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene
+    module load python/2.7.8
+    module load datadir/igcmg
     module list
     ;;
@@ -119,13 +180,12 @@
 # Suffixes
 # ---------------------------------------------------------------------------
-Listocegrid=${ListOCEGRID,,}
 
 case ${OCE} in
-    ( *ORC* )         oce=orc ; oce_domain_type=curvilinear   ;;
+    ( *ORC* )         oce=orc ; oceDomainType=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   ;;
+    ( *dynamico*    ) atm=ico ; atmDomainType=unstructured  ;;
+    ( *ICO*         ) atm=ico ; atmDomainType=unstructured  ;;
+    ( *lmd* | *LMD* ) atm=lmd ; atmDomainType=rectilinear   ;;
 esac
 
@@ -143,4 +203,6 @@
 cp ${SUBMIT_DIR}/bin/interpol.exe    .
 cp ${SUBMIT_DIR}/*.py                .
+cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml   .
+cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   .
 
 cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  .
@@ -181,31 +243,42 @@
 ## NEMO T point towards ATM - 1st order
 ## ===========================================================================
-echo ${Green}"Initial case - ${OCE} T toward ${ATM} - 1stOrder - UnNormalized - Surfacic"${Norm}
-cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   iodef.xml
-Suffix=1stOrder_UnNormalized_Surfacic
+echo "Command parameters : ${Command}"
+read_Command ${DefaultValues}
+read_Command ${Command}
+setValues
+
+cp 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_read"]/file_definition/file[@id="file_src"]/field[@id="area_src"]'   -k name  -v area_grid_T
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${srcDomainType}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${dstDomainType}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity    -v false
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false
 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}_${Suffix}
-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="file_src"]/field[@id="area_source"]' -k name  -v area_grid_T
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${SRC} mask interpolated to ${DST}"
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${dstDomainType}
 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}_${Suffix}.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
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${srcDomainType}
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${dstDomainType}
+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_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.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
 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false
 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t false
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t false
 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v false
 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v false
-
-cp iodef.xml iodef_t${oce}_to_t${atm}_${Suffix}.xml
+python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v false
+
+cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml
 ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
 ln -fs ${ATM}_grid.nc              atm_grid.nc
 
-time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no
+time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea}
 ##
 ## Correct spurious values (extremes)
@@ -266,118 +339,4 @@
 [[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.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 normalize in ${ListNormalize} ; do
-	for quantity in ${ListQuantity} ; do
-	    for OCEGRID in ${ListOCEGRID} ; do
-		ocegrid=${OCEGRID,,}
-		
-		case ${normalize} in
-		    ( true )  NormName=Normalized  ;;
-		    ( false ) NormName=UnNormalized ;;
-		esac
-		case ${quantity} in
-		    ( true )  QuantName=Integrated ;;
-		    ( false ) QuantName=Surfacic ;;
-		esac
-		
-		Suffix=${order}Order_${NormName}_${QuantName}
-		
-		if [[ ! -f rmp_${ocegrid}${oce}_to_t${atm}_${Suffix}.nc ]] ; then
-		    
-		    echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}Order - normalize: ${normalize} - quantity: ${quantity}"${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}_${Suffix}
-		    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"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize}
-		    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${quantity}
- 		    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}_${Suffix}.nc
-		    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize}
-		    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity        -v ${quantity}
-		    
-		    cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${Suffix}.xml
-		    
-		    ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
-		    ln -fs ${ATM}_grid.nc              atm_grid.nc
-		    time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes
-		fi
-		
-	    done
-	done
-    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
-    for normalize in ${ListNormalize} ; do
-	for quantity in ${ListQuantity} ; do
-	    case ${normalize} in
-		( true )  NormName=Normalized  ;;
-		( false ) NormName=UnNormalized ;;
-	    esac
-	    case ${quantity} in
-		( true )  QuantName=Integrated ;;
-		( false ) QuantName=Surfacic ;;
-	    esac
-	    
-	    Suffix=${order}Order_${NormName}_${QuantName}
-	    
-	    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}   
-    	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize}
-    	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${quantity}
-	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize     -v ${normalize}
-	    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity        -v ${quantity}
-	    
-	    for OCEGRID in ${ListOCEGRID} ; do
-		ocegrid=${OCEGRID,,}
-		
-		echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}Order - normalize: ${normalize} - quantity: ${quantity}"${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}_${Suffix}
-		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}_${Suffix}.nc
-		cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${Suffix}.xml
-		
-		ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
-		ln -fs ${ATM}_grid.nc              atm_grid.nc
-		time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes
-		
-	    done
-	done
-    done
-done
 ##
 ## Creates mask of coastal OCE points
@@ -396,57 +355,75 @@
 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc
 
-##
-## ATM towards NEMO points - runoff
-## ===========================================================================
-cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml
-for normalize in ${ListNormalize} ; do
-    for quantity in ${ListQuantity} ; do
-	case ${normalize} in
-	    ( true )  NormName=Normalized  ;;
-	    ( false ) NormName=UnNormalized ;;
-	esac
-	case ${quantity} in
-	    ( true )  QuantName=Integrated ;;
-	    ( false ) QuantName=Surfacic ;;
-	esac
+
+##
+## Other weigths files
+## ===========================================================================
+# Loop on commands
+for Command in ${CommandList[@]}
+do
+    echo "Command parameters : ${Command}"
+    read_Command ${DefaultValues}
+    read_Command ${Command}
+    setValues
+    
+    ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
+    ln -fs ${ATM}_grid.nc              atm_grid.nc
+    
+    case ${Direction} in
+	( o2a )
+	cp iodef_oce_to_atm.xml iodef.xml
 	
-	Suffix=${order}Order_${NormName}_${QuantName}
+	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 mask_${DSTGRID} 
+	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 OceMask
 	
-	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} coastal 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}
-	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1
-	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"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize}
-	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'    -t ${quantity}
-	python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]'                         -k name  -v ${ATM}_grid_maskFrom_${OCE}
-	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 AtmCoastal
-	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 OceCoastal
-	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_o${atm}_to_c${oce}_${Suffix}
-	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_o${atm}_to_c${oce}_${Suffix}.nc
-	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize}
-	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity        -v ${quantity}
+	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_${SRCGRID}
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v area_grid_${SRCGRID}
+	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 OceMask
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]'   -k name -v aire
+	;;
+	( a2o )
+	cp iodef_atm_to_oce.xml iodef.xml
 	
-	cp iodef.xml iodef_o${atm}_to_c${oce}_${Suffix}.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 OceMask
+	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_${DSTGRID}
 	
-	ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
-	ln -fs ${ATM}_grid.nc              atm_grid.nc
-	time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes
-	
-	# Now we should divide weight par source (atm) grid area : run-off is a quantity/s integrated on the grid mox, not a flux 
-    done
+	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 OceMask
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name  -v aire
+	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_${DSTGRID}
+	python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]'   -k name  -v area_grid_${DSTGRID}
+	;;
+    esac
+    
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${dstDomainType}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${srcDomainType}
+    
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${srcDomainType}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${dstDomainType}
+    
+    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_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order       -v ${numOrder}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v ${Quantity}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v ${Renormalize}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v ${useArea}
+    
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                                 -k name -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'         -t "${SRC} mask interpolated to ${DST}"
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'     -t ${dstDomainType}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]'   -t ${srcDomainType}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${numOrder}   
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${Quantity}
+    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t ${useArea}
+    
+    cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml
+    time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea}
 done
-    ##
+
+##
 ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS)
 ## ===========================================================================
 for InFile in *.nc ; do
     OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc
-    if [[ ! -f ${OuFile} ]] ; then
-	ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile}
-    fi
+    [[ ! -f ${OuFile} ]] && ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile}
 done
 
@@ -573,6 +550,6 @@
 	ncatted --history \
 		--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}"   \
+		--attribute source_grid,global,o,c,"${oceDomainType}" \
+		--attribute dest_grid,global,o,c,"${atmDomainType}"   \
 		${rmpFile}	
 	;;
@@ -580,6 +557,6 @@
 	ncatted --history \
 		--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}"   \
+		--attribute source_grid,global,o,c,"${atmDomainType}" \
+		--attribute dest_grid,global,o,c,"${oceDomainType}"   \
 		${rmpFile}
 	;;
Index: /TOOLS/MOSAIX/check_conserv.py
===================================================================
--- /TOOLS/MOSAIX/check_conserv.py	(revision 4152)
+++ /TOOLS/MOSAIX/check_conserv.py	(revision 4153)
@@ -14,4 +14,7 @@
 ##  personal.
 ##
+#
+# python3 -i check_conserv.py --file dia_tORCA2.3_to_tLMD9695_1stOrder_Normalized_Surfacic_NoArea.nc --grids grids_ORCA2.3xLMD9695.nc --areas areas_ORCA2.3xLMD9695.nc --masks masks_ORCA2.3xLMD9695.nc --frac LMD9695_grid_maskFrom_ORCA2.3.nc
+#
 ## SVN information
 __Author__   = "$Author$"
@@ -21,9 +24,10 @@
 __HeadURL    = "$HeadURL$"
 
-import cdms2
+import netCDF4
 import numpy as np
 import glob
 import sys, argparse, textwrap
 import nemo
+import os
 
 # Creating a parser
@@ -50,8 +54,14 @@
 name_input = myargs.file
 
-# Determination des modeles
-Elements = myargs.file.split('_')
-
-#
+# Get dir and file
+InDir  =  os.path.dirname  (os.path.abspath(myargs.file))
+InFile =  os.path.basename (os.path.abspath(myargs.file))
+
+print ('InDir  : ' + InDir )
+print ('InFile : ' + InFile )
+
+Elements = InFile.split('_')
+
+# Get models
 Name_src = Elements[1][1:] ; Name_dst = Elements[3][1:]
 grid_src = Elements[1][0]  ; grid_dst = Elements[3][0]
@@ -84,18 +94,18 @@
 if Name_dst.count('ORC') : CplModel = Name_dst + 'x' + Name_src
 
-print ('CplModel : ' + CplModel )
-print ('Input file: ' + name_input )
+print ('CplModel   : ' + CplModel )
+print ('Input file : ' + name_input )
      
 # Coordonnees et masques
 if myargs.fracs == None :
-    if Name_src.count('ORC') : name_frc = Name_dst + '_grid_maskFrom_' + Name_src + '.nc'
-    if Name_dst.count('ORC') : name_frc = Name_src + '_grid_maskFrom_' + Name_dst + '.nc'
+    if Name_src.count('ORC') : name_frc = InDir + '/' + Name_dst + '_grid_maskFrom_' + Name_src + '.nc'
+    if Name_dst.count('ORC') : name_frc = InDir + '/' + Name_src + '_grid_maskFrom_' + Name_dst + '.nc'
 else:
     name_frc = myargs.fracs
 
 if myargs.guess :
-    n_grids =  'grids_' + CplModel + '.nc'
-    n_masks =  'masks_' + CplModel + '.nc'
-    n_areas =  'areas_' + CplModel + '.nc'
+    n_grids =  InDir + '/grids_' + CplModel + '.nc'
+    n_masks =  InDir + '/masks_' + CplModel + '.nc'
+    n_areas =  InDir + '/areas_' + CplModel + '.nc'
 else :
     n_grids = myargs.grids
@@ -104,34 +114,37 @@
 
 print ('Opening grids file: ' + n_grids )
-f_grids = cdms2.open ( n_grids )
+f_grids = netCDF4.Dataset ( n_grids )
 print ('Opening masks file: ' + n_masks )
-f_masks = cdms2.open ( n_masks )
+f_masks = netCDF4.Dataset  ( n_masks )
 print ('Opening areas file: ' + n_areas )
-f_areas = cdms2.open ( n_areas )
+f_areas = netCDF4.Dataset  ( n_areas )
 print ('Opening fracs file: ' + name_frc )   
-f_frac  = cdms2.open ( name_frc     )
-
-#
-msk_src = np.float64(1.0) - f_masks ( grid_src + name_src + '.msk', squeeze=True )
-lon_src = f_grids ( grid_src + name_src + '.lon', squeeze=True )
-lat_src = f_grids ( grid_src + name_src + '.lat', squeeze=True )
-if myargs.src_int : srf_src = np.ones ( (msk_src.shape), dtype=np.float64 )
-else              : srf_src = f_areas ( grid_src + name_src + '.srf', squeeze=True )
-
-#
-msk_dst = np.float64(1.0) - f_masks ( grid_dst + name_dst + '.msk', squeeze=True )
-lon_dst = f_grids ( grid_dst + name_dst + '.lon', squeeze=True )
-lat_dst = f_grids ( grid_dst + name_dst + '.lat', squeeze=True )
-if myargs.dst_int : srf_dst = np.ones ( (msk_dst.shape), dtype=np.float64)
-else              : srf_dst = f_areas ( grid_dst + name_dst + '.srf' )
+f_frac  = netCDF4.Dataset  ( name_frc     )
+
+#
+msk_src = np.float64(1.0) - f_masks.variables[ grid_src + name_src + '.msk'][:].squeeze()
+lon_src = f_grids.variables [grid_src + name_src + '.lon'][:].squeeze()
+lat_src = f_grids.variables [grid_src + name_src + '.lat'][:].squeeze()
+if myargs.src_int : srf_src = np.ones ( (msk_src.shape), dtype=np.float64 )[:]
+else              : srf_src = f_areas.variables [grid_src + name_src + '.srf'][:].squeeze()
+
+#
+msk_dst = np.float64(1.0) - f_masks.variables[grid_dst + name_dst + '.msk'][:]
+lon_dst = f_grids.variables [grid_dst + name_dst + '.lon'][:].squeeze()
+lat_dst = f_grids.variables [grid_dst + name_dst + '.lat'][:].squeeze()
+if myargs.dst_int : srf_dst = np.ones ( (msk_dst.shape), dtype=np.float64)[:]
+else              : srf_dst = f_areas.variables [grid_dst + name_dst + '.srf'][:].squeeze()
 
 #
 if name_src in ( 'ico', 'lmd' ) :
     if myargs.src_nofrac : frc_src = np.ones ( (msk_src.shape), dtype=np.float64)
-    else                 : frc_src = f_frac ( 'OceFrac', squeeze=True )
+    else                 : frc_src = f_frac.variables ['OceFrac'][:].squeeze()
+        
 if name_src == 'orc'     : frc_src = np.ones ( (msk_src.shape), dtype=np.float64)
+    
 if name_dst in ( 'ico', 'lmd' ) :
     if myargs.dst_nofrac : frc_dst = np.ones ( (msk_dst.shape), dtype=np.float64)
-    else                 : frc_dst = f_frac ( 'OceFrac', squeeze=True )
+    else                 : frc_dst = f_frac.variables['OceFrac'][:].squeeze()
+        
 if name_dst == 'orc'     : frc_dst = np.ones ( (msk_dst.shape), dtype=np.float64)
 
@@ -156,12 +169,12 @@
 
 print ( Name_src )
-print 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_src), np.max(msk_src), np.sum(msk_src) )
-print 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_src), np.max(frc_src), np.sum(frc_src) )
-print 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_src), np.max(srf_src), np.sum(srf_src) )
+print ( 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_src), np.max(msk_src), np.sum(msk_src) ) )
+print ( 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_src), np.max(frc_src), np.sum(frc_src) ) )
+print ( 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_src), np.max(srf_src), np.sum(srf_src) ) )
 
 print ( Name_dst )
-print 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_dst), np.max(msk_dst), np.sum(msk_dst) )
-print 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_dst), np.max(frc_dst), np.sum(frc_dst) )
-print 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_dst), np.max(srf_dst), np.sum(srf_dst) )
+print ( 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_dst), np.max(msk_dst), np.sum(msk_dst) ) )
+print ( 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_dst), np.max(frc_dst), np.sum(frc_dst) ) )
+print ( 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_dst), np.max(srf_dst), np.sum(srf_dst) ) )
 print (' ')
 print ( "Surfaces   : %14.6e %14.6e %11.3e"%( area_src, area_dst, (area_src-area_dst)/(area_src+area_dst)*0.5 ) )
@@ -169,5 +182,5 @@
 
 ##
-f_input = cdms2.open ( name_input )
+f_input = netCDF4.Dataset( name_input )
 # Loop over fields
 for num in np.arange (1, 7) :
@@ -177,6 +190,6 @@
 
     # Reading field
-    v_src = f_input ( name_src )
-    v_dst = f_input ( name_dst )
+    v_src = f_input [ name_src ][:]
+    v_dst = f_input [ name_dst ][:]
 
     # Compute integrals
Index: /TOOLS/MOSAIX/iodef_atm_to_oce.xml
===================================================================
--- /TOOLS/MOSAIX/iodef_atm_to_oce.xml	(revision 4152)
+++ /TOOLS/MOSAIX/iodef_atm_to_oce.xml	(revision 4153)
@@ -1,3 +1,7 @@
 <?xml version="1.0"?>
+
+<!-- Earth radius NEMO ra = 6371229 -->
+<!-- Earth radius LMDZ RA=6371229. -->
+
 <simulation>
 
@@ -9,8 +13,10 @@
       <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" /> 
+        <field id="area_src" name="aire"    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" /> 
+	<field id="mask_dst" name="mask_T"      operation="instant" domain_ref="domain_dst" /> 
+	<field id="area_dst" name="area_grid_T" operation="instant" domain_ref="domain_dst" /> 
       </file>
       
@@ -59,8 +65,10 @@
       <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" /> 
+	<field id="area_source"  name="aire"    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" />
+	<field id="mask_dest"  name="mask_T"      operation="instant" domain_ref="domain_dst" />
+	<field id="area_dest"  name="area_grid_T" operation="instant" domain_ref="domain_dst" />
       </file>
 
@@ -74,4 +82,5 @@
 	<variable name="normalization" type="string">none</variable>
 	<variable name="quantity"      type="string">none</variable>
+	<variable name="use_area"      type="string">none</variable>
 	<variable name="source_grid"   type="string">curvilinear</variable>
 	<variable name="dest_grid"     type="string">unstructured</variable>
@@ -102,11 +111,11 @@
 
     <domain_definition>
-      <domain id="domain_src" type="unstructured" >
+      <domain id="domain_src" type="unstructured" radius="6371229.0" >
 	<generate_rectilinear_domain/>
       </domain>
       
-      <domain id="domain_dst" type="curvilinear" prec="8" >
+      <domain id="domain_dst" type="curvilinear" prec="8" radius="6371229.0" >
 	<generate_rectilinear_domain/>
-	<interpolate_domain order="1" renormalize="false" quantity="false" write_weight="true" weight_filename="rmp_tatm_to_toce_1storder.nc"/>
+	<interpolate_domain order="1" renormalize="false" quantity="false" use_area="false" write_weight="true" weight_filename="rmp_tatm_to_toce.nc" />
       </domain>
     </domain_definition>
Index: /TOOLS/MOSAIX/iodef_oce_to_atm.xml
===================================================================
--- /TOOLS/MOSAIX/iodef_oce_to_atm.xml	(revision 4152)
+++ /TOOLS/MOSAIX/iodef_oce_to_atm.xml	(revision 4153)
@@ -8,9 +8,11 @@
 
       <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" /> 
+        <field id="mask_src"  name="maskutil_T"  operation="instant" domain_ref="domain_src" /> 
+        <field id="area_src"  name="area_grid_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" /> 
+        <field id="area_dst"  name="aire"    operation="instant" domain_ref="domain_dst" /> 
       </file>
       
@@ -58,9 +60,11 @@
 
       <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" /> 
+        <field id="mask_source"  name="maskutil_T"  operation="instant" domain_ref="domain_src" /> 
+        <field id="area_source"  name="area_grid_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" />
+	<field id="mask_dest"  name="OceMask" operation="instant" domain_ref="domain_dst" />
+	<field id="area_dest"  name="aire"    operation="instant" domain_ref="domain_dst" />
       </file>
 
@@ -74,4 +78,5 @@
 	<variable name="normalization" type="string">none</variable>
 	<variable name="quantity"      type="string">none</variable>
+	<variable name="use_area"      type="string">none</variable>
 	<variable name="source_grid"   type="string">curvilinear</variable>
 	<variable name="dest_grid"     type="string">unstructured</variable>
@@ -105,11 +110,11 @@
 
     <domain_definition>
-      <domain id="domain_src" type="curvilinear" >
+      <domain id="domain_src" type="curvilinear" radius="6371229.0" >
 	<generate_rectilinear_domain/>
       </domain>
       
-      <domain id="domain_dst" type="unstructured" prec="8" >
+      <domain id="domain_dst" type="unstructured" prec="8" radius="6371229.0" >
 	<generate_rectilinear_domain/>
-	<interpolate_domain order="1" renormalize="false" quantity="false" write_weight="true" weight_filename="rmp_toce_to_tatm_1storder.nc"/>
+	<interpolate_domain order="1" renormalize="false" quantity="false" use_area="false" write_weight="true" weight_filename="rmp_toce_to_tatm.nc" />
       </domain>
     </domain_definition>
Index: /TOOLS/MOSAIX/rangement.bash
===================================================================
--- /TOOLS/MOSAIX/rangement.bash	(revision 4152)
+++ /TOOLS/MOSAIX/rangement.bash	(revision 4153)
@@ -17,5 +17,5 @@
 # ============================================================
 
-for ATM in LMD144X142 LMD9695 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450
+for ATM in LMD144142 LMD9695 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450
 do
     for OCE in ORCA2.3 eORCA1.2 ORCA025
@@ -27,4 +27,5 @@
 	else
 	    echo "${ATM} : ${OCE} : ${Liste}"
+	    echo "${WORK_MOSAIC}/${OCE}x${ATM}"
 	    mkdir -p ${WORK_MOSAIC}/${OCE}x${ATM}
 	    mv ${Liste}  ${WORK_MOSAIC}/${OCE}x${ATM}
Index: /TOOLS/MOSAIX/src/MOSAIX/interpol.f90
===================================================================
--- /TOOLS/MOSAIX/src/MOSAIX/interpol.f90	(revision 4152)
+++ /TOOLS/MOSAIX/src/MOSAIX/interpol.f90	(revision 4153)
@@ -16,10 +16,10 @@
    INTEGER :: ni_src, nj_src !< Dimensions of the source grid
    INTEGER :: ni_dst, nj_dst !< Dimensions of the source grid
-   REAL (kind=rl), ALLOCATABLE :: imask_src (:,:), imask_dst (:,:)
+   REAL (kind=rl), ALLOCATABLE :: imask_src (:,:), imask_dst (:,:), area_src(:,:), area_dst(:,:)
    REAL (kind=rl), ALLOCATABLE :: lon_src(:,:), lat_src(:,:), field_src(:,:)
    LOGICAL, ALLOCATABLE :: lmask_src (:,:), lmask_dst (:,:)
    INTEGER :: nout = 0, jf
    CHARACTER (LEN=20) :: nchar, type_src, type_dst
-   LOGICAL :: l_mask_src = .TRUE. , l_mask_dst = .TRUE.
+   LOGICAL :: l_mask_src = .TRUE. , l_mask_dst = .TRUE., l_use_area = .FALSE.
    !
    REAL (kind=rl), PARAMETER :: rpi = ACOS ( -1.0_rl)
@@ -64,8 +64,10 @@
       CALL getarg ( ja, cmd_arg )
       SELECT CASE ( TRIM (cmd_arg) )
-      CASE ( '--mask_src=yes' ) ; l_mask_src = .TRUE.
-      CASE ( '--mask_src=no'  ) ; l_mask_src = .FALSE.
-      CASE ( '--mask_dst=yes' ) ; l_mask_dst = .TRUE.
-      CASE ( '--mask_dst=no'  ) ; l_mask_dst = .FALSE.
+      CASE ( '--mask_src=true'  ) ; l_mask_src = .TRUE.
+      CASE ( '--mask_src=false' ) ; l_mask_src = .FALSE.
+      CASE ( '--mask_dst=true'  ) ; l_mask_dst = .TRUE.
+      CASE ( '--mask_dst=false' ) ; l_mask_dst = .FALSE.
+      CASE ( '--use_area=true'  ) ; l_use_area = .TRUE.
+      CASE ( '--use_area=no'    ) ; l_use_area = .FALSE.
       END SELECT
    END DO
@@ -73,28 +75,29 @@
    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- mask_src : ', 1L)" ) rank, l_mask_src
    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- mask_dst : ', 1L)" ) rank, l_mask_dst
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- use_area : ', 1L)" ) rank, l_use_area
 
    !< Context interpol_read : read masks
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- debut interpol_read')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Starting interpol_read')" ) rank
    CALL xios_context_initialize  ("interpol_read", comm)
    CALL xios_get_handle          ("interpol_read", ctx_hdl)
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- set current context interpol_read')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Set current context interpol_read')" ) rank
    CALL xios_set_current_context (ctx_hdl)
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- close context definition interpol_read')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Close context definition interpol_read')" ) rank
    CALL xios_close_context_definition ()
 
    !< Read characteristics of the source grid
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_src')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_src')" ) rank
    CALL xios_get_domain_attr ("domain_src", ni=ni_src, nj=nj_src)
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_src ', 6I9)") rank, ni_src, nj_src
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_src ', 6I9)") rank, ni_src, nj_src
    ALLOCATE ( lon_src (ni_src, nj_src), lat_src (ni_src, nj_src) )
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src ', 6I9)") rank, SIZE (lon_src), &
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src ', 6I9)") rank, SIZE (lon_src), &
       &        SHAPE (lon_src), SIZE (lat_src), SHAPE (lat_src)
    !!
    !
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture type src ', 6I9)") rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading type src ', 6I9)") rank
    CALL xios_get_domain_attr ("domain_src", TYPE=type_src )
    SELECT CASE ( TRIM (type_src))
    CASE ( "rectilinear" )
-      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src rectilinear', 6I9)") rank
+      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src rectilinear', 6I9)") rank
       CALL xios_get_domain_attr ("domain_src", lonvalue_1d=lon_src(:,1), latvalue_1d=lat_src(1,:) )
       lon_src (:,:) = SPREAD ( lon_src(:,1), DIM=2, ncopies=nj_src)
@@ -102,18 +105,19 @@
    CASE default
       IF ( nj_src == 1 .AND. ni_src==1) THEN
-         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src 2D ', 6I9)") rank
+         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 2D ', 6I9)") rank
          CALL xios_get_domain_attr ("domain_src", lonvalue_2d=lon_src(:,:), latvalue_2d=lat_src(:,:) )
       ELSE IF ( nj_src == 1 ) THEN
-         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src 1D ', 6I9)") rank
+         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 1D ', 6I9)") rank
          CALL xios_get_domain_attr ("domain_src", lonvalue_1d=lon_src(:,1), latvalue_1d=lat_src(:,1) )
       ELSE
-         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src 2D ', 6I9)") rank
+         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 2D ', 6I9)") rank
          CALL xios_get_domain_attr ("domain_src", lonvalue_2d=lon_src(:,:), latvalue_2d=lat_src(:,:) )
       ENDIF
    END SELECT
+   
    !< Read mask on the source grid
    ALLOCATE ( imask_src (ni_src, nj_src), lmask_src (ni_src, nj_src) )
    IF ( l_mask_src ) THEN 
-      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field mask_src')" ) rank
+      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field mask_src')" ) rank
       CALL xios_recv_field ("mask_src", imask_src)
       lmask_src = .FALSE.
@@ -122,13 +126,23 @@
       imask_src (:,:) = 1 ; lmask_src (:,:) = .TRUE.
    ENDIF
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- counting mask_src : ', 1I8)" ) rank, COUNT(lmask_src)
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Counting mask_src : ', 1I8)" ) rank, COUNT(lmask_src)
+
+   !< Read area on the source grid
+   ALLOCATE ( area_src (ni_src, nj_src) )
+   IF ( l_use_area ) THEN
+      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field area_src')" ) rank
+      CALL xios_recv_field ("area_src", area_src)
+   ELSE
+      area_src (:,:) = 1
+   ENDIF
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Sum area_src : ', 2E15.3)" ) rank, SUM(area_src) !, SUM(area_src, mask=lmask_src)
    
    !< Read mask on the destination grid
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_dst')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_dst')" ) rank
    CALL xios_get_domain_attr ("domain_dst", ni=ni_dst, nj=nj_dst)
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_dst ', 6I7)") rank, ni_dst, nj_dst
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_dst ', 6I7)") rank, ni_dst, nj_dst
    ALLOCATE ( imask_dst (ni_dst, nj_dst), lmask_dst (ni_dst, nj_dst) )
    IF ( l_mask_dst ) THEN
-      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field mask_dst')" ) rank 
+      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field mask_dst')" ) rank 
       CALL xios_recv_field ("mask_dst", imask_dst)
       lmask_dst = .FALSE.
@@ -139,25 +153,39 @@
    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- counting mask_dst : ', 1I8)" ) rank, COUNT(lmask_dst)
 
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_read (1)')") rank
+   !< Read area on the destination grid
+   ALLOCATE ( area_dst (ni_dst, nj_dst) )
+   IF ( l_use_area ) THEN
+      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field area_dst')" ) rank 
+      CALL xios_recv_field ("area_dst", area_dst)
+   ELSE
+      area_dst (:,:) = 1.0
+   ENDIF
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Counting mask_dst : ', 2E15.3)" ) rank, SUM(area_dst) !, SUM(area_dst,mask=lmask_dst)
+
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_read (1)')") rank
    CALL xios_context_finalize ()
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_read (2)')") rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_read (2)')") rank
    
    !< Context interpol run : generates weights, interpolate mask from source to destination
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- debut interpol_run')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Starting interpol_run')" ) rank
    CALL xios_context_initialize  ("interpol_run", comm)
    CALL xios_get_handle          ("interpol_run", ctx_hdl)
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- set context interpol_run')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Set context interpol_run')" ) rank
    CALL xios_set_current_context (ctx_hdl)
 
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- get attributes domain_src')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Get attributes domain_src')" ) rank
    IF ( l_mask_src ) CALL xios_set_domain_attr ("domain_src", mask_2d=lmask_src)
+   IF ( l_use_area ) CALL xios_set_domain_attr ("domain_src", area   =area_src )
+   !CALL xios_set_domain_attr ("domain_src", radius= 6371229.0 )
    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- get attributes domain_src')" ) rank
    IF ( l_mask_dst ) CALL xios_set_domain_attr ("domain_dst", mask_2d=lmask_dst)
-
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- close context definition')" ) rank
+   IF ( l_use_area ) CALL xios_set_domain_attr ("domain_dst", area   =area_dst )
+   !CALL xios_set_domain_attr ("domain_dst", radius= 6371229.0 )
+   
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Close context definition')" ) rank
    CALL xios_close_context_definition ()
 
    CALL xios_update_calendar (1)
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- send field mask_src')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Send field mask_src')" ) rank
    CALL xios_send_field ("mask_src", imask_src)
 
@@ -166,5 +194,5 @@
 
    DO jf = 1, 6
-      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- working on test case ', 1I2.2)" ) rank, jf
+      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Working on test case ', 1I2.2)" ) rank, jf
       SELECT CASE ( jf)
       CASE ( 1) ; field_src (:,:) = REAL ( imask_src, kind=rl)
@@ -181,5 +209,5 @@
    !!<
    
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_run')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_run')" ) rank
    CALL xios_context_finalize ()
 
@@ -193,5 +221,5 @@
    CALL MPI_FINALIZE (ierr)
 
-   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fini')" ) rank
+   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- The end')" ) rank
 
 END PROGRAM interpol
Index: /TOOLS/MOSAIX/update_xml.py
===================================================================
--- /TOOLS/MOSAIX/update_xml.py	(revision 4152)
+++ /TOOLS/MOSAIX/update_xml.py	(revision 4153)
@@ -108,5 +108,8 @@
 
 if FileOut == None : FileOut = FileIn
-    
+
+## Remove white spaces at beginning and end of line
+Node = Node.rstrip().lstrip()
+
 ## Get XML tree from input file
 iodef = xml.etree.ElementTree.parse ( FileIn )
