/[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.155 - (hide annotations) (download)
Wed Jan 19 22:12:55 2011 UTC (13 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.154: +19 -14 lines
-avoid the use of "seq" command (not so standard);
-adjust number of MPI processors in COMMAND by replacing TR_NPROC
 (instead of "-np XX").

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

  ViewVC Help
Powered by ViewVC 1.1.22