Index: trunk/libIGCM/AA_job
===================================================================
--- trunk/libIGCM/AA_job	(revision 1188)
+++ trunk/libIGCM/AA_job	(revision 1189)
@@ -241,5 +241,5 @@
 # Activate BigBrother so as to supervise this simulation
 # ------------------------------------------------------------------
-IGCM_debug_ActivateBigBro
+IGCM_debug_BigBro_Initialize
 
 #D-
Index: trunk/libIGCM/AA_metrics_LMDZ
===================================================================
--- trunk/libIGCM/AA_metrics_LMDZ	(revision 1188)
+++ trunk/libIGCM/AA_metrics_LMDZ	(revision 1189)
@@ -118,4 +118,9 @@
 IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
 
+# ------------------------------------------------------------------
+# Activate BigBrother so as to supervise this job
+# ------------------------------------------------------------------
+IGCM_debug_BigBro_Initialize
+
 #==================================
 # Then set up several directories
@@ -181,2 +186,7 @@
 # Clean RUN_DIR_PATH (necessary for cesium and titane only)
 IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Finalize BigBrother to inform that the jobs end
+# ------------------------------------------------------------------
+IGCM_debug_BigBro_Finalize
Index: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1188)
+++ trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1189)
@@ -1248,4 +1248,5 @@
     # End of entire simulation #
     #==========================#
+    simulationIsOver=true
 
     # Mail notification
@@ -1256,22 +1257,9 @@
     IGCM_debug_Print 1 "Normal End of computation."
 
-    if ( $DEBUG_debug ) ; then
-      if [ X${ActivateBigBro} = Xtrue ] ; then
-        # RabbitMQ message code "END OF SIMULATION"
-        code=0100
-        # RabbitMQ message body
-        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
-        # Fill the rabbitMQ queue
-        IGCM_debug_sendAMQP
-      fi
-    fi
-
-    # To be sure we flush message buffer and clean up behind us before the end of the simulation
-    FlushAMQP=TRUE
-
   else
     #=================#
     # Submit next job #
     #=================#
+    simulationIsOver=false
 
     IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
@@ -1291,10 +1279,4 @@
   fi
 
-  # Supress Non Deleted Boundary files
-  #if [ ${DRYRUN} -le 2 ] ; then
-  #  IGCM_comp_DelFixeBoundaryFiles
-  #  ls -la
-  #fi
-
   # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_JobName}.${$}
   # Only for production run (No clean up in DEV or DEB mode)
@@ -1303,15 +1285,6 @@
   [ X${JobType} = XRUN ] && IGCM_sys_RmRunDir -rf ${RUN_DIR_PATH}
 
-  if ( $DEBUG_debug ) ; then
-    # Inform the rabbitMQ queue
-    if [ X${ActivateBigBro} = Xtrue ] ; then
-      # RabbitMQ message code "WAITING"
-      code=1100
-      # RabbitMQ message body
-      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
-      # Fill the rabbitMQ queue
-      IGCM_debug_sendAMQP
-    fi
-  fi
+  # Inform the rabbitMQ queue
+  IGCM_debug_BigBro_Finalize
 
   IGCM_debug_PopStack "IGCM_config_Finalize"
Index: trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh
===================================================================
--- trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh	(revision 1188)
+++ trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh	(revision 1189)
@@ -171,5 +171,5 @@
   fi
 
-  if [ X${FlushAMQP} = XTRUE ] ; then
+  if ( ${FlushAMQP} ) ; then
     mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
     rm -f ${buffer}                                                    # cleaning behind us
@@ -325,8 +325,8 @@
     fi
 
-    # Unplugged message 2000 handling for now. To ease downstream treatment.
+    # Unplugged message 4000 handling for now. To ease downstream treatment.
     #if [ X${ActivateBigBro} = Xtrue ] ; then
     #  # RabbitMQ message code "PUSHSTACK"
-    #  code=2000
+    #  code=4000
     #  # 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" )\"}" )
@@ -530,5 +530,5 @@
       if [ X${ActivateBigBro} = Xtrue ] ; then
         # RabbitMQ message code "ERROR HAS BEEN TRIGGERED"
-        code=9000
+        code=4900
         # 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" )\"}" )
@@ -542,8 +542,8 @@
       fi
 
-      # Unplugged message 3000 handling for now. To ease downstream treatment.
+      # Unplugged message 4100 handling for now. To ease downstream treatment.
       #if [ X${ActivateBigBro} = Xtrue ] ; then
       #  # RabbitMQ message code "POPSTACK"
-      #  code=3000
+      #  code=4100
       #  # 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" )\"}" )
@@ -570,9 +570,9 @@
 
 #D-#==================================================================
-#D-function IGCM_debug_ActivateBigBro
+#D-function IGCM_debug_BigBro_Initialize
 #D-* Purpose: switch rabbitMQ on
 #D-
