Index: TOOLS/MOSAIX/CreateWeightsMask.bash
===================================================================
--- TOOLS/MOSAIX/CreateWeightsMask.bash	(revision 4172)
+++ TOOLS/MOSAIX/CreateWeightsMask.bash	(revision 4186)
@@ -5,7 +5,6 @@
 #MSUB -eo
 #MSUB -n 16                 # Number of processors
-#MSUB -T 1800               # Time limit (seconds)
+#MSUB -T 7200               # Time limit (seconds)
 #MSUB -q skylake
-#MSUB -Q test
 #MSUB -p gen2212
 #MSUB -m work
@@ -45,5 +44,5 @@
 couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" )
 for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done
-export Norm=$(tput sgr0 )
+export Norm=$(tput sgr0)
 export Titre=${Bold}${Blue}
 
@@ -56,25 +55,31 @@
 echo ${Titre}"Defines models"${Norm}
 # ==============
-OCE=ORCA2.3
-#OCE=eORCA1.2
+#OCE=ORCA2.3
+OCE=eORCA1.2
 #OCE=eORCA025
 
 #ATM=ICO30
-#ATM=ICO40
+ATM=ICO40
 #ATM=ICO450
-ATM=LMD9695
+#ATM=LMD9695
 #ATM=LMD144142
 #ATM=LMD256256
 
