/[MITgcm]/MITgcm/verification/testreport
ViewVC logotype

Annotation of /MITgcm/verification/testreport

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.171 - (hide annotations) (download)
Wed Mar 14 02:34:20 2012 UTC (12 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63l, checkpoint63m, checkpoint63k
Changes since 1.170: +10 -6 lines
- add option to use a home made wrapper around "make"
- remove MITGCM_IEEE env. variable (no longer active)

1 edhill 1.19 #! /usr/bin/env bash
2 edhill 1.1 #
3 jmc 1.171 # $Header: /u/gcmpack/MITgcm/verification/testreport,v 1.170 2011/12/22 12:55:05 mlosch Exp $
4 edhill 1.12 # $Name: $
5 edhill 1.1 #
6    
7     usage()
8     {
9     echo
10     echo "Usage: $0 [OPTIONS]"
11     echo
12     echo "where possible OPTIONS are:"
13     echo " (-help|-h) print usage"
14 jmc 1.122 echo " (-mth) run multi-threaded (using eedata.mth)"
15 jmc 1.154 echo " (-mpi) use MPI to compile and run on 2 processors"
16     echo " (-MPI) NUMBER use MPI to compile and run on max NUMBER procs"
17 jmc 1.156 echo " (-mfile|-mf) STRING MPI: file with list of possible machines to run on"
18 jmc 1.164 echo " (-fast) use optfile default for compiler flags (no '-ieee')"
19     echo " DEF=off => use IEEE numerics option (if available)"
20     echo " (-devel) use optfile developement flags (if available)"
21 jmc 1.109 echo " (-gsl) compile with \"-gsl\" flag"
22 jmc 1.136 echo " (-use_r4|-ur4) if allowed, use real*4 type for '_RS' variable"
23     echo " (-optfile|-of) STRING list of optfiles to use"
24     echo " (-addr|-a) STRING list of email recipients"
25 jmc 1.108 echo " (DEF=\"\" no email is sent)"
26 jmc 1.136 echo " (-mpackdir|-mpd) DIR location of the mpack utility"
27 jmc 1.113 echo " (DEF=\"../tools/mpack-1.6\")"
28 jmc 1.136 echo " (-tdir|-t) STRING list of group and/or exp. dirs to test"
29 jmc 1.84 echo " (recognized groups: basic, tutorials)"
30     echo " (DEF=\"\" which test all)"
31 jmc 1.149 echo " (if list= 'start_from THIS_EXP' then"
32     echo " test THIS_EXP + all the following)"
33 jmc 1.136 echo " (-skipdir|-skd) STRING list of exp. dirs to skip"
34 jmc 1.89 echo " (DEF=\"\" which test all)"
35 jmc 1.136 echo " (-bash|-b) STRING preferred location of a \"bash\" or"
36 edhill 1.20 echo " Bourne-compatible \"sh\" shell"
37     echo " (DEF=\"\" for \"bash\")"
38 edhill 1.24 echo " (-adm|-ad) perform an adjoint run"
39 utke 1.120 echo " (-oad) perform an OpenAD adjoint run"
40 jmc 1.136 echo " (-command|-c) STRING command to run"
41 jmc 1.141 echo " (-makedepend|-md) STRING command to use for \"makedepend\""
42 jmc 1.136 echo " (-make|-m) STRING command to use for \"make\""
43 edhill 1.8 echo " (DEF=\"make\")"
44 jmc 1.70 echo " (-odir) STRING used to build output directory name"
45     echo " (DEF=\"hostname\")"
46 jmc 1.156 # echo " (-ptracers|-ptr) STRING specify which ptracers to test"
47     # echo " (DEF=\"1 2 3 4 5\")"
48 jmc 1.92 echo " (-match) NUMBER Matching Criteria (number of digits)"
49 jmc 1.141 echo " (DEF=\"$MATCH_CRIT\")"
50 edhill 1.43 echo " (-j) JOBS use \"make -j JOBS\" for parallel builds"
51 jmc 1.165 echo " (-ef) STRING used as genmake2 \"-extra_flag\" argument"
52 jmc 1.156 echo " (-clean) *ONLY* run \"make CLEAN\" & clean run-dir"
53 jmc 1.133 echo " (-norun|-nr) skip the \"runmodel\" stage (stop after make)"
54 jmc 1.165 echo " (-obj) only produces objects (=norun & no executable)"
55 jmc 1.136 echo " (-runonly|-ro) *ONLY* run stage (=\"-quick\" without make)"
56 ce107 1.90 echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\""
57     echo " (-nogenmake|-ng) skip the genmake stage"
58     echo " (-noclean|-nc) skip the \"make clean\" stage"
59     echo " (-nodepend|-nd) skip the \"make depend\" stage"
60 jmc 1.156 echo " (-postclean|-pc) after each exp. test, clean build-dir & run-dir"
61     echo " (-deloutp|-do) delete output files after successful run"
62 ce107 1.90 echo " (-deldir|-dd) on success, delete the output directory"
63     echo " (-ts) provide timing information per timestep"
64     echo " (-papis) provide MFlop/s per timestep using PAPI"
65     echo " (-pcls) provide MFlop/s per timestep using PCL"
66 edhill 1.6 echo
67 edhill 1.50 echo "and where STRING can be a whitespace-delimited list"
68 edhill 1.6 echo "such as:"
69 edhill 1.50 echo
70 edhill 1.6 echo " -t 'exp0 exp2 exp3' "
71     echo " -addr='abc@123.com testing@home.org'"
72 edhill 1.1 echo
73 edhill 1.50 echo "provided that the expression is properly quoted within the current"
74     echo "shell (note the use of single quotes to protect white space)."
75     echo
76 edhill 1.1 exit 1
77     }
78    
79     # build the mpack utility
80     build_mpack()
81     {
82 edhill 1.34 printf "building the mpack utility... "
83 jmc 1.113 MPACK="$MPACKDIR/mpack"
84     if test ! -x $MPACK ; then
85 edhill 1.1 if test ! -d $MPACKDIR ; then
86 edhill 1.20 echo
87 edhill 1.1 echo "Error: can't find \"$MPACKDIR\""
88     echo " are you sure this program is being run in the correct "
89     echo " (that is, \"MITGCM_ROOT\verification\") directory?"
90 edhill 1.20 echo
91     HAVE_MPACK=f
92 edhill 1.1 fi
93 edhill 1.26 if test "x$CC" = x ; then
94     export CC=cc
95     fi
96 jmc 1.112 printf "building mpack (using CC=$CC)... "
97 edhill 1.25 ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
98 edhill 1.1 RETVAL=$?
99     if test "x$RETVAL" != x0 ; then
100     echo
101     echo "Error building the mpack tools at: $MPACK_DIR"
102 edhill 1.20 echo
103     HAVE_MPACK=f
104     else
105 edhill 1.25 rm -f tr_build_mpack.out
106 edhill 1.20 HAVE_MPACK=t
107 jmc 1.113 echo "done"
108 edhill 1.1 fi
109 edhill 1.20 else
110     HAVE_MPACK=t
111 jmc 1.113 echo "already exist"
112 edhill 1.1 fi
113     }
114    
115 jmc 1.93 testoutput_var()
116 edhill 1.1 {
117 jmc 1.99 # testoutput_var dir s1 label subdir reference_output
118 edhill 1.1 #
119 jmc 1.135 # compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE
120 jmc 1.99 # with same output from reference file $dir/results/$reference_output
121 jmc 1.93 # using search strings s1 and text label
122 edhill 1.1
123     if [ $debug -gt 0 ]; then
124 jmc 1.93 echo testoutput_var: grep "$2" $1/$4/$OUTPUTFILE 1>&2
125 edhill 1.1 fi
126 jmc 1.87 if [ -r $1/$4/$OUTPUTFILE ]; then
127     grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt
128 jmc 1.67 lncntA=`wc -l tmp1.txt | awk '{print $1}' `
129 jmc 1.100 if [ $lncntA -lt 2 ]; then
130 edhill 1.1 if [ $verbose -gt 0 ]; then
131     echo Not enough lines of output when searching for "$2" 1>&2
132     fi
133     return 99
134     fi
135     else
136 jmc 1.93 echo testoutput_var: $OUTPUTFILE from model run was not readable 1>&2
137 edhill 1.1 return 99
138     fi
139     if [ $debug -gt 0 ]; then
140 jmc 1.99 echo testoutput_var: grep "$2" $1/results/$5 1>&2
141 edhill 1.1 fi
142 jmc 1.99 grep "$2" $1/results/$5 | sed 's/.*=//' | cat -n > tmp2.txt
143 jmc 1.67 lncntB=`wc -l tmp2.txt | awk '{print $1}' `
144 jmc 1.100 if [ $lncntB -lt 2 ]; then
145 edhill 1.1 if [ $verbose -gt 0 ]; then
146     echo Not enough lines of output when searching for "$2" 1>&2
147     fi
148     return 99
149     fi
150 jmc 1.67 if [ $lncntA -ne $lncntB ]; then
151     if [ $verbose -gt 0 ]; then
152     echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
153     fi
154     return 99
155     fi
156 edhill 1.72 has_nan=`cat tmp1.txt | grep -i nan | wc -l`
157     if [ $has_nan -gt 0 ] ; then
158 jmc 1.93 echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values 1>&2
159 edhill 1.72 return 99
160     fi
161     has_inf=`cat tmp1.txt | grep -i inf | wc -l`
162     if [ $has_inf -gt 0 ] ; then
163 jmc 1.93 echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values 1>&2
164 jmc 1.71 return 99
165     fi
166 edhill 1.1 if [ $debug -gt 0 ]; then
167 jmc 1.93 echo testoutput_var: join tmp1.txt tmp2.txt 1>&2
168 edhill 1.1 fi
169     join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
170     if [ $debug -gt 0 ]; then
171 jmc 1.93 echo testoutput_var: compare_lines 1>&2
172 edhill 1.1 fi
173 edhill 1.22 if [ $verbose -gt 1 ]; then
174     cat tmp3.txt 1>&2
175     fi
176     echo "-1" >> tmp3.txt
177 edhill 1.23 # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
178     cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
179 jmc 1.91 digits_of_similarity=`./tr_cmpnum < tmp4.txt`
180 edhill 1.1 if [ $digits_of_similarity -eq 99 ]; then
181     if [ $verbose -gt 0 ]; then
182 jmc 1.99 echo testoutput_var: No comparison was available for \"$3\" 1>&2
183 edhill 1.1 fi
184     digits_of_similarity=99
185     else
186     if [ $verbose -gt 0 ]; then
187 jmc 1.99 echo There were $digits_of_similarity decimal places of similarity for \"$3\" 1>&2
188 edhill 1.1 fi
189     fi
190 edhill 1.23 rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
191 jmc 1.135
192 edhill 1.1 return $digits_of_similarity
193     }
194    
195 jmc 1.93 testoutput_run()
196 edhill 1.1 {
197 jmc 1.99 # testoutput_run directory subdir reference_output
198 edhill 1.1 #
199 jmc 1.93 # test output from 1 run in "directory"
200 jmc 1.103 # --> same processing for adjoint & forward test
201 jmc 1.94 # default list of output variables to be checked:
202     # 1rst : main variable used to decide if it pass or FAIL
203     # others : number of matching digits to be printed in summary.txt
204     listChk=$DEF_CHECK_LIST
205     # load experiment-specific list from file "tr_checklist" (if it exist)
206     if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi
207     sVar=`echo $listChk | awk '{print $1}'`
208     # remove 1rst var and expand the list: + => min max mean s.d
209 jmc 1.97 listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \
210     | sed 's/+//g' | sed "s/^$sVar//"`
211 jmc 1.94 if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(I)='$listVar'" 1>&2 ; fi
212 jmc 1.117 # check for ptracer output in reference_output file :
213     outpref=$1/results/$3
214     ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max"
215     ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
216     for ii in $PTRACERS_NUM ; do
217     ptrfound=0
218     for jj in $ptr_mon ; do
219     name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
220     tst=`grep $name $outpref | wc -l | awk '{print $1}'`
221     if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
222     done
223     if test $ptrfound = '1' ; then
224     eval "HAVE_PTR0"$ii"=t"
225     else
226     eval "HAVE_PTR0"$ii"=f"
227 utke 1.120 if test "x$ADM" = x -a "x$OADM" = x; then
228 jmc 1.117 # remove this ptr from the list of output variable to check
229     # echo "-- ptr test=" $tst "number of var=" `echo $listVar | awk '{print NF}'` 1>&2
230     listVar=`echo "$listVar" | sed "s/ pt$ii..//g"`
231     fi
232     fi
233     # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
234     done
235 mlosch 1.116 tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'`
236 jmc 1.94 if test $tst != 1 ; then
237     if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2
238     else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi
239     echo "==> WARNING: in checked list:" $listVar 1>&2
240     #- put it back once:
241     listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
242     fi
243     if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(M)='$listVar'" 1>&2 ; fi
244 jmc 1.154 echo "listVar='$listVar'" >> $locDIR"/summary.txt"
245     #---
246 jmc 1.94 allargs=""
247     for xx in $listVar
248     do
249     case $xx in
250     'PS') if [ $debug -gt 0 ]
251     then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
252 jmc 1.99 testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $3; yy=$?
253 jmc 1.94 if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
254 jmc 1.167 'Cost') testoutput_var $1 "ADM ref_cost_function" "ADM CostFct" $2 $3; yy=$? ;;
255     'AdGrd') testoutput_var $1 "ADM adjoint_gradient" "ADM Ad Grad" $2 $3; yy=$? ;;
256     'FDGrd') testoutput_var $1 "ADM finite-diff_grad" "ADM FD Grad" $2 $3; yy=$? ;;
257 jmc 1.99 'Tmn') testoutput_var $1 "dynstat_theta_min" "Theta minimum" $2 $3; yy=$? ;;
258     'Tmx') testoutput_var $1 "dynstat_theta_max" "Theta maximum" $2 $3; yy=$? ;;
259     'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean" $2 $3; yy=$? ;;
260     'Tsd') testoutput_var $1 "dynstat_theta_sd" "Theta Std.Dev" $2 $3; yy=$? ;;
261     'Smn') testoutput_var $1 "dynstat_salt_min" "Salt minimum" $2 $3; yy=$? ;;
262     'Smx') testoutput_var $1 "dynstat_salt_max" "Salt maximum" $2 $3; yy=$? ;;
263     'Sav') testoutput_var $1 "dynstat_salt_mean" "Salt mean" $2 $3; yy=$? ;;
264     'Ssd') testoutput_var $1 "dynstat_salt_sd" "Salt Std.Dev" $2 $3; yy=$? ;;
265 jmc 1.94 'Umn') testoutput_var $1 "dynstat_uvel_min" "U minimum" $2 $3; yy=$? ;;
266     'Umx') testoutput_var $1 "dynstat_uvel_max" "U maximum" $2 $3; yy=$? ;;
267     'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean" $2 $3; yy=$? ;;
268 jmc 1.99 'Usd') testoutput_var $1 "dynstat_uvel_sd" "U Std.Dev" $2 $3; yy=$? ;;
269 jmc 1.94 'Vmn') testoutput_var $1 "dynstat_vvel_min" "V minimum" $2 $3; yy=$? ;;
270     'Vmx') testoutput_var $1 "dynstat_vvel_max" "V maximum" $2 $3; yy=$? ;;
271     'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean" $2 $3; yy=$? ;;
272 jmc 1.99 'Vsd') testoutput_var $1 "dynstat_vvel_sd" "V Std.Dev" $2 $3; yy=$? ;;
273 jmc 1.94 'pt1mn'|'pt2mn'|'pt3mn'|'pt4mn'|'pt5mn') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
274     testoutput_var $1 "trcstat_ptracer0"$ii"_min" "p0"$ii"_min" $2 $3; yy=$? ;;
275     'pt1mx'|'pt2mx'|'pt3mx'|'pt4mx'|'pt5mx') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
276     testoutput_var $1 "trcstat_ptracer0"$ii"_max" "p0"$ii"_max" $2 $3; yy=$? ;;
277     'pt1av'|'pt2av'|'pt3av'|'pt4av'|'pt5av') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
278     testoutput_var $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $3; yy=$? ;;
279     'pt1sd'|'pt2sd'|'pt3sd'|'pt4sd'|'pt5sd') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
280 jmc 1.99 testoutput_var $1 "trcstat_ptracer0"$ii"_sd" "p0"$ii"_StDv" $2 $3; yy=$? ;;
281 jmc 1.130 'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum" $2 $3; yy=$? ;;
282     'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum" $2 $3; yy=$? ;;
283     'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean" $2 $3; yy=$? ;;
284     'Qntsd') testoutput_var $1 "forcing_qnet_sd" "Qnet Std.Dev" $2 $3; yy=$? ;;
285 jmc 1.101 'aSImn') testoutput_var $1 "seaice_area_min" "SIce Area min" $2 $3; yy=$? ;;
286     'aSImx') testoutput_var $1 "seaice_area_max" "SIce Area max" $2 $3; yy=$? ;;
287     'aSIav') testoutput_var $1 "seaice_area_mean" "SIce Area mean" $2 $3; yy=$? ;;
288     'aSIsd') testoutput_var $1 "seaice_area_sd" "SIce Area StDv" $2 $3; yy=$? ;;
289     'hSImn') testoutput_var $1 "seaice_heff_min" "SIce Heff min" $2 $3; yy=$? ;;
290 jmc 1.126 'hSImx') testoutput_var $1 "seaice_heff_max" "SIce Heff max" $2 $3; yy=$? ;;
291     'hSIav') testoutput_var $1 "seaice_heff_mean" "SIce Heff mean" $2 $3; yy=$? ;;
292     'hSIsd') testoutput_var $1 "seaice_heff_sd" "SIce Heff StDv" $2 $3; yy=$? ;;
293 mlosch 1.170 'uSImn') testoutput_var $1 "seaice_uice_min" "SIce Uice min" $2 $3; yy=$? ;;
294     'uSImx') testoutput_var $1 "seaice_uice_max" "SIce Uice max" $2 $3; yy=$? ;;
295     'uSIav') testoutput_var $1 "seaice_uice_mean" "SIce Uice mean" $2 $3; yy=$? ;;
296     'uSIsd') testoutput_var $1 "seaice_uice_sd" "SIce Uice StDv" $2 $3; yy=$? ;;
297     'vSImn') testoutput_var $1 "seaice_vice_min" "SIce Vice min" $2 $3; yy=$? ;;
298     'vSImx') testoutput_var $1 "seaice_vice_max" "SIce Vice max" $2 $3; yy=$? ;;
299     'vSIav') testoutput_var $1 "seaice_vice_mean" "SIce Vice mean" $2 $3; yy=$? ;;
300     'vSIsd') testoutput_var $1 "seaice_vice_sd" "SIce Vice StDv" $2 $3; yy=$? ;;
301 jmc 1.101 'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $3; yy=$? ;;
302     'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South" $2 $3; yy=$? ;;
303     'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North" $2 $3; yy=$? ;;
304     'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Global" $2 $3; yy=$? ;;
305     'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South" $2 $3; yy=$? ;;
306     'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North" $2 $3; yy=$? ;;
307 jmc 1.94 *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
308     esac
309     if test $xx = $sVar
310     then allargs="$allargs > $yy <"
311     else allargs="$allargs $yy"
312     fi
313     done
314    
315     nbVar=`echo $listVar | awk '{print NF}'`
316 jmc 1.135 if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
317 jmc 1.94 #-- fill line (up to standard length) with dot:
318 jmc 1.97 adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
319 jmc 1.94 echo $allargs $adNul
320     else
321     echo $allargs
322 jmc 1.135 fi
323 jmc 1.103 # <-- same processing for adjoint & forward test
324 edhill 1.1 }
325    
326     genmakemodel()
327     {
328     # genmakemodel directory
329 edhill 1.10 if test "x$NOGENMAKE" = xt ; then
330     echo "genmake skipped!"
331     else
332 edhill 1.34 if test "x$BASH" = x ; then
333     GENMAKE2="../../../tools/genmake2"
334     else
335     GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
336     fi
337 edhill 1.10 (
338     cd $1;
339 edhill 1.24 command="$GENMAKE2 -ds -m $MAKE"
340 jmc 1.141 if test "x$MKDEPEND" != x ; then
341     command="$command -makedepend=$MKDEPEND"
342     fi
343 utke 1.120 if test "x$ADM" = xt ; then
344     command="$command --mods=../code_ad"
345     elif test "x$OADM" = xt ; then
346     command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods '../code_oad ../../OpenAD/code_oad_all'"
347     else
348 jmc 1.124 command="$command -mods=../code"
349 edhill 1.24 fi
350 edhill 1.10 if test "x$OPTFILE" != xNONE ; then
351 jmc 1.124 command="$command -optfile=$OPTFILE"
352 edhill 1.10 fi
353 jmc 1.164 if test $OptLev = 1 ; then
354     command="$command -ieee"
355     fi
356     if test $OptLev = 0 ; then
357     command="$command -devel"
358 edhill 1.10 fi
359 jmc 1.109 if test "x$GSL" = xt ; then
360     command="$command -gsl"
361     fi
362 jmc 1.154 if test "x$MPI" != x0 ; then
363 edhill 1.66 command="$command -mpi"
364     fi
365 jmc 1.122 if test "x$MULTI_THREAD" = xt ; then
366     #- run multi-threaded using OpenMP:
367     command="$command -omp"
368     fi
369 jmc 1.135 if test "x$USE_R4" = xt ; then
370     command="$command -use_r4"
371     fi
372 jmc 1.165 if test "x$EXTRFLG" != x ; then
373     command="$command -extra_flag $EXTRFLG"
374     fi
375 ce107 1.90 if test "x$TS" = xt ; then
376     command="$command -ts"
377     fi
378     if test "x$PAPIS" = xt ; then
379     command="$command -papis"
380 jmc 1.135 else
381 ce107 1.90 if test "x$PCLS" = xt ; then
382     command="$command -pcls"
383     fi
384     fi
385 jmc 1.139 printf 'genmake ... '
386 jmc 1.146 eval $command > genmake.tr_log 2>&1
387 edhill 1.10 RETVAL=$?
388 edhill 1.44 # Reduce the size of the testing emails!
389 edhill 1.47 head -100 Makefile > $CDIR/Makefile_head
390 edhill 1.10 if test "x$RETVAL" != x0 ; then
391 jmc 1.146 tail genmake.tr_log
392 jmc 1.139 echo "genmakemodel: genmake failed"
393 jmc 1.148 cp genmake.log genmake_* genmake.tr_log $CDIR
394 edhill 1.10 return 1
395     else
396 jmc 1.139 echo "successful"
397 edhill 1.1 fi
398 edhill 1.10 )
399     fi
400 edhill 1.1 }
401    
402     makeclean()
403     {
404     # makeclean directory
405 jmc 1.146 if test "x$NODEPEND" = xf ; then rm -f $1/make.tr_log ; fi
406 edhill 1.10 if test "x$NOCLEAN" = xt ; then
407 jmc 1.83 echo "make Clean skipped!"
408 edhill 1.10 else
409     (
410     cd $1;
411 jmc 1.87 #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
412 edhill 1.10 if test -r Makefile ; then
413 jmc 1.139 printf 'clean build-dir: make Clean ... '
414 jmc 1.146 $MAKE Clean >> make.tr_log 2>&1
415 edhill 1.10 RETVAL=$?
416     if test "x$RETVAL" != x0 ; then
417 jmc 1.146 tail make.tr_log
418 jmc 1.139 echo "makeclean: \"make Clean\" failed"
419 jmc 1.148 cp make.tr_log genmake.log genmake.tr_log $CDIR
420 edhill 1.10 return 1
421     fi
422 jmc 1.139 echo successful
423 jmc 1.127 else
424     echo ''
425 edhill 1.10 fi
426     exit 0
427     )
428     fi
429     }
430    
431 jmc 1.83 run_clean()
432 edhill 1.68 {
433 jmc 1.83 # run_clean directory
434     if test "x$NOCLEAN" = xt ; then
435     echo "run_clean skipped!"
436     else
437 edhill 1.68 (
438     cd $1;
439 jmc 1.139 printf 'clean run-dir ... '
440 jmc 1.83 # part of what is done after "make clean" when doing "make CLEAN"
441     find . -name "*.meta" -exec rm {} \;
442     find . -name "*.data" -exec rm {} \;
443     find . -name "fort.*" -exec rm {} \;
444     find . -type l -exec rm {} \;
445 jmc 1.161 #- should remove executable only if sym-link (alredy done above)
446 jmc 1.160 rm -f $RUNLOG *.txt STD* *diagnostics.log datetime
447 jmc 1.83 rm -rf mnc_test_*
448 jmc 1.107 rm -f *_MIT_CE_000.opt0000 costfunction*0000
449 jmc 1.139 echo successful
450 edhill 1.68 exit 0
451     )
452     fi
453     }
454    
455 edhill 1.10 makedependmodel()
456     {
457     # makedependmodel directory
458     if test "x$NODEPEND" = xt ; then
459     echo "make depend skipped!"
460     else
461     (
462     cd $1;
463 jmc 1.139 printf 'make depend ... '
464 jmc 1.146 $MAKE depend >> make.tr_log 2>&1
465 edhill 1.1 RETVAL=$?
466     if test "x$RETVAL" != x0 ; then
467 jmc 1.146 tail make.tr_log
468 jmc 1.139 echo "makedependmodel: make depend failed"
469 jmc 1.148 cp make.tr_log genmake.log genmake.tr_log $CDIR
470 edhill 1.1 return 1
471 edhill 1.10 else
472 jmc 1.139 echo successful
473 edhill 1.1 fi
474 edhill 1.10 )
475     fi
476 edhill 1.1 }
477    
478     makemodel()
479     {
480     # makemodel directory
481     (
482 jmc 1.159 mk_fail=0
483 jmc 1.136 if test "x$NOMAKE" = xt ; then
484     cd $1;
485     if test -x $EXECUTABLE ; then
486     echo "make skipped!"
487     else
488     echo "no executable!"
489 jmc 1.159 mk_fail=3
490 jmc 1.136 fi
491     else
492 edhill 1.1 cd $1;
493     if test -r Makefile ; then
494 jmc 1.139 printf 'make ... '
495 jmc 1.171 if test "x$REPLMAKE" = x ; then
496     $MAKE $TARG >> make.tr_log 2>&1
497     else
498     $REPLMAKE $TARG >> make.tr_log 2>&1
499     fi
500 edhill 1.1 RETVAL=$?
501     if test "x$RETVAL" != x0 ; then
502 jmc 1.146 tail make.tr_log
503 jmc 1.139 echo failed
504 jmc 1.163 cp genmake.log genmake.tr_log $CDIR
505     tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
506 jmc 1.131 rm -f $EXECUTABLE
507 jmc 1.159 mk_fail=1
508 edhill 1.1 else
509 jmc 1.139 echo successful
510 edhill 1.1 fi
511 jmc 1.159 else
512     echo "no Makefile !"
513     mk_fail=2
514 edhill 1.1 fi
515 jmc 1.136 fi
516 jmc 1.158 if test "x$ADM" = xt -a -f taf_ad.log ; then
517     head -1 taf_ad.log >> $CDIR"/summary.txt"
518     nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log`
519     nwar=`grep -c 'TAF RECOMPUTATION *.* WARNING ' taf_ad.log`
520     echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \
521     >> $CDIR"/summary.txt"
522     fi
523 jmc 1.159 if test $mk_fail != 0 ; then return $mk_fail ; fi
524 edhill 1.1 )
525     }
526    
527 jmc 1.154 mk_mpi_size()
528     {
529 jmc 1.161 # mk_mpi_size input_file output_file proc_Nb prefer_to_split_X
530 jmc 1.154 #
531     # make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file)
532     # for an MPI build with no more than proc_Nb processors ;
533     # return the effective number of processors.
534    
535     inp=$1
536     out=$2
537     np=$3
538 jmc 1.161 dirX=$4
539 jmc 1.154 tmp=TTT.$$
540    
541     px=`grep "^ & *nPx *=" $inp | sed "s/^ & *nPx *= *//" | sed 's/, *$//'`
542     py=`grep "^ & *nPy *=" $inp | sed "s/^ & *nPy *= *//" | sed 's/, *$//'`
543     sx=`grep "^ & *nSx *=" $inp | sed "s/^ & *nSx *= *//" | sed 's/, *$//'`
544     sy=`grep "^ & *nSy *=" $inp | sed "s/^ & *nSy *= *//" | sed 's/, *$//'`
545    
546     #- find the largest divisor of input_file proc Nb, but not larger than $np
547     pp=0
548 jmc 1.155 i=1
549     while [ $i -le $px ] ; do
550 jmc 1.154 if [ `expr $px % $i` -eq 0 ] ; then
551 jmc 1.155 j=1
552     while [ $j -le $py ] ; do
553     if [ `expr $py % $j` -eq 0 ] ; then
554     ij=`expr $i \* $j`
555     if [ $ij -gt $pp ] ; then
556 jmc 1.161 flag=1
557     elif [ $ij -eq $pp ] ; then
558     flag=$dirX
559     else
560     flag=0
561     fi
562     if test $flag = 1 ; then
563 jmc 1.155 if [ $ij -le $np ] ; then
564     ix=$i ; jy=$j ; pp=$ij
565     #echo " ix,jy= $ix,$jy"
566     fi
567     fi
568     fi
569     j=`expr $j + 1`
570     done
571 jmc 1.154 fi
572 jmc 1.155 i=`expr $i + 1`
573 jmc 1.154 done
574    
575     #- create new SIZE.h type file:
576     sx=`expr $sx \* $px / $ix`
577     sy=`expr $sy \* $py / $jy`
578     if [ $verbose -gt 1 ]; then
579     echo " px,py,np= $px,$py,$np : New MPI size: px,py= $ix,$jy : sx,sy= $sx,$sy"
580     fi
581     sed "/^ \& *nPx *=/s/[0-9]*,/$ix,/" $inp > $tmp
582     sed "/^ \& *nPy *=/s/[0-9]*,/$jy,/" $tmp > $out
583     sed "/^ \& *nSx *=/s/[0-9]*,/$sx,/" $out > $tmp
584     sed "/^ \& *nSy *=/s/[0-9]*,/$sy,/" $tmp > $out
585     rm -f $tmp
586     return $pp
587     }
588    
589 edhill 1.27 symlink_mpifiles()
590     {
591     # Put special links so that MPI specific files are used
592     # This MUST be invoked between makeclean and makelinks because
593     # the Makefile will link to non-mpi files by default
594    
595     dir=$1
596     code_dir=$2
597 jmc 1.154 build_dir=$dir/$3
598 jmc 1.135
599 edhill 1.27 # These are files that should replace their counter-part when using -mpi
600 jmc 1.154 MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
601 edhill 1.27
602 jmc 1.154 for ii in $MPI_FILES ; do
603     i=`echo $ii | sed 's:^\./::'`
604     name=`echo $i | sed 's:_mpi::'`
605     file="../$code_dir/$i"
606     if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
607    
608     # Is this an MPI run?
609     if test "x$MPI" = x0 ; then
610     # NO: We undo any _mpi symbolically linked files
611     if test -L $build_dir/$name ; then
612     ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
613     RETVAL=$?
614     if test "x$RETVAL" = x0 ; then
615     if [ $verbose -gt 1 ]; then
616     echo " Un-linking $name from ../$code_dir" ; fi
617     rm -f $build_dir/$name
618     fi
619     fi
620     else
621     # YES: We symbolically link these files to the build
622     # dir so long as there is no real file in place
623     ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
624 edhill 1.27 RETVAL=$?
625 jmc 1.154 if [ $verbose -gt 1 ]; then echo " cmp $name $file returns: $RETVAL" ; fi
626 edhill 1.27 if test "x$RETVAL" != x0 ; then
627 jmc 1.154 if test -h $build_dir/$name ; then rm -f $build_dir/$name ; fi
628     if test ! -r $build_dir/$name ; then
629     if [ $verbose -gt 1 ]; then echo " Linking $name to $file" ; fi
630     (cd $build_dir; ln -sf $file $name)
631 edhill 1.27 fi
632     fi
633 jmc 1.154 fi
634     done
635 edhill 1.27 }
636    
637 edhill 1.1 linkdata()
638     {
639 jmc 1.83 # linkdata run_dir input_dir_1 input_dir_2 ...
640 edhill 1.1 #
641     # symbolically link data files to run directory
642 jmc 1.83 if test -d $1 ; then
643 edhill 1.12 (
644 jmc 1.83 cd $1 ; shift
645 jmc 1.139 echo 'linkdata from dirs:' $*
646 jmc 1.125 inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
647     for xx in $inpMPI ; do
648     if test -r "../"$1"/"$xx ; then
649     # found 1 _mpi sfx file in 1rst input dir and it is readable
650     yy=`echo $xx | sed 's:\.mpi$::'`
651 jmc 1.154 if test "x$MPI" = "x0" ; then
652     # not mpi test: remove symbolic link
653     if test -h $yy ; then rm -f $yy ; fi
654     else
655     # mpi test: remove symbolic link & link .mpi sfx file
656 jmc 1.125 if test -h $yy ; then rm -f $yy ; fi
657 jmc 1.135 if test ! -r $yy ; then
658 jmc 1.125 ln -sf "../"$1"/"$xx $yy ;
659 jmc 1.139 printf " $xx" 1>&2
660 jmc 1.125 fi
661     fi
662     fi
663     done
664 jmc 1.83 if test -r "../"$1"/eedata.mth" ; then
665     # found eedata.mth in 1rst input dir and it is readable
666     if test "x$MULTI_THREAD" = "xt" ; then
667     # multi-threaded test: remove symbolic link & link eedata.mth
668     if test -h eedata ; then rm -f eedata ; fi
669 jmc 1.135 if test ! -r eedata ; then
670 jmc 1.83 ln -sf "../"$1"/eedata.mth" eedata ;
671 jmc 1.139 printf ' eedata.mth' 1>&2
672 edhill 1.24 fi
673 jmc 1.83 else
674     # not multi-threaded test: remove eedata symbolic link
675     if test -h eedata ; then rm -f eedata ; fi
676     fi
677     fi
678 jmc 1.108 prevDir='NONE'
679 jmc 1.83 for ldir in $* ; do
680 jmc 1.108 if test -d "../"$ldir -a $ldir != $prevDir ; then
681 jmc 1.139 printf " ldir=${ldir}:" 1>&2
682 jmc 1.83 files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
683     for i in $files ; do
684     if test ! -d "../"$ldir/$i ; then
685     if test ! -r $i ; then
686     printf ' '$i 1>&2
687     ln -sf "../"$ldir"/"$i $i
688     fi
689     fi
690     done
691 jmc 1.139 printf ' ;' 1>&2
692 jmc 1.83 if test -x "../"$ldir"/"prepare_run ; then
693 jmc 1.139 "../"$ldir"/"prepare_run 1>&2
694     else
695     echo '' 1>&2
696 edhill 1.24 fi
697 jmc 1.82 fi
698 jmc 1.108 prevDir=$ldir
699 jmc 1.83 done
700 edhill 1.12 )
701 edhill 1.1 fi
702     }
703    
704     runmodel()
705     {
706 edhill 1.6 # runmodel directory
707 edhill 1.1 #
708 jmc 1.154 # runs $COMMAND in "directory"
709 edhill 1.6 # (where "$COMMAND" is relative to "directory")
710 edhill 1.1 (
711     cd $1
712 jmc 1.139 printf 'runmodel in %s ... ' $1
713 jmc 1.158 if test "x$MPI" != x0 ; then
714     #- adjust the MPI run command with the right number of Procs
715     #echo '' ; echo " COMMAND='$COMMAND'"
716     COMMAND=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
717     if test "x$MPI_MFILE" != x ; then
718     COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
719     fi
720     #echo " COMMAND='$COMMAND'"
721     fi
722 jmc 1.134 if test -L $EXECUTABLE ; then
723     if test -x "../"$builddir"/"$EXECUTABLE ; then
724 jmc 1.154 cmp $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
725     outD=$? ; if test "x$outD" != x0 ; then rm -f $EXECUTABLE ; fi
726 jmc 1.134 else rm -f $EXECUTABLE
727     fi
728 jmc 1.106 fi
729 jmc 1.83 if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
730 jmc 1.119 echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
731 jmc 1.83 ln -sf "../"$builddir"/"$EXECUTABLE .
732     fi
733     if test ! -x $EXECUTABLE ; then
734 jmc 1.156 rm -f $RUNLOG ; touch $RUNLOG
735     if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
736     echo " no executable:" $EXECUTABLE >> $RUNLOG
737     RETVAL=8
738     ENDVAL=-1
739 jmc 1.75 else
740 jmc 1.156 if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
741     # output do not exist or is older than executable:
742 jmc 1.162 rm -f $OUTPUTFILE $RUNLOG ; touch $RUNLOG
743 jmc 1.156 if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
744     ( eval $COMMAND ) >> $RUNLOG 2>&1
745     RETVAL=$?
746     ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
747     if [ $POSTCLEAN -eq 1 -a $ENDVAL -gt 0 ] ; then
748     find . -name "*.meta" -exec rm {} \;
749     find . -name "*.data" -exec rm {} \;
750     rm -rf mnc_test_*
751 jmc 1.83 fi
752 jmc 1.156 else
753     RETVAL=0
754 jmc 1.153 ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
755 jmc 1.156 touch $RUNLOG
756     if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
757     echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
758     fi
759 jmc 1.75 fi
760 jmc 1.119 rm -f run.log_tmp
761 jmc 1.158 #- in all cases where OutputFile exists, report SIZE (and AD time)
762     if test -f $OUTPUTFILE ; then
763     grep '(PID\.TID 0000\.0001) n.. =' $OUTPUTFILE \
764     | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt"
765     if test "x$ADM" = xt ; then
766     grep -A3 'Seconds in section "ALL' $OUTPUTFILE >> $CDIR"/summary.txt"
767     fi
768     fi
769     if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
770 jmc 1.88 if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
771 jmc 1.139 echo successful
772     printf '=> output from running in %s :\n' $1 1>&2
773     tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
774 edhill 1.6 return 0
775 jmc 1.132 elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
776     #-- for some weird cases (run is finihed but with error code)
777 jmc 1.139 echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
778     printf '=> output from running in %s :\n' $1 1>&2
779     tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
780 jmc 1.132 return 0
781 edhill 1.6 else
782 jmc 1.139 echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
783     printf '=> output from running in %s :\n' $1 1>&2
784     tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
785 jmc 1.119 cp $RUNLOG $CDIR"/"$RUNLOG
786 edhill 1.6 return 1
787 edhill 1.1 fi
788     )
789     }
790    
791     createcodelet()
792     {
793     # create codelet for comparing model output
794    
795 jmc 1.112 printf "creating the comparison code (using CC=$CC)... "
796 jmc 1.91 cat > tr_cmpnum.c <<EOF
797 edhill 1.22 #include <stdio.h>
798     #include <math.h>
799     int main( int argc, char** argv ) {
800 jmc 1.91 int linnum,cmplin,best,lncnt;
801 edhill 1.52 double a,b,abave,relerr;
802 jmc 1.57 best = -22;
803 adcroft 1.33 lncnt = 0;
804 jmc 1.96 while( 1 & ( (lncnt+=1) < 999 ) ) {
805 edhill 1.22 scanf("%d", &linnum);
806     if (linnum == -1) break;
807     scanf("%lf", &a); scanf("%lf", &b);
808 edhill 1.52 abave = 0.5*(fabs(a)+fabs(b));
809 jmc 1.91 if ( abave == abave ) {
810     if (abave > 0.0) {
811     relerr=fabs(a-b)/abave;
812     if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
813     else { cmplin = -16 ; }
814     best = (best > cmplin) ? best : cmplin; }
815     else { cmplin = -22 ; }
816     /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
817     }
818     else {
819     /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
820     break; }
821 edhill 1.22 }
822 adcroft 1.33 if (lncnt == 999) best=-29;
823 jmc 1.91 if (linnum != -1) best=-99;
824 edhill 1.22 printf("%d\n", -best);
825     return 0;
826     }
827     EOF
828 jmc 1.91 $CC -o tr_cmpnum tr_cmpnum.c -lm
829 edhill 1.1
830 jmc 1.91 if [ -x ./tr_cmpnum ]; then
831 edhill 1.1 echo "OK"
832     return 0
833     else
834     echo
835 jmc 1.135 echo "ERROR: failed to compile comparison code -- please specify"
836 edhill 1.58 echo " a C compiler using the CC environment variable."
837 edhill 1.1 exit 1
838     fi
839     }
840    
841     formatresults()
842     {
843     # formatresults expt genmake depend make run results*
844    
845     nm=$1
846     printf '%s %s %s %s' $2 $3 $4 $5
847     shift; shift; shift; shift; shift;
848 jmc 1.94 listPrt=$@
849     listRes=`echo $listPrt | sed 's/>//' | sed 's/<//'`
850     xx=`echo $listPrt | sed 's/.*>//' | sed 's/<.*//' | awk '{print $1}'`
851 jmc 1.97 printf '%3s' $listPrt
852 jmc 1.98 # line below does not work on hp-ux_ia64 : do those substitutions later on
853 jmc 1.95 # printf '%3s' $listPrt | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /</'
854 jmc 1.135
855 jmc 1.94 if [ $xx = '..' ]; then
856     printf ' N/O '
857     elif [ $xx = '--' ]; then
858     printf ' N/O '
859     elif [ $xx = 99 ]; then
860 edhill 1.1 printf ' N/O '
861     else
862 jmc 1.94 if [ $xx -ge $MATCH_CRIT ]; then
863 edhill 1.1 printf ' pass'
864     else
865     printf ' FAIL'
866     fi
867     fi
868     printf ' %s' $nm
869     printf '\n'
870 jmc 1.135
871 edhill 1.1 }
872    
873     scandirs()
874     {
875 jmc 1.81 if [ $# -eq 1 ]; then
876     for arg in * ; do
877 jmc 1.99 test -f $arg/$1 && echo $arg
878 jmc 1.81 done
879 edhill 1.1 else
880 jmc 1.81 echo $*
881 edhill 1.1 fi
882     }
883    
884    
885 jmc 1.123 check_eedata()
886     {
887 jmc 1.161 # check_eedata eedata size.h
888 jmc 1.123 if [ $# -eq 2 ] ; then
889 jmc 1.161 if test -f $1 -a -f $2 ; then
890     nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
891     sx=`grep "^ & *nSx *=" $2 | sed "s/^ & *nSx *=//" | sed 's/, *$//'`
892 jmc 1.123 if test "x$nx" = x ; then
893     rx=10
894     else
895     rx=`expr $sx % $nx`
896     fi
897 jmc 1.161 ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
898     sy=`grep "^ & *nSy *=" $2 | sed "s/^ & *nSy *=//" | sed 's/, *$//'`
899 jmc 1.123 if test "x$ny" = x ; then
900     ry=20
901     else
902     ry=`expr $sy % $ny`
903     fi
904     echo `expr $rx + $ry`
905 jmc 1.161 else
906     echo '-1'
907     fi
908     elif [ $# -eq 1 ] ; then
909     if test -f $1 ; then
910     nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
911     if test "x$nx" = x ; then nx=1 ; fi
912     ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
913     if test "x$ny" = x ; then ny=1 ; fi
914     #echo $nx $ny
915     echo $nx
916     else
917 jmc 1.123 echo '-1'
918 jmc 1.161 fi
919 jmc 1.123 else
920     echo '-2'
921     fi
922    
923     }
924    
925 edhill 1.1 ###############################################################################
926    
927    
928     # Default properties
929     debug=0
930     verbose=1
931 jmc 1.163 NBLINES_MKLOG=16000
932 edhill 1.10
933 jmc 1.164 OptLev=1
934 jmc 1.109 GSL=f
935 edhill 1.10
936     CLEANUP=f
937 jmc 1.133 NORUN=f
938 edhill 1.10 QUICK=f
939 jmc 1.136 NOMAKE=f
940 edhill 1.10 NOGENMAKE=f
941     NOCLEAN=f
942     NODEPEND=f
943 jmc 1.156 POSTCLEAN=0
944 edhill 1.1
945 edhill 1.4 BASH=
946 edhill 1.10 OPTFILE=NONE
947     ADDRESSES=
948 edhill 1.1 TESTDIRS=
949 jmc 1.89 SKIPDIRS=
950 edhill 1.1 MPACKDIR="../tools/mpack-1.6"
951 edhill 1.20 HAVE_MPACK=
952 jmc 1.113 MPACK=
953 edhill 1.24 COMMAND=
954 jmc 1.141 MKDEPEND=
955 edhill 1.59 if test "x$MAKE" = x ; then
956     MAKE=make
957     fi
958 jmc 1.171 REPLMAKE=
959 edhill 1.59 if test "x$CC" = x ; then
960     CC=cc
961     fi
962 edhill 1.43 JOBS=
963 jmc 1.165 TARG=
964 jmc 1.154 MPI=0
965 jmc 1.156 MPI_MFILE=
966 jmc 1.83 MULTI_THREAD=f
967 jmc 1.70 OUTDIR=
968 edhill 1.40 DELDIR=
969 jmc 1.135 USE_R4=
970 jmc 1.165 EXTRFLG=
971 edhill 1.1
972 edhill 1.24 ADM=
973 utke 1.120 OADM=
974 edhill 1.24
975 jmc 1.117 # list of pTracers to check for monitor output
976 edhill 1.50 PTRACERS_NUM="1 2 3 4 5"
977 edhill 1.49
978 jmc 1.147 MATCH_CRIT=10
979 jmc 1.92
980 edhill 1.34 printf "parsing options... "
981 edhill 1.1
982     ac_prev=
983     for ac_option ; do
984    
985     # If the previous option needs an argument, assign it.
986     if test -n "$ac_prev"; then
987     eval "$ac_prev=\$ac_option"
988     ac_prev=
989     continue
990     fi
991    
992     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
993 jmc 1.135
994 edhill 1.1 case $ac_option in
995    
996 jmc 1.156 -help | --help | -h | --h) usage ;;
997    
998     -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;;
999     -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;;
1000    
1001     -addr | --addr | -a | --a) ac_prev=ADDRESSES ;;
1002     -addr=* | --addr=* | -a=* | --a=*) ADDRESSES=$ac_optarg ;;
1003     -mpackdir | --mpackdir | -mpd | --mpd) ac_prev=MPACKDIR ;;
1004     -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*) MPACKDIR=$ac_optarg ;;
1005    
1006     -tdir | --tdir | -t | --t) ac_prev=TESTDIRS ;;
1007     -tdir=* | --tdir=* | -t=* | --t=*) TESTDIRS=$ac_optarg ;;
1008     -skipdir | --skipdir | -skd | --skd) ac_prev=SKIPDIRS ;;
1009     -skipdir=* | --skipdir=* | -skd=* | --skd=*) SKIPDIRS=$ac_optarg ;;
1010    
1011     -bash | --bash | -b | --b) ac_prev=BASH ;;
1012     -bash=* | --bash=* | -b=* | --b=*) BASH=$ac_optarg ;;
1013    
1014     -command | --command | -c | --c) ac_prev=COMMAND ;;
1015     -command=* | --command=* | -c=* | --c=*) COMMAND=$ac_optarg ;;
1016    
1017     -makedepend | --makedepend | -md | --md) ac_prev=MKDEPEND ;;
1018     -makedepend=* | --makedepend=* | -md=* | --md=*) MKDEPEND=$ac_optarg ;;
1019    
1020     -make | --make | -m | --m) ac_prev=MAKE ;;
1021     -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;;
1022    
1023 jmc 1.171 -repl_mk | --repl_mk ) ac_prev=REPLMAKE ;;
1024     -repl_mk=* | --repl_mk=*) REPLMAKE=$ac_optarg ;;
1025    
1026 jmc 1.156 -odir | --odir) ac_prev=OUTDIR ;;
1027     -odir=* | --odir=*) OUTDIR=$ac_optarg ;;
1028    
1029     -ptracers | --ptracers | -ptr | --ptr) ac_prev=PTRACERS_NUM ;;
1030     -ptracers=* | --ptracers=* | -ptr=* | --ptr=*) PTRACERS_NUM=$ac_optarg ;;
1031 edhill 1.50
1032 jmc 1.92 -match | --match ) ac_prev=MATCH_CRIT ;;
1033     -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
1034    
1035 jmc 1.136 -j | --j) ac_prev=JOBS ;;
1036     -j=* | --j=*) JOBS=$ac_optarg ;;
1037 edhill 1.43
1038 jmc 1.165 -ef | --ef) ac_prev=EXTRFLG ;;
1039     -ef=* | --ef=*) EXTRFLG=$ac_optarg ;;
1040    
1041 jmc 1.156 -clean | --clean) CLEANUP=t ; DELDIR=t ;;
1042 edhill 1.10
1043 jmc 1.156 -norun | --norun | -nr | --nr) NORUN=t ;;
1044 jmc 1.165 -obj | --obj ) TARG='obj' ; NORUN=t ;;
1045 jmc 1.156 -runonly | --runonly | -ro | --ro) QUICK=t ; NOMAKE=t ;;
1046     -quick | --quick | -q | --q) QUICK=t ;;
1047     -nogenmake | --nogenmake | -ng | --ng) NOGENMAKE=t ;;
1048     -noclean | --noclean | -nc | --nc) NOCLEAN=t ;;
1049     -nodepend | --nodepend | -nd | --nd) NODEPEND=t ;;
1050 edhill 1.10
1051 jmc 1.156 -postclean | --postclean | -pc | --pc) POSTCLEAN=2 ;;
1052     -deloutp | --deloutp | -do | --do) POSTCLEAN=1 ;;
1053 edhill 1.68
1054 jmc 1.154 -mpi | --mpi) MPI=2 ;;
1055     -MPI | --MPI) ac_prev=MPI ;;
1056     -MPI=* | --MPI=*) MPI=$ac_optarg ;;
1057 edhill 1.10
1058 jmc 1.156 -mfile | --mfile | -mf | --mf) ac_prev=MPI_MFILE ;;
1059     -mfile=* | --mfile=* | -mf=* | --mf=*) MPI_MFILE=$ac_optarg ;;
1060    
1061 jmc 1.83 -mth) MULTI_THREAD=t ;;
1062    
1063 edhill 1.24 -adm | -ad) ADM=t ;;
1064 utke 1.120 -oad) OADM=t; NODEPEND=t ;;
1065    
1066 jmc 1.164 -ieee) echo "Warning: ignore option '-ieee' (already the default)"
1067     printf " ... " ;;
1068     -noieee) echo "Warning: will use option '-fast' instead of '-noieee' (obsolete)"
1069     printf " ... " ; OptLev=`expr $OptLev \* 2` ;;
1070     -fast) OptLev=`expr $OptLev \* 2` ;;
1071     -devel) OptLev=0 ;;
1072 jmc 1.156 -gsl) GSL=t ;;
1073 edhill 1.10
1074 edhill 1.1 -verbose) verbose=2 ;;
1075     -debug) debug=1 ;;
1076     -quiet) verbose=0 ;;
1077    
1078 edhill 1.40 -deldir | -dd) DELDIR=t ;;
1079    
1080 jmc 1.136 -use_r4|-ur4) USE_R4=t ;;
1081 jmc 1.135
1082 ce107 1.90 -ts) TS=t;;
1083     -papis) PAPIS=t;;
1084     -pcls) PCL=t;;
1085    
1086 jmc 1.156 -*) echo "Error: unrecognized option: "$ac_option
1087     usage ;;
1088     *) echo "Error: unrecognized argument: "$ac_option
1089     usage ;;
1090 jmc 1.135
1091 edhill 1.1 esac
1092 jmc 1.135
1093 edhill 1.1 done
1094    
1095 edhill 1.10 if test "x$QUICK" = xt ; then
1096     NOGENMAKE=t
1097     NOCLEAN=t
1098     NODEPEND=t
1099     fi
1100    
1101 jmc 1.156 #- check length of MPI machine file:
1102     if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then
1103     if test -r $MPI_MFILE ; then
1104     nl=`wc -l $MPI_MFILE | awk '{print $1}'`
1105     if [ $nl -lt $MPI ] ; then
1106     echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE"
1107     usage
1108     fi
1109     if [ $verbose -gt 1 ]; then
1110     echo " MPI_MFILE=$MPI_MFILE : $nl procs for MPI=$MPI run"
1111     fi
1112     else
1113     echo "Error: cannot access MPI_MFILE=$MPI_FILE"
1114     usage
1115     fi
1116     fi
1117    
1118 jmc 1.99 #- setting for forward or ADM testing
1119     if test "x$ADM" = xt ; then
1120 jmc 1.168 if test "x$TARG" = xobj ; then TARG=adobj ; else TARG=adall ; fi
1121 jmc 1.99 code_dir=code_ad
1122 jmc 1.108 inputdir=input_ad
1123 jmc 1.99 ref_outp="output_adm.txt"
1124     EXECUTABLE="mitgcmuv_ad"
1125 utke 1.120 elif test "x$OADM" = xt ; then
1126 jmc 1.168 TARG=adAll
1127 utke 1.120 code_dir=code_oad
1128     inputdir=input_oad
1129     ref_outp="output_oadm.txt"
1130     EXECUTABLE="mitgcmuv_ad"
1131 jmc 1.99 else
1132 jmc 1.168 if test "x$JOBS" != x ; then TARG="-j $JOBS $TARG" ; fi
1133 jmc 1.99 code_dir=code
1134 jmc 1.108 inputdir=input
1135 jmc 1.99 ref_outp="output.txt"
1136     EXECUTABLE="mitgcmuv"
1137     fi
1138    
1139 jmc 1.142 xx=`echo $TESTDIRS | awk '{print $1}'`
1140 edhill 1.1 if test "x$TESTDIRS" = x ; then
1141 jmc 1.103 LIST=`scandirs results/$ref_outp`
1142 jmc 1.142 elif test $xx = 'start_from' ; then
1143     xx=`echo $TESTDIRS | awk '{print $2}'`
1144     LIST=`scandirs results/$ref_outp | sed -n "/$xx/,$ p"`
1145 jmc 1.84 else
1146     #- expand group of experiments:
1147     LIST=" "
1148     for xx in $TESTDIRS
1149     do
1150     case $xx in
1151 jmc 1.86 'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
1152     LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
1153     LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
1154 jmc 1.84 ;;
1155     'tutorials')
1156     LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
1157     *) LIST=${LIST}" "$xx ;;
1158     esac
1159 jmc 1.135 done
1160 jmc 1.89 fi
1161     #echo 'LIST='${LIST}'<'
1162     #- skip dirs, remove duplicate and non-directory:
1163     TESTDIRS=" "
1164     count=0
1165     for xx in $LIST
1166     do
1167     yy=`echo $SKIPDIRS | grep -c $xx`
1168     if test $yy = 0 ; then
1169 jmc 1.84 if test -d $xx ; then
1170     yy=`echo $TESTDIRS | grep -c $xx`
1171     if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
1172 jmc 1.89 else count=1 ;
1173     echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
1174     fi
1175     else
1176     if test $count = 1 ; then echo -n ", \"$xx\""
1177     else count=1 ; echo "" ; echo -n " skip: \"$xx\""
1178 jmc 1.84 fi
1179 jmc 1.89 fi
1180 jmc 1.135 done
1181 jmc 1.89 if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
1182 jmc 1.84 #echo 'TESTDIRS='${TESTDIRS}'<'
1183 edhill 1.1
1184 edhill 1.10 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
1185     OPTFILE=$MITGCM_OF
1186     fi
1187    
1188 jmc 1.156 LOC_MFILE='tr_mpi_mfile'
1189 jmc 1.146 RUNLOG="run.tr_log"
1190 jmc 1.99 OUTPUTFILE=$ref_outp
1191 jmc 1.87 if test "x$COMMAND" = x ; then
1192 jmc 1.77 COMMAND="./$EXECUTABLE > $OUTPUTFILE"
1193 edhill 1.24 fi
1194 jmc 1.154 if test "x$MPI" != x0 ; then
1195 jmc 1.87 OUTPUTFILE="STDOUT.0000"
1196 edhill 1.24 fi
1197    
1198 jmc 1.76 echo "OK (COMMAND= $COMMAND )"
1199 edhill 1.1
1200 jmc 1.94 # set the Default List of output variables to be checked:
1201     # (use default or load experiment-specific list from file "tr_checklist")
1202     # content : 1rst = main variable used to decide if it pass or FAIL
1203     # others = number of matching digits to be printed in summary.txt
1204 utke 1.120 if test "x$ADM" = x -a "x$OADM" = x; then
1205 jmc 1.94 DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+'
1206     EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..'
1207 jmc 1.97 LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1208 jmc 1.94 ii=`echo $EMPTY_RESULTS | awk '{print NF}'`
1209 jmc 1.97 EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf " ."}}'`
1210 jmc 1.99 else
1211 jmc 1.167 DEF_CHECK_LIST='AdGrd Cost AdGrd FDGrd'
1212 jmc 1.169 EMPTY_RESULTS='.. .. ..'
1213 jmc 1.99 LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1214 jmc 1.94 fi
1215    
1216 edhill 1.1 # create the FORTRAN comparison code
1217 jmc 1.133 if test -x tr_cmpnum ; then
1218     echo "skipping comparison code build"
1219     else
1220     createcodelet
1221     fi
1222 edhill 1.1
1223 jmc 1.112 # build the mpack utility (if ADDRESSES = NONE, do it to test the build)
1224     if test "x$ADDRESSES" = x ; then
1225 edhill 1.32 echo "skipping mpack build"
1226     else
1227 edhill 1.31 build_mpack
1228     fi
1229 edhill 1.1
1230     # Create a uniquely named directory to store results
1231 jmc 1.110 CMDLINE=$0
1232 jmc 1.118 for xx in "$@" ; do nw=`echo $xx | wc -w`
1233     if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
1234     else CMDLINE="$CMDLINE '$xx'" ; fi
1235     done
1236     #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
1237 edhill 1.1 MACH=`hostname`
1238 edhill 1.2 UNAMEA=`uname -a`
1239 edhill 1.1 DATE=`date +%Y%m%d`
1240 edhill 1.25 BASE="tr_"$MACH"_"$DATE"_"
1241 jmc 1.70 if test "x$OUTDIR" != x ; then
1242     BASE="tr_"$OUTDIR"_"$DATE"_"
1243 jmc 1.121 else
1244     short_name=`hostname | sed 's/\..*$//'`
1245     BASE="tr_"$short_name"_"$DATE"_"
1246 jmc 1.70 fi
1247 edhill 1.1 DNUM=0
1248     DRESULTS="$BASE$DNUM"
1249     while test -e $DRESULTS ; do
1250     DNUM=$(( $DNUM + 1 ))
1251     DRESULTS="$BASE$DNUM"
1252     done
1253     mkdir $DRESULTS
1254     RETVAL=$?
1255     if test "x$RETVAL" != x0 ; then
1256 edhill 1.20 echo "ERROR: Can't create results directory \"./$DRESULTS\""
1257 edhill 1.1 exit 1
1258     fi
1259     SUMMARY="$DRESULTS/summary.txt"
1260 edhill 1.16 start_date=`date`
1261 edhill 1.17 echo $start_date > $SUMMARY
1262 jmc 1.110 echo 'run:' $CMDLINE >> $SUMMARY
1263     echo 'on :' $UNAMEA >> $SUMMARY
1264 edhill 1.1
1265 edhill 1.11 of_path=
1266 edhill 1.10 if test "x$OPTFILE" != xNONE ; then
1267     if test -r $OPTFILE ; then
1268 edhill 1.11 # get the path
1269     path=${OPTFILE%/*}
1270     if test "x$path" = x ; then
1271     of_path=`pwd`
1272     else
1273     of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
1274     fi
1275     file=${OPTFILE##*/}
1276     OPTFILE=$of_path/$file
1277 edhill 1.21 cp $OPTFILE $DRESULTS
1278     echo >> $SUMMARY
1279     echo " OPTFILE=$OPTFILE" >> $SUMMARY
1280 edhill 1.11 else
1281 edhill 1.21 echo | tee $SUMMARY
1282     echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
1283     exit 1
1284 edhill 1.10 fi
1285 edhill 1.21 else
1286     echo >> $SUMMARY
1287 jmc 1.152 echo "No \"OPTFILE\" was specified ; genmake2 found and uses:" >> $SUMMARY
1288     #-note: to be filled later after 1rst run
1289 edhill 1.10 fi
1290     echo
1291     echo >> $SUMMARY
1292 utke 1.120 if test "x$ADM" = x -a "x$OADM" = x; then
1293 jmc 1.135 if [ $MATCH_CRIT -lt 10 ] ;
1294     then line_0="default "$MATCH_CRIT ;
1295 jmc 1.94 else line_0="default "$MATCH_CRIT ; fi
1296     line_0="$line_0 ----T----- ----S----- ----U----- ----V-----"
1297 edhill 1.49 line_1="G D M c m s m s m s m s"
1298 jmc 1.167 line_2="e p a R g m m e . m m e . m m e . m m e ."
1299     line_3="n n k u 2 i a a d i a a d i a a d i a a d"
1300 edhill 1.49 line_4="2 d e n d n x n . n x n . n x n . n x n ."
1301 edhill 1.50 for ii in $PTRACERS_NUM ; do
1302 edhill 1.49 line_0="$line_0 --PTR 0"$ii"--"
1303     line_1="$line_1 m s"
1304     line_2="$line_2 m m e ."
1305     line_3="$line_3 i a a d"
1306     line_4="$line_4 n x n ."
1307     done
1308     echo "$line_0" | tee -a $SUMMARY
1309     echo "$line_1" | tee -a $SUMMARY
1310     echo "$line_2" | tee -a $SUMMARY
1311     echo "$line_3" | tee -a $SUMMARY
1312     echo "$line_4" | tee -a $SUMMARY
1313     echo " " | tee -a $SUMMARY
1314 edhill 1.24 else
1315     echo "ADJOINT=true" >> $SUMMARY
1316     echo >> $SUMMARY
1317 jmc 1.135 if [ $MATCH_CRIT -lt 10 ] ;
1318     then line_0="default "$MATCH_CRIT ;
1319 jmc 1.103 else line_0="default "$MATCH_CRIT ; fi
1320 jmc 1.100 echo "$line_0" | tee -a $SUMMARY
1321 edhill 1.24 cat << EOF | tee -a $SUMMARY
1322 jmc 1.167 G D M C A F
1323     e p a R o d D
1324     n n k u s G G
1325     2 d e n t r r
1326 edhill 1.24
1327     EOF
1328     fi
1329 jmc 1.139 echo "-------------------------------------------------------------------------------"
1330 edhill 1.1
1331 edhill 1.10 # ...and each test directory...
1332     for dir in $TESTDIRS ; do
1333 jmc 1.135
1334 jmc 1.106 # set builddir & rundir:
1335     builddir="build"
1336     if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1337     rundir="run"
1338 jmc 1.143 pfxdir="tr_$rundir"
1339 jmc 1.106 if test ! -d $dir/$rundir ; then
1340     rundir=$builddir
1341     fi
1342     CODE_DIR=$dir/$code_dir
1343     BUILD_DIR=$dir/$builddir
1344    
1345 edhill 1.10 # Cleanup only!
1346     if test "x$CLEANUP" = xt ; then
1347 jmc 1.127 echo -n ' --- dir:' $BUILD_DIR ': '
1348     makeclean $BUILD_DIR
1349 jmc 1.145 ( cd $BUILD_DIR
1350     rm -f $EXECUTABLE *.bak
1351 jmc 1.146 rm -f genmake_state genmake_*optfile genmake.log
1352 jmc 1.154 rm -f SIZE.h.mpi genmake.tr_log make.tr_log
1353 jmc 1.145 )
1354 jmc 1.106 if test -d $dir/$rundir/CVS ; then
1355 jmc 1.127 echo -n ' --- dir:' $dir/$rundir ': '
1356 jmc 1.106 run_clean $dir/$rundir
1357 edhill 1.10 fi
1358 jmc 1.143 trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')`
1359 jmc 1.127 ttd=`echo $trdir | wc -w`
1360     if test $ttd != 0 ; then
1361     echo ' --- rm dir:' $trdir
1362     ( cd $dir ; rm -rf $trdir )
1363     fi
1364 edhill 1.10 continue
1365 edhill 1.1 fi
1366 edhill 1.3
1367 jmc 1.135 # Verify that the testdir exists and contains previous
1368 edhill 1.10 # results in the correct location--or skip this directory!
1369 jmc 1.104 fout=$dir"/results/"$ref_outp
1370 edhill 1.24 if test ! -r $fout ; then
1371     echo "can't read \"$fout\" -- skipping $dir"
1372 edhill 1.10 continue
1373     fi
1374 edhill 1.7
1375 jmc 1.117 # Check for specific files for particular type of run
1376 edhill 1.49
1377 jmc 1.161 if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" != "x0" ; then
1378     echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1379     continue
1380     fi
1381     if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1382     echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1383     continue
1384     fi
1385    
1386 jmc 1.154 if test "x$MPI" != "x0" ; then
1387 jmc 1.161 prefer_X=0
1388     if test "x$MULTI_THREAD" = "xt" ; then
1389     retv=`check_eedata $dir"/input/eedata.mth"`
1390     if test $retv = 1 ; then prefer_X=1 ; fi
1391     fi
1392     #- create new SIZE.h with no more than '$MPI' Procs
1393     mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $prefer_X
1394     LOC_NPROC=$?
1395     ( cd $BUILD_DIR
1396     if test -r SIZE.h.mpi ; then
1397     cmp tr_size.mpi SIZE.h.mpi > /dev/null 2>&1 ; RETVAL=$?
1398     else RETVAL=1
1399     fi
1400     if test "x$RETVAL" = x0 ; then
1401     rm -f tr_size.mpi
1402     else
1403     rm -f SIZE.h.mpi ; mv tr_size.mpi SIZE.h.mpi
1404     fi
1405     )
1406 jmc 1.156 if test "x$MPI_MFILE" != x ; then
1407     #- create new MPI machine-file with the right number of Procs
1408     rm -f $LOC_MFILE
1409     cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
1410     nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1411     if [ $nl -lt $LOC_NPROC ] ; then
1412     rm -f $LOC_MFILE
1413     cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
1414     #sed -n "1,$LOC_NPROC p" $MPI_MFILE > $LOC_MFILE
1415     fi
1416     if [ $verbose -gt 1 ]; then
1417     nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1418     echo " new LOC_MFILE=$LOC_MFILE : $nl procs for LOC_NPROC=$LOC_NPROC"
1419     fi
1420     fi
1421 jmc 1.161 if test "x$MULTI_THREAD" = "xt" ; then
1422     retv=`check_eedata $dir"/input/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
1423     if test $retv != 0 ; then
1424     echo "input/eedata.mth tiling misfit -- skipping $dir"
1425     continue
1426     fi
1427 jmc 1.154 fi
1428 jmc 1.123 fi
1429 jmc 1.83
1430     # Check whether there are "extra runs" for this testdir
1431     extra_runs=
1432 jmc 1.133 if test "x$NORUN" = xf ; then
1433     ex_run_dirs=`( cd $dir ; echo $inputdir.* )`
1434     fi
1435 jmc 1.108 #echo "ex_run_dirs='$ex_run_dirs'"
1436     for exd in $ex_run_dirs ; do
1437     name=`echo $exd | sed -e "s/$inputdir\.//"`
1438     refExOut=`echo $ref_outp | sed "s/\./.${name}./"`
1439     outf="$dir/results/$refExOut"
1440     if test -f $outf -a -r $outf ; then
1441 jmc 1.135 if test "x$MULTI_THREAD" = "xt" ; then
1442 jmc 1.123 if test -r $dir"/"$exd"/eedata.mth" ; then
1443 jmc 1.154 if test "x$MPI" = "x0" ; then
1444     extra_runs="$extra_runs $name"
1445     else
1446 jmc 1.161 retv=`check_eedata $dir"/"$exd"/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
1447 jmc 1.123 if test $retv = 0 ; then
1448 jmc 1.83 extra_runs="$extra_runs $name"
1449 jmc 1.123 else
1450     echo $exd"/eedata.mth tiling misfit -- skipping $dir"
1451 jmc 1.83 fi
1452 jmc 1.123 fi
1453     #else echo $dir"/"$exd"/eedata.mth: not found"
1454 jmc 1.83 fi
1455 jmc 1.123 else
1456     extra_runs="$extra_runs $name"
1457     fi
1458 jmc 1.108 fi
1459     done
1460 edhill 1.28
1461     echo
1462 jmc 1.135 if test "x$extra_runs" = "x" ; then
1463 jmc 1.83 echo "Experiment: $dir"
1464     else
1465     echo "Experiment: $dir ; extra_runs=$extra_runs"
1466     fi
1467 edhill 1.28 echo
1468     unset genmake makedepend make run
1469 jmc 1.94 results=$EMPTY_RESULTS
1470 edhill 1.10
1471 jmc 1.158 # Create an output dir & summary.txt file for each tested experiment (tdir)
1472 jmc 1.138 locDIR=$DRESULTS"/"$dir
1473     mkdir $locDIR
1474 jmc 1.158 #- report to this experiment local summary file ---
1475     echo "DATE='$DATE' ; tdir='$dir'" > $locDIR"/summary.txt"
1476     echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1477     echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1478 jmc 1.138 CDIR=`pwd`"/$locDIR"
1479 jmc 1.135
1480 jmc 1.133 if test "x$NORUN" = xt ; then
1481     run=N
1482     genmakemodel $dir/$builddir && genmake=Y \
1483     && makeclean $dir/$builddir \
1484     && symlink_mpifiles $dir $code_dir $builddir \
1485     && makedependmodel $dir/$builddir && makedepend=Y \
1486     && makemodel $dir/$builddir && make=Y
1487 edhill 1.10 else
1488 edhill 1.1 genmakemodel $dir/$builddir && genmake=Y \
1489     && makeclean $dir/$builddir \
1490 edhill 1.27 && symlink_mpifiles $dir $code_dir $builddir \
1491 edhill 1.1 && makedependmodel $dir/$builddir && makedepend=Y \
1492     && makemodel $dir/$builddir && make=Y \
1493 jmc 1.139 && run_clean $dir/$rundir \
1494 jmc 1.140 && linkdata $dir/$rundir $inputdir \
1495 edhill 1.12 && runmodel $dir/$rundir && run=Y \
1496 jmc 1.99 && results=`testoutput_run $dir $rundir $ref_outp`
1497 edhill 1.10 fi
1498 jmc 1.139 #echo "results='$results'"
1499 jmc 1.135
1500 edhill 1.24 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1501 jmc 1.139 echo 1>&2
1502 jmc 1.98 echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /</' >> $SUMMARY
1503 jmc 1.138 echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1504 edhill 1.34
1505     for ex in $extra_runs ; do
1506 jmc 1.73 unset run
1507 jmc 1.94 results=$EMPTY_RESULTS
1508 jmc 1.106 # reference output file
1509     refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
1510 jmc 1.158 # Create an output dir & summary.txt file for each extra run (tdir.ex)
1511 jmc 1.138 locDIR=$DRESULTS"/"$dir"."$ex
1512     mkdir $locDIR
1513 jmc 1.158 #- report to this experiment local summary file ---
1514     echo "DATE='$DATE' ; tdir='$dir.$ex'" > $locDIR"/summary.txt"
1515     #echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1516     #echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1517 jmc 1.138 CDIR=`pwd`"/$locDIR"
1518 jmc 1.143 test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
1519     run_clean $dir/$pfxdir.$ex
1520     linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
1521     runmodel $dir/$pfxdir.$ex && run=Y \
1522     && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
1523 edhill 1.34 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1524     fres="$fres.$ex"
1525 jmc 1.139 echo 1>&2
1526 jmc 1.100 echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /</' >> $SUMMARY
1527 jmc 1.138 echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1528 jmc 1.156 if test "x$POSTCLEAN" = x2 ; then
1529 jmc 1.143 run_clean $dir/$pfxdir.$ex
1530 jmc 1.83 fi
1531 edhill 1.34 done
1532 edhill 1.68
1533 jmc 1.139 if test -f $DRESULTS"/"genmake_state ; then : ; else
1534 jmc 1.137 if test -f $dir/$builddir/Makefile ; then
1535     mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
1536     echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
1537     sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
1538 jmc 1.151 echo " $mkOpt" >> $DRESULTS/genmake_state
1539 jmc 1.152 if test "x$OPTFILE" = xNONE ; then
1540     eval $mkOpt
1541     sed "/^No \"OPTFILE\" was specified ; genmake2/a\ OPTFILE=${OPTFILE}"\
1542     $SUMMARY > tr_0.tmp_log
1543     RETVAL=$?
1544     if test "x$RETVAL" = x0 ; then rm -f $SUMMARY
1545     cp tr_0.tmp_log $SUMMARY
1546     else rm -f tr_0.tmp_log
1547     fi
1548     fi
1549 jmc 1.150 gmkLog=$dir/$builddir/genmake.log
1550     grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
1551     RETVAL=$?
1552     if test "x$RETVAL" = x0 ; then
1553     echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
1554 jmc 1.151 sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
1555 jmc 1.166 | grep -v '^... compiler version ' > tr_1.tmp_log
1556     sed -n '1p' tr_1.tmp_log >> $DRESULTS/genmake_state
1557     sed -n '2,/^$/p' tr_1.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
1558 jmc 1.151 >> $DRESULTS/genmake_state
1559 jmc 1.152 rm -f tr_1.tmp_log
1560 jmc 1.150 fi
1561 jmc 1.137 fi
1562     fi
1563 jmc 1.83 #postclean $dir/$builddir
1564 jmc 1.156 if test "x$POSTCLEAN" = x2 ; then
1565 jmc 1.83 makeclean $dir/$builddir \
1566     && run_clean $dir/$rundir
1567     fi
1568 jmc 1.156 if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
1569 jmc 1.135
1570 edhill 1.10 echo "-------------------------------------------------------------------------------"
1571 jmc 1.135
1572 edhill 1.1 done
1573    
1574 edhill 1.34 printf "Start time: " >> $SUMMARY
1575 jmc 1.114 echo "$start_date" >> $SUMMARY
1576 edhill 1.34 printf "End time: " >> $SUMMARY
1577 edhill 1.13 date >> $SUMMARY
1578 edhill 1.20
1579     # If addresses were supplied and mpack built successfully, then try
1580     # to send email using mpack.
1581     if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1582     echo "No results email was sent."
1583     else
1584     if test "x$HAVE_MPACK" = xt ; then
1585     tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1586     && gzip $DRESULTS".tar" \
1587 edhill 1.44 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1588 edhill 1.20 RETVAL=$?
1589     if test "x$RETVAL" != x0 ; then
1590     echo
1591     echo "Warning: The tar, gzip, & mpack step failed. Please send email"
1592     echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
1593     echo " summary of results from the directory \"$DRESULTS\"."
1594     echo
1595     else
1596     echo
1597     echo "An email containing results was sent to the following addresses:"
1598     echo " \"$ADDRESSES\""
1599     echo
1600 jmc 1.129 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
1601     test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
1602 edhill 1.20 fi
1603     fi
1604     fi
1605 edhill 1.13
1606 jmc 1.133 if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
1607     rm -f tr_cmpnum.c tr_cmpnum
1608     fi
1609 edhill 1.1
1610 edhill 1.12 if test "x$CLEANUP" != xt ; then
1611 jmc 1.102 cat $SUMMARY | sed 's/ \. \. \. \. \. \. \. \. \. \. \. \. //'
1612 edhill 1.25 if test -e tr_out.txt ; then
1613     mv tr_out.txt tr_out.txt.old
1614 edhill 1.14 fi
1615 jmc 1.103 cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
1616 edhill 1.12 fi
1617 edhill 1.1
1618 edhill 1.40 if test "x$DELDIR" = xt ; then
1619     rm -rf $DRESULTS
1620     fi
1621    

  ViewVC Help
Powered by ViewVC 1.1.22