Index: /trunk/libIGCM/AA_job
===================================================================
--- /trunk/libIGCM/AA_job	(revision 1050)
+++ /trunk/libIGCM/AA_job	(revision 1051)
@@ -166,10 +166,10 @@
 #D-
 #D--------------------------------------------------------------------==
-#D- 0. SYSTEM ENVIRONMENT
-#D-    - Define variables for Number of processors
-#D-    - Define MPI variables
-#D-    - Define batch scheduler variables
-#D-    - Source IGCM Library
-#D-    - Get RESOLution in .resol file (temporary)
+#D- 0.0 SYSTEM ENVIRONMENT
+#D-     - Define variables for Number of processors
+#D-     - Define MPI variables
+#D-     - Define batch scheduler variables
+#D-     - Source IGCM Library
+#D-     - Get RESOLution in .resol file (temporary)
 #D--------------------------------------------------------------------==
 
@@ -200,4 +200,20 @@
 #D-
 #D--------------------------------------------------------------------==
+#D- 0.1 COMMON ENVIRONMENT
+#D-     - Read libIGCM compatibility version in config.card
+#D-     - Read UserChoices section
+#D-     - Read Ensemble section
+#D-     - Read Post section
+#D-     - Define all netcdf output directories
+#D--------------------------------------------------------------------==
+IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
+
+# ------------------------------------------------------------------
+# Activate BigBrother so as to supervise this simulation
+# ------------------------------------------------------------------
+IGCM_debug_ActivateBigBro
+
+#D-
+#D--------------------------------------------------------------------==
 #D- 1. INITIALIZE CONFIGURATION
 #D-    - Simulation configuration
@@ -207,5 +223,5 @@
 #D-    - Read or initialize CumulPeriod
 #D-    - run.card
-#D---------------------------------------------------------------------==
+#D--------------------------------------------------------------------==
 IGCM_config_Initialize
 
@@ -248,9 +264,4 @@
 # ------------------------------------------------------------------
 IGCM_debug_Verif_Exit
-
-# ------------------------------------------------------------------
-# Activate BigBrother so as to supervise this simulation
-# ------------------------------------------------------------------
-IGCM_debug_ActivateBigBro
 
 #D-
Index: /trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1050)
+++ /trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1051)
@@ -176,13 +176,4 @@
     ls -lta ${SUBMIT_DIR}
   fi
-
-  #==================================
-  # Read libIGCM compatibility version in config.card
-  # Read UserChoices section
-  # Read Ensemble section
-  # Read Post section
-  # Define all netcdf output directories
-  #==================================
-  IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
 
   #==================================
@@ -1241,5 +1232,5 @@
       code=1100
       # RabbitMQ message body
-      Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"status\":\"OK\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
       # Fill the rabbitMQ queue
       IGCM_debug_sendAMQP
@@ -1264,5 +1255,5 @@
         code=0100
         # RabbitMQ message body
-        Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"status\":\"OK\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
         # Fill the rabbitMQ queue
         IGCM_debug_sendAMQP
Index: /trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh	(revision 1050)
+++ /trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh	(revision 1051)
@@ -145,4 +145,6 @@
 #D- * Purpose: Take over AMQP C client using mail as a message recipient
 #D- * One argument : base64 encoded message
