forked from meom-group/DCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcmtk_journal_cpu
executable file
·88 lines (78 loc) · 3.14 KB
/
dcmtk_journal_cpu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# This script is used to update a Journal wiki page with the CPU used for a job.
# it requires 2 files for input :
# 1: a text copy of the wiki page ( option -w )
# 2: a text extraction of the cpu used on HPC ( option -c )
# class = @Run management tools@
usage() {
echo
echo "USAGE : $(basename $0 ) -w Journal_wiki.txt -c cpu_used.txt [-h] [-o output file] [-m machine ]"
echo
echo " PURPOSE:"
echo " Use accounting information hold in cpu_used.txt in order to finish the run's journal"
echo " created by dcmtk_journal_make."
echo
echo " ARGUMENTS: (mandatory)"
echo " -w Journal_wiki.txt : the name of the text file created from the wiki page"
echo " -c cpu_used.txt : the name of the acounting file on HPC computer (see dcmtk_getcpu) "
echo
echo " OPTIONS:"
echo " -h : this help message "
echo " : It can be obtained at https://reser.cines.fr/ with detailed option"
echo " -o output file : specify the output file name ( optional, default is Journal_cpu.txt )"
echo " : This file is then to be paste into the wiki, in place of the original table"
echo " -m machine : Specify the machine you are working on [occigen]. ada is also suported"
echo " On ada, cpu_used_ada.txt file can be obtained with idrjar -d 01/01-nn/mm"
echo
exit
}
chkfile() {
if [ ! -f $1 ] ; then
echo "ERROR : file $1 is missing "
exit
fi
}
if [ $# = 0 ] ; then usage ; fi
raw_journal=''
cpu_list=''
cpu_journal=Journal_cpu.txt
ierr=0
machine=occigen
while getopts :hw:m:c:o: opt ; do
case $opt in
(h) usage ;;
(w) raw_journal=$OPTARG ;;
(m) machine=$OPTARG ;;
(c) cpu_list=$OPTARG ;;
(o) cpu_journal=$OPTARG ;;
(\?) echo $( basename $0 ): option -$OPTARG not valid. ; usage ;;
esac
done
if [ ! $raw_journal ] ; then
ierr=1
echo "ERROR : you must specify a Journal_wiki.txt file "
fi
if [ ! $cpu_list ] ; then
ierr=1
echo "ERROR : you must specify a cpu_used.txt file "
fi
if [ $machine != ada -a $machine != occigen -a $machine != irene ] ; then
ierr=1
echo " ERROR : valid machines are occigen irene and ada "
fi
if [ $ierr = 1 ] ; then echo "" ; usage ; fi
chkfile $raw_journal
chkfile $cpu_list
case $machine in
( occigen | irene)
cat $cpu_list | awk 'NR != 1 { jobid=$2 ; cpu=$6 ; i=index(cpu,"-"); t=substr(cpu,i+1) ; split(t,a,":") ; cpuh=substr(cpu,1,i-1)*24+ a[1]+a[2]/60.+a[3]/3600 ; print cpuh}' > ztmplist2
cat $cpu_list | awk 'NR != 1 { jobid=$2 ; print jobid }' > zjobid ;;
( ada )
cat $cpu_list | awk '{printf "%6.1f\n", $5*$7/3600.}' > ztmplist2
cat $cpu_list | awk -F. '{print $2}' > zjobid ;;
esac
paste zjobid ztmplist2 > ztmplist
# \rm ztmplist2 zjobid
cmd=$(cat ztmplist | awk 'BEGIN{cmd= "sed "} { tpl= $1 "_CPU"; cmd= cmd " -e s/" tpl "/" $2"/" } END{ print cmd }' )
echo $cmd
cat $raw_journal | $cmd > $cpu_journal