/[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.164 - (hide annotations) (download)
Mon Jun 27 18:45:16 2011 UTC (12 years, 9 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63a, checkpoint63
Changes since 1.163: +16 -7 lines
rename "-noieee" to "-fast" (but still accept -noieee); add option
 "-devel" to pass to genmake2.

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

  ViewVC Help
Powered by ViewVC 1.1.22