source: trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh @ 1478

Last change on this file since 1478 was 1478, checked in by mafoipsl, 5 years ago

Consolidation of AA_pack_restart and AA_pack_debug to stop when tar failed.
Consolidation of libIGCM_debug IGCM_debug_Verif_Exit : initialisation of !postProcessingName added.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 40.9 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Patrick Brockmann, Martial Mancip
5# Contact: Patrick.Brockmann__at__cea.fr Martial.Mancip__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#==================================================
15# The documentation of this file can be automatically generated
16# if you use the prefix #D- for comments to be extracted.
17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#==================================================
19
20#==================================================
21# Add high level verbosity
22typeset -i Verbosity=${Verbosity:=3}
23
24#==================================================
25# DEBUG_debug
26# Add low level verbosity
27DEBUG_debug=${DEBUG_debug:=false}
28
29#D- postProcessingStopLevel (0,1,2,3)
30#D- 3 stop if any post-processing went wrong
31#D- 2 dont stop if atlas, monitoring or metrics failed
32#D- 1 dont stop if atlas, monitoring, metrics, create_ts or create_se failed
33#D- 0 dont stop if atlas, monitoring, metrics, create_ts, create_se, rebuild or pack_* failed
34postProcessingStopLevel=${postProcessingStopLevel:=0}
35
36#==================================================
37# GENERATE RANDOM ERROR ; only apply if ( ${DEBUG_debug} )
38typeset -r RandomError=false
39
40#==================================================
41# NULL_STR
42# Default null string
43typeset -r NULL_STR="_0_"
44
45#==================================================
46# libIGCM_CurrentTag
47# Current libIGCM tag, check compatibilty with *.card
48typeset -r libIGCMVersion="2.8.3"
49
50#==================================================
51# Exit Flag (internal debug)
52# When true, end the master loop AFTER SAVES FILES
53ExitFlag=false
54
55#==================================================
56# When we start to run the simulation is not finished
57simulationIsOver=false
58
59#==================================================
60# When we start to run we dont flush AMQP messages
61FlushAMQP=false
62
63#==================================================
64# Declare a stack of functions calls
65unset IGCM_debug_Stack
66unset IGCM_debug_StackArgs
67unset IGCM_debug_StackTiming
68IGCM_debug_Stack[0]=${NULL_STR}
69IGCM_debug_StackArgs[0]=${NULL_STR}
70IGCM_debug_StackTiming[0]=${NULL_STR}
71IGCM_debug_LenStack=0
72
73#D-#==================================================================
74#D-function IGCM_debug_getDate_ms
75#D- * Purpose: Give number of milliseconds since 01-jan-1970
76function IGCM_debug_getDate_ms
77{
78  typeset nanosecs ms
79  # nano secondes since 01-jan-1970
80  nanosecs=$( date +%s%N )
81
82  # truncate the last 6 digits to get milliseconds since 01-jan-1970
83  ms=${nanosecs:0:${#nanosecs}-6}
84
85  echo "$ms"
86}
87
88#D-#==================================================================
89#D-function IGCM_debug_sizeOfTabContent
90#D- * Purpose: Give sumed size of a list of files
91#D- * Usage: IGCM_debug_sizeOfTabContent entityList destination
92#D- *        where entityList is a list of files or directory
93#D- *        where dest is either a directory or a file name
94function IGCM_debug_sizeOfTabContent
95{
96  typeset entityListe destination iEntity sizeKo sumSizeKo sumSizeMo
97
98  eval set +A entityListe \${${1}}
99  destination=${2}
100  sumSizeKo=0
101
102  # Here we will try to compute size (file or directory size) from local path and not from archive.
103  for ((i = 0; i < ${#entityListe[*]}; i += 1)) ; do
104    if [ -f ${entityListe[$i]} ] ; then
105      # One file or a bunch of files has been copied without renaming from a visible filesystem
106      iEntity=${entityListe[$i]}
107    elif [ -f ${entityListe[$i]##/*/} ] ; then
108      # One file or a bunch of files has been copied without renaming from an non visible filesystem
109      # remove path /home/login/../ from entityListe elements
110      iEntity=${entityListe[$i]##/*/}
111    elif [ -f ${destination} ] ; then
112      # a file has been copied and renamed
113      iEntity=${destination}
114    elif [ -f ${destination}/${entityListe[$i]##/*/} ] ; then
115      # a copy in a directory but not in ${PWD}
116      iEntity=${destination}/${entityListe[$i]##/*/}
117    elif [ -d ${entityListe[$i]} ] ; then
118      # a directory has been copied from a non remote place
119      iEntity=${entityListe[$i]}
120    elif [ -d ${destination}/${entityListe[$i]##/*/} ] ; then
121      # a directory has been copied from a remote archive and not renamed
122      iEntity=${destination}/${entityListe[$i]##/*/}
123    elif [ -d ${destination} ] ; then
124      # a directory has been copied from a remote archive and renamed
125      iEntity=${destination}
126    fi
127    sizeKo=$( du --apparent-size -skL ${iEntity} | gawk '{print $1}' )
128    sumSizeKo=$(( $sumSizeKo + $sizeKo ))
129  done
130  sumSizeMo=$( echo "scale=6;${sumSizeKo}/1024" | bc )
131  echo "${sumSizeKo}|${sumSizeMo}"
132}
133
134#D-#==================================================================
135#D-function IGCM_debug_send_AMQP_msg__MAILTUNNEL
136#D- * Purpose: Take over AMQP C client using mail as a message recipient
137#D- * One argument : base64 encoded message
138#D- * Attach encoded config.card when starting the simulation
139
140function IGCM_debug_send_AMQP_msg__MAILTUNNEL {
141
142  typeset b64_encoded_msg mail_recipient
143  typeset buffer send_messages mail_frequency
144  typeset last_mail_date__file
145  typeset secondsBetweenRefAndLastMail secondsSinceLastMail
146
147  b64_encoded_msg=$1
148
149  mail_recipient="superviseur@mail.ipsl.upmc.fr"
150  send_messages=0
151  mail_frequency=3600 # in seconds
152  # use to keep track when was last mail sent (maybe to be replaced with global variable)
153  last_mail_date__file=${R_BUF}/.stamp.${config_UserChoices_TagName}.${config_UserChoices_JobName}
154  # use to accumulate messages before sending them
155  buffer=${R_BUF}/.buffer.${config_UserChoices_TagName}.${config_UserChoices_JobName}
156
157  # init
158  if [ ! -f "${buffer}" ]; then
159    touch ${buffer}
160  fi
161
162  if [ ! -f "${last_mail_date__file}" ]; then
163    touch ${last_mail_date__file}
164  else
165    # compute last time the file was changed (in seconds)
166    secondsBetweenRefAndLastMail=$(stat -c %Y ${last_mail_date__file})
167    status=$?
168    #
169    # Only execute this block when the stat command succeeded.
170    # The stat command might fail in some circumstance but we consider it is ok to continue anyway.
171    if [ ${status} -eq 0 ] ; then
172      secondsSinceLastMail=$(( $(date +%s) - ${secondsBetweenRefAndLastMail} ))
173      # send message when exceeding threshold
174      [ ${secondsSinceLastMail} -gt ${mail_frequency} ] && send_messages=1
175    fi
176  fi
177
178  # queue messages in the buffer
179  echo ${b64_encoded_msg} >> ${buffer}
180
181  # send mail
182
183  if [ X${initBigBro} = Xtrue ] ; then
184    #echo $(date +"%Y-%m-%dT%H:%M:%S.%N%z") > ${SUBMIT_DIR}/mail.txt
185    mailx -s "[TEMPORARY AMQP CHANNEL]" -a ${SUBMIT_DIR}/config.card.base64 ${mail_recipient} < ${buffer} # send buffer
186    rm -f $buffer ; touch ${buffer}                                    # clear buffer
187    touch ${last_mail_date__file}                                      # memorize last mail date
188    rm -f ${SUBMIT_DIR}/config.card.base64                             # remove temporary file
189    initBigBro=false
190  elif [ ${send_messages} -eq 1 ] ; then
191    #echo $(date +"%Y-%m-%dT%H:%M:%S.%N%z") >> ${SUBMIT_DIR}/mail.txt
192    mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
193    rm -f ${buffer} ; touch ${buffer}                                  # flush the buffer
194    touch ${last_mail_date__file}                                      # memorize last mail date
195  fi
196
197  if ( ${FlushAMQP} ) ; then
198    mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
199    rm -f ${buffer}                                                    # cleaning behind us
200    rm -f ${last_mail_date__file}                                      # cleaning behind us
201  fi
202
203  # Allways all good for now.
204  return 0
205}
206
207#D-#==================================================================
208#D-function IGCM_debug_sendAMQP_Purge
209#D- * Purpose: Take over AMQP C client using mail as a message recipient
210#D- * No argument : send a message indicating a simulation has been purged
211
212function IGCM_debug_sendAMQP_Purge {
213
214  typeset mail_recipient encodedBody
215  if [ X${ActivateBigBro} = Xtrue ] ; then
216    mail_recipient="superviseur@mail.ipsl.upmc.fr"
217    # Clea nup tag on server side
218    code=8888
219    # Usual AMQP message to route messages on server side
220    encodedBody=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" |  base64 -w 0 )
221    # send mail
222
223    IGCM_debug_Print 2 "IGCM_debug_sendAMQP_Purge"
224    echo ${encodedBody}|mailx -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}
225  fi
226
227  # Allways all good for now.
228  return 0
229}
230
231#D-#==================================================================
232#D-function IGCM_debug_sendAMQP_Metrics
233#D- * Purpose: Take over AMQP C client using mail as a message recipient
234#D- * Two arguments : - Directory where metrics.json files can be found
235#D- *                 - Metrics Group Name. metrics will be added to this group
236#D- * Attach encoded metrics.json files.
237
238function IGCM_debug_sendAMQP_Metrics {
239
240  typeset mail_recipient encodedBody
241  if [ X${ActivateBigBro} = Xtrue ] ; then
242    mail_recipient="superviseur@mail.ipsl.upmc.fr"
243    # Metrics tag on server side
244    code=7100
245    # Usual AMQP message to route messages on server side
246    encodedBody=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"metricsGroupName\":\"${2}\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" |  base64 -w 0 )
247    # send mail
248    attachmentsOptions=""
249    for metricsFile in $( ls $1/*json ) ; do
250      attachmentsOptions="-a ${metricsFile} ${attachmentsOptions}"
251    done
252    IGCM_debug_Print 2 "IGCM_debug_sendAMQP_Metrics"
253    echo ${encodedBody}|mailx -s "[TEMPORARY AMQP CHANNEL]" ${attachmentsOptions} ${mail_recipient}
254  fi
255
256  # Allways all good for now.
257  return 0
258}
259
260#D-#==================================================================
261#D-function IGCM_debug_sendAMQP_projectAccounting
262#D- * Purpose: Take over AMQP C client using mail as a message recipient
263#D- * One argument : - File name where project accounting details are stored
264#D- * Attach encoded accounting file.
265
266function IGCM_debug_sendAMQP_projectAccounting {
267
268  typeset mail_recipient encodedBody
269  if [ X${ActivateBigBro} = Xtrue ] ; then
270    mail_recipient="superviseur@mail.ipsl.upmc.fr"
271    # Metrics tag on server side
272    code=7010
273    # Usual AMQP message to route messages on server side
274    encodedBody=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"accountingProject\":\"${PROJECT}\",\"centre\":\"${CENTER}\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" |  base64 -w 0 )
275    # send mail
276    attachmentsOptions="-a ${1}"
277    IGCM_debug_Print 2 "IGCM_debug_sendAMQP_projectAccounting"
278    echo ${encodedBody}|mailx -s "[TEMPORARY AMQP CHANNEL]" ${attachmentsOptions} ${mail_recipient}
279    # clean behind
280    rm -f $1
281  fi
282
283  # Allways all good for now.
284  return 0
285}
286
287#D-#==================================================================
288#D-function IGCM_debug_SendAMQP
289#D- * Purpose: Send body; encoded body and config.card to rabbitMQ
290function IGCM_debug_sendAMQP {
291
292  typeset decal first additionnalOption encodedBody
293
294  # Encode message Body
295  encodedBody=$( echo "${Body}" | base64 -w 0 )
296
297  # Send config.card ?
298  if [ X${1} = Xactivate ] ; then
299    # Encode config.card
300    cat ${SUBMIT_DIR}/config.card | base64 -w 0 > ${SUBMIT_DIR}/config.card.base64
301    # Prepare additionnal option
302    additionnalOption="-f ${SUBMIT_DIR}/config.card.base64"
303    #
304    initBigBro=true
305  else
306    additionnalOption=
307    #
308    initBigBro=false
309  fi
310
311  # Only cosmetics : stack file
312  if [ X${ActivateStackFilling} = Xtrue ] ; then
313    decal=0
314    while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do
315      printf ' ' >> ${StackFileLocation}/${StackFileName}
316      (( decal = decal + 1 ))
317    done
318    # Log to stack file using human readable format
319    echo "${Body}" >> ${StackFileLocation}/${StackFileName}
320  fi
321
322  # Log separately encoded AMQP message command for reuse in a mock up
323  #echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} >> ${RUN_DIR_PATH}/send.AMQP.${config_UserChoices_JobName}.${config_UserChoices_ExperimentName}.${config_UserChoices_SpaceName}.${config_UserChoices_TagName}.${CumulPeriod}.history.txt
324
325  # Send the message
326  if [ X${BigBrotherChannel} = XMAIL ] ; then
327    IGCM_debug_send_AMQP_msg__MAILTUNNEL "${encodedBody}"
328    status=$?
329  else
330    sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody}
331    status=$?
332  fi
333
334  if [ ${status} -gt 0 ] ; then
335    IGCM_debug_Print 2 "IGCM_debug_Push/PopStack/ActivateBigBro : command sendAMQPMsg failed error code ${status}"
336    echo sendAMQPMsg -h localhost -p 5672 -b "${Body}"
337    exit 1
338  fi
339}
340
341#D-#==================================================================
342#D-function IGCM_debug_CallStack
343#D-* Purpose: Print the call stack tree from the oldest to the youngest (opposite of the display standard)
344#D-
345function IGCM_debug_CallStack {
346  if ( $DEBUG_debug ) ; then
347    # Cosmetics
348    typeset i decal
349    i=0
350    until [ $i -eq ${IGCM_debug_LenStack} ]; do
351      decal=0
352      until [ $decal -eq ${i} ]; do
353        printf -- ' '
354        (( decal = decal + 1 ))
355      done
356      echo "$i - ${IGCM_debug_Stack[$(( $IGCM_debug_LenStack-$i-1 ))]}" "(${IGCM_debug_StackArgs[$(( $IGCM_debug_LenStack-$i-1 ))]})"
357      ((i = i + 1))
358    done
359  fi
360}
361
362#D-#==================================================================
363#D-function IGCM_debug_PushStack
364#D-* Purpose: Push a function name in the stack
365#D-
366function IGCM_debug_PushStack {
367  if ( $DEBUG_debug ) ; then
368    typeset decal inputs startTime_ms
369
370    # Only cosmetics : stack file
371    if [ X${ActivateStackFilling} = Xtrue ] ; then
372      echo >> ${StackFileLocation}/${StackFileName}
373      decal=0
374      while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do
375        printf ' ' >> ${StackFileLocation}/${StackFileName}
376        (( decal = decal + 1 ))
377      done
378
379      # Fill the stack file
380      echo "> ${IGCM_debug_LenStack} : ${@}" >> ${StackFileLocation}/${StackFileName}
381    fi
382
383    # Save input list in an indexed array
384    INPUTS=( $@ )
385
386    # Get timing information
387    startTime_ms=$( IGCM_debug_getDate_ms )
388
389    # We add function call name on beginning of the stack
390    set +A IGCM_debug_Stack -- ${1} ${IGCM_debug_Stack[*]}
391
392    # Save timing in milliseconds in an indexed array
393    set +A IGCM_debug_StackTiming -- ${startTime_ms} ${IGCM_debug_StackTiming[*]}
394
395    # We include the "null" Args in the beginning of the StackArgs
396    set +A IGCM_debug_StackArgs ${NULL_STR} ${IGCM_debug_StackArgs[*]}
397
398    # Then, we shift StackArgs tabular
399    # Replacing blank separated list by comma separated list of quoted elements (except the first and last element)
400    if [ $# -gt 1 ]; then
401      IGCM_debug_StackArgs[0]=$(echo ${INPUTS[*]:1} | sed -e "s/\ /\",\"/g" )
402    fi
403
404    # Increment LenStack
405    (( IGCM_debug_LenStack = IGCM_debug_LenStack + 1 ))
406
407    #IGCM_debug_CallStack
408  fi
409}
410
411#D-#==================================================================
412#D-function IGCM_debug_PopStack
413#D-* Purpose: Pop a function name in the stack
414#D-
415function IGCM_debug_PopStack {
416  if ( $DEBUG_debug ) ; then
417    typeset i decal command arguments startTime_ms endTime_ms
418    typeset instrumentation dest prefix
419    # they are not typeset because they are send "by adress" to son functions
420    # we unset them to avoid "memory effect"
421    unset fileList source
422
423    # INTRODUCE SIMPLE ERROR GENERATOR TO TEST SUPERVISOR
424    # PROBABILITY ERROR IS 0.0001 PER COMMAND OR FUNCTION CALL
425    # THERE ARE ~500 COMMAND OR FUNCTION CALL PER PERIOD
426    # ONLY WHEN TaskType is "computing".
427    if [ X${ActivateBigBro} = Xtrue ] ; then
428      if [ X${TaskType} = Xcomputing ]; then
429        if ( ${RandomError} ) ; then
430          if [ $((RANDOM%10000)) -le 10 ] ; then
431            IGCM_debug_Print 1 "Random error has been triggered"
432            if [ X${ActivateStackFilling} = Xtrue ] ; then
433              echo "RANDOM ERROR" >> ${StackFileLocation}/${StackFileName}
434            fi
435            ExitFlag=true
436          fi
437        fi
438      fi
439    fi
440
441    if [ "${IGCM_debug_Stack[0]}" = "${1}" ]; then
442      # Everything is cool
443
444      # Get timing information
445      endTime_ms=$( IGCM_debug_getDate_ms )
446
447      # Save Stack information before poping the stack
448      command=${IGCM_debug_Stack[0]}
449
450      # Go from comma separated list of quoted elements (except the first and the last element)
451      # to unquoted space separated elements in an array
452      set -A arguments -- $( echo ${IGCM_debug_StackArgs[0]} | sed -e "s/\",\"/\ /g" )
453
454      # Save Stack information before poping the stack
455      startTime_ms=${IGCM_debug_StackTiming[0]}
456
457      # Pop the stack
458      (( IGCM_debug_LenStack = IGCM_debug_LenStack - 1 ))
459      set -A IGCM_debug_Stack -- ${IGCM_debug_Stack[*]:1}
460      set -A IGCM_debug_StackArgs -- ${IGCM_debug_StackArgs[*]:1}
461      set -A IGCM_debug_StackTiming -- ${IGCM_debug_StackTiming[*]:1}
462    else
463      echo 'IGCM_debug_Exit : stack is corrupted ! LenStack =' ${IGCM_debug_LenStack}
464      IGCM_debug_Exit $@
465    fi
466
467    # Special actions depending on command to prepare IGCM_debug_PrintInfosActions call
468    # We are interested in:
469    #  0. Which command performs the work
470    #  1. Size of entity we are working with
471    #  2. Where are we reading
472    #  3. Where are we writing
473    #  4. How long it took
474
475    instrumentation=false
476
477    case ${command} in
478    # Classical copy (only files are given to IGCM_sys_Cp as options)
479    IGCM_sys_Cp)
480      instrumentation=true
481      # All but the latest
482      fileList=${arguments[*]:0:${#arguments[*]}-1}
483      # just need the first file to get the directory
484      source=${arguments[0]}
485      # Nothing but the latest
486      dest=${arguments[${#arguments[*]}-1]}
487      # Size of file whose name are stored in a list
488      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
489      ;;
490
491    # Copy from archive machine or from buffer
492    IGCM_sys_Get|IGCM_sys_GetBuffer)
493      instrumentation=true
494      if [ ${#arguments[*]} -eq 2 ] ; then
495        source=${arguments[0]}
496        dest=${arguments[1]}
497        # Size of file whose name are stored in a variable
498        entitySize=$( IGCM_debug_sizeOfTabContent source ${dest} )
499      elif ( [ ${#arguments[*]} -eq 3 ] && [ ${arguments[0]} = '/l' ] ) ; then
500        # IGCM_sys_Get /l liste_file[*] /ccc/scratch/cont003/dsm/p86denv/RUN_DIR/985998_14754/
501        # Keep the array name hosting the all list
502        eval set +A fileList \${${arguments[1]}}
503        # just need the first file to get the directory
504        source=${fileList[0]}
505        dest=${arguments[2]}
506        # Size of file whose name are stored in a list
507        entitySize=$( IGCM_debug_sizeOfTabContent fileList[*] ${dest} )
508      elif [ [ ${#arguments[*]} -ge 3 ] ; then
509       # All but the latest
510        fileList=${arguments[*]:0:${#arguments[*]}-1}
511        # just need the first file to get the directory
512        source=${arguments[0]}
513        # Nothing but the latest
514        dest=${arguments[${#arguments[*]}-1]}
515        # Size of file whose name are stored in a list
516        entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
517      fi
518      ;;
519
520    # Copy from compute node or copy to archive/buffer
521    IGCM_sys_Get_Master|IGCM_sys_Get_Dir|IGCM_sys_Put_Out|IGCM_sys_PutBuffer_Out)
522      instrumentation=true
523      source=${arguments[0]}
524      dest=${arguments[1]}
525      # Size of file whose name are stored in a variable
526      entitySize=$( IGCM_debug_sizeOfTabContent source ${dest} )
527      ;;
528
529    # Rebuild command
530    IGCM_sys_rebuild|IGCM_sys_rebuild_station)
531      instrumentation=true
532      # All but the first
533      fileList=${arguments[*]:1:${#arguments[*]}-1}
534      # just need a file to get the directory
535      source=${arguments[1]}
536      # Nothing but the first
537      dest=${arguments[0]}
538      # Size of file whose name are stored in a list
539      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
540      ;;
541
542    # NCO commands
543    IGCM_sys_ncrcat|IGCM_sys_ncecat|IGCM_sys_ncra|IGCM_sys_ncks|IGCM_sys_cdo)
544      # Example of what we want to catch : only filenames in those command lines
545      # IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_SE}
546      # IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${file1} ${liste_file_tmp[*]} ${file_out}
547      # IGCM_sys_ncrcat -p ${dir} ${liste_file_tmp} --output ${output}
548      # IGCM_sys_ncrcat -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
549      instrumentation=true
550      keepGoing=true
551      prefix=.
552      i=0
553      while ( ${keepGoing} ) ; do
554        # the last one is not interesting
555        if [ ${i} -eq ${#arguments[*]}-1 ] ; then
556          keepGoing=false
557        # look after "-p" option. Path prefix is the following arguments
558        elif [ ${arguments[${i}]} = "-p" ] ; then
559          ((i = i + 1))
560          prefix=${arguments[${i}]}
561          ((i = i + 1))
562        elif [ ${i} -eq ${#arguments[*]}-1 ] ; then
563          keepGoing=false
564        # looking for files
565        elif [ -f ${prefix}/${arguments[${i}]} ] ; then
566          fileList="${fileList} ${prefix}/${arguments[${i}]}"
567          ((i = i + 1))
568        # other options are not interesting
569        else
570          ((i = i + 1))
571        fi
572      done
573
574      # i value is at least 1
575      # just need one file to get the directory
576      source=$( echo ${fileList} | gawk '{print $1}' )
577      # Nothing but the latest
578      dest=${arguments[${#arguments[*]}-1]}
579      # Size of file whose name are stored in a list
580      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
581      ;;
582    esac
583
584    # Print information related to instrumentation
585    ( ${instrumentation} ) && IGCM_debug_PrintInfosActions ${command} ${entitySize} ${startTime_ms} ${endTime_ms} ${dest} ${source}
586
587    # Only cosmetics : stack file
588    if [ X${ActivateStackFilling} = Xtrue ] ; then
589      decal=0
590      while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do
591        printf ' ' >> ${StackFileLocation}/${StackFileName}
592        (( decal = decal + 1 ))
593      done
594    fi
595
596    if ( ${ExitFlag} ) ; then
597      # Inform the stack file
598      if [ X${ActivateStackFilling} = Xtrue ] ; then
599        echo '!!! ExitFlag has been activated !!!' >> ${StackFileLocation}/${StackFileName}
600      fi
601
602      # Unplugged message 4900 handling for now. To ease downstream treatment.
603      if [ X${ActivateBigBro} = Xtrue ] ; then
604        if [ X${TaskType} = Xcomputing ]; then
605          # RabbitMQ message code "COMPUTING JOBs COMMAND FAILURE"
606          code=1900
607        elif [ X${TaskType} = Xpost-processing ]; then
608          # RabbitMQ message code "POST-PROCESSING JOBs COMMAND FAILURE"
609          code=2900
610        elif [ X${TaskType} = Xchecking ]; then
611          # RabbitMQ message code "POST-PROCESSING FROM CHECKER JOBs COMMAND FAILURE"
612          code=3900
613        fi
614        # RabbitMQ message body
615        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"command\":\"${command}\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
616
617        # Fill the rabbitMQ queue
618        IGCM_debug_sendAMQP
619      fi
620    else
621      # Inform the stack file
622      if [ X${ActivateStackFilling} = Xtrue ] ; then
623        echo "< ${IGCM_debug_LenStack} : ${@}" >> ${StackFileLocation}/${StackFileName}
624      fi
625    fi
626
627    # Reset array if necessary
628    if [ ${IGCM_debug_LenStack} = 0 ]; then
629      #echo
630      #IGCM_debug_Print 3 "Clean stack array"
631      #echo
632      unset IGCM_debug_Stack
633      unset IGCM_debug_StackArgs
634      unset IGCM_debug_StackTiming
635      IGCM_debug_Stack[0]=${NULL_STR}
636      IGCM_debug_StackArgs[0]=${NULL_STR}
637      IGCM_debug_StackTiming[0]=${NULL_STR}
638    fi
639  fi
640  #IGCM_debug_CallStack
641}
642
643#D-#==================================================================
644#D-function IGCM_debug_BigBro_Initialize
645#D-* Purpose: switch rabbitMQ on
646#D-
647function IGCM_debug_BigBro_Initialize {
648  IGCM_debug_PushStack "IGCM_debug_BigBro_Initialize"
649
650  typeset postProcessingIDLength postProcessingName postProcessingDate postProcessingDimn postProcessingComp postProcessingFile accountingFile
651
652# Message type standard fields:
653# https://github.com/Prodiguer/prodiguer-docs/wiki/MQ-Standard-Message-Fields
654
655# Message type dictionnary and custom fields:
656# https://github.com/Prodiguer/prodiguer-docs/wiki/Monitoring-Message-Dictionary
657
658  if [ X${BigBrother} = Xtrue ] ; then
659    # create a unique ID for this specific job
660    jobuid=$(uuidgen)
661
662    # get the assigned id by the scheduler for that job
663    IGCM_sys_getJobSchedulerID jobSchedulerID
664
665    if [ X${TaskType} = Xcomputing ]; then
666      if ( ${FirstInitialize} ) ; then
667        # RabbitMQ message code "BEGIN A SIMULATION"
668        code=0000
669        # create and persist a unique id for this simulation
670        simuid=$(uuidgen)
671        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration simuid ${simuid}
672        # Standard fields for the first message
673        genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"msgProducerVersion\":\"${libIGCMVersion}\",\"activity\":\"IPSL\",\"name\":\"${config_UserChoices_JobName}\",\"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}\"" )
674        # RabbitMQ message body with specific fields associated message codes treated here
675        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"accountingProject\":\"${PROJECT}\",\"jobWarningDelay\":\"${jobWarningDelay}\",\"jobSchedulerID\":\"${jobSchedulerID}\",\"jobSubmissionPath\":\"${SUBMIT_DIR}\",\"archivePath\":\"${R_SAVE}\",\"storagePath\":\"${R_BUFR}\",\"storageSmallPath\":\"${R_FIGR}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
676        # Fill the rabbitMQ queue (the config.card in use will be sent)
677        IGCM_debug_sendAMQP activate
678      else
679        # RabbitMQ message code "A NEW COMPUTING JOB IS RUNNING PART OF A SIMULATION"
680        code=1000
681        # retrieve this simulation's unique id
682        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration simuid
683        simuid=${run_Configuration_simuid}
684        # Using standard fields for message others than the first one. Still subject to change
685        genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"msgProducerVersion\":\"${libIGCMVersion}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
686        # RabbitMQ message body with specific fields associated message codes treated here
687        Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"accountingProject\":\"${PROJECT}\",\"jobWarningDelay\":\"${jobWarningDelay}\",\"jobSchedulerID\":\"${jobSchedulerID}\",\"jobSubmissionPath\":\"${SUBMIT_DIR}\",\"archivePath\":\"${R_SAVE}\",\"storagePath\":\"${R_BUFR}\",\"storageSmallPath\":\"${R_FIGR}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
688        # Fill the rabbitMQ queue
689        IGCM_debug_sendAMQP
690      fi
691
692      # NOT VERY NICE BUT ... IT WORKS
693      # Be sure that the genericSimulationID will be small from now on
694      # Using standard fields for messages others than the first one. Still subject to change
695      genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"msgProducerVersion\":\"${libIGCMVersion}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
696
697    elif [ X${TaskType} = Xpost-processing ]; then
698      # RabbitMQ message code "A NEW POST-PROCESSING JOB IS RUNNING PART OF A SIMULATION"
699      code=2000
700      # retrieve this simulation's unique id
701      IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration simuid
702      simuid=${run_Configuration_simuid}
703      # Using standard fields for message others than the first one. Still subject to change
704      genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"msgProducerVersion\":\"${libIGCMVersion}\",\"simuid\":\"${simuid}\",\"jobuid\":\"${jobuid}\"" )
705     
706      # Specify the post-processing task we are dealing with
707      postProcessingIDLength=$( echo "${Script_Post_Output}" | tr -d -c "\." | wc -c )
708      postProcessingName=$( echo "${Script_Post_Output}" | gawk -F. '{print $1}' )
709      postProcessingDate=$( echo "${Script_Post_Output}" | gawk -F. '{print $2}' )
710      postProcessingDimn="null"
711      postProcessingComp="null"
712      postProcessingFile="null"
713      if [ ${postProcessingIDLength} -eq 2 ] ; then
714        postProcessingDimn=$( echo "${Script_Post_Output}" | gawk -F. '{print $3}' )
715      elif [ ${postProcessingIDLength} -eq 4 ] ; then
716        postProcessingComp=$( echo "${Script_Post_Output}" | gawk -F. '{print $4}' )
717        postProcessingFile=$( echo "${Script_Post_Output}" | gawk -F. '{print $5}' )
718      fi
719
720      # RabbitMQ message body with specific fields associated message codes treated here
721      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"accountingProject\":\"${PROJECT}\",\"jobWarningDelay\":\"${jobWarningDelay}\",\"jobSchedulerID\":\"${jobSchedulerID}\",\"jobSubmissionPath\":\"${SUBMIT_DIR}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\",\"postProcessingName\":\"${postProcessingName}\",\"postProcessingDate\":\"${postProcessingDate}\",\"postProcessingDimn\":\"${postProcessingDimn}\",\"postProcessingComp\":\"${postProcessingComp}\",\"postProcessingFile\":\"${postProcessingFile}\"}" )
722      # Fill the rabbitMQ queue
723      IGCM_debug_sendAMQP
724
725    elif [ X${TaskType} = Xchecking ]; then
726      # retrieve this simulation's unique id
727      IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration simuid
728      simuid=${run_Configuration_simuid}
729      # Using standard fields for message others than the first one. Still subject to change
730      genericSimulationID=$( echo "\"msgApplication\":\"monitoring\",\"msgProducer\":\"libigcm\",\"msgProducerVersion\":\"${libIGCMVersion}\",\"simuid\":\"${simuid}\",\"jobuid\":\"N\/A\"" )
731    fi
732
733    # Turn the flag on
734    ActivateBigBro=true
735
736    if [ X${TaskType} = Xcomputing ]; then
737      # Save project accounting details in a file
738      accountingFile=cpt_${CENTER}_${PROJECT}_$( date +"%Y%m%d_%H%M" ).dat
739      IGCM_sys_projectAccounting ${accountingFile}
740
741      # And send it
742      IGCM_debug_sendAMQP_projectAccounting ${accountingFile}
743    fi
744  fi
745  IGCM_debug_PopStack "IGCM_debug_BigBro_Initialize"
746}
747
748#D-#==================================================================
749#D-function IGCM_debug_BigBro_Update
750#D-* Purpose: Update rabbitMQ messages exchanges during the run
751#D-
752function IGCM_debug_BigBro_Update {
753  IGCM_debug_PushStack "IGCM_debug_BigBro_Update"
754
755  # Message type standard fields:
756  # https://github.com/Prodiguer/prodiguer-docs/wiki/MQ-Standard-Message-Fields
757
758  # Message type dictionnary and custom fields:
759  # https://github.com/Prodiguer/prodiguer-docs/wiki/Monitoring-Message-Dictionary
760
761  if [ X${ActivateBigBro} = Xtrue ] ; then
762    if [ X${TaskType} = Xcomputing ]; then
763      # Send ${PeriodDateBegin}, ${PeriodDateEnd} and ${CumulPeriod}
764      # RabbitMQ message body
765      Body=$( echo "{${genericSimulationID},\"msgCode\":\"1001\",\"PeriodDateBegin\":\"${PeriodDateBegin}\",\"PeriodDateEnd\":\"${PeriodDateEnd}\",\"CumulPeriod\":\"${CumulPeriod}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
766      # Fill the rabbitMQ queue
767      IGCM_debug_sendAMQP
768    fi
769  fi
770  IGCM_debug_PopStack "IGCM_debug_BigBro_Update"
771}
772
773#D-#==================================================================
774#D-function IGCM_debug_BigBro_Finalize
775#D-* Purpose: Finalize rabbitMQ messages exchanges
776#D-
777function IGCM_debug_BigBro_Finalize {
778  IGCM_debug_PushStack "IGCM_debug_BigBro_Finalize"
779
780  # Message type standard fields:
781  # https://github.com/Prodiguer/prodiguer-docs/wiki/MQ-Standard-Message-Fields
782
783  # Message type dictionnary and custom fields:
784  # https://github.com/Prodiguer/prodiguer-docs/wiki/Monitoring-Message-Dictionary
785
786  if ( $DEBUG_debug ) ; then
787    if [ X${ActivateBigBro} = Xtrue ] ; then
788      if [ X${TaskType} = Xcomputing ]; then
789        if ( ${simulationIsOver} ) ; then
790          # RabbitMQ message code "SIMULATION ENDS"
791          code=0100
792          FlushAMQP=true
793        elif ( ${ExitFlag} ) ; then
794          # RabbitMQ message code "EXIT THE JOBS BECAUSE ERROR(S) HAS BEEN TRIGGERED"
795          code=1999
796          FlushAMQP=true
797        else
798          # RabbitMQ message code "COMPUTING JOB ENDS"
799          code=1100
800        fi
801      elif [ X${TaskType} = Xpost-processing ]; then
802        if ( ${ExitFlag} ) ; then
803          # RabbitMQ message code "POST-PROCESSING JOB FAILS"
804          code=2999
805          FlushAMQP=true
806        else
807          # RabbitMQ message code "POST-PROCESSING JOB ENDS"
808          code=2100
809          FlushAMQP=true
810        fi
811      elif [ X${TaskType} = Xchecking ]; then
812        if ( ${ExitFlag} ) ; then
813          # RabbitMQ message code "POST-PROCESSING JOB FAILS"
814          code=3999
815          FlushAMQP=true
816        else
817          # RabbitMQ message code "POST-PROCESSING JOB ENDS"
818          code=3100
819          FlushAMQP=true
820        fi
821      fi
822      # RabbitMQ message body
823      Body=$( echo "{${genericSimulationID},\"msgCode\":\"${code}\",\"msgUID\":\"$(uuidgen)\",\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
824      # Fill the rabbitMQ queue
825      IGCM_debug_sendAMQP
826    fi
827  fi
828 
829  IGCM_debug_PopStack "IGCM_debug_BigBro_Finalize"
830}
831
832#D-#==================================================================
833#D-function IGCM_debug_Exit
834#D-* Purpose: Print Call Stack and set ExitFlag to true
835#D-
836function IGCM_debug_Exit {
837  IGCM_debug_PushStack "IGCM_debug_Exit"
838  echo "IGCM_debug_Exit : " "${@}"
839  echo
840  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!"
841  echo "!!   ERROR TRIGGERED    !!"
842  echo "!!   EXIT FLAG SET      !!"
843  echo "!------------------------!"
844  echo
845  IGCM_debug_CallStack
846  ExitFlag=true
847  IGCM_debug_PopStack "IGCM_debug_Exit"
848}
849
850#D-#==================================================
851#D-function IGCM_debug_Verif_Exit
852#D-* Purpose: exit with number 1 if ExitFlag is true
853#D-
854function IGCM_debug_Verif_Exit {
855  if ( ${ExitFlag} ) ; then
856    echo "IGCM_debug_Verif_Exit : Something wrong happened previously."
857    echo "IGCM_debug_Verif_Exit : ERROR and EXIT keyword will help find out where."
858    # Only computing TaskType stops the job for now.
859    if [ X${TaskType} = Xcomputing ] ; then
860      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Fatal"
861      echo "                        EXIT THE JOB."
862      echo
863      IGCM_debug_CallStack
864
865      # Mail notification
866      IGCM_sys_SendMail
867
868      # Inform the rabbitMQ queue
869      IGCM_debug_BigBro_Finalize
870
871      # And Good Bye
872      date
873      exit 1
874
875    elif [ X${TaskType} = Xpost-processing ] ; then
876      StopAll=false
877      typeset postProcessingName
878      postProcessingName=$( echo "${Script_Post_Output}" | gawk -F. '{print $1}' )
879      # Test if we need to stop the computing job
880      case ${postProcessingName} in
881      atlas*|monitoring*|metrics*)
882        [ ${postProcessingStopLevel} -gt 2 ] && StopAll=true ;;
883      create_*)
884        [ ${postProcessingStopLevel} -gt 1 ] && StopAll=true ;;
885      rebuild*|pack_*)
886        [ ${postProcessingStopLevel} -gt 0 ] && StopAll=true ;;
887      esac
888      # Notify the computing job that something wrong happened and stop it.
889      ( ${StopAll} ) && IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Fatal.${Script_Post_Output}"
890
891      # If SpaceName is PROD we stop when post_processing failed
892      if [ X${config_UserChoices_SpaceName} = XPROD ] ; then
893        echo "                        EXIT THE POST-PROCESSING JOB."
894        echo
895        IGCM_debug_CallStack
896
897        # Inform the rabbitMQ queue
898        IGCM_debug_BigBro_Finalize
899
900        # And Good Bye
901        date
902        exit 1
903      else
904        echo "In config.card the variable SpaceName is not in PROD"
905        echo "              SO WE DO NOT EXIT THE JOB."
906        echo
907        date
908      fi
909    elif [ X${TaskType} = Xchecking ] ; then
910      echo "Nothing will happen for now"
911    fi
912  fi
913}
914
915#D-#==================================================================
916#D-function IGCM_debug_Print
917#D-* Purpose: Print arguments according to a level of verbosity.
918#D-
919function IGCM_debug_Print
920{
921  typeset level=$1
922  shift
923
924  if [ X"${1}" = X"-e" ]; then
925    typeset cmd_echo="echo -e"
926    shift
927  else
928    typeset cmd_echo="echo"
929  fi
930
931  if [ ${level} -le ${Verbosity} ] ; then
932    typeset i
933    case "${level}" in
934    1) for i in "$@" ; do
935      ${cmd_echo} $(date +"%Y-%m-%d %T") "--Debug1-->" ${i}
936      done ;;
937    2) for i in "$@" ; do
938      ${cmd_echo} $(date +"%Y-%m-%d %T") "--------Debug2-->" ${i}
939      done ;;
940    3) for i in "$@" ; do
941      ${cmd_echo} $(date +"%Y-%m-%d %T") "--------------Debug3-->" ${i}
942      done ;;
943    esac
944  fi
945}
946
947#D-#==================================================================
948#D-function IGCM_debug_PrintVariables
949#D-* Purpose: Print arguments when match a pattern
950#D-           according to a level of verbosity.
951function IGCM_debug_PrintVariables
952{
953  typeset level=$1
954  shift
955
956  list=$( set | grep ^$1 | sed -e "s/'//g" )
957
958  if [ "X${list}" != X ]  ; then
959    IGCM_debug_Print ${level} ${list}
960  fi
961}
962
963#D-#==================================================================
964#D-function IGCM_debug_PrintInfosActions
965#D-* Purpose: Print information related to instrumentation
966function IGCM_debug_PrintInfosActions
967{
968  typeset actionType=$1
969  typeset entitySize=$2
970  typeset start_ms=$3
971  typeset end_ms=$4
972
973  typeset dest=$5
974  typeset source=$6
975
976  typeset diff_ms entitySizeKo entitySizeMo flux_Ko_ms flux_Ko_s flux_Mo_s
977  typeset dirFrom dirTo
978
979  diff_ms=$(( $end_ms - $start_ms ))
980  # echo "diff_ms=$diff_ms"
981
982  entitySizeKo=$( echo ${entitySize} | gawk -F"|" '{print $1}' )
983  # echo "entitySizeKo=$entitySizeKo"
984  entitySizeMo=$( echo ${entitySize} | gawk -F"|" '{print $2}' )
985
986  # flux en Ko / ms
987  flux_Ko_ms=$( echo "scale=6;${entitySizeKo}/${diff_ms}" | bc )
988  # echo "flux_Ko_ms=$flux_Ko_ms"
989
990  # flux en Ko / s
991  flux_Ko_s=$(( $flux_Ko_ms * 1000 ))
992  # echo "flux_Ko_s=$flux_Ko_s"
993
994  # flux en Mo / s
995  flux_Mo_s=$( echo "scale=6;${flux_Ko_s}/1024" | bc )
996  # echo "flux_Mo_s=$flux_Mo_s"
997
998  if [ -d $dest ] ; then
999    dirTo=$( readlink -f ${dest} )
1000  else
1001    dirTo=$( readlink -f $( dirname ${dest} ) )
1002  fi
1003
1004  if [ -d $source ] ; then
1005    dirFrom=$( readlink -f ${source} )
1006  else
1007    dirFrom=$( readlink -f $( dirname ${source} ) )
1008  fi
1009
1010  instrumentationContent=$( echo "\"actionName\":\"${actionType}\",\"size_Mo\":\"${entitySizeMo}\",\"duration_ms\":\"${diff_ms}\",\"throughput_Mo_s\":\"${flux_Mo_s}\",\"dirFrom\":\"${dirFrom}\",\"dirTo\":\"${dirTo}\"" )
1011
1012  if [ X${ActivateStackFilling} = Xtrue ] ; then
1013    echo "{${instrumentationContent}}" >> ${StackFileLocation}/${StackFileName}
1014  fi
1015
1016  # Inform the rabbitMQ queue
1017  if [ X${ActivateBigBro} = Xtrue ] ; then
1018    # RabbitMQ message body
1019    Body=$( echo "{${genericSimulationID},\"msgCode\":\"7000\",\"msgUID\":\"$(uuidgen)\",${instrumentationContent},\"msgTimestamp\":\"$( date +"%Y-%m-%dT%H:%M:%S.%N%z" )\"}" )
1020    # Fill the rabbitMQ queue
1021    IGCM_debug_sendAMQP
1022  fi
1023}
1024
1025#D-#==================================================================
1026#D-function IGCM_debug_Check
1027#D- * Purpose: Check the present file by comparison with a reference file
1028function IGCM_debug_Check
1029{
1030  #---------------------
1031  if [ ! -n "${libIGCM}" ] ; then
1032    echo "Check libIGCM_debug ..........................................[ FAILED ]"
1033    echo "--Error--> libIGCM variable is not defined"
1034    exit 2
1035  fi
1036
1037  #---------------------
1038  if [ ! -n "${Verbosity}" ] ; then
1039    echo "Check libIGCM_debug ..........................................[ FAILED ]"
1040    echo "--Error--> Verbosity variable is not defined"
1041    exit 3
1042  fi
1043
1044  #---------------------
1045  # Need to remove timestamps here
1046  diff ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref <(${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh | sed -e "s:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9] ::g") > /dev/null 2>&1
1047  status=$?
1048
1049  if [ ${status} -eq 0 ] ; then
1050    echo "Check libIGCM_debug ..............................................[ OK ]"
1051  else
1052    echo "Check libIGCM_debug ..........................................[ FAILED ]"
1053    echo "--Error--> Execution of ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh"
1054    echo "           has produced the file IGCM_debug_Test.ref.failed"
1055    echo "           Please analyse differences with the reference file by typing:"
1056    echo "           diff IGCM_debug_Test.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref"
1057    echo "           Report errors to the author: Patrick.Brockmann@cea.fr"
1058    diff ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref <(${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh | sed -e "s:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9] ::g")
1059    exit 4
1060  fi
1061  #---------------------
1062}
Note: See TracBrowser for help on using the repository browser.