+#D- * Attach encoded config.card when starting the simulation
+
 function IGCM_debug_send_AMQP_msg__MAILTUNNEL {
 
@@ -183,8 +185,14 @@
 
   # send mail
-  if ( [ ${send_messages} -eq 1 ] || [ X${FlushAMQP} = XTRUE ] ) ; then
-    mail -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
-    rm -f $buffer ; touch ${buffer}                                   # clear buffer
-    touch ${last_mail_date__file}                                     # memorize last mail date
+
+  if [ X${initBigBro}=Xtrue ] ; then
+    mailx -s "[TEMPORARY AMQP CHANNEL]" -a ${SUBMIT_DIR}/config.card.base64 ${mail_recipient} < ${buffer} # send buffer
+    rm -f $buffer ; touch ${buffer}                                    # clear buffer
+    touch ${last_mail_date__file}                                      # memorize last mail date
+    initBigBro=false
+  elif ( [ ${send_messages} -eq 1 ] || [ X${FlushAMQP} = XTRUE ] ) ; then
+    mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
+    rm -f $buffer ; touch ${buffer}                                    # clear buffer
+    touch ${last_mail_date__file}                                      # memorize last mail date
   fi
 
@@ -209,6 +217,10 @@
     # Prepare additionnal option
     additionnalOption="-f ${SUBMIT_DIR}/config.card.base64"
+    # 
+    initBigBro=true
   else
     additionnalOption=
+    #
+    initBigBro=false
   fi
 
@@ -237,5 +249,5 @@
   if [ ${status} -gt 0 ] ; then
     IGCM_debug_Print 2 "IGCM_debug_Push/PopStack/ActivateBigBro : command sendAMQPMsg failed error code ${status}"
-    echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}"
+    echo sendAMQPMsg -h localhost -p 5672 -b "${Body}"
     exit
   fi
@@ -306,5 +318,5 @@
       code=2000
       # RabbitMQ message body
-      Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
       # Fill the rabbitMQ queue
       IGCM_debug_sendAMQP
@@ -501,5 +513,5 @@
         code=9000
         # RabbitMQ message body
-        Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"status\":\"NOK\",\"out\":\"true\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
         # Fill the rabbitMQ queue
         IGCM_debug_sendAMQP
@@ -512,5 +524,5 @@
         code=3000
         # RabbitMQ message body
-        Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"status\":\"OK\",\"out\":\"true\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
         # Fill the rabbitMQ queue
         IGCM_debug_sendAMQP
@@ -541,16 +553,36 @@
   IGCM_debug_PushStack "IGCM_debug_ActivateBigBro"
 
+# 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 [ X${BigBrother} = Xtrue ] ; then
-    # ID to identify a simulation and the current Job. Still subject to change
-    GenericSimulationID=$( echo "\"simulationName\":\"${config_UserChoices_JobName}\",\"Experiment\":\"${config_UserChoices_ExperimentName}\",\"SpaceName\":\"${config_UserChoices_SpaceName}\",\"Model\":\"${config_UserChoices_TagName}\",\"Login\":\"${LOGIN}\",\"Center\":\"${CENTER}\",\"Machine\":\"${MASTER}\",\"CumulPeriod\":\"${CumulPeriod}\"" )
+    # create a unique ID for this specific job
+    jobuid=$(uuidgen)
 
     # RabbitMQ message code
     if ( ${FirstInitialize} ) ; then
       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}\"" )
     else
       code=1000
-    fi
-    # RabbitMQ message body
-    Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"status\":\"OK\",\"out\":\"false\",\"nesting\":\"${IGCM_debug_LenStack}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+      #
+      # retrieve this simulation's unique id 
+      IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration simuid
+      simuid=${config_Configuration_simuid}
+
+      # 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}\"" )
+    fi
+
+    # RabbitMQ message body with specific fields associated message codes treated here
+    Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
     # Fill the rabbitMQ queue (specifying config.card must be send)
     IGCM_debug_sendAMQP activate
@@ -600,5 +632,5 @@
       code=9999
       # RabbitMQ message body
-      Body=$( echo "{${GenericSimulationID},\"code\":\"${code}\",\"uuid\":\"$(uuidgen)\",\"status\":\"FATAL\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
       # Fill the rabbitMQ queue
       IGCM_debug_sendAMQP
@@ -754,5 +786,5 @@
   if [ X${ActivateBigBro} = Xtrue ] ; then
     # RabbitMQ message body
-    Body=$( echo "{${instrumentationContent},\"uuid\":\"$(uuidgen)\",\"timestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
+    Body=$( echo "{${genericSimulationID},${instrumentationContent},\"msgCode\":\"7000\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%d-%T-%N" )\"}" )
     # Fill the rabbitMQ queue
     IGCM_debug_sendAMQP
