47f1183700951ec6e31aff33a915cdee871d6ea3
[u/mrichter/AliRoot.git] / PWGPP / QA / scripts / runQA.sh
1 #!/bin/bash
2 main()
3 {
4   if [[ -z $1 ]]; then
5     echo "Usage: "
6     echo "  ${0##*/} option=value [option=value]"
7     echo "  at least inputList should be specified, or configFile containing it:"
8     echo "  ${0##*/} inputList=file.list"
9     echo "  options override config file (if any), e.g.:"
10     echo "  ${0##*/} configFile=runQA.config inputList=file.list outputDirectory=%det"
11     return 1
12   fi
13  
14   if ! parseConfig "$@"; then
15     ${0}
16     return 1
17   fi
18
19   [[ -z $ALICE_ROOT ]] && echo "ALICE_ROOT not defined" && return 1
20
21   ocdbregex='raw://'
22   if [[ ${ocdbStorage} =~ ${ocdbregex} ]]; then
23     alien-token-init ${alienUserName}
24     #this is a hack! alien-token init seems not enough
25     #but the gclient_env script messes up the LD_LIBRARY_PATH
26     while read x; do
27       eval ${x};
28     done < <(grep -v "LD_LIBRARY_PATH" /tmp/gclient_env_${UID})
29   fi
30
31   updateQA "$@"
32 }
33
34 updateQA()
35 {
36   umask 0002
37   parseConfig "$@"
38
39   #be paranoid and make some full paths
40   [[ ! -f ${inputList} ]] && echo "no input list: ${inputList}" && return 1
41   inputList=$(get_realpath ${inputList})
42   mkdir -p ${workingDirectory}
43   workingDirectory=$(workingDirectory=${workingDirectory%/}; cd ${workingDirectory%/*}; echo "${PWD}/${workingDirectory##*/}")
44   if [[ ! -d ${workingDirectory} ]]; then
45     echo "working dir $workingDirectory does not exist and cannot be created"
46     return 1
47   fi
48   cd ${workingDirectory}
49
50   echo JOB config:
51   echo inputList=$inputList
52   echo outputDirectory=$outputDirectory
53   echo
54
55   dateString=$(date +%Y-%m-%d-%H-%M-%S-%N)
56   echo "Start time QA process: $dateString"
57
58   #logging
59   mkdir -p $logDirectory
60   [[ ! -d $logDirectory ]] && echo "no log dir $logDirectory" && return 1
61   logFile="$logDirectory/${0##*/}.${dateString}.log"
62   touch ${logFile}
63   [[ ! -f ${logFile} ]] && echo "cannot write logfile $logfile" && return 1
64   echo "logFile = $logFile"
65
66   #check lock
67   lockFile=${workingDirectory}/runQA.lock
68   [[ -f ${lockFile} ]] && echo "lock ${lockFile} exists!" | tee ${logFile} && return 1
69   touch ${lockFile}
70   [[ ! -f ${lockFile} ]] && echo "cannot lock $lockFile" | tee ${logFile} && return 1
71   
72   exec &>${logFile}
73
74   ################################################################
75   #ze detector loop
76   for detectorScript in $ALICE_ROOT/PWGPP/QA/detectorQAscripts/*; do
77     echo
78     echo "##############################################"
79     echo $(date)
80     unset planB
81     [[ ! ${detectorScript} =~ .*\.sh$ ]] && continue
82     detector=${detectorScript%.sh}
83     detector=${detector##*/}
84     
85     #skip if excluded
86     if [[ "${excludeDetectors}" =~ ${detector} ]]; then
87       echo "${detector} is excluded in config, skipping..."
88       continue
89     fi
90
91     #if includeDetectors set, only process thoe detectors specified there
92     if [[ -n ${includeDetectors} && ! "${includeDetectors}" =~ ${detector} ]]; then
93       echo "${detector} not included in includeDetectors, skipping..."
94       continue
95     fi
96
97     logSummary=${logDirectory}/summary-${detector}-${dateString}.log
98     hostInfo >> ${logSummary}
99     outputDir=$(substituteDetectorName ${detector} ${outputDirectory})
100     tmpDetectorRunDir=${workingDirectory}/tmpQAtmpRunDir${detector}-${dateString}
101     if ! mkdir -p ${tmpDetectorRunDir}; then
102       echo "cannot create the temp dir $tmpDetectorRunDir"
103       continue
104     fi
105     cd ${tmpDetectorRunDir}
106
107     tmpPrefix=${tmpDetectorRunDir}/${outputDir}
108     echo "running QA for ${detector}"
109     echo "  outputDir=$outputDir"
110     echo "  tmpPrefix=$tmpPrefix"
111     
112     #unset the detector functions from previous iterations (detectors)
113     unset -f runLevelQA
114     unset -f periodLevelQA
115     unset -f runLevelHighPtTreeQA
116     unset -f periodLevelHighPtTreeQA
117     source ${detectorScript}
118
119     #################################################################
120     #produce the QA and trending tree for each file (run)
121     unset arrOfTouchedProductions
122     declare -A arrOfTouchedProductions
123     while read qaFile; do
124       echo
125       echo $(date)
126       
127       #first check if input file exists
128       [[ ! -f ${qaFile%\#*} ]] && echo "file ${qaFile%\#*} not accessible" && continue
129
130       if ! guessRunData ${qaFile}; then
131         echo "could not guess run data from ${qaFile}"
132         continue
133       fi
134       echo "anchorYear for ${originalPeriod} is: ${anchorYear}"
135
136       tmpProductionDir=${tmpPrefix}/${dataType}/${year}/${period}/${pass}
137       tmpRunDir=${tmpProductionDir}/000${runNumber}
138       mkdir -p ${tmpRunDir}
139       cd ${tmpRunDir}
140
141       #by default we expect to have everything in the same archive
142       highPtTree=${qaFile}
143
144       #maybe the input is not an archive, but a file
145       [[ "${qaFile}" =~ QAresults.root$ ]] && highPtTree=""
146       [[ "${qaFile}" =~ FilterEvents_Trees.root$ ]] && qaFile=""
147
148       #it is possible we get the highPt trees from somewhere else
149       #search the list of high pt trees for the proper run number
150       if [[ -n ${inputListHighPtTrees} ]]; then
151         highPtTree=$(egrep -m1 ${runNumber} ${inputListHighPtTrees})
152         echo "loaded the highPtTree ${highPtTree} from external file ${inputListHighPtTrees}"
153       fi
154       
155       echo qaFile=$qaFile
156       echo highPtTree=$highPtTree
157       echo ocdbStorage=${ocdbStorage}
158       echo
159
160       #what if we have a zip archive?
161       if [[ "$qaFile" =~ .*.zip$ ]]; then
162         if unzip -l ${qaFile} | egrep "QAresults.root" &>/dev/null; then
163           qaFile="${qaFile}#QAresults.root"
164         elif unzip -l ${qaFile} | egrep "QAresults_barrel.root" &>/dev/null; then
165           qaFile="${qaFile}#QAresults_barrel.root"
166         else
167           qaFile=""
168         fi
169       fi
170       if [[ "$highPtTree" =~ .*.zip$ ]]; then
171         if unzip -l ${highPtTree} | egrep "FilterEvents_Trees.root" &>/dev/null; then
172           highPtTree="${highPtTree}#FilterEvents_Trees.root"
173         else
174           highPtTree=""
175         fi
176       fi
177      
178       if [[ -n ${qaFile} && $(type -t runLevelQA) =~ "function" ]]; then
179         echo running ${detector} runLevelQA for run ${runNumber} from ${qaFile}
180         runLevelQA "${qaFile}" &> runLevelQA.log
181         #perform some default actions:
182         #if trending.root not created, create a default one
183         if [[ ! -f trending.root ]]; then
184           aliroot -b -q -l "$ALICE_ROOT/PWGPP/macros/simpleTrending.C(\"${qaFile}\",${runNumber},\"${detector}\",\"trending.root\",\"trending\",\"recreate\")" 2>&1 | tee -a runLevelQA.log
185         fi
186         if [[ -f trending.root ]]; then
187           #cache the touched production + an example file to guarantee consistent run data parsing
188           arrOfTouchedProductions[${tmpProductionDir}]="${qaFile%\#*}"
189         else
190           echo "trending.root not created"
191         fi
192       fi
193       #expert QA based on high pt trees
194       if [[ -n ${highPtTree} && $(type -t runLevelHighPtTreeQA) =~ "function" ]]; then
195         echo running ${detector} runLevelHighPtTreeQA for run ${runNumber} from ${highPtTree}
196         runLevelHighPtTreeQA "${highPtTree}" &> runLevelHighPtTreeQA.log
197         arrOfTouchedProductions[${tmpProductionDir}]=1
198       fi
199
200       cd ${tmpDetectorRunDir}
201     
202     done < ${inputList}
203
204     #################################################################
205     #cache which productions were (re)done
206     echo "list of processed productions:"
207     echo "    ${!arrOfTouchedProductions[@]}"
208     echo
209
210     #################################################################
211     #(re)do the merging/trending 
212     for tmpProductionDir in ${!arrOfTouchedProductions[@]}; do
213       cd ${tmpProductionDir}
214       echo
215       echo "running period level stuff in ${tmpProductionDir}"
216       echo $(date)
217     
218       productionDir=${outputDir}/${tmpProductionDir#${tmpPrefix}}
219       echo productionDir=${outputDir}/${tmpProductionDir#${tmpPrefix}}
220
221       mkdir -p ${productionDir}
222       if [[ ! -d ${productionDir} ]]; then 
223         echo "cannot make productionDir $productionDir" && continue
224       fi
225       
226       #move runs to final destination
227       for dir in ${tmpProductionDir}/000*; do
228         echo 
229         oldRunDir=${outputDir}/${dir#${tmpPrefix}}
230         if ! guessRunData "${arrOfTouchedProductions[${tmpProductionDir}]}"; then
231           echo "could not guess run data from ${dir}"
232           continue
233         fi
234
235         #before moving - VALIDATE!!!
236         if ! validate ${dir}; then 
237           continue
238         fi
239
240         #moving a dir is an atomic operation, no locking necessary
241         if [[ -d ${oldRunDir} ]]; then
242           echo "removing old ${oldRunDir}"
243           rm -rf ${oldRunDir}
244         fi
245         echo "moving new ${runNumber} to ${productionDir}"
246         mv -f ${dir} ${productionDir}
247       done
248    
249       #go to a temp dir to do the period level stuff in a completely clean dir
250       tmpPeriodLevelQAdir="${tmpProductionDir}/periodLevelQA"
251       echo
252       echo tmpPeriodLevelQAdir="${tmpProductionDir}/periodLevelQA"
253       if ! mkdir -p ${tmpPeriodLevelQAdir}; then continue; fi
254       cd ${tmpPeriodLevelQAdir}
255
256       #link the final list of per-run dirs here, just the dirs
257       #to have a clean working directory
258       unset linkedStuff
259       declare -a linkedStuff
260       for x in ${productionDir}/000*; do [[ -d $x ]] && ln -s $x && linkedStuff+=(${x##*/}); done
261
262       #merge trending files if any
263       if /bin/ls 000*/trending.root &>/dev/null; then
264         hadd trending.root 000*/trending.root &> periodLevelQA.log
265       fi
266       
267       #run the period level trending/QA
268       if [[ -f "trending.root" && $(type -t periodLevelQA) =~ "function" ]]; then
269         echo running ${detector} periodLevelQA for production ${period}/${pass}
270         periodLevelQA trending.root &>> periodLevelQA.log
271       else 
272         echo "WARNING: not running ${detector} periodLevelQA for production ${period}/${pass}, no trending.root"
273       fi
274
275       if ! validate ${PWD}; then continue; fi
276
277       #here we are validated so move the produced QA to the final place
278       #clean up linked stuff first
279       [[ -n ${linkedStuff[@]} ]] && rm ${linkedStuff[@]}
280       periodLevelLock=${productionDir}/runQA.lock
281       if [[ ! -f ${periodLevelLock} ]]; then
282         #some of the output could be a directory, so handle that
283         #TODO: maybe use rsync?
284         #lock to avoid conflicts:
285         echo "${HOSTNAME} ${dateString}" > ${periodLevelLock}
286         for x in ${tmpPeriodLevelQAdir}/*; do  
287           if [[ -d ${x} ]]; then
288             echo "removing ${productionDir}/${x##*/}"
289             rm -rf ${productionDir}/${x##*/}
290             echo "moving ${x} to ${productionDir}"
291             mv ${x} ${productionDir}
292           fi
293           if [[ -f ${x} ]]; then
294             echo "moving ${x} to ${productionDir}"
295             mv -f ${x} ${productionDir} 
296           fi
297         done
298         rm -f ${periodLevelLock}
299         #remove the temp dir
300         rm -rf ${tmpPeriodLevelQAdir}
301       else
302         echo "ERROR: cannot move to destination"                     >> ${logSummary}
303         echo "production dir ${productionDir} locked!"               >> ${logSummary}
304         echo "check and maybe manually do:"                          >> ${logSummary}
305         echo " rm ${periodLevelLock}"                                >> ${logSummary}
306         echo " rsync -av ${tmpPeriodLevelQAdir}/ ${productionDir}/"  >> ${logSummary}
307         planB=1
308       fi
309
310     done
311
312     cd ${workingDirectory}
313
314     if [[ -z ${planB} ]]; then
315       echo
316       echo removing ${tmpDetectorRunDir}
317       rm -rf ${tmpDetectorRunDir}
318     else
319       executePlanB
320     fi
321   done #end of detector loop
322
323   #remove lock
324   rm -f ${lockFile}
325 }
326
327 executePlanB()
328 {
329   #in case of emergency
330   if [[ -n ${MAILTO} ]]; then 
331     echo
332     echo "trouble detected, sending email to ${MAILTO}"
333     cat ${logSummary} | mail -s "qa in need of assistance" ${MAILTO}
334   fi
335 }
336
337 validate()
338 {
339   summarizeLogs ${1} >> ${logSummary}
340   logStatus=$?
341   if [[ ${logStatus} -ne 0 ]]; then 
342     echo "WARNING not validated: ${1}"
343     planB=1
344     return 1
345   fi
346   return 0
347 }
348
349 summarizeLogs()
350 {
351   local dir=$1
352   [[ ! -d ${dir} ]] && dir=${PWD}
353
354   #print a summary of logs
355   logFiles=(
356       "*.log"
357       "stdout"
358       "stderr"
359   )
360
361   #check logs
362   local logstatus=0
363   for log in ${dir}/${logFiles[*]}; do
364     [[ ! -f ${log} ]] && continue
365     errorSummary=$(validateLog ${log})
366     validationStatus=$?
367     [[ validationStatus -ne 0 ]] && logstatus=1
368     if [[ ${validationStatus} -eq 0 ]]; then 
369       #in pretend mode randomly report an error in rec.log some cases
370       if [[ -n ${pretend} && "${log}" == "rec.log" ]]; then
371         [[ $(( ${RANDOM}%2 )) -ge 1 ]] && echo "${log} BAD random error" || echo "${log} OK"
372       else
373         echo "${log} OK"
374       fi
375     elif [[ ${validationStatus} -eq 1 ]]; then
376       echo "${log} BAD ${errorSummary}"
377     elif [[ ${validationStatus} -eq 2 ]]; then
378       echo "${log} OK MWAH ${errorSummary}"
379     fi
380   done
381
382   #report core files
383   while read x; do
384     echo ${x}
385     chmod 644 ${x}
386     gdb --batch --quiet -ex "bt" -ex "quit" aliroot ${x} > stacktrace_${x//\//_}.log
387   done < <(/bin/ls ${PWD}/*/core 2>/dev/null; /bin/ls ${PWD}/core 2>/dev/null)
388
389   return ${logstatus}
390 }
391
392 validateLog()
393 {
394   log=${1}
395   errorConditions=(
396             'There was a crash'
397             'floating'
398             'error while loading shared libraries'
399             'std::bad_alloc'
400             's_err_syswatch_'
401             'Thread [0-9]* (Thread'
402             'AliFatal'
403             'core dumped'
404             '\.C.*error:.*\.h: No such file'
405             'segmentation'
406             'Interpreter error recovered'
407   )
408
409   warningConditions=(
410             'This is serious'
411   )
412
413   local logstatus=0
414   local errorSummary=""
415   local warningSummary=""
416
417   for ((i=0; i<${#errorConditions[@]};i++)); do
418     local tmp=$(grep -m1 -e "${errorConditions[${i}]}" ${log})
419     [[ -n ${tmp} ]] && tmp+=" : "
420     errorSummary+=${tmp}
421   done
422
423   for ((i=0; i<${#warningConditions[@]};i++)); do
424     local tmp=$(grep -m1 -e "${warningConditions[${i}]}" ${log})
425     [[ -n ${tmp} ]] && tmp+=" : "
426     warningSummary+=${tmp}
427   done
428
429   if [[ -n ${errorSummary} ]]; then 
430     echo "${errorSummary}"
431     return 1
432   fi
433
434   if [[ -n ${warningSummary} ]]; then
435     echo "${warningSummary}"
436     return 2
437   fi
438
439   return 0
440 }
441
442 parseConfig()
443 {
444   args=("$@")
445
446   #config file
447   configFile=""
448   #where to search for qa files
449   inputList=file.list
450   #working directory
451   workingDirectory="${PWD}"
452   #where to place the final qa plots
453   #outputDirectory="/afs/cern.ch/work/a/aliqa%det/www/"
454   outputDirectory="${workingDirectory}/%DET"
455   #filter out detector option
456   excludeDetectors="EXAMPLE"
457   #logs
458   logDirectory=${workingDirectory}/logs
459   #OCDB storage
460   ocdbStorage="raw://"
461   #email to
462   #MAILTO="fbellini@cern.ch"
463
464   #first, check if the config file is configured
465   #is yes - source it so that other options can override it
466   #if any
467   for opt in "${args[@]}"; do
468     if [[ ${opt} =~ configFile=.* ]]; then
469       eval "${opt}"
470       [[ ! -f ${configFile} ]] && echo "configFile ${configFile} not found, exiting..." && return 1
471       echo "using config file: ${configFile}"
472       source "${configFile}"
473       break
474     fi
475   done
476
477   #then, parse the options as they override the options from file
478   for opt in "${args[@]}"; do
479     if [[ ! "${opt}" =~ .*=.* ]]; then
480       echo "badly formatted option ${var}, should be: option=value, stopping..."
481       return 1
482     fi
483     local var="${opt%%=*}"
484     local value="${opt#*=}"
485     echo "${var}=${value}"
486     export ${var}="${value}"
487   done
488 }
489
490 guessRunData()
491 {
492   #guess the period from the path, pick the rightmost one
493   period=""
494   runNumber=""
495   year=""
496   pass=""
497   legoTrainRunNumber=""
498   dataType=""
499   originalPass=""
500   originalPeriod=""
501   anchorYear=""
502
503   shortRunNumber=""
504   oldIFS=${IFS}
505   local IFS="/"
506   declare -a path=( $1 )
507   IFS="${oldIFS}"
508   local dirDepth=$(( ${#path[*]}-1 ))
509   i=0
510   for ((x=${dirDepth};x>=0;x--)); do
511
512     [[ $((x-1)) -ge 0 ]] && local fieldPrev=${path[$((x-1))]}
513     local field=${path[${x}]}
514     local fieldNext=${path[$((x+1))]}
515
516     [[ ${field} =~ ^[0-9]*$ && ${fieldNext} =~ (.*\.zip$|.*\.root$) ]] && legoTrainRunNumber=${field}
517     [[ -n ${legoTrainRunNumber} && -z ${pass} ]] && pass=${fieldPrev}
518     [[ ${field} =~ ^LHC[0-9][0-9][a-z].*$ ]] && period=${field%_*} && originalPeriod=${field}
519     [[ ${field} =~ ^000[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && runNumber=${field#000}
520     [[ ${field} =~ ^[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && shortRunNumber=${field}
521     [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field}
522     [[ ${field} =~ ^(^sim$|^data$) ]] && dataType=${field}
523     (( i++ ))
524   done
525   originalPass=${pass}
526   [[ -n ${shortRunNumber} && "${legoTrainRunNumber}" =~ ${shortRunNumber} ]] && legoTrainRunNumber=""
527   [[ -z ${legoTrainRunNumber} ]] && pass=${path[$((dirDepth-1))]}
528   [[ "${dataType}" =~ ^sim$ ]] && pass="passMC" && runNumber=${shortRunNumber} && originalPass="" #for MC not from lego, the runnumber is identified as lego train number, thus needs to be nulled
529   [[ -n ${legoTrainRunNumber} ]] && pass+="_lego${legoTrainRunNumber}"
530   
531   #modify the OCDB: set the year
532   if [[ ${dataType} =~ sim ]]; then 
533     anchorYear=$(for x in $mcProductionMap ; do [[ "${x}" =~ ${originalPeriod} ]] && echo ${x} && break; done)
534     anchorYear=${anchorYear#*=}
535     ocdbStorage=$(setYear ${anchorYear} ${ocdbStorage})
536   else
537     ocdbStorage=$(setYear ${year} ${ocdbStorage})
538   fi
539
540   #if [[ -z ${dataType} || -z ${year} || -z ${period} || -z ${runNumber}} || -z ${pass} ]];
541   if [[ -z ${runNumber}} ]]
542   then
543     #error condition
544     return 1
545   else
546     #ALL OK
547     return 0
548   fi
549 }
550
551 substituteDetectorName()
552 {
553   local det=$1
554   local dir=$2
555   [[ ${dir} =~ \%det ]] && det=${det,,} && echo ${dir/\%det/${det}}
556   [[ ${dir} =~ \%DET ]] && det=${det} && echo ${dir/\%DET/${det}}
557 }
558
559 get_realpath() 
560 {
561   if [[ -f "$1" ]]
562   then
563     # file *must* exist
564     if cd "$(echo "${1%/*}")" &>/dev/null
565     then
566       # file *may* not be local
567       # exception is ./file.ext
568       # try 'cd .; cd -;' *works!*
569       local tmppwd="$PWD"
570       cd - &>/dev/null
571     else
572       # file *must* be local
573       local tmppwd="$PWD"
574     fi
575   else
576     # file *cannot* exist
577     return 1 # failure
578   fi
579   # reassemble realpath
580   echo "$tmppwd"/"${1##*/}"
581   return 0 # success
582 }
583
584 setYear()
585 {
586   #set the year
587   #  ${1} - year to be set
588   #  ${2} - where to set the year
589   local year1=$(guessYear ${1})
590   local year2=$(guessYear ${2})
591   local path=${2}
592   [[ ${year1} -ne ${year2} && -n ${year2} && -n ${year1} ]] && path=${2/\/${year2}\//\/${year1}\/}
593   echo ${path}
594   return 0
595 }
596
597 guessYear()
598 {
599   #guess the year from the path, pick the rightmost one
600   local IFS="/"
601   declare -a pathArray=( ${1} )
602   local field
603   local year
604   for field in ${pathArray[@]}; do
605     [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field}
606   done
607   echo ${year}
608   return 0
609 }
610
611 hostInfo(){
612 #
613 # Hallo world -  Print AliRoot/Root/Alien system info
614 #
615
616 #
617 # HOST info
618 #
619     echo --------------------------------------
620         echo 
621         echo HOSTINFO
622         echo 
623         echo HOSTINFO HOSTNAME"      "$HOSTNAME
624         echo HOSTINFO DATE"          "`date`
625         echo HOSTINFO gccpath"       "`which gcc` 
626         echo HOSTINFO gcc version"   "`gcc --version | grep gcc`
627         echo --------------------------------------    
628
629 #
630 # ROOT info
631 #
632         echo --------------------------------------
633         echo
634         echo ROOTINFO
635         echo 
636         echo ROOTINFO ROOT"           "`which root`
637         echo ROOTINFO VERSION"        "`root-config --version`
638         echo 
639         echo --------------------------------------
640
641
642 #
643 # ALIROOT info
644 #
645         echo --------------------------------------
646         echo
647         echo ALIROOTINFO
648         echo 
649         echo ALIROOTINFO ALIROOT"        "`which aliroot`
650         echo ALIROOTINFO VERSION"        "`echo $ALICE_LEVEL`
651         echo ALIROOTINFO TARGET"         "`echo $ALICE_TARGET`
652         echo 
653         echo --------------------------------------
654
655 #
656 # Alien info
657 #
658 #echo --------------------------------------
659 #echo
660 #echo ALIENINFO
661 #for a in `alien --printenv`; do echo ALIENINFO $a; done 
662 #echo
663 #echo --------------------------------------
664
665 #
666 # Local Info
667 #
668         echo PWD `pwd`
669         echo Dir 
670         ls -al
671         echo
672         echo
673         echo
674 }
675
676 main "$@"