/[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.163 - (hide annotations) (download)
Wed May 18 22:03:57 2011 UTC (12 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62z, checkpoint62y
Changes since 1.162: +4 -2 lines
failed compilation: limit Nb of lines of make log-file to be saved in
 output directory (now in file "make.tr_log_tail").

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

  ViewVC Help
Powered by ViewVC 1.1.22