-function IGCM_debug_ActivateBigBro {
-  IGCM_debug_PushStack "IGCM_debug_ActivateBigBro"
+function IGCM_debug_BigBro_Initialize {
+  IGCM_debug_PushStack "IGCM_debug_BigBro_Initialize"
 
 # Message type standard fields:
@@ -586,19 +586,39 @@
     jobuid=$(uuidgen)
 
-    if ( ${FirstInitialize} ) ; then
-      # RabbitMQ message code "BEGIN A SIMULATION"
-      code=0000
-      # create and persist a unique id for this simulation
-      simuid=$(uuidgen)
-      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration simuid ${simuid}
-      # Standard fields for the first message
-      genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"activity\":\"IPSL\",\"name\":\"${config_UserChoices_JobName}\",\"cumulPeriod\":\"${CumulPeriod}\",\"experiment\":\"${config_UserChoices_ExperimentName}\",\"space\":\"${config_UserChoices_SpaceName}\",\"model\":\"${config_UserChoices_TagName}\",\"startDate\":\"${config_UserChoices_DateBegin}\",\"endDate\":\"${config_UserChoices_DateEnd}\",\"login\":\"${LOGIN}\",\"centre\":\"${CENTER}\",\"machine\":\"${MASTER}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
-      # RabbitMQ message body with specific fields associated message codes treated here
-      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
-      # Fill the rabbitMQ queue (the config.card in use will be sent)
-      IGCM_debug_sendAMQP activate
-    else
-      # RabbitMQ message code "A NEW JOB IS RUNNING PART OF A SIMULATION"
-      code=1000
+    if [ X${TaskType} = Xcomputing ]; then
+      if ( ${FirstInitialize} ) ; then
+        # RabbitMQ message code "BEGIN A SIMULATION"
+        code=0000
+        # create and persist a unique id for this simulation
+        simuid=$(uuidgen)
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration simuid ${simuid}
+        # Standard fields for the first message
+        genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"activity\":\"IPSL\",\"name\":\"${config_UserChoices_JobName}\",\"cumulPeriod\":\"${CumulPeriod}\",\"experiment\":\"${config_UserChoices_ExperimentName}\",\"space\":\"${config_UserChoices_SpaceName}\",\"model\":\"${config_UserChoices_TagName}\",\"startDate\":\"${config_UserChoices_DateBegin}\",\"endDate\":\"${config_UserChoices_DateEnd}\",\"login\":\"${LOGIN}\",\"centre\":\"${CENTER}\",\"machine\":\"${MASTER}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
+        # RabbitMQ message body with specific fields associated message codes treated here
+        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
+        # Fill the rabbitMQ queue (the config.card in use will be sent)
+        IGCM_debug_sendAMQP activate
+      else
+        # RabbitMQ message code "A NEW COMPUTING JOB IS RUNNING PART OF A SIMULATION"
+        code=1000
+        # retrieve this simulation's unique id
+        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration simuid
+        simuid=${run_Configuration_simuid}
+        # Using standard fields for message others than the first one. Still subject to change
+        genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"cumulPeriod\":\"${CumulPeriod}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
+        # RabbitMQ message body with specific fields associated message codes treated here
+        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
+        # Fill the rabbitMQ queue
+        IGCM_debug_sendAMQP
+      fi
+
+      # NOT VERY NICE BUT ... IT WORKS
+      # Be sure that the genericSimulationID will be small from now on
+      # Using standard fields for messages others than the first one. Still subject to change
+      genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"cumulPeriod\":\"${CumulPeriod}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
+
+    elif [ X${TaskType} = Xpost-processing ]; then
+      # RabbitMQ message code "A NEW POST-PROCESSING JOB IS RUNNING PART OF A SIMULATION"
+      code=2000
       # retrieve this simulation's unique id
       IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration simuid
@@ -611,14 +631,49 @@
       IGCM_debug_sendAMQP
     fi
-
-    # NOT VERY NICE BUT ... IT WORKS
-    # Be sure that the genericSimulationID will be small from now on
-    # Using standard fields for messages others than the first one. Still subject to change
-    genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"cumulPeriod\":\"${CumulPeriod}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
-
     # Turn the flag on
     ActivateBigBro=true
-  fi
-  IGCM_debug_PopStack "IGCM_debug_ActivateBigBro"
+    # Dont flush by default
+    FlushAMQP=false
+  fi
+  IGCM_debug_PopStack "IGCM_debug_BigBro_Initialize"
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_BigBro_Finalize
+#D-* Purpose: Finalize rabbitMQ messages exchanges
+#D-
+function IGCM_debug_BigBro_Finalize {
+  IGCM_debug_PushStack "IGCM_debug_BigBro_Finalize"
+
+  # Message type standard fields:
+  # https://github.com/Prodiguer/prodiguer-docs/wiki/MQ-Standard-Message-Fields
+
+  # Message type dictionnary and custom fields:
+  # https://github.com/Prodiguer/prodiguer-docs/wiki/Monitoring-Message-Dictionary
+
+  if ( $DEBUG_debug ) ; then
+    if [ X${ActivateBigBro} = Xtrue ] ; then
+      if [ X${TaskType} = Xcomputing ]; then
+        if ( ${simulationIsOver} ) ; then
+          # RabbitMQ message code "SIMULATION ENDS"
+          code=0100
+          FlushAMQP=true
+        else
+          # RabbitMQ message code "COMPUTING JOB ENDS"
+          code=1100
+        fi
+      elif [ X${TaskType} = Xpost-processing ]; then
+        # RabbitMQ message code "POST-PROCESSING JOB ENDS"
+        code=2100
+        FlushAMQP=true
+      fi
+      # RabbitMQ message body
+      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
+      # Fill the rabbitMQ queue
+      IGCM_debug_sendAMQP
+    fi
+  fi
+  
+  IGCM_debug_PopStack "IGCM_debug_BigBro_Finalize"
 }
 
@@ -663,5 +718,5 @@
       Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
       # To be sure we flush message buffer and clean up behind us before the end of the simulation
-      FlushAMQP=TRUE
+      FlushAMQP=true
       # Fill the rabbitMQ queue
       IGCM_debug_sendAMQP