-# Runoff parameter (LMDZ grids only)
-atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=1000.0
-
-if [[ ${OCE} = ORCA2.3  && ${ATM} = LMD9695   ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi
-if [[ ${OCE} = ORCA2.3  && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi
-if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD9695   ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi
-if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi
+echo ${Titre}"ATM model : ${ATM}"${Norm}
+echo ${Titre}"OCE model : ${OCE}"${Norm}
+
+# Runoff parameter. atmCoastWidth and oceCoastWidth in grid points, searchRadius in km
+atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=600.0
+runOff_atmQuantity=Quantity runOff_oceQuantity=Surfacic
+
+[[ ${ATM} = ICO*     ]] && atmCoastWidth=0 # Parameter relevant for LMD rectilinear grid only
+[[ ${ATM} = LMD*     ]] && atmCoastWidth=2
+[[ ${OCE} = ORCA2.3  ]] && oceCoastWidth=1
+[[ ${OCE} = eORCA1.2 ]] && oceCoastWidth=3
+[[ ${OCE} = eORCA025 ]] && oceCoastWidth=1
+
 
 # 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 )
+DefaultValues=( Direction=o2a,oceGrid=t,atmGrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false,Name=OceFrac )
 
 ## List of weights to build
@@ -98,30 +103,29 @@
 #   maskDst     : true to use the destination grid mask, false to use all grid points
 #
-# Classic cases 
-AtmOceFluxes=" Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # Heat and water fluxes
-OceAtmTemp="   Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # Temperature, sea-ice fraction, albedo
-AtmOceStressU="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO U point
-AtmOceStressV="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO V point
+# Classic cases for IPSLCM6
+AtmOceFluxes="  Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes
+OceAtmTemp="    Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=TempIceAlb" # Temperature, sea-ice fraction, albedo
+AtmOceStressU=" Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true,Name=WindStress" # Wind stress to NEMO U point
+AtmOceStressV=" Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true,Name=WindStress" # Wind stress to NEMO V point
+AtmOceQuantity="Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=t,oceGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=Quantity"   # e.g. runoff
 # Other cases
-OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # e.g. CO2 fluxes
-AtmOceTemp="   Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # e.g. T and S correction from DWL parametrization
-AtmOceCoastal="Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true"  # Runoff atm to oce, limited to oce coastal points
-
-CommandList=( ${AtmOceFluxes} Runoff Calving )
-
-#CommandList=( Runoff Calving ) #\
-#    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   \
-#    Calving \
-#    Runoff  \
-#    )
-
+OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=OceAtmFluxes" # e.g. CO2 fluxes
+AtmOceTemp="   Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=OceTemp" # e.g. T and S correction from DWL parametrization
+
+# Standard list for IPSLCM6
+#CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} Runoff Calving Grids )
+
+# More comprehesive list for IPSLCM6 with new features
+CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids )
+
+# Debugs
+#CommandList=( Runoff )
+#CommandList=( ${AtmOceFluxes} ${OceAtmTemp} Runoff Calving Grids )
+#CommandList=( Calving )
+#CommandList=( Grids )
 
 
 Comment="Preliminary attempt - Do not trust !"
-#Version
+Version="_v0"
 
 ## ===========================================================================
@@ -130,4 +134,5 @@
 ##
 ## ===========================================================================
+Tag="_MOSAIX"
 SUBMIT_DIR=$(pwd)
 
@@ -152,4 +157,7 @@
 function setValues {
     #
+    read_Command "Direction=None,Order=None,Quantity=None,Renormalize=None,atmGrid=None,oceGrid=None,useArea=None,maskSrc=None,maskDst=None"
+    read_Command ${1}
+    #
     oceGrid=${oceGrid,,} ; atmGrid=${atmGrid,,}
     OCEGRID=${oceGrid^^} ; ATMGRID=${atmGrid^^}
@@ -171,6 +179,10 @@
 	( false ) AreaName=NoArea ;;
     esac
-    
-    Suffix=${Order}Order_${NormName}_${QuantName}_${AreaName}
+
+    if [[ "${Name}" != "None" ]] ; then
+	Suffix=${Name}
+    else
+	Suffix=${Order}Order_${NormName}_${QuantName}_${AreaName}
+    fi
 
     case ${Direction} in
@@ -184,7 +196,8 @@
 	;;
     esac
-    echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName}  "${Norm}	     
+    echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName}  "${Norm}
+    echo ${Green}"Suffix : ${Suffix}"${Norm}
 }
-    
+
 #
 # Defines computer
@@ -203,5 +216,5 @@
     PROGRAM=${BRIDGE_MSUB_REQNAME}
     MpiRun="time ccc_mprun"
-    PyRun="ccc_mprun -n 1"
+    PyRun="time ccc_mprun -n 1"
     source ${SUBMIT_DIR}/arch.env
     module load nco
@@ -263,31 +276,31 @@
 ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc             ${ATM}_grid_${FMT_OASIS}.nc
 #
-echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm}
-# --------------------------------------------------------------------------------------------------------
-cat <<EOF >add_c_grid.nco
-defdim("x_grid_C", \$x_grid_T.size) ;
-defdim("y_grid_C", \$y_grid_T.size) ;
-defdim("nvertex_grid_C",  4)         ;
-nav_lon_grid_C[y_grid_C,x_grid_C]    = nav_lon_grid_T(:,:)    ;
-nav_lat_grid_C[y_grid_C,x_grid_C]    = nav_lat_grid_T(:,:)    ;
-bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ;
-bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ;
-mask_C[y_grid_C,x_grid_C]            = maskutil_T(:,:)        ; 
-area_grid_C[y_grid_C,x_grid_C]       = area_grid_T(:,:)       ;
-EOF
-
-ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc
-ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc
-ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc
-ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C       tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
-ncks --history --append    --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
-ncks --history --append    --variable area_grid_C             tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
-
-ncks --history --append C_${OCE}_coordinates_mask.nc            ${OCE}_coordinates_mask.nc
-rm C_${OCE}_coordinates_mask.nc
-
-ncks --history --overwrite --fl_fmt=${FMT_OASIS} ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc
-
-ls -al
+# echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm}
+# # --------------------------------------------------------------------------------------------------------
+# cat <<EOF >add_c_grid.nco
+# defdim("x_grid_C", \$x_grid_T.size) ;
+# defdim("y_grid_C", \$y_grid_T.size) ;
+# defdim("nvertex_grid_C",  4)         ;
+# nav_lon_grid_C[y_grid_C,x_grid_C]    = nav_lon_grid_T(:,:)    ;
+# nav_lat_grid_C[y_grid_C,x_grid_C]    = nav_lat_grid_T(:,:)    ;
+# bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ;
+# bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ;
+# mask_C[y_grid_C,x_grid_C]            = maskutil_T(:,:)        ; 
+# area_grid_C[y_grid_C,x_grid_C]       = area_grid_T(:,:)       ;
+# EOF
+
+# ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc
+# ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc
+# ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc
+# ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C       tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
+# ncks --history --append    --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc
+# ncks --history --append    --variable area_grid_C             tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 
+
+# ncks --history --append C_${OCE}_coordinates_mask.nc            ${OCE}_coordinates_mask.nc
+# rm C_${OCE}_coordinates_mask.nc
+
+# ncks --history --overwrite --fl_fmt=${FMT_OASIS} ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc
+
+# ls -al
 
 ##
@@ -295,7 +308,5 @@
 ## ===========================================================================
 echo "Command parameters : ${Command}"
-read_Command ${DefaultValues}
-read_Command ${Command}
-setValues
+setValues ${DefaultValues}
 
 cp iodef_oce_to_atm.xml   iodef.xml
@@ -416,11 +427,8 @@
 do
     echo "Command parameters : ${Command}"
-    read_Command ${DefaultValues}
-    read_Command ${Command}
-
+    setValues ${Command}
     if [[ ${Command} = "Runoff"  ]] ; then okRunoff=yes  ; continue ; fi
     if [[ ${Command} = "Calving" ]] ; then okCalving=yes ; continue ; fi
