1 | #!/bin/bash -f |
---|
2 | # |
---|
3 | # set -vx |
---|
4 | # simple SETTE report generator. |
---|
5 | # |
---|
6 | # This version should be run in the SETTE directory. |
---|
7 | # The machine name will be picked up from the sette.sh script but the location of the |
---|
8 | # validation directory needs to be set here (currently assumed to reside in the ../CONFIG directory) |
---|
9 | # |
---|
10 | ######################################################################################### |
---|
11 | ######################### Start of function definitions ################################# |
---|
12 | ## |
---|
13 | function resttest() { |
---|
14 | # |
---|
15 | # Restartability checks. Expects LONG and SHORT run directories |
---|
16 | # Compares end of LONG stat files with equivalent entries from the SHORT stat files. |
---|
17 | # |
---|
18 | vdir=$1 |
---|
19 | nam=$2 |
---|
20 | pass=$3 |
---|
21 | # |
---|
22 | if [ -d $vdir/$nam ]; then |
---|
23 | dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l ` |
---|
24 | dorv=`echo $dorv | sed -e 's:.*/::'` |
---|
25 | f1o=$vdir/$nam/$mach/$dorv/LONG/ocean.output |
---|
26 | f1s=$vdir/$nam/$mach/$dorv/LONG/run.stat |
---|
27 | f1t=$vdir/$nam/$mach/$dorv/LONG/tracer.stat |
---|
28 | f2o=$vdir/$nam/$mach/$dorv/SHORT/ocean.output |
---|
29 | f2s=$vdir/$nam/$mach/$dorv/SHORT/run.stat |
---|
30 | f2t=$vdir/$nam/$mach/$dorv/SHORT/tracer.stat |
---|
31 | |
---|
32 | if [ ! -f $f1s ] && [ ! -f $f1t ] ; then |
---|
33 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
34 | return; |
---|
35 | fi |
---|
36 | if [ ! -f $f2s ] && [ ! -f $f2t ] ; then |
---|
37 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
38 | return; |
---|
39 | fi |
---|
40 | # |
---|
41 | done_oce=0 |
---|
42 | |
---|
43 | if [ -f $f1s ] && [ -f $f2s ]; then |
---|
44 | nl=(`wc -l $f2s`) |
---|
45 | tail -${nl[0]} $f1s > f1.tmp$$ |
---|
46 | cmp -s f1.tmp$$ $f2s |
---|
47 | if [ $? == 0 ]; then |
---|
48 | if [ $pass == 0 ]; then |
---|
49 | printf "%-20s %s %s\n" $nam " run.stat restartability passed : " $dorv |
---|
50 | fi |
---|
51 | else |
---|
52 | printf "%-20s %s %s\n" $nam " run.stat restartability FAILED : " $dorv |
---|
53 | # |
---|
54 | # Offer view of differences on the second pass |
---|
55 | # |
---|
56 | if [ $pass == 1 ]; then |
---|
57 | echo "<return> to view run.stat differences" |
---|
58 | read y |
---|
59 | sdiff f1.tmp$$ $f2s |
---|
60 | echo "<return> to view ocean.output differences" |
---|
61 | read y |
---|
62 | sdiff $f1o $f2o | grep "|" |
---|
63 | done_oce=1 |
---|
64 | echo "<return> to continue" |
---|
65 | read y |
---|
66 | fi |
---|
67 | fi |
---|
68 | fi |
---|
69 | # |
---|
70 | # Check tracer.stat files (if they exist) |
---|
71 | # |
---|
72 | if [ -f $f1t ] && [ -f $f2t ]; then |
---|
73 | nl=(`wc -l $f2t`) |
---|
74 | tail -${nl[0]} $f1t > f1.tmp$$ |
---|
75 | cmp -s f1.tmp$$ $f2t |
---|
76 | if [ $? == 0 ]; then |
---|
77 | if [ $pass == 0 ]; then |
---|
78 | printf "%-20s %s %s\n" $nam " tracer.stat restartability passed : " $dorv |
---|
79 | fi |
---|
80 | else |
---|
81 | printf "%-20s %s %s\n" $nam " tracer.stat restartability FAILED : " $dorv |
---|
82 | # |
---|
83 | # Offer view of differences on the second pass |
---|
84 | # |
---|
85 | if [ $pass == 1 ]; then |
---|
86 | echo "<return> to view tracer.stat differences" |
---|
87 | read y |
---|
88 | sdiff f1.tmp$$ $f2t |
---|
89 | # |
---|
90 | # Only offer ocean.output view if it has not been viewed previously |
---|
91 | # |
---|
92 | if [ $done_oce == 0 ]; then |
---|
93 | echo "<return> to view ocean.output differences" |
---|
94 | read y |
---|
95 | sdiff $f1o $f2o | grep "|" |
---|
96 | fi |
---|
97 | echo "<return> to continue" |
---|
98 | read y |
---|
99 | fi |
---|
100 | fi |
---|
101 | fi |
---|
102 | rm f1.tmp$$ |
---|
103 | fi |
---|
104 | } |
---|
105 | |
---|
106 | function reprotest(){ |
---|
107 | # |
---|
108 | # Reproducibility checks. Expects REPRO_N_M and REPRO_I_J run directories |
---|
109 | # Compares end of stat files from each |
---|
110 | # |
---|
111 | vdir=$1 |
---|
112 | nam=$2 |
---|
113 | pass=$3 |
---|
114 | # |
---|
115 | if [ -d $vdir/$nam ]; then |
---|
116 | dorv=`ls -1rt $vdir/$nam/$mach/ | tail -1l ` |
---|
117 | dorv=`echo $dorv | sed -e 's:.*/::'` |
---|
118 | rep1=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -2l | head -1 ` |
---|
119 | rep2=`ls -1rt $vdir/$nam/$mach/$dorv/ | tail -1l` |
---|
120 | f1o=$vdir/$nam/$mach/$dorv/$rep1/ocean.output |
---|
121 | f1s=$vdir/$nam/$mach/$dorv/$rep1/run.stat |
---|
122 | f1t=$vdir/$nam/$mach/$dorv/$rep1/tracer.stat |
---|
123 | f2o=$vdir/$nam/$mach/$dorv/$rep2/ocean.output |
---|
124 | f2s=$vdir/$nam/$mach/$dorv/$rep2/run.stat |
---|
125 | f2t=$vdir/$nam/$mach/$dorv/$rep2/tracer.stat |
---|
126 | |
---|
127 | if [ ! -f $f1s ] && [ ! -f $f1t ] ; then |
---|
128 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
129 | return; |
---|
130 | fi |
---|
131 | if [ ! -f $f2s ] && [ ! -f $f2t ] ; then |
---|
132 | printf "%-20s %s\n" $nam " incomplete test"; |
---|
133 | return; |
---|
134 | fi |
---|
135 | # |
---|
136 | done_oce=0 |
---|
137 | |
---|
138 | if [ -f $f1s ] && [ -f $f2s ] ; then |
---|
139 | cmp -s $f1s $f2s |
---|
140 | if [ $? == 0 ]; then |
---|
141 | if [ $pass == 0 ]; then |
---|
142 | printf "%-20s %s %s\n" $nam " run.stat reproducibility passed : " $dorv |
---|
143 | fi |
---|
144 | else |
---|
145 | printf "%-20s %s %s\n" $nam " run.stat reproducibility FAILED : " $dorv |
---|
146 | # |
---|
147 | # Offer view of differences on the second pass |
---|
148 | # |
---|
149 | if [ $pass == 1 ]; then |
---|
150 | echo "<return> to view run.stat differences" |
---|
151 | read y |
---|
152 | sdiff f1.tmp$$ $f2s |
---|
153 | echo "<return> to view ocean.output differences" |
---|
154 | read y |
---|
155 | sdiff $f1o $f2o | grep "|" |
---|
156 | done_oce=1 |
---|
157 | echo "<return> to continue" |
---|
158 | read y |
---|
159 | fi |
---|
160 | fi |
---|
161 | fi |
---|
162 | # |
---|
163 | # Check tracer.stat files (if they exist) |
---|
164 | # |
---|
165 | if [ -f $f1t ] && [ -f $f2t ] ; then |
---|
166 | cmp -s $f1t $f2t |
---|
167 | if [ $? == 0 ]; then |
---|
168 | if [ $pass == 0 ]; then printf "%-20s %s %s\n" $nam " tracer.stat reproducibility passed : " $dorv |
---|
169 | fi |
---|
170 | else |
---|
171 | printf "%-20s %s %s\n" $nam " tracer.stat reproducibility FAILED : " $dorv |
---|
172 | # |
---|
173 | # Offer view of differences on the second pass |
---|
174 | # |
---|
175 | if [ $pass == 1 ]; then |
---|
176 | echo "<return> to view tracer.stat differences" |
---|
177 | read y |
---|
178 | sdiff $f1t $f2t |
---|
179 | # |
---|
180 | # Only offer ocean.output view if it has not been viewed previously |
---|
181 | # |
---|
182 | if [ $done_oce == 0 ]; then |
---|
183 | echo "<return> to view ocean.output differences" |
---|
184 | read y |
---|
185 | sdiff $f1o $f2o | grep "|" |
---|
186 | fi |
---|
187 | echo "<return> to continue" |
---|
188 | read y |
---|
189 | fi |
---|
190 | fi |
---|
191 | fi |
---|
192 | fi |
---|
193 | } |
---|
194 | ########################### END of function definitions ################################# |
---|
195 | ## ## |
---|
196 | ## Main script ## |
---|
197 | ## ## |
---|
198 | ######################################################################################### |
---|
199 | # |
---|
200 | mach=`grep "COMPILER=" ./sette.sh | sed -e 's/COMPILER=//'` |
---|
201 | NEMO_VALID=`grep "NEMO_VALIDATION_DIR=" ./param.cfg | sed -e 's/NEMO_VALIDATION_DIR=//'` |
---|
202 | NEMO_VALID=`eval "echo $NEMO_VALID"` |
---|
203 | # |
---|
204 | if [ ! -d $NEMO_VALID ]; then |
---|
205 | echo "$NEMO_VALID validation directory not found" |
---|
206 | exit |
---|
207 | fi |
---|
208 | # |
---|
209 | # The script also needs the date or revision tag. Currently this is taken from the latest sub-directory found in each directory |
---|
210 | # |
---|
211 | for pass in 0 1 |
---|
212 | do |
---|
213 | # |
---|
214 | if [ $pass == 1 ]; then echo "---------------2nd pass------------------";fi |
---|
215 | # |
---|
216 | # Restartability test |
---|
217 | # |
---|
218 | for restart_test in WGYREPIS_LONG WORCA2LIM3PIS_LONG WORCA2OFFPIS_LONG WAMM12_LONG WSAS_LONG WISOMIP_LONG WORCA2AGUL_LONG |
---|
219 | do |
---|
220 | resttest $NEMO_VALID $restart_test $pass |
---|
221 | done |
---|
222 | # |
---|
223 | # Reproducibility tests |
---|
224 | # |
---|
225 | for repro_test in WGYREPIS_32 WORCA2LIM3PIS_32 WORCA2OFFPIS_32 WAMM12_32 WISOMIP_32 WORCA2_LIM3_OBS WORCA2AGUL_1_2 WORCA2AGUL_16 WORCA2AGUL_2_2_NAG |
---|
226 | do |
---|
227 | reprotest $NEMO_VALID $repro_test $pass |
---|
228 | done |
---|
229 | # |
---|
230 | done |
---|
231 | exit |
---|