read_joblist.sh 3.11 KB
Newer Older
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash

joblist=joblist #0

#declare -a myarray
declare -a myarray0
declare -a myarray1
declare -a myarray2

# Load file into array.
let i=0
let i0=0
let i1=0
let i1=0
while IFS=$'\n' read -r line_data; do
    # Parse “${line_data}” to produce content 
    # that will be stored in the array.
    # (Assume content is stored in a variable 
    # named 'array_element'.)
    # ...

#sbatch slurm_batch_pathnames10.sl
#Submitted batch job 113835
#    if [ $((i%2)) -eq 0 ] 
#    then 
##    	echo $i is "even" 
#    	echo line_data=$line_data
#    	array_element0=${i#*pathnames}
#        echo array_element0=$array_element0
#    	myarray0[i]="${array_element0}"
#    	((++i0))
#    fi
    echo line_data read=$line_data
    #array_element1=${line_data#*pathnames}
    array_element1=${line_data#*pathnames}
    echo array_element1=$array_element1    
    array_element1=${array_element1%*.sl}
    echo array_element1=$array_element1    

    myarray1[i]="${array_element1}" # Populate array.
#    myarray[i]="${line_data}"
    ((++i))
done < ${joblist}1$joblistgroup
#done < ${joblist}1


let i=0
while IFS=$'\n' read -r line_data; do
	echo line_data read=$line_data
	array_element2bis=${line_data##job}
	array_element2=${line_data:20:26}
        
	echo array_element2bis=$array_element2
	echo array_element2=$array_element2
    	myarray2[i]="${array_element2}" # Populate array.
    	((++i))
done < ${joblist}2$joblistgroup
#done < ${joblist}2





let i=0
while (( ${#myarray1[@]} > i )); do
    printf "${myarray1[i++]}\n"
done

let i=0
while (( ${#myarray2[@]} > i )); do
    printf "${myarray2[i++]}\n"
done

let i=0
while (( ${#myarray2[@]} > i )); do
    echo 'test' "${myarray1[$i]}" 'is job' "${myarray2[$i]}"
    ((++i))
done

let i=0
while (( ${#myarray2[@]} > i )); do
    
    echo 'test' "${myarray1[$i]}" 'is job' "${myarray2[$i]}"
    ((++i))
done
#exit

tot_successes="$(cat output-*.out  | grep CONGRATULATIONS  | wc -l)"
tot_runs="$(ls -1 output-*.out | wc -l)"
echo $tot_successes successful out of $tot_runs

let isuc=0
let ifail=0
let i=0
while (( ${#myarray2[@]} > i )); do

#    stringin < output-*myarray1[$i].out   
#    issuccess="$(cat output-*myarray1[$i].out  | grep CONGRATULATIONS  | wc -l)"

#echo search output-*${myarray1[$i]}.out
#outputlist=$(ls -1 output-*.out | grep ${myarray1[$i]})
#echo outputlist = $outputlist

nummer=${myarray2[$i]}
echo nummer=$nummer
capture=$(find *"$nummer"*out)
capture2=`find *"$nummer"*out`

echo capture=$capture
echo capture2=$capture2

issuccess="$(cat "$capture"  | grep CONGRATULATIONS  | wc -l)"
issuccess2=`cat "$capture"  | grep CONGRATULATIONS  | wc -l`
echo $issuccess
echo $issuccess2



#[ $1 -gt 100 ]
#if [[grep -Fxq CONGRATULATIONS "$capture"]]

echo issuccess=$issuccess
echo [ $issuccess -eq 1 ]

  if [ $issuccess == 1 ]
   then
    # code if found
    ((++isuc))
    echo 'test' "${myarray1[$i]}" 'is job' "${myarray2[$i]}" success=$issuccess OK
  else
     ((++ifail))
    echo 'test' "${myarray1[$i]}" 'is job' "${myarray2[$i]}" success=$issuccess not found
    # code if not found
  fi


    ((++i))
done

echo i=$i
echo isuc=$isuc
echo ifail=$ifail
#output-prod-cn08-113896.out