-    
-    setValues
+    if [[ ${Command} = "Grids"   ]] ; then okGrids=yes   ; continue ; fi
     
     ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc
@@ -620,8 +628,9 @@
 done
 
+ls
 ##
 echo ${Titre}"Add missing variables in rmp files"${Norm}
 ## ===========================================================================
-for $(ls rmpFile in rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc* 2>/dev/null) ; do
+for rmpFile in $(ls rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc 2>/dev/null) ; do
     echo ${rmpFile}
     a_to_o=false ; o_to_a=false
@@ -760,8 +769,8 @@
 
 ##
+## ============================================================================
 echo ${Titre}"Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc"${Norm}
-## ============================================================================
-bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM}
-
+cp ${SUBMIT_DIR}/CreateOasisGrids.bash .
+bash CreateOasisGrids.bash --oce ${OCE} --atm ${ATM}
 
 
@@ -769,10 +778,12 @@
 echo ${Titre}"Runoff weights"${Norm}
 ## ===========================================================================
-if [[ "X${okRunoff}" = "Xyes" && "${atm}" = "lmd" ]] ; then
+#if [[ "X${okRunoff}" = "Xyes" && "${atm}" = "lmd" ]] ; then
+if [[ "X${okRunoff}" = "Xyes" ]] ; then
     ${PyRun} python3 -u cotes_etal.py --oce=${OCE} --atm=${ATM} \
 	      --atmCoastWidth=${atmCoastWidth} --oceCoastWidth=${oceCoastWidth} --searchRadius=${searchRadius} \
 	      --grids=grids_${OCE}x${ATM}.nc --areas=areas_${OCE}x${ATM}.nc --masks=masks_${OCE}x${ATM}.nc \
-	      --o2a=${ATM}_grid_maskFrom_${OCE}.nc --output=rmp_t${atm}_to_t${oce}_runoff_${FMT_OASIS}.nc \
-              --fmt=${FMT_OASIS}
+	      --o2a=${ATM}_grid_maskFrom_${OCE}.nc --output=rmp_t${atm}_to_t${oce}_runoff_${runOff_atmQuantity}_to_${runOff_oceQuantity}_${FMT_OASIS}.nc \
+              --fmt=${FMT_OASIS} \
+	      --atmQuantity=${runOff_atmQuantity} --oceQuantity=${runOff_oceQuantity}
 fi
 
@@ -783,13 +794,12 @@
     case ${OCE} in
 	( eORCA025 )
-	cp ${R_IN}/OCE/NEMO/ORCA025_LIM3_PISCES/v3.6_stable/eORCA_R025_runoff_v1.1.nc .
-	${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_full_${FMT_OASIS}.nc     --fmt=${FMT_OASIS} \
-		  --oce=${OCE} --atm=${ATM} --type=full     --dir=.
+	# cp ${R_IN}/OCE/NEMO/ORCA025_LIM3_PISCES/v3.6_stable/eORCA_R025_runoff_v1.1.nc .
+	cp /ccc/work/cont003/gencmip6/deshayej/eORCA_R025_runoff_v1.2.nc .
 	${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth_${FMT_OASIS}.nc  --fmt=${FMT_OASIS} \
-		  --oce=${OCE} --atm=${ATM} --type=nosouth  --dir=.  --repartition_file=eORCA_R025_runoff_v1.1.nc
+		  --oce=${OCE} --atm=${ATM} --type=nosouth  --dir=. 
 	${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg_${FMT_OASIS}.nc  --fmt=${FMT_OASIS} \
-		  --oce=${OCE} --atm=${ATM} --type=iceberg  --dir=.  --repartition_file=eORCA_R025_runoff_v1.1.nc --repartition_var=sornficbisf
+		  --oce=${OCE} --atm=${ATM} --type=iceberg  --dir=.  --repartition_file=eORCA_R025_runoff_v1.2.nc --repartition_var=Icb_flux
 	${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \
-		  --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=.  --repartition_file=eORCA_R025_runoff_v1.1.nc --repartition_var=sofwfisf
+		  --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=.  --repartition_file=eORCA_R025_runoff_v1.2.nc --repartition_var=sornfisf
 	;;
 	
@@ -827,8 +837,9 @@
 done
 
-cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR}
-cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR}
-cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR}
-
+if [[ "X${okGrids}" = "Xyes" ]] ; then
+    cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR}
+    cp grids_${OCE}x${ATM}.nc ${SUBMIT_DIR}
+    cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR}
+fi
 
 ##
@@ -892,5 +903,5 @@
 EOF
 
-cp README.txt ${SUBMIT_DIR}/README_${OCE}x${ATM}.txt
+cp README.txt ${SUBMIT_DIR}/README_${OCE}x${ATM}_MOSAIX.txt
 
 ## ===========================================================================
