Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh	(revision 452)
@@ -184,27 +184,18 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	cat  << END_MAIL > job_end.mail
+	status=failed
+    else
+	status=completed
+    fi
+
+    cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
-  Job started : ${PeriodDateBegin}
-  Job ended   : ${PeriodDateEnd}
-  Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
-END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-
-    fi
 
     if [ X${config_UserChoices_MailName} != X ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_cesium.ksh	(revision 452)
@@ -228,5 +228,11 @@
     fi
 
-    IGCM_sys_RshPost <<-EOF
+    if ( ${ExitFlag} ) ; then
+	status=failed
+    else
+	status=completed
+    fi
+
+    ssh mercure <<-EOF
     export LOGIN=${LOGIN}
     export config_UserChoices_JobName=${config_UserChoices_JobName}
@@ -236,30 +242,15 @@
     export R_SAVE=${R_SAVE}
     export SUBMIT_DIR=${SUBMIT_DIR}
-    export ExitFlag=${ExitFlag}
-
-    if ( ${ExitFlag} ) ; then
-	status=FAILED
+    export status=${status}
 
     cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs  and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
-  Job started : ${DateBegin}
-  Job ended   : ${DateEnd}
-  Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
-END_MAIL
-    fi
 
     if [ ! -z ${config_UserChoices_MailName} ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 452)
@@ -215,26 +215,17 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	cat  << END_MAIL > job_end.mail
+	status=failed
+    else
+	status=completed
+    fi
+    cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
-  Job started : ${PeriodDateBegin}
-  Job ended   : ${PeriodDateEnd}
-  Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
-END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    fi
 
     if [ ! -z ${config_UserChoices_MailName} ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 452)
@@ -203,26 +203,17 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	cat  << END_MAIL > job_end.mail
+	status=failed
+    else
+	status=completed
+    fi
+    cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
-  Job started : ${PeriodDateBegin}
-  Job ended   : ${PeriodDateEnd}
-  Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
-END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Ouput files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    fi
 
     if [ ! -z ${config_UserChoices_MailName} ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh	(revision 452)
@@ -206,26 +206,18 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	cat  << END_MAIL > job_end.mail
+	status=failed
+    else
+	status=completed
+    fi
+
+    cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
-  Job started : ${PeriodDateBegin}
-  Job ended   : ${PeriodDateEnd}
-  Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
-END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    fi
 
     if  [ X"${config_UserChoices_MailName}" != X ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh	(revision 452)
@@ -228,9 +228,11 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
+	status=failed
 	# Nothing fo now
     else
-	status=COMPLETED
-	ssh mercure /bin/ksh <<-EOF
+	status=completed
+    fi
+
+    ssh ${MASTER} /bin/ksh <<-EOF
     export LOGIN=${LOGIN}
     export config_UserChoices_JobName=${config_UserChoices_JobName}
@@ -240,13 +242,14 @@
     export R_SAVE=${R_SAVE}
     export SUBMIT_DIR=${SUBMIT_DIR}
+    export status=${status}
 
     cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
 
@@ -260,5 +263,4 @@
     rm -f job_end.mail
 EOF
-    fi
 
     if [ $? -gt 0 ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh	(revision 452)
@@ -237,26 +237,17 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	cat  << END_MAIL > job_end.mail
+	status=failed
+    else
+	status=completed
+    fi
+    cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
-  Job started : ${PeriodDateBegin}
-  Job ended   : ${PeriodDateEnd}
-  Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
-END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    fi
 
     if  [ X"${config_UserChoices_MailName}" != X ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 452)
@@ -231,26 +231,17 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	cat  << END_MAIL > job_end.mail
+	status=failed
+    else
+	status=completed
+    fi
+    cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} ${status} on supercomputer `hostname`.
   Job started : ${PeriodDateBegin}
   Job ended   : ${PeriodDateEnd}
   Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
-  Job started : ${DateBegin}
-  Job ended   : ${DateEnd}
-  Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
-END_MAIL
-    fi
 
     if [ ! -z ${config_UserChoices_MailName} ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_platine.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_platine.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_platine.ksh	(revision 452)
@@ -226,26 +226,17 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
+	status=failed
+    else
+	status=completed
+    fi
 	cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
-  Job started : ${PeriodDateBegin}
-  Job ended   : ${PeriodDateEnd}
-  Output files are available in ${R_SAVE}
-  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
-END_MAIL
-    else
-	status=COMPLETED
-	cat  << END_MAIL > job_end.mail
-Dear ${LOGIN},
-
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
-    fi
 
     if [ ! -z ${config_UserChoices_MailName} ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh	(revision 452)
@@ -251,5 +251,5 @@
 	i=0
 	while [ $i -ne $NB_ESSAI ] ; do
-            ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
+            ssh -t ${MASTER} ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
             status=$?
             if [ ${status} -ne 0 ];
@@ -286,9 +286,10 @@
 
     if ( ${ExitFlag} ) ; then
-	status=FAILED
-	# Nothing more at this point of time
+	status=failed
     else
-	status=COMPLETED
-	IGCM_sys_RshPost <<-EOF
+	status=completed
+    fi
+
+    ssh -t ${MASTER} ssh platine /bin/ksh <<-EOF
     export LOGIN=${LOGIN}
     export config_UserChoices_JobName=${config_UserChoices_JobName}
@@ -298,13 +299,14 @@
     export R_SAVE=${R_SAVE}
     export SUBMIT_DIR=${SUBMIT_DIR}
+    export status=${status}
 
     cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
-  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
   Job started : ${DateBegin}
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
-  Script files and Script Outputs are available in ${SUBMIT_DIR}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
 
@@ -318,5 +320,4 @@
     rm -f job_end.mail
 EOF
-    fi
 
     if [ $? -gt 0 ] ; then
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh	(revision 451)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ulam.ksh	(revision 452)
@@ -182,4 +182,43 @@
 
 #D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+    IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@
+    if ( $DEBUG_sys ) ; then
+       echo "IGCM_sys_SendMail :" $@
+    fi
+
+    if ( ${ExitFlag} ) ; then
+	status=failed
+    else
+	status=completed
+    fi
+	cat  << END_MAIL > job_end.mail
+Dear ${LOGIN},
+
+  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
+  Job started : ${DateBegin}
+  Job ended   : ${DateEnd}
+  Output files are available in ${R_SAVE}
+  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
+END_MAIL
+
+    if [ ! -z ${config_UserChoices_MailName} ] ; then
+	mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail
+    elif [ -f ~/.forward ] ; then
+	mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
+    fi
+
+    if [ $? -gt 0 ] ; then
+	echo "IGCM_sys_SendMail : erreur."
+	IGCM_debug_Exit "IGCM_sys_SendMail"
+    fi
+    IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
 #D-function IGCM_sys_Mkdir
 #D-* Purpose: Master locale mkdir command
