Index: /trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1150)
@@ -95,6 +95,7 @@
   # Define STORAGE : Dedicated to small/medium files
   # Define R_OUT   : Output tree located on ARCHIVE
+  # Define R_BUF   : Output tree located on STORAGE (files waiting treatment, or file lcoation when SpaceName=!PROD)
   # Define R_FIG   : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files)
-  # Define R_BUF   : USELESS and DEPRECATED output tree.
+  # Define R_TMP   : A temporary space used by IGCM_debug_send_AMQP_msg__MAILTUNNEL. Must be persistent in between jobs
   IGCM_sys_defineArchives
 
@@ -1262,4 +1263,8 @@
       fi
     fi
+
+    # To be sure we flush message buffer and clean up behind us before the end of the simulation
+    FlushAMQP=TRUE
+
   else
     #=================#
@@ -1307,7 +1312,4 @@
   fi
 
-  # To be sure we flush message buffer before exiting the job
-  FlushAMQP=TRUE
-
   IGCM_debug_PopStack "IGCM_config_Finalize"
 }
Index: /trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh	(revision 1150)
@@ -131,26 +131,21 @@
   b64_encoded_msg=$1
 
-  # R_TMP point to RUN_DIR_PATH on Ada and on /tmp otherwise
-  buffer=${R_TMP}/buffer.$$
   mail_recipient="superviseur@ipsl.jussieu.fr"
   send_messages=0
   mail_frequency=3600 # in seconds
   # use to keep track when was last mail sent (maybe to be replaced with global variable)
-  last_mail_date__file=${R_TMP}/stamp.$$
+  last_mail_date__file=${R_BUF}/.stamp.${config_UserChoices_TagName}.${config_UserChoices_JobName}
+  # use to accumulate messages before sending them
+  buffer=${R_BUF}/.buffer.${config_UserChoices_TagName}.${config_UserChoices_JobName}
 
   # init
   if [ ! -f "${buffer}" ]; then
-    touch "${buffer}"
-  fi
-
-  # retrieve pending messages number
-  messages_count=$( wc -l ${buffer} | gawk {'print $1'} )
+    touch ${buffer}
+  fi
 
   if [ ! -f "${last_mail_date__file}" ]; then
-    # if we are here, it means no mail has been sent yet
-    # send the first mail
-    [ ${messages_count} -gt 0 ] && send_messages=1
+    touch ${last_mail_date__file}
   else
-     # compute last time the file was changed (in seconds)
+    # compute last time the file was changed (in seconds)
     seconds_since_last_mail=$(( $(date +%s) - $(stat -c %Y ${last_mail_date__file}) ))
     # send message when exceeding threshold
@@ -169,9 +164,15 @@
     touch ${last_mail_date__file}                                      # memorize last mail date
     initBigBro=false
-  elif ( [ ${send_messages} -eq 1 ] || [ X${FlushAMQP} = XTRUE ] ) ; then
+  elif [ ${send_messages} -eq 1 ] ; then
     #echo $(date +"%Y-%m-%dT%H:%M:%S.%N%z") >> ${SUBMIT_DIR}/mail.txt
     mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
-    rm -f $buffer ; touch ${buffer}                                    # clear buffer
+    rm -f ${buffer} ; touch ${buffer}                                  # flush the buffer
     touch ${last_mail_date__file}                                      # memorize last mail date
+  fi
+
+  if [ X${FlushAMQP} = XTRUE ] ; then
+    mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
+    rm -f ${buffer}                                                    # cleaning behind us
+    rm -f ${last_mail_date__file}                                      # cleaning behind us
   fi
 
@@ -297,12 +298,13 @@
     fi
 
-    if [ X${ActivateBigBro} = Xtrue ] ; then
-      # RabbitMQ message code "PUSHSTACK"
-      code=2000
-      # RabbitMQ message body
-      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${IGCM_debug_Stack[0]}\",\"arguments\":[\"${IGCM_debug_StackArgs[0]}\"],\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
-      # Fill the rabbitMQ queue
-      IGCM_debug_sendAMQP
-    fi
+    # Unplugged message 2000 handling for now. To ease downstream treatment.
+    #if [ X${ActivateBigBro} = Xtrue ] ; then
+    #  # RabbitMQ message code "PUSHSTACK"
+    #  code=2000
+    #  # RabbitMQ message body
+    #  Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${IGCM_debug_Stack[0]}\",\"arguments\":[\"${IGCM_debug_StackArgs[0]}\"],\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
+    #  # Fill the rabbitMQ queue
+    #  IGCM_debug_sendAMQP
+    #fi
 
     # Increment LenStack
@@ -513,12 +515,13 @@
       fi
 
-      if [ X${ActivateBigBro} = Xtrue ] ; then
-        # RabbitMQ message code "POPSTACK"
-        code=3000
-        # RabbitMQ message body
-        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${command}\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
-        # Fill the rabbitMQ queue
-        IGCM_debug_sendAMQP
-      fi
+      # Unplugged message 3000 handling for now. To ease downstream treatment.
+      #if [ X${ActivateBigBro} = Xtrue ] ; then
+      #  # RabbitMQ message code "POPSTACK"
+      #  code=3000
+      #  # RabbitMQ message body
+      #  Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${command}\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
+      #  # Fill the rabbitMQ queue
+      #  IGCM_debug_sendAMQP
+      #fi
     fi
 
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh	(revision 1150)
@@ -211,8 +211,4 @@
   #- R_BUF (ONLY FOR double copy an scratch)
   R_BUF=${WORKDIR}/IGCM_OUT
-
-  #====================================================
-  #- R_TMP (point a space acting as /tmp)
-  R_TMP=${RUN_DIR_PATH}
 
   IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 1150)
@@ -245,8 +245,4 @@
   #- R_BUF (ONLY FOR double copy an scratch)
   R_BUF=${SCRATCHDIR}/IGCM_OUT
-
-  #====================================================
-  #- R_TMP (point a space acting as /tmp)
-  R_TMP=/tmp
 
   IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 1150)
@@ -188,8 +188,4 @@
   #- R_BUF (ONLY FOR double copy an scratch)
   R_BUF=${STORAGE}/IGCM_OUT
-
-  #====================================================
-  #- R_TMP (point a space acting as /tmp)
-  R_TMP=/tmp
 
   IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 1150)
@@ -196,8 +196,4 @@
   #- R_BUF (ONLY FOR double copy an scratch)
   R_BUF=${WORKDIR}/IGCM_OUT
-
-  #====================================================
-  #- R_TMP (point a space acting as /tmp)
-  R_TMP=/tmp
 
   IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 1149)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 1150)
@@ -198,8 +198,4 @@
   #- R_BUF (ONLY FOR double copy an scratch)
   R_BUF=${STORAGE}/IGCM_OUT
-
-  #====================================================
-  #- R_TMP (point a space acting as /tmp)
-  R_TMP=/tmp
 
   IGCM_debug_Print 1 "R_OUT has been defined = ${R_OUT}"
