forked from darwinproject/darwin3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
testreport
executable file
·1887 lines (1772 loc) · 62.8 KB
/
testreport
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/env bash
usage()
{
echo
echo "Usage: $0 [OPTIONS]"
echo
echo "where possible OPTIONS are:"
echo " (-help|-h) print usage"
echo " ---- type of test : ----"
echo " (-tlm) perform a Tangent Linear run"
echo " (-adm|-ad) perform an adjoint run"
echo " (-oad) perform an OpenAD adjoint run"
echo " (-oadsingularity|-oadsngl) STRING"
echo " path to singularity container with OpenAD"
echo " (-mth) run multi-threaded (using eedata.mth)"
echo " (-mpi) use MPI to compile and run on 2 processors"
echo " (-MPI) NUMBER use MPI to compile and run on max NUMBER procs"
echo " (-mfile|-mf) STRING MPI: file with list of possible machines to run on"
echo " (-command|-c) STRING command to run (e.g., if non-standard MPI setting)"
echo " DEF='mitgcmuv' or ='mpirun -np TR_NPROC mitgcmuv'"
echo " ---- testing options : ----"
echo " (-optfile|-of) STRING optfile to use"
echo " (-fast) use optfile default for compiler flags (no '-ieee')"
echo " DEF=off => use IEEE numerics option (if available)"
echo " (-devel) use optfile developement flags (if available)"
echo " (-gsl) compile with \"-gsl\" flag"
echo " (-use_r4|-ur4) if allowed, use real*4 type for '_RS' variable"
echo " (-tdir|-t) STRING list of group and/or exp. dirs to test"
echo " (recognized groups: basic, tutorials)"
echo " (DEF=\"\" which test all)"
echo " (if list= 'start_from THIS_EXP' then"
echo " test THIS_EXP + all the following)"
echo " (-skipdir|-skd) STRING list of exp. dirs to skip"
echo " (DEF=\"\" which test all)"
echo " (-ts) provide timing information per timestep"
echo " (-papis) provide MFlop/s per timestep using PAPI"
echo " (-pcls) provide MFlop/s per timestep using PCL"
echo " ---- system options : ----"
echo " (-bash|-b) STRING preferred location of a \"bash\" or \"sh\" shell"
echo " (DEF=\"\" for \"bash\")"
echo " (-ef) STRING used as genmake2 \"-extra_flag\" argument"
echo " (-ncad) use genmake2 option \"-nocat4ad\" (-ncad)"
echo " (-small_f) make target small_f before making target all"
echo " (-makedepend|-md) STRING command to use for \"makedepend\""
echo " (-make|-m) STRING command to use for \"make\""
echo " (DEF=\"make\")"
echo " (-j) JOBS use \"make -j JOBS\" for parallel builds"
echo " ---- output options : ----"
echo " (-match) NUMBER Matching Criteria (number of digits)"
echo " (DEF=\"$MATCH_CRIT\")"
echo " (-odir) STRING used to build output directory name"
echo " (DEF=\"hostname\")"
echo " (-addr|-a) STRING list of email recipients"
echo " (DEF=\"\" no email is sent)"
echo " (-send) STRING sending command (instead of using mpack)"
echo " (-savdir|-sd) STRING location to save output tar file to send (DEF='$SAVDIR')"
echo " (-mpackdir|-mpd) DIR location of the mpack utility"
echo " (DEF=\"../tools/mpack-1.6\")"
echo " -- do only some parts: --"
echo " (-clean) *ONLY* run \"make CLEAN\" & clean run-dir"
echo " (-norun|-nr) skip the \"runmodel\" stage (stop after make)"
echo " (-obj) only produces objects (=norun & no executable)"
echo " (-src) only produces small '*.f' src files (not even obj)"
echo " + with: '-adm/-tlm', also makes taf outp src code"
echo " (-runonly|-ro) *ONLY* run stage (=\"-quick\" without make)"
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\""
echo " (-nogenmake|-ng) skip the genmake stage"
echo " (-noclean|-nc) skip the \"make clean\" stage"
echo " (-nodepend|-nd) skip the \"make depend\" stage"
echo " (-postclean|-pc) after each exp. test, clean build-dir & run-dir"
echo " (-deloutp|-do) delete output files after successful run"
echo " (-deldir|-dd) on success, delete the output directory"
echo
echo "and where STRING can be a whitespace-delimited list"
echo "such as:"
echo
echo " -t 'exp0 exp2 exp3' "
echo " -addr='abc@123.com testing@home.org'"
echo
echo "provided that the expression is properly quoted within the current"
echo "shell (note the use of single quotes to protect white space)."
echo
exit 1
}
# build the mpack utility
build_mpack()
{
printf "building the mpack utility... "
MPACK="$MPACKDIR/mpack"
if test ! -x $MPACK ; then
if test ! -d $MPACKDIR ; then
echo
echo "Error: can't find \"$MPACKDIR\""
echo " are you sure this program is being run in the correct "
echo " (that is, \"MITGCM_ROOT\verification\") directory?"
echo
HAVE_MPACK=f
fi
if test "x$CC" = x ; then
export CC=cc
fi
printf "building mpack (using CC=$CC)... "
( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
RETVAL=$?
if test "x$RETVAL" != x0 ; then
echo
echo "Error building the mpack tools at: $MPACK_DIR"
echo
HAVE_MPACK=f
else
rm -f tr_build_mpack.out
HAVE_MPACK=t
echo "done"
fi
else
HAVE_MPACK=t
echo "already exist"
fi
}
testoutput_var()
{
# testoutput_var dir s1 label subdir reference_output
#
# compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE
# with same output from reference file $dir/$reference_output
# using search strings s1 and text label
if [ $debug -gt 0 ]; then
echo testoutput_var: grep "'$2'" $1/$4/$OUTPUTFILE 1>&2
fi
if [ -r $1/$4/$OUTPUTFILE ]; then
grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | nl > ${TMP}a.txt
lncntA=`wc -l ${TMP}a.txt | awk '{print $1}' `
if [ $lncntA -lt 2 ]; then
if [ $verbose -gt 0 ]; then
echo Not enough lines of output when searching for "$2" 1>&2
fi
rm -f ${TMP}a.txt ; return 99
fi
else
echo testoutput_var: $OUTPUTFILE from model run was not readable 1>&2
return 99
fi
if [ $debug -gt 0 ]; then
echo testoutput_var: grep "'$2'" $1/$5 1>&2
fi
grep "$2" $1/$5 | sed 's/.*=//' | nl > ${TMP}b.txt
lncntB=`wc -l ${TMP}b.txt | awk '{print $1}' `
if [ $lncntB -lt 2 ]; then
if [ $verbose -gt 0 ]; then
echo Not enough lines of output when searching for "$2" 1>&2
fi
rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
fi
if [ $lncntA -ne $lncntB ]; then
if [ $verbose -gt 0 ]; then
echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
fi
rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
fi
has_nan=`cat ${TMP}a.txt | grep -i nan | wc -l`
if [ $has_nan -gt 0 ] ; then
echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values 1>&2
rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
fi
has_inf=`cat ${TMP}a.txt | grep -i inf | wc -l`
if [ $has_inf -gt 0 ] ; then
echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values 1>&2
rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
fi
if [ $debug -gt 0 ]; then
echo testoutput_var: join ${TMP}a.txt ${TMP}b.txt 1>&2
fi
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
join ${TMP}a.txt ${TMP}b.txt | awk '{print $1 " " $2 " " $3}' | sed -e 's|:||g' > ${TMP}c.txt
if [ $debug -gt 0 ]; then
echo testoutput_var: compare_lines 1>&2
fi
if [ $verbose -gt 1 ]; then
cat ${TMP}c.txt 1>&2
fi
echo "-1" >> ${TMP}c.txt
digits_of_similarity=`./tr_cmpnum < ${TMP}c.txt`
if [ $digits_of_similarity -eq 99 ]; then
if [ $verbose -gt 0 ]; then
echo testoutput_var: No comparison was available for \"$3\" 1>&2
fi
digits_of_similarity=99
else
if [ $verbose -gt 0 ]; then
echo There were $digits_of_similarity decimal places of similarity for \"$3\" 1>&2
fi
fi
rm -f ${TMP}a.txt ${TMP}b.txt ${TMP}c.txt
return $digits_of_similarity
}
testoutput_run()
{
# testoutput_run directory subdir reference_output
#
# test output from 1 run in "directory"
# --> same processing for adjoint & forward test
# default list of output variables to be checked:
# 1rst : main variable used to decide if it pass or FAIL
# others : number of matching digits to be printed in summary.txt
listChk=$DEF_CHECK_LIST
# load experiment-specific list from file "tr_checklist" (if it exist)
if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi
if test $KIND = 1 ; then kd='g_';
# TLM use same input_ad/tr_checklist --> convert
listChk=`echo $listChk | sed 's/^adm/tlm/' | sed 's/ adm/ tlm/g'`
if test -r $1/$2/tr_checklist.tlm ; then listChk=`cat $1/$2/tr_checklist.tlm` ; fi
elif test $KIND = 2 ; then kd='ad';
if test -r $1/$2/tr_checklist.adm ; then listChk=`cat $1/$2/tr_checklist.adm` ; fi
elif test $KIND = 4 ; then kd='ad';
else kd=''; fi
if [ $debug -gt 0 ]; then echo "testoutput_run: listChk='$listChk'" 1>&2 ; fi
# remove 1rst var and expand the list: + => min max mean s.d
sVar=`echo $listChk | awk '{print $1}'`
listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \
| sed 's/+//g' | sed "s/^$sVar//"`
# set ref.outp file-name and, if compressed, uncompress it into subdir
refoutp=results/$3
if test ! -r $1/results/$3 ; then
if test -r $1/results/${3}.gz ; then
tmpNam1=$3
tmpNam2=`echo $tmpNam1 | sed 's/\..*\././'`
if test "x$tmpNam1" = "x$tmpNam2" ; then
tmpNam1=`echo $tmpNam2 | sed 's/\./.std./'`
fi
refoutp=$2/$tmpNam1
if [ $debug -gt 0 ]; then
echo "testoutput_run: gunzip 'results/$3.gz' into '$refoutp'" 1>&2
fi
gzip -cd $1/results/${3}.gz > $1/$refoutp
else
echo "missing reference output file '$3' (.gz) in '$1/results/'"
fi
fi
# check for ptracer output in reference_output file :
if test $KIND = 0 ; then
ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max"
ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
for ii in $PTRACERS_NUM ; do
ptrfound=0
for jj in $ptr_mon ; do
name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
tst=`grep $name $1/$refoutp | wc -l | awk '{print $1}'`
if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
done
if test $ptrfound = '1' ; then
eval "HAVE_PTR0"$ii"=t"
else
eval "HAVE_PTR0"$ii"=f"
# remove this ptr from the list of output variable to check
# echo "-- ptr test=" $tst "number of var=" `echo $listVar | awk '{print NF}'` 1>&2
listVar=`echo "$listVar" | sed "s/ pt$ii..//g"`
fi
# eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
done
fi
tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'`
if test $tst != 1 ; then
if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2
else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi
echo "==> WARNING: in checked list:" $listVar 1>&2
#- put it back once:
listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
fi
if [ $debug -gt 0 ]; then echo "testoutput_run: listVar='$listVar'" 1>&2 ; fi
echo "listVar='$listVar'" >> $locDIR"/summary.txt"
#---
allargs=""
for xx in $listVar
do
#ii=`echo $xx | sed 's/^pt[0-9][0-9]*..$/XXX/'` #- any ptr number
ii=`echo $xx | sed 's/^pt[1-9]..$/XXX/'` #- 1 to 9 ptr number
if test $ii != 'XXX' ; then
#- all except ptracer stats:
case $xx in
'PS') if [ $debug -gt 0 ]
then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $refoutp ; yy=$?
if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
'admCst') testoutput_var $1 "ADM ref_cost_function" "ADM CostFct" $2 $refoutp ; yy=$? ;;
'admGrd') testoutput_var $1 "ADM adjoint_gradient" "ADM Ad Grad" $2 $refoutp ; yy=$? ;;
'admFwd') testoutput_var $1 "ADM finite-diff_grad" "ADM FD Grad" $2 $refoutp ; yy=$? ;;
'tlmCst') testoutput_var $1 "TLM ref_cost_function" "TLM CostFct" $2 $refoutp ; yy=$? ;;
'tlmGrd') testoutput_var $1 "TLM tangent-lin_grad" "TLM TL Grad" $2 $refoutp ; yy=$? ;;
'tlmFwd') testoutput_var $1 "TLM finite-diff_grad" "TLM FD Grad" $2 $refoutp ; yy=$? ;;
'Tmn') testoutput_var $1 "dynstat_${kd}theta_min" "${kd}Theta minimum" $2 $refoutp ; yy=$? ;;
'Tmx') testoutput_var $1 "dynstat_${kd}theta_max" "${kd}Theta maximum" $2 $refoutp ; yy=$? ;;
'Tav') testoutput_var $1 "dynstat_${kd}theta_mean" "${kd}Theta mean" $2 $refoutp ; yy=$? ;;
'Tsd') testoutput_var $1 "dynstat_${kd}theta_sd" "${kd}Theta Std.Dev" $2 $refoutp ; yy=$? ;;
'Smn') testoutput_var $1 "dynstat_${kd}salt_min" "${kd}Salt minimum" $2 $refoutp ; yy=$? ;;
'Smx') testoutput_var $1 "dynstat_${kd}salt_max" "${kd}Salt maximum" $2 $refoutp ; yy=$? ;;
'Sav') testoutput_var $1 "dynstat_${kd}salt_mean" "${kd}Salt mean" $2 $refoutp ; yy=$? ;;
'Ssd') testoutput_var $1 "dynstat_${kd}salt_sd" "${kd}Salt Std.Dev" $2 $refoutp ; yy=$? ;;
'Umn') testoutput_var $1 "dynstat_${kd}uvel_min" "${kd}U minimum" $2 $refoutp ; yy=$? ;;
'Umx') testoutput_var $1 "dynstat_${kd}uvel_max" "${kd}U maximum" $2 $refoutp ; yy=$? ;;
'Uav') testoutput_var $1 "dynstat_${kd}uvel_mean" "${kd}U mean" $2 $refoutp ; yy=$? ;;
'Usd') testoutput_var $1 "dynstat_${kd}uvel_sd" "${kd}U Std.Dev" $2 $refoutp ; yy=$? ;;
'Vmn') testoutput_var $1 "dynstat_${kd}vvel_min" "${kd}V minimum" $2 $refoutp ; yy=$? ;;
'Vmx') testoutput_var $1 "dynstat_${kd}vvel_max" "${kd}V maximum" $2 $refoutp ; yy=$? ;;
'Vav') testoutput_var $1 "dynstat_${kd}vvel_mean" "${kd}V mean" $2 $refoutp ; yy=$? ;;
'Vsd') testoutput_var $1 "dynstat_${kd}vvel_sd" "${kd}V Std.Dev" $2 $refoutp ; yy=$? ;;
'Etamn') testoutput_var $1 "dynstat_${kd}eta_min" "${kd}Eta minimum" $2 $refoutp ; yy=$? ;;
'Etamx') testoutput_var $1 "dynstat_${kd}eta_max" "${kd}Eta maximum" $2 $refoutp ; yy=$? ;;
'Etaav') testoutput_var $1 "dynstat_${kd}eta_mean" "${kd}Eta mean" $2 $refoutp ; yy=$? ;;
'Etasd') testoutput_var $1 "dynstat_${kd}eta_sd" "${kd}Eta Std.Dev" $2 $refoutp ; yy=$? ;;
'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum" $2 $refoutp ; yy=$? ;;
'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum" $2 $refoutp ; yy=$? ;;
'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean" $2 $refoutp ; yy=$? ;;
'Qntsd') testoutput_var $1 "forcing_qnet_sd" "Qnet Std.Dev" $2 $refoutp ; yy=$? ;;
'aSImn') testoutput_var $1 "seaice_${kd}area_min" "SIce ${kd}Area min" $2 $refoutp ; yy=$? ;;
'aSImx') testoutput_var $1 "seaice_${kd}area_max" "SIce ${kd}Area max" $2 $refoutp ; yy=$? ;;
'aSIav') testoutput_var $1 "seaice_${kd}area_mean" "SIce ${kd}Area mean" $2 $refoutp ; yy=$? ;;
'aSIsd') testoutput_var $1 "seaice_${kd}area_sd" "SIce ${kd}Area StDv" $2 $refoutp ; yy=$? ;;
'hSImn') testoutput_var $1 "seaice_${kd}heff_min" "SIce ${kd}Heff min" $2 $refoutp ; yy=$? ;;
'hSImx') testoutput_var $1 "seaice_${kd}heff_max" "SIce ${kd}Heff max" $2 $refoutp ; yy=$? ;;
'hSIav') testoutput_var $1 "seaice_${kd}heff_mean" "SIce ${kd}Heff mean" $2 $refoutp ; yy=$? ;;
'hSIsd') testoutput_var $1 "seaice_${kd}heff_sd" "SIce ${kd}Heff StDv" $2 $refoutp ; yy=$? ;;
'uSImn') testoutput_var $1 "seaice_${kd}uice_min" "SIce ${kd}Uice min" $2 $refoutp ; yy=$? ;;
'uSImx') testoutput_var $1 "seaice_${kd}uice_max" "SIce ${kd}Uice max" $2 $refoutp ; yy=$? ;;
'uSIav') testoutput_var $1 "seaice_${kd}uice_mean" "SIce ${kd}Uice mean" $2 $refoutp ; yy=$? ;;
'uSIsd') testoutput_var $1 "seaice_${kd}uice_sd" "SIce ${kd}Uice StDv" $2 $refoutp ; yy=$? ;;
'vSImn') testoutput_var $1 "seaice_${kd}vice_min" "SIce ${kd}Vice min" $2 $refoutp ; yy=$? ;;
'vSImx') testoutput_var $1 "seaice_${kd}vice_max" "SIce ${kd}Vice max" $2 $refoutp ; yy=$? ;;
'vSIav') testoutput_var $1 "seaice_${kd}vice_mean" "SIce ${kd}Vice mean" $2 $refoutp ; yy=$? ;;
'vSIsd') testoutput_var $1 "seaice_${kd}vice_sd" "SIce ${kd}Vice StDv" $2 $refoutp ; yy=$? ;;
'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $refoutp ; yy=$? ;;
'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South" $2 $refoutp ; yy=$? ;;
'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North" $2 $refoutp ; yy=$? ;;
'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Glob-ave" $2 $refoutp ; yy=$? ;;
'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South-av" $2 $refoutp ; yy=$? ;;
'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North-av" $2 $refoutp ; yy=$? ;;
'HthMxS') testoutput_var $1 "thSI_IceH_max_S" "thSIc H South-max" $2 $refoutp ; yy=$? ;;
'HthMxN') testoutput_var $1 "thSI_IceH_max_N" "thSIc H North-max" $2 $refoutp ; yy=$? ;;
'sbo_M') testoutput_var $1 "sbo_mass" "SBO mass" $2 $refoutp ; yy=$? ;;
'sboFW') testoutput_var $1 "sbo_mass_fw" "SBO m-FW" $2 $refoutp ; yy=$? ;;
'sboAc') testoutput_var $1 "sbo_zoamc" "SBO AM-C" $2 $refoutp ; yy=$? ;;
'sboAp') testoutput_var $1 "sbo_zoamp" "SBO AM-P" $2 $refoutp ; yy=$? ;;
'StrmIc') testoutput_var $1 "STREAMICE_FP_ERR" "StreamIce Solver" $2 $refoutp ; yy=$? ;;
*) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
esac
else
#- ptracers stats:
nn=`echo $xx | sed 's/pt//' | sed 's/..$//'`
ii=`echo $xx | sed 's/^pt[0-9]*//'`
case $ii in
'mn') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_min" "${kd}pTr0"$nn"_min" $2 $refoutp ; yy=$? ;;
'mx') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_max" "${kd}pTr0"$nn"_max" $2 $refoutp ; yy=$? ;;
'av') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_mean" "${kd}pTr0"$nn"_mean" $2 $refoutp ; yy=$? ;;
'sd') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_sd" "${kd}pTr0"$nn"_StDv" $2 $refoutp ; yy=$? ;;
esac
fi
if test $xx = $sVar
then allargs="$allargs > $yy <"
else allargs="$allargs $yy"
fi
done
nbVar=`echo $listVar | awk '{print NF}'`
if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
#-- fill line (up to standard length) with dot:
adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
echo $allargs $adNul
else
echo $allargs
fi
# <-- same processing for adjoint & forward test
}
genmakemodel()
{
# genmakemodel directory
if test "x$NOGENMAKE" = xt ; then
echo "genmake skipped!"
else
if test "x$BASH" = x ; then
GENMAKE2="../../../tools/genmake2"
else
GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
fi
(
cd $1;
command="$GENMAKE2 -ds -m $MAKE"
if test "x$MKDEPEND" != x ; then
command="$command -makedepend=$MKDEPEND"
fi
if test $KIND = 4 ; then
command="$command -oad -mods=../$code_dir"
else
command="$command -mods=../$code_dir"
fi
if test "x$OPTFILE" != xNONE ; then
command="$command -optfile=$OPTFILE"
fi
if test $OptLev = 1 ; then
command="$command -ieee"
fi
if test $OptLev = 0 ; then
command="$command -devel"
fi
if test "x$GSL" = xt ; then
command="$command -gsl"
fi
if test "x$MPI" != x0 ; then
command="$command -mpi"
fi
if test "x$MULTI_THREAD" = xt ; then
#- run multi-threaded using OpenMP:
command="$command -omp"
fi
if test "x$USE_R4" = xt ; then
command="$command -use_r4"
fi
if test "x$EXTRFLG" != x ; then
command="$command -extra_flag $EXTRFLG"
fi
if test "x$NOCATAD" = xt ; then
command="$command -nocat4ad"
fi
if test "x$TS" = xt ; then
command="$command -ts"
fi
if test "x$PAPIS" = xt ; then
command="$command -papis"
else
if test "x$PCLS" = xt ; then
command="$command -pcls"
fi
if test "x$OADSINGULARITY" != x ; then
command="$command -oadsingularity \"$OADSINGULARITY\""
fi
fi
printf 'genmake ... '
eval $command > genmake.tr_log 2>&1
RETVAL=$?
# Reduce the size of the testing emails!
head -100 Makefile > $CDIR/Makefile_head
if test "x$RETVAL" != x0 ; then
tail genmake.tr_log
echo "genmakemodel: genmake failed"
cp genmake.log genmake_* genmake.tr_log $CDIR
return 1
else
echo "successful"
fi
)
fi
}
makeclean()
{
# makeclean directory
if test "x$NOGENMAKE" = xf ; then rm -f $1/make.tr_log ; fi
if test "x$NOCLEAN" = xt ; then
echo "make Clean skipped!"
else
(
cd $1;
#if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
if test -r Makefile ; then
printf 'clean build-dir: make Clean ... '
$MAKE Clean >> make.tr_log 2>&1
RETVAL=$?
if test "x$RETVAL" != x0 ; then
tail make.tr_log
echo "makeclean: \"make Clean\" failed"
cp make.tr_log genmake.log genmake.tr_log $CDIR
return 1
fi
echo successful
else
echo ''
fi
exit 0
)
fi
}
run_clean()
{
# run_clean directory
if test "x$NOCLEAN" = xt ; then
echo "run_clean skipped!"
else
(
cd $1;
printf 'clean run-dir ... '
# part of what is done after "make clean" when doing "make CLEAN"
find . -name "*.meta" -exec rm {} \;
find . -name "*.data" -exec rm {} \;
find . -name "*.tmp" -exec rm {} \;
find . -name "fort.*" -exec rm {} \;
find . -type l -exec rm {} \;
#- should remove executable only if sym-link (already done above)
rm -f $RUNLOG *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
rm -f datetime costfinal divided.ctrl snapshot* output_adm.*.diva_*
rm -f *_MIT_CE_000.opt0000 costfunction*0000
rm -f oad_cp.[0-9][0-9][0-9].?????
rm -rf mnc_test_*
echo successful
exit 0
)
fi
}
makedependmodel()
{
# makedependmodel directory
if test "x$NODEPEND" = xt ; then
echo "make depend skipped!"
else
(
cd $1;
printf 'make depend ... '
$MAKE depend >> make.tr_log 2>&1
RETVAL=$?
if test "x$RETVAL" != x0 ; then
tail make.tr_log
echo "makedependmodel: make depend failed"
cp make.tr_log genmake.log genmake.tr_log $CDIR
return 1
else
echo successful
fi
)
fi
}
makemodel()
{
# makemodel directory
(
mk_fail=0
if test "x$NOMAKE" = xt ; then
cd $1;
if test -x $EXECUTABLE ; then
echo "make skipped!"
else
echo "no executable!"
mk_fail=3
fi
else
cd $1;
if test -r Makefile ; then
if test "x$MKSMALLF" = xt ; then
printf 'make small_f ... '
$MAKE_CMD small_f >> make.tr_log 2>&1
RETVAL=$?
if test "x$RETVAL" != x0 ; then
tail make.tr_log
echo failed
cp genmake.log genmake.tr_log $CDIR
tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
rm -f $EXECUTABLE
mk_fail=1
else
echo successful
fi
fi
printf "make $TARG ... "
$MAKE_CMD $TARG >> make.tr_log 2>&1
RETVAL=$?
if test "x$RETVAL" != x0 ; then
tail make.tr_log
echo failed
cp genmake.log genmake.tr_log $CDIR
tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
rm -f $EXECUTABLE
mk_fail=1
else
echo successful
fi
else
echo "no Makefile !"
mk_fail=2
fi
fi
if test $KIND = 1 -a -f taf_ftl.log ; then
grep 'Processing files at' make.tr_log | tail -1 >> $CDIR"/summary.txt"
head -1 taf_ftl.log >> $CDIR"/summary.txt"
fi
if test $KIND = 2 -a -f taf_ad.log ; then
grep 'Processing files at' make.tr_log | tail -1 >> $CDIR"/summary.txt"
head -1 taf_ad.log >> $CDIR"/summary.txt"
nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log`
nwar=`grep -c '^TAF *.* RECOMPUTATION *.* WARNING ' taf_ad.log`
if test -f taf_output ; then
n2er=`grep -c 'TAF *.* ERROR ' taf_output`
n3er=`grep -c '\*ERROR\* ' taf_output`
nerr=`expr $nerr + $n2er + $n3er`
fi
echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \
>> $CDIR"/summary.txt"
if test -f ad_taf_output.f ; then
adfile=ad_taf_output.f
elif test -f ad_taf_output.for ; then
adfile=ad_taf_output.for
else
echo "WARNING: neither ad_output_ad.f nor ad_output_ad.for found" \
>> $CDIR"/summary.txt"
adfile=missing ; nlfd=0 ; ndop=0 ; nsm=0
fi
if test $adfile != missing ; then
# count number of times load_fields_driver and do_oceanic_phys are called
nlfd=`grep "call load_fields_driver(" ${adfile} | wc -l`
nlfdmd=`grep "call load_fields_drivermd(" ${adfile} | wc -l`
if (( $nlfdmd == 0 )) ; then
# if there is no load_fields_driver, we can substract one assuming
# that load_fields_driver is called once from forward_stepmd
nlfd=$((nlfd-1))
fi
ndop=`grep "call do_oceanic_phys(" ${adfile} | wc -l`
nsm=`grep "call seaice_model(" ${adfile} | wc -l`
fi
echo " load_fields_driver, do_oceanic_phys, seaice_model are called " \
"( $nlfd , $ndop , $nsm ) time(s)" >> $CDIR"/summary.txt"
fi
if test $mk_fail != 0 ; then return $mk_fail ; fi
)
}
mk_mpi_size()
{
# mk_mpi_size input_file output_file proc_Nb threads_Nb_X threads_Nb_Y
#
# make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file)
# for an MPI build with no more than proc_Nb processors ;
# ensure that enough tiles per proc (nSx,nSy) remain for the given
# number of threads (nTx,nTy) ;
# return the effective number of processors.
inp=$1
out=$2
np=$3
tx=$4
ty=$5
tmp=TTT.$$
# dirX : select with direction to favor in MPI process repartition
# dirX=1 : prefer to put more proc in X direction
# dirX=0 : prefer to put more proc in Y direction
dirX=0
px=`grep "^ & *nPx *=" $inp | sed "s/^ & *nPx *= *//" | sed 's/, *$//'`
py=`grep "^ & *nPy *=" $inp | sed "s/^ & *nPy *= *//" | sed 's/, *$//'`
sx=`grep "^ & *nSx *=" $inp | sed "s/^ & *nSx *= *//" | sed 's/, *$//'`
sy=`grep "^ & *nSy *=" $inp | sed "s/^ & *nSy *= *//" | sed 's/, *$//'`
#- for each direction, assume # of threads is a multiple of total number of tiles
nx=$px
if [ `expr $sx % $tx` -ne 0 -a `expr $sx \* $px % $tx` -eq 0 ] ; then
nx=`expr $sx \* $px / $tx`
if [ $verbose -gt 1 ]; then
echo " change px from $px to $nx to accommodate $tx threads"
fi
fi
ny=$py
if [ `expr $sy % $ty` -ne 0 -a `expr $sy \* $py % $ty` -eq 0 ] ; then
ny=`expr $sy \* $py / $ty`
if [ $verbose -gt 1 ]; then
echo " change py from $py to $ny to accommodate $ty threads"
fi
fi
#- find the largest divisor of input_file proc Nb, but not larger than $np
pp=0
i=1
while [ $i -le $nx ] ; do
if [ `expr $nx % $i` -eq 0 ] ; then
j=1
while [ $j -le $ny ] ; do
if [ `expr $ny % $j` -eq 0 ] ; then
ij=`expr $i \* $j`
if [ $ij -gt $pp ] ; then
flag=1
elif [ $ij -eq $pp ] ; then
flag=$dirX
else
flag=0
fi
if test $flag = 1 ; then
if [ $ij -le $np ] ; then
ix=$i ; jy=$j ; pp=$ij
#echo " ix,jy= $ix,$jy"
fi
fi
fi
j=`expr $j + 1`
done
fi
i=`expr $i + 1`
done
#- create new SIZE.h type file:
sx=`expr $sx \* $px / $ix`
sy=`expr $sy \* $py / $jy`
if [ $verbose -gt 1 ]; then
echo " px,py,np= $px,$py,$np : New MPI size: px,py= $ix,$jy : sx,sy= $sx,$sy"
fi
sed "/^ \& *nPx *=/s/[0-9]*,/$ix,/" $inp > $tmp
sed "/^ \& *nPy *=/s/[0-9]*,/$jy,/" $tmp > $out
sed "/^ \& *nSx *=/s/[0-9]*,/$sx,/" $out > $tmp
sed "/^ \& *nSy *=/s/[0-9]*,/$sy,/" $tmp > $out
rm -f $tmp
return $pp
}
symlink_mpifiles()
{
# Put special links so that MPI specific files are used
# This MUST be invoked between makeclean and makelinks because
# the Makefile will link to non-mpi files by default
dir=$1
code_dir=$2
build_dir=$dir/$3
# These are files that should replace their counter-part when using -mpi
MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
for ii in $MPI_FILES ; do
i=`echo $ii | sed 's:^\./::'`
name=`echo $i | sed 's:_mpi::'`
file="../$code_dir/$i"
if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
# Is this an MPI run?
if test "x$MPI" = x0 ; then
# NO: We undo any _mpi symbolically linked files
if test -L $build_dir/$name ; then
( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
RETVAL=$?
if test "x$RETVAL" = x0 ; then
if [ $verbose -gt 1 ]; then
echo " Un-linking $name from ../$code_dir" ; fi
rm -f $build_dir/$name
fi
fi
else
# YES: We symbolically link these files to the build
# dir so long as there is no real file in place
( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
RETVAL=$?
if [ $verbose -gt 1 ]; then echo " cmp $name $file returns: $RETVAL" ; fi
if test "x$RETVAL" != x0 ; then
if test -h $build_dir/$name ; then rm -f $build_dir/$name ; fi
if test ! -r $build_dir/$name ; then
if [ $verbose -gt 1 ]; then echo " Linking $name to $file" ; fi
(cd $build_dir; ln -sf $file $name)
fi
fi
fi
done
}
linkdata()
{
# linkdata run_dir input_dir_1 input_dir_2 ...
#
# symbolically link data files to run directory
if test -d $1 ; then
(
cd $1 ; shift
echo 'linkdata from dirs:' $*
inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
for xx in $inpMPI ; do
if test -r "../"$1"/"$xx ; then
# found 1 _mpi sfx file in 1rst input dir and it is readable
yy=`echo $xx | sed 's:\.mpi$::'`
if test "x$MPI" = "x0" ; then
# not mpi test: remove symbolic link
if test -h $yy ; then rm -f $yy ; fi
else
# mpi test: remove symbolic link & link .mpi sfx file
if test -h $yy ; then rm -f $yy ; fi
if test ! -r $yy ; then
ln -sf "../"$1"/"$xx $yy ;
printf " $xx" 1>&2
fi
fi
fi
done
if test -r "../"$1"/eedata.mth" ; then
# found eedata.mth in 1rst input dir and it is readable
if test "x$MULTI_THREAD" = "xt" ; then
# multi-threaded test: remove symbolic link & link eedata.mth
if test -h eedata ; then rm -f eedata ; fi
if test ! -r eedata ; then
ln -sf "../"$1"/eedata.mth" eedata ;
printf ' eedata.mth' 1>&2
fi
else
# not multi-threaded test: remove eedata symbolic link
if test -h eedata ; then rm -f eedata ; fi
fi
fi
prevDir='NONE'
for ldir in $* ; do
if test -d "../"$ldir -a $ldir != $prevDir ; then
printf " ldir=${ldir}:" 1>&2
files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
for i in $files ; do
if test ! -d "../"$ldir/$i ; then
if test ! -r $i ; then
printf ' '$i 1>&2
ln -sf "../"$ldir"/"$i $i
fi
fi
done
printf ' ;' 1>&2
if test -x "../"$ldir"/"prepare_run ; then
"../"$ldir"/"prepare_run 1>&2
else
echo '' 1>&2
fi
fi
prevDir=$ldir
done
)
fi
}
runmodel()
{
# runmodel directory
#
# runs $COMMAND in "directory"
# (where "$COMMAND" is relative to "directory")
(
cd $1
printf 'runmodel in %s ... ' $1
if test "x$MPI" != x0 ; then
#- adjust the MPI run command with the right number of Procs
#echo '' ; echo " COMMAND='$COMMAND'"
COMMAND=`echo $COMMAND | sed "s/ TR_NPROC/ $LOC_NPROC/"`
if test "x$MPI_MFILE" != x ; then
COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
fi
#echo " COMMAND='$COMMAND'"
fi
if test -L $EXECUTABLE ; then
if test -x "../"$builddir"/"$EXECUTABLE ; then
cmp $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
outD=$? ; if test "x$outD" != x0 ; then rm -f $EXECUTABLE ; fi
else rm -f $EXECUTABLE
fi
fi
if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
ln -sf "../"$builddir"/"$EXECUTABLE .
fi
if test ! -x $EXECUTABLE ; then
rm -f $RUNLOG ; touch $RUNLOG
if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
echo " no executable:" $EXECUTABLE >> $RUNLOG
RETVAL=8
ENDVAL=-1
else
if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
# output do not exist or is older than executable:
rm -f $OUTPUTFILE $RUNLOG ; touch $RUNLOG
if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
#- Divided Adjoint Run:
# get the number of additional runs (add_DIVA_runs) from file "run_ADM_DIVA"
if test $KIND = 2 -a -f run_ADM_DIVA ; then
adm_diva_nb=`sed -n '/^ *add_DIVA_runs *=/p' run_ADM_DIVA | sed 's/ //g'`
echo " Divided Adjoint Run: $adm_diva_nb" >> $RUNLOG
eval "let $adm_diva_nb"
if [ $add_DIVA_runs -ge 1 ] ; then
rm -f costf* divided.ctrl snapshot*
echo -n "(add_DIVA_runs=$add_DIVA_runs) ... "
for ii in `seq 1 $add_DIVA_runs` ; do
( eval $COMMAND ) >> $RUNLOG 2>&1
echo " additional DIVA run # $ii : done" >> $RUNLOG
mv -f $OUTPUTFILE ${OUTPUTFILE}.diva_${ii}
done
fi
elif test -f run_ADM_DIVA ; then
rm -f costf* divided.ctrl snapshot*
fi
#- special DIVA processing ends here
( eval $COMMAND ) >> $RUNLOG 2>&1
RETVAL=$?
ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
if [ $POSTCLEAN -eq 1 -a $ENDVAL -gt 0 ] ; then
find . -name "*.meta" -exec rm {} \;
find . -name "*.data" -exec rm {} \;
rm -rf mnc_test_*
fi
else
RETVAL=0
ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
touch $RUNLOG
if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
fi
fi
rm -f run.log_tmp
#- in all cases where OutputFile exists, report SIZE and time
if test -f $OUTPUTFILE ; then
grep '(PID\.TID 0000\.0001) n.. =' $OUTPUTFILE \
| sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt"
# grep -A3 'Seconds in section "ALL' $OUTPUTFILE \
# | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt"
# some implementations of grep cannot do contextual searches so we
# replace the above with a sed command
cat $OUTPUTFILE | sed -n '/Seconds in section "ALL/{N
N
N
p
}' | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt"
fi
if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
echo successful
printf '=> output from running in %s :\n' $1 1>&2
tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
return 0
elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
#-- for some weird cases (run is finihed but with error code)
echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
printf '=> output from running in %s :\n' $1 1>&2
tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
return 0
else
echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
printf '=> output from running in %s :\n' $1 1>&2
tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
cp $RUNLOG $CDIR"/"$RUNLOG
return 1
fi
)
}
createcodelet()
{
# create codelet for comparing model output
printf "creating the comparison code (using CC=$CC)... "
cat > tr_cmpnum.c <<EOF
#include <stdio.h>
#include <math.h>
int main( int argc, char** argv ) {
int linnum,cmplin,best,lncnt;
double a,b,abave,relerr;
best = -22;
lncnt = 0;
while( 1 & ( (lncnt+=1) < 999 ) ) {
scanf("%d", &linnum);
if (linnum == -1) break;
scanf("%lf", &a); scanf("%lf", &b);
abave = 0.5*(fabs(a)+fabs(b));
if ( abave == abave ) {
if (abave > 0.0) {
relerr=fabs(a-b)/abave;
if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
else { cmplin = -16 ; }
best = (best > cmplin) ? best : cmplin; }
else { cmplin = -22 ; }
/* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
}
else {
/* printf("%lf ; %lf ; %lf\n",abave,a,b); */
break; }
}
if (lncnt == 999) best=-29;
if (linnum != -1) best=-99;
printf("%d\n", -best);
return 0;
}
EOF
$CC -o tr_cmpnum tr_cmpnum.c -lm
if [ -x ./tr_cmpnum ]; then
echo "OK"
return 0
else
echo
echo "ERROR: failed to compile comparison code -- please specify"
echo " a C compiler using the CC environment variable."
exit 1
fi
}
formatresults()
{
# formatresults expt genmake depend make run results*
nm=$1
printf '%s %s %s %s' $2 $3 $4 $5
shift; shift; shift; shift; shift;
listPrt=$@