Back to home page

MITgcm

 
 

    


Warning, /verification/testreport is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit c908a600 on 2024-12-18 17:03:09 UTC
f610331bb1 Ed H*0001 #! /usr/bin/env bash
2ff82eb834 Ed H*0002 
                0003 usage()
                0004 {
                0005     echo
                0006     echo "Usage:  $0 [OPTIONS]"
                0007     echo
                0008     echo "where possible OPTIONS are:"
                0009     echo "  (-help|-h)               print usage"
ee57712ddb Jean*0010     echo " ---- type of test : ----"
b4daa24319 Shre*0011     echo "  (-tlm)                   perform a Tangent-Linear run (defaut: using TAF)"
                0012     echo "  (-adm|-ad)               perform an Adjoint run (default: using TAF)"
                0013     echo "  (-tap)                   use Tapenade for Adjoint or Tangent-Linear run"
ee57712ddb Jean*0014     echo "  (-oad)                   perform an OpenAD adjoint run"
9d0c386f0c dngo*0015     echo "  (-oadsingularity|-oadsngl) STRING"
                0016     echo "                           path to singularity container with OpenAD"
616bf911ff Jean*0017     echo "  (-mth)                   run multi-threaded (using eedata.mth)"
d9ae4e2b34 Jean*0018     echo "  (-mpi)                   use MPI to compile and run on 2 processors"
                0019     echo "  (-MPI)  NUMBER           use MPI to compile and run on max NUMBER procs"
bbea11a65d Jean*0020     echo "  (-mfile|-mf) STRING      MPI: file with list of possible machines to run on"
442de1f446 Jean*0021     echo "  (-command|-c) STRING     command to run (e.g., if non-standard MPI setting)"
                0022     echo "                            DEF='mitgcmuv' or ='mpirun -np TR_NPROC mitgcmuv'"
ee57712ddb Jean*0023     echo " ---- testing options : ----"
e355dad078 Jean*0024     echo "  (-optfile|-of) STRING    optfile to use"
5a67953813 Jean*0025     echo "  (-fast)                  use optfile default for compiler flags (no '-ieee')"
                0026     echo "                            DEF=off => use IEEE numerics option (if available)"
                0027     echo "  (-devel)                 use optfile developement flags (if available)"
232027f18d Jean*0028     echo "  (-gsl)                   compile with \"-gsl\" flag"
416e70d1a2 Jean*0029     echo "  (-use_r4|-ur4)           if allowed, use real*4 type for '_RS' variable"
                0030     echo "  (-tdir|-t) STRING        list of group and/or exp. dirs to test"
35aa6741f4 Jean*0031     echo "                             (recognized groups: basic, tutorials)"
                0032     echo "                             (DEF=\"\" which test all)"
ef1af8ad10 Jean*0033     echo "                             (if list= 'start_from THIS_EXP' then"
                0034     echo "                              test THIS_EXP + all the following)"
416e70d1a2 Jean*0035     echo "  (-skipdir|-skd) STRING   list of exp. dirs to skip"
6d0f07d5b0 Jean*0036     echo "                             (DEF=\"\" which test all)"
ee57712ddb Jean*0037     echo "  (-ts)                    provide timing information per timestep"
                0038     echo "  (-papis)                 provide MFlop/s per timestep using PAPI"
                0039     echo "  (-pcls)                  provide MFlop/s per timestep using PCL"
                0040     echo " ---- system options : ----"
                0041     echo "  (-bash|-b) STRING        preferred location of a \"bash\" or \"sh\" shell"
002054e5e5 Ed H*0042     echo "                             (DEF=\"\" for \"bash\")"
ee57712ddb Jean*0043     echo "  (-ef) STRING             used as genmake2 \"-extra_flag\" argument"
e977410d1b Mart*0044     echo "  (-ncad)                  use genmake2 option \"-nocat4ad\" (-ncad)"
                0045     echo "  (-small_f)               make target small_f before making target all"
ca2316a28b Jean*0046     echo "  (-makedepend|-md) STRING command to use for \"makedepend\""
416e70d1a2 Jean*0047     echo "  (-make|-m) STRING        command to use for \"make\""
fd381e7ade Ed H*0048     echo "                             (DEF=\"make\")"
ee57712ddb Jean*0049     echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"
                0050     echo " ---- output options : ----"
aaf4336666 Jean*0051     echo "  (-match) NUMBER          Matching Criteria (number of digits)"
ca2316a28b Jean*0052     echo "                             (DEF=\"$MATCH_CRIT\")"
13cadcbe59 Oliv*0053     echo "  (-pass)                  return non-zero exit code if any exp do not pass"
ee57712ddb Jean*0054     echo "  (-odir) STRING           used to build output directory name"
                0055     echo "                             (DEF=\"hostname\")"
                0056     echo "  (-addr|-a) STRING        list of email recipients"
                0057     echo "                             (DEF=\"\" no email is sent)"
                0058     echo "  (-send)       STRING     sending command (instead of using mpack)"
                0059     echo "  (-savdir|-sd) STRING     location to save output tar file to send (DEF='$SAVDIR')"
                0060     echo "  (-mpackdir|-mpd) DIR     location of the mpack utility"
                0061     echo "                             (DEF=\"../tools/mpack-1.6\")"
                0062     echo " -- do only some parts: --"
bbea11a65d Jean*0063     echo "  (-clean)                 *ONLY* run \"make CLEAN\" & clean run-dir"
ca6d5f1072 Jean*0064     echo "  (-norun|-nr)             skip the \"runmodel\" stage (stop after make)"
1f09e8610e Jean*0065     echo "  (-obj)                   only produces objects (=norun & no executable)"
f6209765b3 Jean*0066     echo "  (-src)                   only produces small '*.f' src files (not even obj)"
                0067     echo "                            + with: '-adm/-tlm', also makes taf outp src code"
416e70d1a2 Jean*0068     echo "  (-runonly|-ro)           *ONLY* run stage (=\"-quick\" without make)"
a986ef8661 Cons*0069     echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
                0070     echo "  (-nogenmake|-ng)         skip the genmake stage"
                0071     echo "  (-noclean|-nc)           skip the \"make clean\" stage"
                0072     echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
bbea11a65d Jean*0073     echo "  (-postclean|-pc)         after each exp. test, clean build-dir & run-dir"
                0074     echo "  (-deloutp|-do)           delete output files after successful run"
a986ef8661 Cons*0075     echo "  (-deldir|-dd)            on success, delete the output directory"
96d85cca71 Ed H*0076     echo
a18b9b1964 Ed H*0077     echo "and where STRING can be a whitespace-delimited list"
96d85cca71 Ed H*0078     echo "such as:"
a18b9b1964 Ed H*0079     echo
96d85cca71 Ed H*0080     echo "  -t 'exp0 exp2 exp3' "
                0081     echo "  -addr='abc@123.com testing@home.org'"
2ff82eb834 Ed H*0082     echo
a18b9b1964 Ed H*0083     echo "provided that the expression is properly quoted within the current"
                0084     echo "shell (note the use of single quotes to protect white space)."
                0085     echo
2ff82eb834 Ed H*0086     exit 1
                0087 }
                0088 
                0089 #  build the mpack utility
                0090 build_mpack()
                0091 {
e53112a6cf Ed H*0092     printf "building the mpack utility...  "
d6829a17bc Jean*0093     MPACK="$MPACKDIR/mpack"
                0094     if test ! -x $MPACK ; then
2ff82eb834 Ed H*0095         if test ! -d $MPACKDIR ; then
002054e5e5 Ed H*0096             echo
2ff82eb834 Ed H*0097             echo "Error: can't find \"$MPACKDIR\""
                0098             echo "  are you sure this program is being run in the correct "
                0099             echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
002054e5e5 Ed H*0100             echo
                0101             HAVE_MPACK=f
2ff82eb834 Ed H*0102         fi
2e69e179c3 Ed H*0103         if test "x$CC" = x ; then
                0104             export CC=cc
                0105         fi
63e0800ef7 Jean*0106         printf "building mpack (using CC=$CC)...  "
54db3dc364 Ed H*0107         ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
2ff82eb834 Ed H*0108         RETVAL=$?
                0109         if test "x$RETVAL" != x0 ; then
                0110             echo
                0111             echo "Error building the mpack tools at: $MPACK_DIR"
002054e5e5 Ed H*0112             echo
                0113             HAVE_MPACK=f
                0114         else
54db3dc364 Ed H*0115             rm -f tr_build_mpack.out
002054e5e5 Ed H*0116             HAVE_MPACK=t
d6829a17bc Jean*0117             echo "done"
2ff82eb834 Ed H*0118         fi
002054e5e5 Ed H*0119     else
                0120         HAVE_MPACK=t
d6829a17bc Jean*0121         echo "already exist"
2ff82eb834 Ed H*0122     fi
                0123 }
                0124 
3f7ac1ee60 Jean*0125 testoutput_var()
2ff82eb834 Ed H*0126 {
6d41b7da3e Jean*0127     # testoutput_var dir s1 label subdir reference_output
2ff82eb834 Ed H*0128     #
9750e41317 Jean*0129     #  compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE
6418c0ec62 Jean*0130     #     with same output from reference file $dir/$reference_output
3f7ac1ee60 Jean*0131     #  using search strings s1 and text label
2ff82eb834 Ed H*0132 
                0133     if [ $debug -gt 0 ]; then
d81415648f Jean*0134         echo testoutput_var: grep "'$2'" $1/$4/$OUTPUTFILE 1>&2
2ff82eb834 Ed H*0135     fi
84370bfea3 Jean*0136     if [ -r $1/$4/$OUTPUTFILE ]; then
deb0ad3aea Mart*0137         grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | nl > ${TMP}a.txt
ee57712ddb Jean*0138         lncntA=`wc -l ${TMP}a.txt | awk '{print $1}' `
c5e604105c Jean*0139         if [ $lncntA -lt 2 ]; then
2ff82eb834 Ed H*0140             if [ $verbose -gt 0 ]; then
                0141                 echo Not enough lines of output when searching for "$2" 1>&2
                0142             fi
ee57712ddb Jean*0143             rm -f ${TMP}a.txt ; return 99
2ff82eb834 Ed H*0144         fi
                0145     else
3f7ac1ee60 Jean*0146         echo testoutput_var: $OUTPUTFILE from model run was not readable 1>&2
2ff82eb834 Ed H*0147         return 99
                0148     fi
                0149     if [ $debug -gt 0 ]; then
d81415648f Jean*0150         echo testoutput_var: grep "'$2'" $1/$5 1>&2
2ff82eb834 Ed H*0151     fi
deb0ad3aea Mart*0152     grep "$2" $1/$5 | sed 's/.*=//' | nl > ${TMP}b.txt
ee57712ddb Jean*0153     lncntB=`wc -l ${TMP}b.txt | awk '{print $1}' `
c5e604105c Jean*0154     if [ $lncntB -lt 2 ]; then
2ff82eb834 Ed H*0155         if [ $verbose -gt 0 ]; then
                0156             echo Not enough lines of output when searching for "$2" 1>&2
                0157         fi
ee57712ddb Jean*0158         rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
2ff82eb834 Ed H*0159     fi
ce680526d4 Jean*0160     if [ $lncntA -ne $lncntB ]; then
6418c0ec62 Jean*0161         if [ $verbose -gt 0 ]; then
                0162             echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
                0163         fi
ee57712ddb Jean*0164         rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
ce680526d4 Jean*0165     fi
ee57712ddb Jean*0166     has_nan=`cat ${TMP}a.txt | grep -i nan | wc -l`
ef3ea31c23 Ed H*0167     if [ $has_nan -gt 0  ] ; then
3f7ac1ee60 Jean*0168         echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values  1>&2
ee57712ddb Jean*0169         rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
ef3ea31c23 Ed H*0170     fi
ee57712ddb Jean*0171     has_inf=`cat ${TMP}a.txt | grep -i inf | wc -l`
ef3ea31c23 Ed H*0172     if [ $has_inf -gt 0  ] ; then
3f7ac1ee60 Jean*0173         echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values  1>&2
ee57712ddb Jean*0174         rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
7bcfb3f76d Jean*0175     fi
2ff82eb834 Ed H*0176     if [ $debug -gt 0 ]; then
ee57712ddb Jean*0177         echo testoutput_var: join ${TMP}a.txt ${TMP}b.txt 1>&2
2ff82eb834 Ed H*0178     fi
ee57712ddb Jean*0179     # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
                0180     join ${TMP}a.txt ${TMP}b.txt | awk '{print $1 " " $2 " " $3}' | sed -e 's|:||g' > ${TMP}c.txt
2ff82eb834 Ed H*0181     if [ $debug -gt 0 ]; then
3f7ac1ee60 Jean*0182         echo testoutput_var: compare_lines 1>&2
2ff82eb834 Ed H*0183     fi
cfc62862f0 Ed H*0184     if [ $verbose -gt 1 ]; then
ee57712ddb Jean*0185         cat ${TMP}c.txt 1>&2
cfc62862f0 Ed H*0186     fi
ee57712ddb Jean*0187     echo "-1" >> ${TMP}c.txt
                0188     digits_of_similarity=`./tr_cmpnum < ${TMP}c.txt`
2ff82eb834 Ed H*0189     if [ $digits_of_similarity -eq 99 ]; then
                0190         if [ $verbose -gt 0 ]; then
6d41b7da3e Jean*0191             echo testoutput_var: No comparison was available for \"$3\" 1>&2
2ff82eb834 Ed H*0192         fi
                0193         digits_of_similarity=99
                0194     else
                0195         if [ $verbose -gt 0 ]; then
6d41b7da3e Jean*0196             echo There were $digits_of_similarity decimal places of similarity for \"$3\" 1>&2
2ff82eb834 Ed H*0197         fi
                0198     fi
ee57712ddb Jean*0199     rm -f ${TMP}a.txt ${TMP}b.txt ${TMP}c.txt
9750e41317 Jean*0200 
2ff82eb834 Ed H*0201     return $digits_of_similarity
                0202 }
                0203 
3f7ac1ee60 Jean*0204 testoutput_run()
2ff82eb834 Ed H*0205 {
6d41b7da3e Jean*0206     # testoutput_run directory subdir reference_output
2ff82eb834 Ed H*0207     #
3f7ac1ee60 Jean*0208     #  test output from 1 run in "directory"
456c314cce Jean*0209 # --> same processing for adjoint & forward test
6418c0ec62 Jean*0210         # default list of output variables to be checked:
                0211         #  1rst : main variable used to decide if it pass or FAIL
                0212         #  others : number of matching digits to be printed in summary.txt
                0213         listChk=$DEF_CHECK_LIST
eb7e5e62ed Jean*0214         #  load experiment-specific list from file "tr_checklist" (if it exist)
6418c0ec62 Jean*0215         if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi
b4daa24319 Shre*0216         if test $KIND = 1 -o $KIND = 4 ; then kd='g_';
d81415648f Jean*0217           #  TLM use same input_ad/tr_checklist --> convert
c59dd234b1 Jean*0218           listChk=`echo $listChk | sed 's/^adm/tlm/' | sed 's/ adm/ tlm/g'`
                0219           if test -r $1/$2/tr_checklist.tlm ; then listChk=`cat $1/$2/tr_checklist.tlm` ; fi
b4daa24319 Shre*0220         elif test $KIND = 2 -o $KIND = 5 ; then kd='ad';
d81415648f Jean*0221           if test -r $1/$2/tr_checklist.adm ; then listChk=`cat $1/$2/tr_checklist.adm` ; fi
b4daa24319 Shre*0222         elif test $KIND = 6 ; then kd='ad';
d81415648f Jean*0223         else kd=''; fi
                0224         if [ $debug -gt 0 ]; then echo "testoutput_run: listChk='$listChk'" 1>&2 ; fi
6418c0ec62 Jean*0225         # remove 1rst var and expand the list: + => min max mean s.d
d81415648f Jean*0226         sVar=`echo $listChk | awk '{print $1}'`
6418c0ec62 Jean*0227         listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \
                0228                                | sed 's/+//g' | sed "s/^$sVar//"`
                0229         # set ref.outp file-name and, if compressed, uncompress it into subdir
                0230         refoutp=results/$3
                0231         if test ! -r $1/results/$3 ; then
                0232           if test -r $1/results/${3}.gz ; then
                0233             tmpNam1=$3
                0234             tmpNam2=`echo $tmpNam1 | sed 's/\..*\././'`
                0235             if test "x$tmpNam1" = "x$tmpNam2" ; then
                0236                 tmpNam1=`echo $tmpNam2 | sed 's/\./.std./'`
                0237             fi
                0238             refoutp=$2/$tmpNam1
                0239             if [ $debug -gt 0 ]; then
                0240                 echo "testoutput_run: gunzip 'results/$3.gz' into '$refoutp'" 1>&2
                0241             fi
                0242             gzip -cd $1/results/${3}.gz > $1/$refoutp
                0243           else
                0244             echo "missing reference output file '$3' (.gz) in '$1/results/'"
                0245           fi
                0246         fi
                0247         # check for ptracer output in reference_output file :
                0248         if test $KIND = 0 ; then
                0249           ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max"
                0250           ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
                0251           for ii in $PTRACERS_NUM ; do
bef69cc95f Jean*0252             ptrfound=0
                0253             for jj in $ptr_mon ; do
                0254                 name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
6418c0ec62 Jean*0255                 tst=`grep $name $1/$refoutp | wc -l | awk '{print $1}'`
bef69cc95f Jean*0256                 if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
                0257             done
                0258             if test $ptrfound = '1' ; then
                0259                 eval "HAVE_PTR0"$ii"=t"
                0260             else
                0261                 eval "HAVE_PTR0"$ii"=f"
                0262               # remove this ptr from the list of output variable to check
                0263               # echo "-- ptr test=" $tst "number of var=" `echo $listVar | awk '{print NF}'` 1>&2
                0264                 listVar=`echo "$listVar" | sed "s/ pt$ii..//g"`
                0265             fi
6418c0ec62 Jean*0266           # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
                0267           done
                0268         fi
                0269         tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'`
                0270         if test $tst != 1 ; then
                0271           if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2
                0272                  else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi
                0273           echo "==> WARNING: in checked list:" $listVar 1>&2
                0274         #- put it back once:
                0275           listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
                0276         fi
d81415648f Jean*0277         if [ $debug -gt 0 ]; then echo "testoutput_run: listVar='$listVar'" 1>&2 ; fi
d9ae4e2b34 Jean*0278         echo "listVar='$listVar'" >> $locDIR"/summary.txt"
6418c0ec62 Jean*0279         #---
                0280         allargs=""
                0281         for xx in $listVar
                0282         do
7ee8179b2a Jean*0283          #ii=`echo $xx | sed 's/^pt[0-9][0-9]*..$/XXX/'`        #- any ptr number
                0284           ii=`echo $xx | sed 's/^pt[1-9]..$/XXX/'`              #- 1 to 9 ptr number
                0285           if test $ii != 'XXX' ; then
                0286           #- all except ptracer stats:
                0287             case $xx in
eb7e5e62ed Jean*0288            'PS')  if [ $debug -gt 0 ]
                0289                   then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
6418c0ec62 Jean*0290                   testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $refoutp ; yy=$?
eb7e5e62ed Jean*0291                   if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
d81415648f Jean*0292         'admCst') testoutput_var $1 "ADM  ref_cost_function" "ADM CostFct" $2 $refoutp ; yy=$? ;;
                0293         'admGrd') testoutput_var $1 "ADM  adjoint_gradient"  "ADM Ad Grad" $2 $refoutp ; yy=$? ;;
                0294         'admFwd') testoutput_var $1 "ADM  finite-diff_grad"  "ADM FD Grad" $2 $refoutp ; yy=$? ;;
6418c0ec62 Jean*0295         'tlmCst') testoutput_var $1 "TLM  ref_cost_function" "TLM CostFct" $2 $refoutp ; yy=$? ;;
                0296         'tlmGrd') testoutput_var $1 "TLM  tangent-lin_grad"  "TLM TL Grad" $2 $refoutp ; yy=$? ;;
d81415648f Jean*0297         'tlmFwd') testoutput_var $1 "TLM  finite-diff_grad"  "TLM FD Grad" $2 $refoutp ; yy=$? ;;
                0298            'Tmn') testoutput_var $1 "dynstat_${kd}theta_min"  "${kd}Theta minimum" $2 $refoutp ; yy=$? ;;
                0299            'Tmx') testoutput_var $1 "dynstat_${kd}theta_max"  "${kd}Theta maximum" $2 $refoutp ; yy=$? ;;
                0300            'Tav') testoutput_var $1 "dynstat_${kd}theta_mean" "${kd}Theta mean"    $2 $refoutp ; yy=$? ;;
                0301            'Tsd') testoutput_var $1 "dynstat_${kd}theta_sd"   "${kd}Theta Std.Dev" $2 $refoutp ; yy=$? ;;
                0302            'Smn') testoutput_var $1 "dynstat_${kd}salt_min"   "${kd}Salt minimum"  $2 $refoutp ; yy=$? ;;
                0303            'Smx') testoutput_var $1 "dynstat_${kd}salt_max"   "${kd}Salt maximum"  $2 $refoutp ; yy=$? ;;
                0304            'Sav') testoutput_var $1 "dynstat_${kd}salt_mean"  "${kd}Salt mean"     $2 $refoutp ; yy=$? ;;
                0305            'Ssd') testoutput_var $1 "dynstat_${kd}salt_sd"    "${kd}Salt Std.Dev"  $2 $refoutp ; yy=$? ;;
                0306            'Umn') testoutput_var $1 "dynstat_${kd}uvel_min"   "${kd}U minimum"     $2 $refoutp ; yy=$? ;;
                0307            'Umx') testoutput_var $1 "dynstat_${kd}uvel_max"   "${kd}U maximum"     $2 $refoutp ; yy=$? ;;
                0308            'Uav') testoutput_var $1 "dynstat_${kd}uvel_mean"  "${kd}U mean"        $2 $refoutp ; yy=$? ;;
                0309            'Usd') testoutput_var $1 "dynstat_${kd}uvel_sd"    "${kd}U Std.Dev"     $2 $refoutp ; yy=$? ;;
                0310            'Vmn') testoutput_var $1 "dynstat_${kd}vvel_min"   "${kd}V minimum"     $2 $refoutp ; yy=$? ;;
                0311            'Vmx') testoutput_var $1 "dynstat_${kd}vvel_max"   "${kd}V maximum"     $2 $refoutp ; yy=$? ;;
                0312            'Vav') testoutput_var $1 "dynstat_${kd}vvel_mean"  "${kd}V mean"        $2 $refoutp ; yy=$? ;;
                0313            'Vsd') testoutput_var $1 "dynstat_${kd}vvel_sd"    "${kd}V Std.Dev"     $2 $refoutp ; yy=$? ;;
                0314          'Etamn') testoutput_var $1 "dynstat_${kd}eta_min"    "${kd}Eta minimum"   $2 $refoutp ; yy=$? ;;
                0315          'Etamx') testoutput_var $1 "dynstat_${kd}eta_max"    "${kd}Eta maximum"   $2 $refoutp ; yy=$? ;;
                0316          'Etaav') testoutput_var $1 "dynstat_${kd}eta_mean"   "${kd}Eta mean"      $2 $refoutp ; yy=$? ;;
                0317          'Etasd') testoutput_var $1 "dynstat_${kd}eta_sd"     "${kd}Eta Std.Dev"   $2 $refoutp ; yy=$? ;;
                0318          'Qntmn') testoutput_var $1 "forcing_qnet_min"  "Qnet minimum"  $2 $refoutp ; yy=$? ;;
                0319          'Qntmx') testoutput_var $1 "forcing_qnet_max"  "Qnet maximum"  $2 $refoutp ; yy=$? ;;
                0320          'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean"     $2 $refoutp ; yy=$? ;;
                0321          'Qntsd') testoutput_var $1 "forcing_qnet_sd"   "Qnet Std.Dev"  $2 $refoutp ; yy=$? ;;
                0322          'aSImn') testoutput_var $1 "seaice_${kd}area_min"  "SIce ${kd}Area min"   $2 $refoutp ; yy=$? ;;
                0323          'aSImx') testoutput_var $1 "seaice_${kd}area_max"  "SIce ${kd}Area max"   $2 $refoutp ; yy=$? ;;
                0324          'aSIav') testoutput_var $1 "seaice_${kd}area_mean" "SIce ${kd}Area mean"  $2 $refoutp ; yy=$? ;;
                0325          'aSIsd') testoutput_var $1 "seaice_${kd}area_sd"   "SIce ${kd}Area StDv"  $2 $refoutp ; yy=$? ;;
                0326          'hSImn') testoutput_var $1 "seaice_${kd}heff_min"  "SIce ${kd}Heff min"   $2 $refoutp ; yy=$? ;;
                0327          'hSImx') testoutput_var $1 "seaice_${kd}heff_max"  "SIce ${kd}Heff max"   $2 $refoutp ; yy=$? ;;
                0328          'hSIav') testoutput_var $1 "seaice_${kd}heff_mean" "SIce ${kd}Heff mean"  $2 $refoutp ; yy=$? ;;
                0329          'hSIsd') testoutput_var $1 "seaice_${kd}heff_sd"   "SIce ${kd}Heff StDv"  $2 $refoutp ; yy=$? ;;
                0330          'uSImn') testoutput_var $1 "seaice_${kd}uice_min"  "SIce ${kd}Uice min"   $2 $refoutp ; yy=$? ;;
                0331          'uSImx') testoutput_var $1 "seaice_${kd}uice_max"  "SIce ${kd}Uice max"   $2 $refoutp ; yy=$? ;;
                0332          'uSIav') testoutput_var $1 "seaice_${kd}uice_mean" "SIce ${kd}Uice mean"  $2 $refoutp ; yy=$? ;;
                0333          'uSIsd') testoutput_var $1 "seaice_${kd}uice_sd"   "SIce ${kd}Uice StDv"  $2 $refoutp ; yy=$? ;;
                0334          'vSImn') testoutput_var $1 "seaice_${kd}vice_min"  "SIce ${kd}Vice min"   $2 $refoutp ; yy=$? ;;
                0335          'vSImx') testoutput_var $1 "seaice_${kd}vice_max"  "SIce ${kd}Vice max"   $2 $refoutp ; yy=$? ;;
                0336          'vSIav') testoutput_var $1 "seaice_${kd}vice_mean" "SIce ${kd}Vice mean"  $2 $refoutp ; yy=$? ;;
                0337          'vSIsd') testoutput_var $1 "seaice_${kd}vice_sd"   "SIce ${kd}Vice StDv"  $2 $refoutp ; yy=$? ;;
6418c0ec62 Jean*0338         'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $refoutp ; yy=$? ;;
                0339         'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South"  $2 $refoutp ; yy=$? ;;
                0340         'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North"  $2 $refoutp ; yy=$? ;;
0f2059bcae Jean*0341         'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Glob-ave"  $2 $refoutp ; yy=$? ;;
                0342         'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South-av"  $2 $refoutp ; yy=$? ;;
                0343         'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North-av"  $2 $refoutp ; yy=$? ;;
                0344         'HthMxS') testoutput_var $1 "thSI_IceH_max_S" "thSIc H South-max" $2 $refoutp ; yy=$? ;;
                0345         'HthMxN') testoutput_var $1 "thSI_IceH_max_N" "thSIc H North-max" $2 $refoutp ; yy=$? ;;
ab6a12ddc5 Jean*0346          'sbo_M') testoutput_var $1 "sbo_mass"          "SBO mass"        $2 $refoutp ; yy=$? ;;
                0347          'sboFW') testoutput_var $1 "sbo_mass_fw"       "SBO m-FW"        $2 $refoutp ; yy=$? ;;
                0348          'sboAc') testoutput_var $1 "sbo_zoamc"         "SBO AM-C"        $2 $refoutp ; yy=$? ;;
                0349          'sboAp') testoutput_var $1 "sbo_zoamp"         "SBO AM-P"        $2 $refoutp ; yy=$? ;;
bce14c7299 Jean*0350         'StrmIc') testoutput_var $1 "STREAMICE_FP_ERR" "StreamIce Solver" $2 $refoutp ; yy=$? ;;
6418c0ec62 Jean*0351               *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
7ee8179b2a Jean*0352             esac
                0353           else
                0354           #- ptracers stats:
                0355             nn=`echo $xx | sed 's/pt//' | sed 's/..$//'`
                0356             ii=`echo $xx | sed 's/^pt[0-9]*//'`
                0357             case $ii in
d81415648f Jean*0358             'mn') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_min"  "${kd}pTr0"$nn"_min"  $2 $refoutp ; yy=$? ;;
                0359             'mx') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_max"  "${kd}pTr0"$nn"_max"  $2 $refoutp ; yy=$? ;;
                0360             'av') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_mean" "${kd}pTr0"$nn"_mean" $2 $refoutp ; yy=$? ;;
                0361             'sd') testoutput_var $1 "trcstat_${kd}ptracer0"$nn"_sd"   "${kd}pTr0"$nn"_StDv" $2 $refoutp ; yy=$? ;;
7ee8179b2a Jean*0362             esac
                0363           fi
6418c0ec62 Jean*0364           if test $xx = $sVar
                0365           then allargs="$allargs > $yy <"
                0366           else allargs="$allargs $yy"
                0367           fi
                0368         done
eb7e5e62ed Jean*0369 
                0370         nbVar=`echo $listVar | awk '{print NF}'`
6418c0ec62 Jean*0371         if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
                0372         #-- fill line (up to standard length) with dot:
                0373           adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
eb7e5e62ed Jean*0374           echo $allargs $adNul
6418c0ec62 Jean*0375         else
eb7e5e62ed Jean*0376           echo $allargs
9750e41317 Jean*0377         fi
456c314cce Jean*0378 # <-- same processing for adjoint & forward test
2ff82eb834 Ed H*0379 }
                0380 
                0381 genmakemodel()
                0382 {
                0383     # genmakemodel directory
6d54cf9ca1 Ed H*0384     if test "x$NOGENMAKE" = xt ; then
                0385         echo "genmake skipped!"
                0386     else
e53112a6cf Ed H*0387         if test "x$BASH" = x ; then
                0388             GENMAKE2="../../../tools/genmake2"
                0389         else
                0390             GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
                0391         fi
6d54cf9ca1 Ed H*0392         (
                0393             cd $1;
4619920a5f Ed H*0394             command="$GENMAKE2  -ds -m $MAKE"
ca2316a28b Jean*0395             if test "x$MKDEPEND" != x ; then
                0396                 command="$command -makedepend=$MKDEPEND"
                0397             fi
b4daa24319 Shre*0398             if test $KIND = 6 ; then
b63206be5d Jean*0399                 command="$command -oad -mods=../$code_dir"
b4daa24319 Shre*0400             elif [ $KIND -ge 3 ] ; then
                0401                 command="$command -tap -mods=../$code_dir"
3907106aba Jean*0402             else
b63206be5d Jean*0403                 command="$command -mods=../$code_dir"
4619920a5f Ed H*0404             fi
6d54cf9ca1 Ed H*0405             if test "x$OPTFILE" != xNONE ; then
a7c0a887cd Jean*0406                 command="$command -optfile=$OPTFILE"
2ff82eb834 Ed H*0407             fi
5a67953813 Jean*0408             if test $OptLev = 1 ; then
6418c0ec62 Jean*0409                 command="$command -ieee"
                0410             fi
5a67953813 Jean*0411             if test $OptLev = 0 ; then
                0412                 command="$command -devel"
6d54cf9ca1 Ed H*0413             fi
232027f18d Jean*0414             if test "x$GSL" = xt ; then
                0415                 command="$command -gsl"
                0416             fi
d9ae4e2b34 Jean*0417             if test "x$MPI" != x0 ; then
152b247de4 Ed H*0418                 command="$command -mpi"
                0419             fi
616bf911ff Jean*0420             if test "x$MULTI_THREAD" = xt ; then
                0421             #- run multi-threaded using OpenMP:
                0422                 command="$command -omp"
                0423             fi
9750e41317 Jean*0424             if test "x$USE_R4" = xt ; then
                0425                 command="$command -use_r4"
                0426             fi
1f09e8610e Jean*0427             if test "x$EXTRFLG" != x ; then
                0428                 command="$command -extra_flag $EXTRFLG"
                0429             fi
72af1157c6 Jean*0430             if test "x$NOCATAD" = xt ; then
                0431                 command="$command -nocat4ad"
                0432             fi
a986ef8661 Cons*0433             if test "x$TS" = xt ; then
                0434                 command="$command -ts"
                0435             fi
                0436             if test "x$PAPIS" = xt ; then
                0437                 command="$command -papis"
9750e41317 Jean*0438             else
a986ef8661 Cons*0439             if test "x$PCLS" = xt ; then
                0440                 command="$command -pcls"
                0441             fi
9d0c386f0c dngo*0442             if test "x$OADSINGULARITY" != x ; then
                0443                 command="$command -oadsingularity \"$OADSINGULARITY\""
                0444             fi
a986ef8661 Cons*0445             fi
6fcdccb64d Jean*0446             printf 'genmake ... '
0093035fc0 Jean*0447             eval $command > genmake.tr_log 2>&1
6d54cf9ca1 Ed H*0448             RETVAL=$?
59e7e2f70f Ed H*0449             #  Reduce the size of the testing emails!
33ebd8ef34 Ed H*0450             head -100 Makefile > $CDIR/Makefile_head
6d54cf9ca1 Ed H*0451             if test "x$RETVAL" != x0 ; then
0093035fc0 Jean*0452                 tail genmake.tr_log
6fcdccb64d Jean*0453                 echo "genmakemodel: genmake failed"
4cc2b2ecef Jean*0454                 cp genmake.log genmake_* genmake.tr_log $CDIR
6d54cf9ca1 Ed H*0455                 return 1
                0456             else
6fcdccb64d Jean*0457                 echo "successful"
6d54cf9ca1 Ed H*0458             fi
                0459         )
                0460     fi
2ff82eb834 Ed H*0461 }
                0462 
                0463 makeclean()
                0464 {
                0465     # makeclean directory
d5ed8695dd Jean*0466     if test "x$NOGENMAKE" = xf ; then rm -f $1/make.tr_log ; fi
6d54cf9ca1 Ed H*0467     if test "x$NOCLEAN" = xt ; then
0e6cc40375 Jean*0468         echo "make Clean skipped!"
6d54cf9ca1 Ed H*0469     else
                0470         (
                0471             cd $1;
84370bfea3 Jean*0472             #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
6d54cf9ca1 Ed H*0473             if test -r Makefile ; then
6fcdccb64d Jean*0474                 printf 'clean build-dir: make Clean ... '
0093035fc0 Jean*0475                 $MAKE Clean >> make.tr_log 2>&1
6d54cf9ca1 Ed H*0476                 RETVAL=$?
                0477                 if test "x$RETVAL" != x0 ; then
0093035fc0 Jean*0478                     tail make.tr_log
6fcdccb64d Jean*0479                     echo "makeclean: \"make Clean\" failed"
4cc2b2ecef Jean*0480                     cp make.tr_log genmake.log genmake.tr_log $CDIR
6d54cf9ca1 Ed H*0481                     return 1
                0482                 fi
6fcdccb64d Jean*0483                 echo successful
642fbd44e7 Jean*0484             else
                0485                 echo ''
6d54cf9ca1 Ed H*0486             fi
                0487             exit 0
                0488         )
                0489     fi
2ff82eb834 Ed H*0490 }
                0491 
0e6cc40375 Jean*0492 run_clean()
0b035b108c Ed H*0493 {
0e6cc40375 Jean*0494     # run_clean directory
                0495     if test "x$NOCLEAN" = xt ; then
                0496         echo "run_clean skipped!"
                0497     else
e6f2a663b8 Jean*0498       (
                0499         cd $1;
                0500         printf 'clean run-dir ... '
                0501         # part of what is done after "make clean" when doing "make CLEAN"
                0502         find . -name "*.meta" -exec rm {} \;
                0503         find . -name "*.data" -exec rm {} \;
deacece587 Oliv*0504         find . -name "*.tmp"  -exec rm {} \;
e6f2a663b8 Jean*0505         find . -name "fort.*" -exec rm {} \;
                0506         find . -type l -exec rm {} \;
                0507         #- should remove executable only if sym-link (already done above)
                0508         rm -f $RUNLOG *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
                0509         rm -f datetime costfinal divided.ctrl snapshot* output_adm.*.diva_*
                0510         rm -f *_MIT_CE_000.opt0000 costfunction*0000
5542b50cd2 Jean*0511         rm -f oad_cp.[0-9][0-9][0-9].?????
e6f2a663b8 Jean*0512         rm -rf mnc_test_*
                0513         echo successful
                0514         exit 0
                0515       )
0b035b108c Ed H*0516     fi
                0517 }
                0518 
2ff82eb834 Ed H*0519 makedependmodel()
                0520 {
                0521     # makedependmodel directory
6d54cf9ca1 Ed H*0522     if test "x$NODEPEND" = xt ; then
                0523         echo "make depend skipped!"
                0524     else
                0525         (
                0526             cd $1;
6fcdccb64d Jean*0527             printf 'make depend ... '
0093035fc0 Jean*0528             $MAKE depend >> make.tr_log 2>&1
6d54cf9ca1 Ed H*0529             RETVAL=$?
                0530             if test "x$RETVAL" != x0 ; then
0093035fc0 Jean*0531                 tail make.tr_log
6fcdccb64d Jean*0532                 echo "makedependmodel: make depend failed"
4cc2b2ecef Jean*0533                 cp make.tr_log genmake.log genmake.tr_log $CDIR
6d54cf9ca1 Ed H*0534                 return 1
                0535             else
6fcdccb64d Jean*0536                 echo successful
6d54cf9ca1 Ed H*0537             fi
                0538         )
                0539     fi
2ff82eb834 Ed H*0540 }
                0541 
                0542 makemodel()
                0543 {
                0544     # makemodel directory
                0545     (
f459d64861 Jean*0546     mk_fail=0
416e70d1a2 Jean*0547     if test "x$NOMAKE" = xt ; then
                0548         cd $1;
                0549         if test -x $EXECUTABLE ; then
                0550             echo "make skipped!"
                0551         else
                0552             echo "no executable!"
f459d64861 Jean*0553             mk_fail=3
416e70d1a2 Jean*0554         fi
                0555     else
2ff82eb834 Ed H*0556         cd $1;
                0557         if test -r Makefile ; then
e977410d1b Mart*0558             if test "x$MKSMALLF" = xt ; then
                0559                 printf 'make small_f ... '
                0560                 $MAKE_CMD small_f >> make.tr_log 2>&1
                0561                 RETVAL=$?
                0562                 if test "x$RETVAL" != x0 ; then
                0563                     tail make.tr_log
                0564                     echo failed
                0565                     cp genmake.log genmake.tr_log $CDIR
                0566                     tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
                0567                     rm -f $EXECUTABLE
                0568                     mk_fail=1
                0569                 else
                0570                     echo successful
                0571                 fi
                0572             fi
cc019522d9 Jean*0573             printf "make $TARG ... "
72af1157c6 Jean*0574             $MAKE_CMD $TARG >> make.tr_log 2>&1
2ff82eb834 Ed H*0575             RETVAL=$?
                0576             if test "x$RETVAL" != x0 ; then
0093035fc0 Jean*0577                 tail make.tr_log
6fcdccb64d Jean*0578                 echo failed
da8170bd49 Jean*0579                 cp genmake.log genmake.tr_log $CDIR
                0580                 tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
e49dac07a6 Jean*0581                 rm -f $EXECUTABLE
f459d64861 Jean*0582                 mk_fail=1
2ff82eb834 Ed H*0583             else
6fcdccb64d Jean*0584                 echo successful
2ff82eb834 Ed H*0585             fi
f459d64861 Jean*0586         else
                0587             echo "no Makefile !"
                0588             mk_fail=2
2ff82eb834 Ed H*0589         fi
416e70d1a2 Jean*0590     fi
1fff053a17 Jean*0591     if test $KIND = 1 -a -f taf_ftl.log ; then
3513440a2a Jean*0592         grep 'Processing files at' make.tr_log | tail -1 >> $CDIR"/summary.txt"
f561fdaba7 Jean*0593         head -1 taf_ftl.log >> $CDIR"/summary.txt"
1fff053a17 Jean*0594     fi
6418c0ec62 Jean*0595     if test $KIND = 2 -a -f taf_ad.log ; then
3513440a2a Jean*0596         grep 'Processing files at' make.tr_log | tail -1 >> $CDIR"/summary.txt"
f561fdaba7 Jean*0597         head -1 taf_ad.log >> $CDIR"/summary.txt"
                0598         nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log`
9243e50d1e Jean*0599         nwar=`grep -c '^TAF *.* RECOMPUTATION *.* WARNING ' taf_ad.log`
f561fdaba7 Jean*0600         if test -f taf_output ; then
                0601             n2er=`grep -c 'TAF *.* ERROR ' taf_output`
d758744a4f Jean*0602             n3er=`grep -c '\*ERROR\* ' taf_output`
                0603             nerr=`expr $nerr + $n2er + $n3er`
f561fdaba7 Jean*0604         fi
                0605         echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \
360fa2f691 Jean*0606                                 >> $CDIR"/summary.txt"
49a029e3de Mart*0607         if test -f ad_taf_output.f ; then
                0608             adfile=ad_taf_output.f
                0609         elif test -f ad_taf_output.for ; then
                0610             adfile=ad_taf_output.for
                0611         else
                0612             echo "WARNING: neither ad_output_ad.f nor ad_output_ad.for found" \
                0613                                 >> $CDIR"/summary.txt"
d37c4896c1 Mart*0614             adfile=missing ; nlfd=0 ; ndop=0 ; nsm=0
49a029e3de Mart*0615         fi
                0616         if test $adfile != missing ; then
                0617             # count number of times load_fields_driver and do_oceanic_phys are called
                0618             nlfd=`grep "call load_fields_driver(" ${adfile} | wc -l`
                0619             nlfdmd=`grep "call load_fields_drivermd(" ${adfile} | wc -l`
                0620             if (( $nlfdmd == 0 )) ; then
                0621                 # if there is no load_fields_driver, we can substract one assuming
                0622                 # that load_fields_driver is called once from forward_stepmd
                0623                 nlfd=$((nlfd-1))
                0624             fi
                0625             ndop=`grep "call do_oceanic_phys("    ${adfile} | wc -l`
d37c4896c1 Mart*0626             nsm=`grep "call seaice_model(" ${adfile} | wc -l`
49a029e3de Mart*0627         fi
d37c4896c1 Mart*0628         echo " load_fields_driver, do_oceanic_phys, seaice_model are called " \
                0629              "( $nlfd , $ndop , $nsm ) time(s)" >> $CDIR"/summary.txt"
360fa2f691 Jean*0630     fi
b4daa24319 Shre*0631     if test -f make.tr_log && test $KIND = 4 -o $KIND = 5 ; then
                0632         grep '^Tapenade ' make.tr_log | tail -n 1 >> $CDIR"/summary.txt"
                0633     fi
f459d64861 Jean*0634     if test $mk_fail != 0 ; then return $mk_fail ; fi
2ff82eb834 Ed H*0635     )
                0636 }
                0637 
d9ae4e2b34 Jean*0638 mk_mpi_size()
                0639 {
6c95586363 Jean*0640     # mk_mpi_size input_file output_file proc_Nb threads_Nb_X threads_Nb_Y
d9ae4e2b34 Jean*0641     #
6c95586363 Jean*0642     #  make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file)
d9ae4e2b34 Jean*0643     #     for an MPI build with no more than proc_Nb processors ;
6c95586363 Jean*0644     #  ensure that enough tiles per proc (nSx,nSy) remain for the given
                0645     #     number of threads (nTx,nTy) ;
                0646     #  return the effective number of processors.
d9ae4e2b34 Jean*0647 
                0648     inp=$1
                0649     out=$2
                0650     np=$3
6c95586363 Jean*0651     tx=$4
                0652     ty=$5
d9ae4e2b34 Jean*0653     tmp=TTT.$$
                0654 
6c95586363 Jean*0655     # dirX : select with direction to favor in MPI process repartition
                0656     #   dirX=1 : prefer to put more proc in X direction
                0657     #   dirX=0 : prefer to put more proc in Y direction
                0658     dirX=0
                0659 
d9ae4e2b34 Jean*0660     px=`grep "^     & *nPx *=" $inp | sed "s/^     & *nPx *= *//" | sed 's/, *$//'`
                0661     py=`grep "^     & *nPy *=" $inp | sed "s/^     & *nPy *= *//" | sed 's/, *$//'`
                0662     sx=`grep "^     & *nSx *=" $inp | sed "s/^     & *nSx *= *//" | sed 's/, *$//'`
                0663     sy=`grep "^     & *nSy *=" $inp | sed "s/^     & *nSy *= *//" | sed 's/, *$//'`
                0664 
6c95586363 Jean*0665     #- for each direction, assume # of threads is a multiple of total number of tiles
                0666     nx=$px
                0667     if [ `expr $sx % $tx` -ne 0 -a `expr $sx \* $px % $tx` -eq 0 ] ; then
                0668         nx=`expr $sx \* $px / $tx`
                0669         if [ $verbose -gt 1 ]; then
                0670             echo " change px from $px to $nx to accommodate $tx threads"
                0671         fi
                0672     fi
                0673     ny=$py
                0674     if [ `expr $sy % $ty` -ne 0 -a `expr $sy \* $py % $ty` -eq 0 ] ; then
                0675         ny=`expr $sy \* $py / $ty`
                0676         if [ $verbose -gt 1 ]; then
                0677             echo " change py from $py to $ny to accommodate $ty threads"
                0678         fi
                0679     fi
d9ae4e2b34 Jean*0680     #- find the largest divisor of input_file proc Nb, but not larger than $np
                0681     pp=0
2f7af142fa Jean*0682     i=1
6c95586363 Jean*0683     while [ $i -le $nx ] ; do
                0684       if [ `expr $nx % $i` -eq 0 ] ; then
2f7af142fa Jean*0685         j=1
6c95586363 Jean*0686         while [ $j -le $ny ] ; do
                0687           if [ `expr $ny % $j` -eq 0 ] ; then
2f7af142fa Jean*0688             ij=`expr $i \* $j`
                0689             if [ $ij -gt $pp ] ; then
7ba778f1ca Jean*0690                 flag=1
                0691             elif [ $ij -eq $pp ] ; then
                0692                 flag=$dirX
                0693             else
                0694                 flag=0
                0695             fi
                0696             if test $flag = 1 ; then
2f7af142fa Jean*0697               if [ $ij -le $np ] ; then
                0698                 ix=$i ; jy=$j ; pp=$ij
                0699                 #echo "  ix,jy= $ix,$jy"
                0700               fi
                0701             fi
                0702           fi
                0703           j=`expr $j + 1`
                0704         done
d9ae4e2b34 Jean*0705       fi
2f7af142fa Jean*0706       i=`expr $i + 1`
d9ae4e2b34 Jean*0707     done
                0708 
                0709     #- create new SIZE.h type file:
                0710     sx=`expr $sx \* $px / $ix`
                0711     sy=`expr $sy \* $py / $jy`
                0712     if [ $verbose -gt 1 ]; then
                0713         echo " px,py,np= $px,$py,$np : New MPI size: px,py= $ix,$jy : sx,sy= $sx,$sy"
                0714     fi
                0715     sed "/^     \& *nPx *=/s/[0-9]*,/$ix,/" $inp > $tmp
                0716     sed "/^     \& *nPy *=/s/[0-9]*,/$jy,/" $tmp > $out
                0717     sed "/^     \& *nSx *=/s/[0-9]*,/$sx,/" $out > $tmp
                0718     sed "/^     \& *nSy *=/s/[0-9]*,/$sy,/" $tmp > $out
                0719     rm -f $tmp
                0720     return $pp
                0721 }
                0722 
e61115937c Ed H*0723 symlink_mpifiles()
                0724 {
                0725     # Put special links so that MPI specific files are used
                0726     # This MUST be invoked between makeclean and makelinks because
                0727     # the Makefile will link to non-mpi files by default
                0728 
                0729     dir=$1
                0730     code_dir=$2
d9ae4e2b34 Jean*0731     build_dir=$dir/$3
9750e41317 Jean*0732 
e61115937c Ed H*0733     # These are files that should replace their counter-part when using -mpi
d9ae4e2b34 Jean*0734     MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
                0735 
                0736     for ii in $MPI_FILES ; do
                0737         i=`echo $ii | sed 's:^\./::'`
                0738         name=`echo $i | sed 's:_mpi::'`
                0739         file="../$code_dir/$i"
                0740         if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
                0741 
                0742         #  Is this an MPI run?
                0743         if test "x$MPI" = x0 ; then
                0744             # NO: We undo any _mpi symbolically linked files
                0745             if test -L $build_dir/$name ; then
                0746                 ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
3007f9fbc4 Ed H*0747                 RETVAL=$?
                0748                 if test "x$RETVAL" = x0 ; then
d9ae4e2b34 Jean*0749                     if [ $verbose -gt 1 ]; then
                0750                         echo "  Un-linking $name from ../$code_dir" ; fi
                0751                     rm -f $build_dir/$name
e61115937c Ed H*0752                 fi
                0753             fi
d9ae4e2b34 Jean*0754         else
                0755             # YES: We symbolically link these files to the build
                0756             # dir so long as there is no real file in place
                0757             ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
                0758             RETVAL=$?
                0759             if [ $verbose -gt 1 ]; then echo "  cmp $name $file returns: $RETVAL" ; fi
                0760             if test "x$RETVAL" != x0 ; then
                0761                 if test -h $build_dir/$name ; then rm -f $build_dir/$name ; fi
                0762                 if test ! -r $build_dir/$name ; then
                0763                     if [ $verbose -gt 1 ]; then echo "  Linking $name to $file" ; fi
                0764                     (cd $build_dir; ln -sf $file $name)
                0765                 fi
                0766             fi
                0767         fi
                0768     done
e61115937c Ed H*0769 }
                0770 
2ff82eb834 Ed H*0771 linkdata()
                0772 {
0e6cc40375 Jean*0773     # linkdata run_dir input_dir_1 input_dir_2 ...
2ff82eb834 Ed H*0774     #
                0775     # symbolically link data files to run directory
0e6cc40375 Jean*0776     if test -d $1 ; then
474019363f Ed H*0777         (
0e6cc40375 Jean*0778             cd $1 ; shift
6fcdccb64d Jean*0779             echo 'linkdata from dirs:' $*
6418c0ec62 Jean*0780             inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
8bd4a294c2 Jean*0781             for xx in $inpMPI ; do
                0782               if test -r "../"$1"/"$xx ; then
6418c0ec62 Jean*0783                 # found 1 _mpi sfx file in 1rst input dir and it is readable
8bd4a294c2 Jean*0784                 yy=`echo $xx | sed 's:\.mpi$::'`
d9ae4e2b34 Jean*0785                 if test "x$MPI" = "x0" ; then
                0786                     # not mpi test: remove symbolic link
                0787                     if test -h $yy ; then rm -f $yy ; fi
                0788                 else
                0789                     # mpi test: remove symbolic link & link .mpi sfx file
8bd4a294c2 Jean*0790                     if test -h $yy ; then rm -f $yy ; fi
9750e41317 Jean*0791                     if test ! -r $yy ; then
8bd4a294c2 Jean*0792                         ln -sf "../"$1"/"$xx $yy ;
6fcdccb64d Jean*0793                         printf " $xx" 1>&2
8bd4a294c2 Jean*0794                     fi
                0795                 fi
                0796               fi
                0797             done
0e6cc40375 Jean*0798             if test -r "../"$1"/eedata.mth" ; then
                0799             # found eedata.mth in 1rst input dir and it is readable
                0800                 if test "x$MULTI_THREAD" = "xt" ; then
                0801                 # multi-threaded test: remove symbolic link & link eedata.mth
                0802                     if test -h eedata ; then rm -f eedata ; fi
9750e41317 Jean*0803                     if test ! -r eedata ; then
0e6cc40375 Jean*0804                         ln -sf "../"$1"/eedata.mth" eedata ;
6fcdccb64d Jean*0805                         printf ' eedata.mth' 1>&2
4619920a5f Ed H*0806                     fi
0e6cc40375 Jean*0807                 else
                0808                 # not multi-threaded test: remove eedata symbolic link
                0809                     if test -h eedata ; then rm -f eedata ; fi
23874084ad Jean*0810                 fi
4619920a5f Ed H*0811             fi
878c588496 Jean*0812             prevDir='NONE'
0e6cc40375 Jean*0813             for ldir in $* ; do
878c588496 Jean*0814                 if test -d "../"$ldir -a $ldir != $prevDir ; then
6418c0ec62 Jean*0815                     printf " ldir=${ldir}:" 1>&2
0e6cc40375 Jean*0816                     files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
                0817                     for i in $files ; do
                0818                         if test ! -d "../"$ldir/$i ; then
                0819                             if test ! -r $i  ; then
                0820                                 printf ' '$i 1>&2
                0821                                 ln -sf "../"$ldir"/"$i $i
                0822                             fi
                0823                         fi
                0824                     done
6fcdccb64d Jean*0825                     printf ' ;' 1>&2
0e6cc40375 Jean*0826                     if test -x "../"$ldir"/"prepare_run ; then
6fcdccb64d Jean*0827                         "../"$ldir"/"prepare_run 1>&2
                0828                     else
                0829                         echo '' 1>&2
0e6cc40375 Jean*0830                     fi
                0831                 fi
878c588496 Jean*0832                 prevDir=$ldir
0e6cc40375 Jean*0833             done
474019363f Ed H*0834         )
2ff82eb834 Ed H*0835     fi
                0836 }
                0837 
                0838 runmodel()
                0839 {
96d85cca71 Ed H*0840     # runmodel directory
2ff82eb834 Ed H*0841     #
d9ae4e2b34 Jean*0842     #  runs $COMMAND in "directory"
96d85cca71 Ed H*0843     #  (where "$COMMAND" is relative to "directory")
2ff82eb834 Ed H*0844     (
                0845         cd $1
6fcdccb64d Jean*0846         printf 'runmodel in %s ... ' $1
360fa2f691 Jean*0847         if test "x$MPI" != x0 ; then
                0848             #- adjust the MPI run command with the right number of Procs
                0849             #echo '' ; echo "  COMMAND='$COMMAND'"
250e8a7757 Jean*0850             COMMAND=`echo $COMMAND | sed "s/ TR_NPROC/ $LOC_NPROC/"`
360fa2f691 Jean*0851             if test "x$MPI_MFILE" != x ; then
                0852               COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
                0853             fi
                0854             #echo "  COMMAND='$COMMAND'"
                0855         fi
28b546244a Jean*0856         if test -L $EXECUTABLE ; then
                0857           if test -x "../"$builddir"/"$EXECUTABLE ; then
d9ae4e2b34 Jean*0858             cmp $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
                0859             outD=$? ; if test "x$outD" != x0 ; then rm -f $EXECUTABLE ; fi
28b546244a Jean*0860           else rm -f $EXECUTABLE
                0861           fi
7e8ef1f316 Jean*0862         fi
6418c0ec62 Jean*0863         if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
baf6258c8a Jean*0864             echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
0e6cc40375 Jean*0865             ln -sf "../"$builddir"/"$EXECUTABLE .
                0866         fi
6418c0ec62 Jean*0867         if test ! -x $EXECUTABLE ; then
bbea11a65d Jean*0868             rm -f $RUNLOG ; touch $RUNLOG
                0869             if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
                0870             echo " no executable:" $EXECUTABLE >> $RUNLOG
                0871             RETVAL=8
                0872             ENDVAL=-1
2b043763fc Jean*0873         else
6418c0ec62 Jean*0874           if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
                0875             # output do not exist or is older than executable:
840f5814ba Jean*0876             rm -f $OUTPUTFILE $RUNLOG ; touch $RUNLOG
bbea11a65d Jean*0877             if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
ba205b1a1d Jean*0878         #- Divided Adjoint Run:
                0879         #  get the number of additional runs (add_DIVA_runs) from file "run_ADM_DIVA"
                0880             if test $KIND = 2 -a -f run_ADM_DIVA ; then
aad71d9e67 Mart*0881               adm_diva_nb=`sed -n '/^ *add_DIVA_runs *=/p' run_ADM_DIVA | sed 's/ //g'`
ba205b1a1d Jean*0882               echo " Divided Adjoint Run: $adm_diva_nb" >> $RUNLOG
                0883               eval "let $adm_diva_nb"
                0884               if [ $add_DIVA_runs -ge 1 ] ; then
3a516654c6 Jean*0885                 extraRuns=`expr $add_DIVA_runs - 1`
ba205b1a1d Jean*0886                 rm -f costf* divided.ctrl snapshot*
                0887                 echo -n "(add_DIVA_runs=$add_DIVA_runs) ... "
3a516654c6 Jean*0888                 for ii in `seq 0 $extraRuns` ; do
ba205b1a1d Jean*0889                   ( eval $COMMAND ) >> $RUNLOG 2>&1
                0890                   echo " additional DIVA run # $ii : done" >> $RUNLOG
                0891                   mv -f $OUTPUTFILE ${OUTPUTFILE}.diva_${ii}
                0892                 done
                0893               fi
ebcc29af97 Jean*0894             elif test -f run_ADM_DIVA ; then
                0895                 rm -f costf* divided.ctrl snapshot*
ba205b1a1d Jean*0896             fi
                0897         #- special DIVA processing ends here
bbea11a65d Jean*0898             ( eval $COMMAND ) >> $RUNLOG 2>&1
                0899             RETVAL=$?
                0900             ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
                0901             if [ $POSTCLEAN -eq 1 -a $ENDVAL -gt 0 ] ; then
                0902                 find . -name "*.meta" -exec rm {} \;
                0903                 find . -name "*.data" -exec rm {} \;
                0904                 rm -rf mnc_test_*
0e6cc40375 Jean*0905             fi
bbea11a65d Jean*0906           else
                0907             RETVAL=0
871a0c28c5 Jean*0908             ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
bbea11a65d Jean*0909             touch $RUNLOG
                0910             if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
6418c0ec62 Jean*0911             echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
bbea11a65d Jean*0912           fi
2b043763fc Jean*0913         fi
baf6258c8a Jean*0914         rm -f run.log_tmp
1fff053a17 Jean*0915         #- in all cases where OutputFile exists, report SIZE and time
360fa2f691 Jean*0916         if test -f $OUTPUTFILE ; then
                0917           grep '(PID\.TID 0000\.0001)      n.. =' $OUTPUTFILE \
1fff053a17 Jean*0918                 | sed 's/(PID.TID 0000.0001)   //' >> $CDIR"/summary.txt"
deb0ad3aea Mart*0919 #         grep -A3 'Seconds in section "ALL' $OUTPUTFILE \
                0920 #               | sed 's/(PID.TID 0000.0001)   //' >> $CDIR"/summary.txt"
                0921 #         some implementations of grep cannot do contextual searches so we
                0922 #         replace the above with a sed command
                0923           cat $OUTPUTFILE | sed -n '/Seconds in section "ALL/{N
                0924           N
                0925           N
                0926           p
                0927           }' | sed 's/(PID.TID 0000.0001)   //' >> $CDIR"/summary.txt"
360fa2f691 Jean*0928         fi
                0929         if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
3f26a348bd Jean*0930         if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
6fcdccb64d Jean*0931             echo successful
                0932             printf '=> output from running in %s :\n' $1 1>&2
                0933             tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
96d85cca71 Ed H*0934             return 0
3cf8d39958 Jean*0935         elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
                0936             #-- for some weird cases (run is finihed but with error code)
6fcdccb64d Jean*0937             echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
                0938             printf '=> output from running in %s :\n' $1 1>&2
                0939             tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
3cf8d39958 Jean*0940             return 0
96d85cca71 Ed H*0941         else
6fcdccb64d Jean*0942             echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
                0943             printf '=> output from running in %s :\n' $1 1>&2
                0944             tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
baf6258c8a Jean*0945             cp $RUNLOG $CDIR"/"$RUNLOG
96d85cca71 Ed H*0946             return 1
2ff82eb834 Ed H*0947         fi
                0948     )
                0949 }
                0950 
                0951 createcodelet()
                0952 {
                0953     # create codelet for comparing model output
                0954 
63e0800ef7 Jean*0955     printf "creating the comparison code (using CC=$CC)...  "
2366f571a5 Jean*0956     cat > tr_cmpnum.c <<EOF
cfc62862f0 Ed H*0957 #include <stdio.h>
                0958 #include <math.h>
                0959 int main( int argc, char** argv )  {
2366f571a5 Jean*0960   int linnum,cmplin,best,lncnt;
2adbdc8a5e Ed H*0961   double a,b,abave,relerr;
8d90f27f15 Jean*0962   best = -22;
852a4acb3d Alis*0963   lncnt = 0;
3ff2fe3646 Jean*0964   while( 1 & ( (lncnt+=1) < 999 ) )  {
cfc62862f0 Ed H*0965     scanf("%d", &linnum);
                0966     if (linnum == -1)  break;
                0967     scanf("%lf", &a);  scanf("%lf", &b);
2adbdc8a5e Ed H*0968     abave = 0.5*(fabs(a)+fabs(b));
2366f571a5 Jean*0969     if ( abave == abave ) {
                0970       if (abave > 0.0) {
                0971         relerr=fabs(a-b)/abave;
                0972         if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
                0973         else { cmplin = -16 ; }
                0974         best = (best > cmplin) ? best : cmplin; }
                0975       else { cmplin = -22 ; }
                0976    /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
                0977       }
                0978    else {
                0979    /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
                0980       break; }
cfc62862f0 Ed H*0981   }
852a4acb3d Alis*0982   if (lncnt == 999) best=-29;
2366f571a5 Jean*0983   if (linnum != -1) best=-99;
cfc62862f0 Ed H*0984   printf("%d\n", -best);
                0985   return 0;
                0986 }
                0987 EOF
2366f571a5 Jean*0988     $CC -o tr_cmpnum tr_cmpnum.c -lm
cfc62862f0 Ed H*0989 
2366f571a5 Jean*0990     if [ -x ./tr_cmpnum ]; then
2ff82eb834 Ed H*0991         echo "OK"
                0992         return 0
                0993     else
                0994         echo
9750e41317 Jean*0995         echo "ERROR: failed to compile comparison code -- please specify"
a581267379 Ed H*0996         echo "  a C compiler using the CC environment variable."
2ff82eb834 Ed H*0997         exit 1
                0998     fi
                0999 }
                1000 
                1001 formatresults()
                1002 {
                1003     # formatresults expt genmake depend make run results*
                1004 
                1005     nm=$1
                1006     printf '%s %s %s %s' $2 $3 $4 $5
                1007     shift; shift; shift; shift; shift;
eb7e5e62ed Jean*1008     listPrt=$@
                1009     listRes=`echo $listPrt | sed 's/>//' | sed 's/<//'`
                1010     xx=`echo $listPrt | sed 's/.*>//' | sed 's/<.*//' | awk '{print $1}'`
4d91a93b49 Jean*1011     printf '%3s' $listPrt
44a2688a94 Jean*1012 #   line below does not work on hp-ux_ia64 : do those substitutions later on
6ce7c44299 Jean*1013 #   printf '%3s' $listPrt | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</'
9750e41317 Jean*1014 
eb7e5e62ed Jean*1015     if [ $xx = '..' ]; then
                1016         printf ' N/O '
                1017     elif [ $xx = '--' ]; then
                1018         printf ' N/O '
                1019     elif [ $xx = 99 ]; then
2ff82eb834 Ed H*1020         printf ' N/O '
                1021     else
eb7e5e62ed Jean*1022         if [ $xx -ge $MATCH_CRIT ]; then
2ff82eb834 Ed H*1023             printf ' pass'
                1024         else
                1025             printf ' FAIL'
                1026         fi
                1027     fi
                1028     printf '  %s' $nm
f561fdaba7 Jean*1029     if test $KIND = 2 ; then
49a029e3de Mart*1030         #-- append taf report summary:
f561fdaba7 Jean*1031         tafrep=`grep -c '^ TAF reports ' $CDIR/summary.txt`
                1032         if test $tafrep = 1 ; then
49a029e3de Mart*1033             grep '^ TAF reports ' $CDIR/summary.txt | awk '{printf "  (e=%i, w=%i,",$3,$6}'
                1034             grep '^ load_fields_driver,' $CDIR/summary.txt \
d37c4896c1 Mart*1035                 | awk '{printf " lfd=%i, dop=%i, sm=%i)",$7,$9,$11}'
f561fdaba7 Jean*1036         fi
                1037     fi
2ff82eb834 Ed H*1038     printf '\n'
9750e41317 Jean*1039 
2ff82eb834 Ed H*1040 }
                1041 
                1042 scandirs()
                1043 {
b2fb7c7569 Jean*1044     if [ $# -eq 1 ]; then
                1045         for arg in * ; do
6418c0ec62 Jean*1046            #test -f $arg/$1 && echo $arg
                1047             test -f $arg/$1 -o -f $arg/$1.gz && echo $arg
b2fb7c7569 Jean*1048         done
2ff82eb834 Ed H*1049     else
b2fb7c7569 Jean*1050         echo $*
2ff82eb834 Ed H*1051     fi
                1052 }
                1053 
0179fa2c74 Jean*1054 check_eedata()
                1055 {
7ba778f1ca Jean*1056     # check_eedata eedata size.h
0179fa2c74 Jean*1057     if [ $# -eq 2 ] ; then
7ba778f1ca Jean*1058      if test -f $1 -a -f $2 ; then
                1059       nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
                1060       sx=`grep "^     & *nSx *=" $2 | sed "s/^     & *nSx *=//" | sed 's/, *$//'`
0179fa2c74 Jean*1061       if test "x$nx" = x ; then
                1062         rx=10
                1063       else
                1064         rx=`expr $sx % $nx`
                1065       fi
7ba778f1ca Jean*1066       ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
                1067       sy=`grep "^     & *nSy *=" $2 | sed "s/^     & *nSy *=//" | sed 's/, *$//'`
0179fa2c74 Jean*1068       if test "x$ny" = x ; then
                1069         ry=20
                1070       else
                1071         ry=`expr $sy % $ny`
                1072       fi
                1073       echo `expr $rx + $ry`
7ba778f1ca Jean*1074      else
0179fa2c74 Jean*1075       echo '-1'
7ba778f1ca Jean*1076      fi
                1077     elif [ $# -eq 1 ] ; then
                1078      if test -f $1 ; then
                1079       nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
                1080       if test "x$nx" = x ; then nx=1 ; fi
                1081       ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
                1082       if test "x$ny" = x ; then ny=1 ; fi
                1083      #echo $nx $ny
                1084       echo $nx
                1085      else
                1086       echo '-1'
                1087      fi
0179fa2c74 Jean*1088     else
                1089       echo '-2'
                1090     fi
                1091 
                1092 }
                1093 
2ff82eb834 Ed H*1094 ###############################################################################
                1095 
                1096 #  Default properties
                1097 debug=0
                1098 verbose=1
da8170bd49 Jean*1099 NBLINES_MKLOG=16000
6d54cf9ca1 Ed H*1100 
5a67953813 Jean*1101 OptLev=1
232027f18d Jean*1102 GSL=f
6d54cf9ca1 Ed H*1103 
                1104 CLEANUP=f
ca6d5f1072 Jean*1105 NORUN=f
6d54cf9ca1 Ed H*1106 QUICK=f
416e70d1a2 Jean*1107 NOMAKE=f
6d54cf9ca1 Ed H*1108 NOGENMAKE=f
                1109 NOCLEAN=f
                1110 NODEPEND=f
bbea11a65d Jean*1111 POSTCLEAN=0
2ff82eb834 Ed H*1112 
ac4ed47881 Ed H*1113 BASH=
6d54cf9ca1 Ed H*1114 OPTFILE=NONE
                1115 ADDRESSES=
2ff82eb834 Ed H*1116 TESTDIRS=
6d0f07d5b0 Jean*1117 SKIPDIRS=
2ff82eb834 Ed H*1118 MPACKDIR="../tools/mpack-1.6"
002054e5e5 Ed H*1119 HAVE_MPACK=
d6829a17bc Jean*1120 MPACK=
ee57712ddb Jean*1121 SENDCMD=
                1122 SAVDIR='.'
4619920a5f Ed H*1123 COMMAND=
ca2316a28b Jean*1124 MKDEPEND=
df038dc180 Ed H*1125 if test "x$MAKE" = x ; then
                1126     MAKE=make
                1127 fi
72af1157c6 Jean*1128 MAKE_CMD=
df038dc180 Ed H*1129 if test "x$CC" = x ; then
                1130     CC=cc
                1131 fi
8c9e835c69 Ed H*1132 JOBS=
1f09e8610e Jean*1133 TARG=
d9ae4e2b34 Jean*1134 MPI=0
bbea11a65d Jean*1135 MPI_MFILE=
0e6cc40375 Jean*1136 MULTI_THREAD=f
065c45c70d Jean*1137 OUTDIR=
384dccb29e Ed H*1138 DELDIR=
9750e41317 Jean*1139 USE_R4=
1f09e8610e Jean*1140 EXTRFLG=
72af1157c6 Jean*1141 NOCATAD=
e977410d1b Mart*1142 MKSMALLF=
9d0c386f0c dngo*1143 OADSINGULARITY=
13cadcbe59 Oliv*1144 CHECK_PASS=f
2ff82eb834 Ed H*1145 
6418c0ec62 Jean*1146 #- type of testing (KIND):
b4daa24319 Shre*1147 #   KIND=0 : forward (= default) ;     KIND=6 : Adjoint with OpenAD
                1148 #   KIND=1 : Tangent-Linear with TAF ; KIND=2 : Adjoint with TAF ;
                1149 #   KIND=4 : Tang-Lin. with Tapenade ; KIND=5 : Adjoint with Tapenade ;
6418c0ec62 Jean*1150 KIND=0
4619920a5f Ed H*1151 
bef69cc95f Jean*1152 # list of pTracers to check for monitor output
a18b9b1964 Ed H*1153 PTRACERS_NUM="1 2 3 4 5"
68c34fd102 Ed H*1154 
759f576934 Jean*1155 MATCH_CRIT=10
aaf4336666 Jean*1156 
e53112a6cf Ed H*1157 printf "parsing options...  "
2ff82eb834 Ed H*1158 
                1159 ac_prev=
                1160 for ac_option ; do
                1161 
                1162     # If the previous option needs an argument, assign it.
                1163     if test -n "$ac_prev"; then
                1164         eval "$ac_prev=\$ac_option"
                1165         ac_prev=
                1166         continue
                1167     fi
                1168 
                1169     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
9750e41317 Jean*1170 
2ff82eb834 Ed H*1171     case $ac_option in
49a029e3de Mart*1172 
bbea11a65d Jean*1173         -help | --help | -h | --h) usage ;;
                1174 
                1175         -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;;
                1176         -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;;
                1177 
                1178         -addr | --addr | -a | --a) ac_prev=ADDRESSES ;;
                1179         -addr=* | --addr=* | -a=* | --a=*) ADDRESSES=$ac_optarg ;;
                1180         -mpackdir | --mpackdir | -mpd | --mpd) ac_prev=MPACKDIR ;;
                1181         -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*) MPACKDIR=$ac_optarg ;;
                1182 
ee57712ddb Jean*1183         -send | --send ) ac_prev=SENDCMD ;;
                1184         -send=* | --send=* ) SENDCMD=$ac_optarg ;;
                1185         -savdir | --savdir | -sd | --sd ) ac_prev=SAVDIR ;;
                1186         -savdir=* | --savdir=* | -sd=* | --sd=* ) SAVDIR=$ac_optarg ;;
                1187 
bbea11a65d Jean*1188         -tdir | --tdir | -t | --t) ac_prev=TESTDIRS ;;
                1189         -tdir=* | --tdir=* | -t=* | --t=*) TESTDIRS=$ac_optarg ;;
                1190         -skipdir | --skipdir | -skd | --skd) ac_prev=SKIPDIRS ;;
                1191         -skipdir=* | --skipdir=* | -skd=* | --skd=*) SKIPDIRS=$ac_optarg ;;
                1192 
                1193         -bash | --bash | -b | --b) ac_prev=BASH ;;
                1194         -bash=* | --bash=* | -b=* | --b=*) BASH=$ac_optarg ;;
                1195 
                1196         -command | --command | -c | --c) ac_prev=COMMAND ;;
                1197         -command=* | --command=* | -c=* | --c=*) COMMAND=$ac_optarg ;;
                1198 
                1199         -makedepend | --makedepend | -md | --md) ac_prev=MKDEPEND ;;
                1200         -makedepend=* | --makedepend=* | -md=* | --md=*) MKDEPEND=$ac_optarg ;;
                1201 
                1202         -make | --make | -m | --m) ac_prev=MAKE ;;
                1203         -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;;
                1204 
72af1157c6 Jean*1205         -repl_mk | --repl_mk ) ac_prev=MAKE_CMD ;;
                1206         -repl_mk=* | --repl_mk=*) MAKE_CMD=$ac_optarg ;;
462ccb31f3 Jean*1207 
bbea11a65d Jean*1208         -odir | --odir) ac_prev=OUTDIR ;;
                1209         -odir=* | --odir=*) OUTDIR=$ac_optarg ;;
                1210 
                1211         -ptracers | --ptracers | -ptr | --ptr) ac_prev=PTRACERS_NUM ;;
                1212         -ptracers=* | --ptracers=* | -ptr=* | --ptr=*) PTRACERS_NUM=$ac_optarg ;;
a18b9b1964 Ed H*1213 
aaf4336666 Jean*1214         -match | --match ) ac_prev=MATCH_CRIT ;;
                1215         -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
                1216 
416e70d1a2 Jean*1217         -j | --j) ac_prev=JOBS ;;
                1218         -j=* | --j=*) JOBS=$ac_optarg ;;
8c9e835c69 Ed H*1219 
1f09e8610e Jean*1220         -ef | --ef) ac_prev=EXTRFLG ;;
                1221         -ef=* | --ef=*) EXTRFLG=$ac_optarg ;;
                1222 
bbea11a65d Jean*1223         -clean | --clean) CLEANUP=t ; DELDIR=t ;;
                1224 
                1225         -norun | --norun | -nr | --nr) NORUN=t ;;
1f09e8610e Jean*1226         -obj | --obj ) TARG='obj' ; NORUN=t ;;
f6209765b3 Jean*1227         -src | --src ) TARG='small_f' ; NORUN=t ;;
bbea11a65d Jean*1228         -runonly | --runonly | -ro | --ro) QUICK=t ; NOMAKE=t ;;
                1229         -quick | --quick | -q | --q) QUICK=t ;;
                1230         -nogenmake | --nogenmake | -ng | --ng) NOGENMAKE=t ;;
                1231         -noclean | --noclean | -nc | --nc) NOCLEAN=t ;;
                1232         -nodepend | --nodepend | -nd | --nd) NODEPEND=t ;;
                1233 
                1234         -postclean | --postclean | -pc | --pc) POSTCLEAN=2 ;;
                1235         -deloutp | --deloutp | -do | --do) POSTCLEAN=1 ;;
0b035b108c Ed H*1236 
13cadcbe59 Oliv*1237         -pass) CHECK_PASS=t ;;
                1238 
d9ae4e2b34 Jean*1239         -mpi | --mpi) MPI=2 ;;
                1240         -MPI | --MPI) ac_prev=MPI ;;
                1241         -MPI=* | --MPI=*) MPI=$ac_optarg ;;
6d54cf9ca1 Ed H*1242 
bbea11a65d Jean*1243         -mfile | --mfile | -mf | --mf) ac_prev=MPI_MFILE ;;
                1244         -mfile=* | --mfile=* | -mf=* | --mf=*) MPI_MFILE=$ac_optarg ;;
                1245 
0e6cc40375 Jean*1246         -mth) MULTI_THREAD=t ;;
                1247 
b4daa24319 Shre*1248         -tlm) if test $KIND = 0 -o $KIND = 3 ; then KIND=`expr $KIND + 1`; else
                1249                 echo "Error: '-tlm', '-adm' and '-oad' are exclusive + no duplicate" ; usage
                1250               fi ;;
                1251         -adm | -ad) if test $KIND = 0 -o $KIND = 3 ; then KIND=`expr $KIND + 2` ; else
                1252                 echo "Error: '-tlm', '-adm' and '-oad' are exclusive + no duplicate" ; usage
6418c0ec62 Jean*1253               fi ;;
b4daa24319 Shre*1254         -tap) if [ $KIND -le 2 ] ; then KIND=`expr $KIND + 3` ; else
                1255                 echo "Error: '-tap' and '-oad' are exclusive + no duplicate" ; usage
6418c0ec62 Jean*1256               fi ;;
b4daa24319 Shre*1257         -oad) if test $KIND = 0 ; then KIND=6 ; NODEPEND=t ; else
                1258                 echo "Error: '-tlm', '-adm' and '-oad' are exclusive + no duplicate" ; usage
6418c0ec62 Jean*1259               fi ;;
9d0c386f0c dngo*1260         -oadsingularity | --oadsingularity | -oadsngl | --oadsngl) ac_prev=OADSINGULARITY ;;
                1261         -oadsingularity=* | --oadsingularity=* | -oadsngl=* | --oadsngl=*) OADSINGULARITY=$ac_optarg ;;
                1262 
72af1157c6 Jean*1263         -ncad) NOCATAD=t ;;
e977410d1b Mart*1264         -small_f) MKSMALLF=t ;;
3907106aba Jean*1265 
5a67953813 Jean*1266         -ieee)   echo "Warning: ignore option '-ieee' (already the default)"
6418c0ec62 Jean*1267                  printf " ... " ;;
5a67953813 Jean*1268         -noieee) echo "Warning: will use option '-fast' instead of '-noieee' (obsolete)"
6418c0ec62 Jean*1269                  printf " ... " ; OptLev=`expr $OptLev \* 2` ;;
5a67953813 Jean*1270         -fast)  OptLev=`expr $OptLev \* 2` ;;
                1271         -devel) OptLev=0 ;;
bbea11a65d Jean*1272         -gsl) GSL=t ;;
6d54cf9ca1 Ed H*1273 
2ff82eb834 Ed H*1274         -verbose) verbose=2 ;;
                1275         -debug) debug=1 ;;
                1276         -quiet) verbose=0 ;;
                1277 
384dccb29e Ed H*1278         -deldir | -dd) DELDIR=t ;;
                1279 
416e70d1a2 Jean*1280         -use_r4|-ur4) USE_R4=t ;;
a986ef8661 Cons*1281 
9750e41317 Jean*1282         -ts) TS=t;;
a986ef8661 Cons*1283         -papis) PAPIS=t;;
72af1157c6 Jean*1284         -pcls) PCLS=t;;
a986ef8661 Cons*1285 
bbea11a65d Jean*1286         -*) echo "Error: unrecognized option: "$ac_option
                1287             usage ;;
                1288         *)  echo "Error: unrecognized argument: "$ac_option
                1289             usage ;;
9750e41317 Jean*1290 
2ff82eb834 Ed H*1291      esac
9750e41317 Jean*1292 
2ff82eb834 Ed H*1293 done
                1294 
6d54cf9ca1 Ed H*1295 if test "x$QUICK" = xt ; then
                1296     NOGENMAKE=t
                1297     NOCLEAN=t
                1298     NODEPEND=t
                1299 fi
72af1157c6 Jean*1300 if test "x$MAKE_CMD" = x ; then MAKE_CMD=$MAKE ; fi
6d54cf9ca1 Ed H*1301 
bbea11a65d Jean*1302 #- check length of MPI machine file:
                1303 if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then
                1304     if test -r $MPI_MFILE ; then
                1305         nl=`wc -l $MPI_MFILE | awk '{print $1}'`
                1306         if [ $nl -lt $MPI ] ; then
6418c0ec62 Jean*1307           echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE"
                1308           usage
bbea11a65d Jean*1309         fi
                1310         if [ $verbose -gt 1 ]; then
                1311             echo " MPI_MFILE=$MPI_MFILE : $nl procs for MPI=$MPI run"
                1312         fi
                1313     else
6418c0ec62 Jean*1314           echo "Error: cannot access MPI_MFILE=$MPI_FILE"
                1315           usage
bbea11a65d Jean*1316     fi
                1317 fi
                1318 
b4daa24319 Shre*1319 #- setting for forward, TLM or ADM testing
6418c0ec62 Jean*1320 if test $KIND = 1 ; then
c59dd234b1 Jean*1321     if test "x$TARG" = x        ; then TARG=ftlall ; fi
                1322     if test "x$TARG" = xobj     ; then TARG=ftlobj ; fi
                1323     if test "x$TARG" = xsmall_f ; then TARG=ftltaf ; fi
6418c0ec62 Jean*1324     code_dir=code_ad
                1325     inputdir=input_ad
                1326     ref_outp="output_tlm.txt"
                1327     EXECUTABLE="mitgcmuv_ftl"
                1328 elif test $KIND = 2 ; then
f6209765b3 Jean*1329     if test "x$TARG" = x        ; then TARG=adall ; fi
                1330     if test "x$TARG" = xobj     ; then TARG=adobj ; fi
                1331     if test "x$TARG" = xsmall_f ; then TARG=adtaf ; fi
6d41b7da3e Jean*1332     code_dir=code_ad
878c588496 Jean*1333     inputdir=input_ad
6d41b7da3e Jean*1334     ref_outp="output_adm.txt"
                1335     EXECUTABLE="mitgcmuv_ad"
b4daa24319 Shre*1336 elif test $KIND = 4 -o $KIND = 5 ; then
                1337     if test $KIND = 4 ; then TARG=tap_tlm ; else TARG=tap_adj ; fi
                1338     code_dir=code_tap
                1339     inputdir=input_tap
                1340     ref_outp="output_${TARG}.txt"
                1341     EXECUTABLE="mitgcmuv_${TARG}"
                1342 elif test $KIND = 6 ; then
f9b75e9bda Jean*1343     TARG=adAll
3907106aba Jean*1344     code_dir=code_oad
                1345     inputdir=input_oad
                1346     ref_outp="output_oadm.txt"
                1347     EXECUTABLE="mitgcmuv_ad"
6d41b7da3e Jean*1348 else
                1349     code_dir=code
878c588496 Jean*1350     inputdir=input
6d41b7da3e Jean*1351     ref_outp="output.txt"
                1352     EXECUTABLE="mitgcmuv"
                1353 fi
72af1157c6 Jean*1354 if test "x$JOBS" != x ; then TARG="-j $JOBS $TARG" ; fi
6d41b7da3e Jean*1355 
b4daa24319 Shre*1356 if [ $verbose -gt 1 ]; then
                1357     echo ""
                1358     echo "--- print $0 setting:"
                1359     echo " KIND     =  '$KIND'"
                1360     echo " TARG     =  '$TARG'"
                1361     echo " code_dir =  '$code_dir'"
                1362     echo " inputdir =  '$inputdir'"
                1363     echo " ref_outp =  '$ref_outp'"
                1364     echo " EXECUTABLE= '$EXECUTABLE'"
                1365     echo "--- printing ends."
                1366    #exit 0
                1367 fi
                1368 
ed9f439d26 Jean*1369 xx=`echo $TESTDIRS | awk '{print $1}'`
2ff82eb834 Ed H*1370 if test "x$TESTDIRS" = x ; then
456c314cce Jean*1371     LIST=`scandirs results/$ref_outp`
ed9f439d26 Jean*1372 elif test $xx = 'start_from' ; then
                1373     xx=`echo $TESTDIRS | awk '{print $2}'`
                1374     LIST=`scandirs results/$ref_outp | sed -n "/$xx/,$ p"`
35aa6741f4 Jean*1375 else
                1376     #- expand group of experiments:
                1377     LIST=" "
                1378     for xx in $TESTDIRS
                1379     do
                1380       case $xx in
c4ead643ab Jean*1381         'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
                1382                  LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
                1383                  LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
35aa6741f4 Jean*1384                 ;;
                1385         'tutorials')
                1386                  LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
                1387         *)       LIST=${LIST}" "$xx ;;
                1388       esac
9750e41317 Jean*1389     done
6d0f07d5b0 Jean*1390 fi
                1391 #echo 'LIST='${LIST}'<'
                1392 #- skip dirs, remove duplicate and non-directory:
                1393 TESTDIRS=" "
                1394 count=0
                1395 for xx in $LIST
                1396 do
                1397     yy=`echo $SKIPDIRS | grep -c $xx`
                1398     if test $yy = 0 ; then
35aa6741f4 Jean*1399         if test -d $xx ; then
                1400             yy=`echo $TESTDIRS | grep -c $xx`
                1401             if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
6d0f07d5b0 Jean*1402         else count=1 ;
                1403             echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
35aa6741f4 Jean*1404         fi
6d0f07d5b0 Jean*1405     else
6418c0ec62 Jean*1406         if test $count = 1 ; then echo -n ", \"$xx\""
6d0f07d5b0 Jean*1407         else count=1 ; echo "" ;  echo -n " skip: \"$xx\""
                1408         fi
                1409     fi
9750e41317 Jean*1410 done
6d0f07d5b0 Jean*1411 if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
35aa6741f4 Jean*1412 #echo 'TESTDIRS='${TESTDIRS}'<'
2ff82eb834 Ed H*1413 
bbea11a65d Jean*1414 LOC_MFILE='tr_mpi_mfile'
0093035fc0 Jean*1415 RUNLOG="run.tr_log"
442de1f446 Jean*1416 if test "x$MPI" = x0 ; then
                1417   OUTPUTFILE=$ref_outp
                1418   if test "x$COMMAND" = x ; then COMMAND="./$EXECUTABLE > $OUTPUTFILE" ; fi
                1419 else
                1420   OUTPUTFILE="STDOUT.0000"
75c0ee3505 Jean*1421   if test "x$COMMAND" = x ; then COMMAND="mpirun -np TR_NPROC ./$EXECUTABLE" ; fi
84370bfea3 Jean*1422 fi
4619920a5f Ed H*1423 
442de1f446 Jean*1424 echo "OK (COMMAND='$COMMAND')"
2ff82eb834 Ed H*1425 
72af1157c6 Jean*1426 #TMP=./tr_$$
ee57712ddb Jean*1427 #- try to put temporary files in system-local /tmp dir
72af1157c6 Jean*1428 TMP=/tmp/tr_${USER}_$$
                1429 touch $TMP ; retVal=$?
                1430 if [ $retVal -eq 0 ] ; then
                1431   if test ! -r $TMP ; then TMP=./tr_$$ ; fi
                1432 else
                1433   TMP=./tr_$$
                1434 fi
                1435 rm -f $TMP
                1436 if [ $verbose -gt 1 ]; then echo " temp files: $TMP" ; fi
ee57712ddb Jean*1437 
eb7e5e62ed Jean*1438 # set the Default List of output variables to be checked:
                1439 #  (use default or load experiment-specific list from file "tr_checklist")
                1440 # content : 1rst = main variable used to decide if it pass or FAIL
                1441 #         others = number of matching digits to be printed in summary.txt
d81415648f Jean*1442 if test $KIND = 0 ; then
eb7e5e62ed Jean*1443     DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+'
                1444     EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..'
4d91a93b49 Jean*1445     LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
eb7e5e62ed Jean*1446     ii=`echo $EMPTY_RESULTS | awk '{print NF}'`
4d91a93b49 Jean*1447     EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf "  ."}}'`
d81415648f Jean*1448 elif test $KIND = 2 ; then
                1449     DEF_CHECK_LIST='admGrd admCst admGrd admFwd T+ S+ U+ V+'
                1450     EMPTY_RESULTS='.. .. .. .. .. .. ..  .. .. .. ..  .. .. .. ..  .. .. .. ..'
                1451     LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
                1452 else
                1453     DEF_CHECK_LIST='admGrd admCst admGrd admFwd'
                1454     EMPTY_RESULTS='.. .. ..'
                1455     LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
eb7e5e62ed Jean*1456 fi
                1457 
2ff82eb834 Ed H*1458 #  create the FORTRAN comparison code
122c9245be Jean*1459 if test "x$CLEANUP" = xt -o -x tr_cmpnum ; then
ca6d5f1072 Jean*1460     echo "skipping comparison code build"
                1461 else
                1462     createcodelet
                1463 fi
2ff82eb834 Ed H*1464 
63e0800ef7 Jean*1465 #  build the mpack utility (if ADDRESSES = NONE, do it to test the build)
ee57712ddb Jean*1466 if test "x$ADDRESSES" = x -o "x$SENDCMD" != x ; then
7a89945018 Ed H*1467     echo "skipping mpack build"
                1468 else
9cfcd12778 Ed H*1469     build_mpack
ee57712ddb Jean*1470     if test "x$HAVE_MPACK" = xt ; then SENDCMD=$MPACK ; fi
9cfcd12778 Ed H*1471 fi
2ff82eb834 Ed H*1472 
                1473 #  Create a uniquely named directory to store results
e72086803c Jean*1474 CMDLINE=$0
6c32747881 Jean*1475 for xx in "$@" ; do nw=`echo $xx | wc -w`
27d53f6f29 Jean*1476     if test $nw = '1' ; then CMDLINE="$CMDLINE $xx" ; else
                1477       nb=`echo $xx | grep -c '='`
                1478       if test $nb = 0 ; then CMDLINE="$CMDLINE '$xx'"
                1479       else yy=`echo "$xx'" | sed "s/=/='/"` ;
                1480                              CMDLINE="$CMDLINE $yy" ; fi
                1481     fi
6c32747881 Jean*1482 done
2ff82eb834 Ed H*1483 MACH=`hostname`
7d86f89c7f Ed H*1484 UNAMEA=`uname -a`
2ff82eb834 Ed H*1485 DATE=`date +%Y%m%d`
54db3dc364 Ed H*1486 BASE="tr_"$MACH"_"$DATE"_"
065c45c70d Jean*1487 if test "x$OUTDIR" != x ; then
                1488     BASE="tr_"$OUTDIR"_"$DATE"_"
276c0f056b Jean*1489 else
fb06fe5592 Mart*1490    #short_name=`hostname -s | tr '[:upper:]' '[:lower:]'`
                1491    # hostname -s is not universal (does work on AIX system)
72af1157c6 Jean*1492     short_name=`hostname | sed 's/\..*$//' | tr '[:upper:]' '[:lower:]'`
276c0f056b Jean*1493     BASE="tr_"$short_name"_"$DATE"_"
065c45c70d Jean*1494 fi
2ff82eb834 Ed H*1495 DNUM=0
                1496 DRESULTS="$BASE$DNUM"
                1497 while test -e $DRESULTS ; do
                1498     DNUM=$(( $DNUM + 1 ))
                1499     DRESULTS="$BASE$DNUM"
                1500 done
                1501 mkdir $DRESULTS
                1502 RETVAL=$?
                1503 if test "x$RETVAL" != x0 ; then
002054e5e5 Ed H*1504     echo "ERROR: Can't create results directory \"./$DRESULTS\""
2ff82eb834 Ed H*1505     exit 1
                1506 fi
                1507 SUMMARY="$DRESULTS/summary.txt"
67e2869886 Ed H*1508 start_date=`date`
b46c5fdcd4 Ed H*1509 echo $start_date > $SUMMARY
e72086803c Jean*1510 echo 'run:' $CMDLINE >> $SUMMARY
                1511 echo 'on :' $UNAMEA  >> $SUMMARY
2ff82eb834 Ed H*1512 
893b53ecae Ed H*1513 of_path=
6d54cf9ca1 Ed H*1514 if test "x$OPTFILE" != xNONE ; then
                1515     if test -r $OPTFILE ; then
893b53ecae Ed H*1516         # get the path
                1517         path=${OPTFILE%/*}
                1518         if test "x$path" = x ; then
                1519             of_path=`pwd`
                1520         else
                1521             of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
                1522         fi
                1523         file=${OPTFILE##*/}
                1524         OPTFILE=$of_path/$file
2995826769 Ed H*1525         cp $OPTFILE $DRESULTS
                1526         echo >> $SUMMARY
                1527         echo "  OPTFILE=$OPTFILE" >> $SUMMARY
893b53ecae Ed H*1528     else
7509d1d274 Jean*1529         echo | tee -a $SUMMARY
                1530         echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee -a $SUMMARY
2995826769 Ed H*1531         exit 1
2ff82eb834 Ed H*1532     fi
2995826769 Ed H*1533 else
                1534     echo >> $SUMMARY
935c582112 Jean*1535     echo "No \"OPTFILE\" was specified ; genmake2 found and uses:" >> $SUMMARY
                1536     #-note: to be filled later after 1rst run
6d54cf9ca1 Ed H*1537 fi
                1538 echo
                1539 echo >> $SUMMARY
6418c0ec62 Jean*1540 if test $KIND = 0 ; then
                1541     line_0=`printf '%s %2i' 'default' $MATCH_CRIT`
eb7e5e62ed Jean*1542        line_0="$line_0  ----T-----  ----S-----  ----U-----  ----V-----"
68c34fd102 Ed H*1543     line_1="G D M    c        m  s        m  s        m  s        m  s"
4d66dcbdcc Jean*1544     line_2="e p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."
                1545     line_3="n n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"
68c34fd102 Ed H*1546     line_4="2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."
a18b9b1964 Ed H*1547     for ii in $PTRACERS_NUM ; do
68c34fd102 Ed H*1548         line_0="$line_0  --PTR 0"$ii"--"
                1549         line_1="$line_1        m  s"
                1550         line_2="$line_2  m  m  e  ."
                1551         line_3="$line_3  i  a  a  d"
                1552         line_4="$line_4  n  x  n  ."
                1553     done
6418c0ec62 Jean*1554 else
                1555   if test $KIND = 1 ; then
fb1e235660 Jean*1556     echo "TangLin generated by TAF" >> $SUMMARY
                1557   elif test $KIND = 2 ; then
                1558     echo "Adjoint generated by TAF" >> $SUMMARY
b4daa24319 Shre*1559   elif test $KIND = 4 ; then
                1560     echo "TangLin generated by Tapenade" >> $SUMMARY
                1561   elif test $KIND = 5 ; then
                1562     echo "Adjoint generated by Tapenade" >> $SUMMARY
fb1e235660 Jean*1563   else
                1564     echo "Adjoint generated by OpenAD" >> $SUMMARY
                1565   fi
d81415648f Jean*1566     line_0=`printf '%s %2i' 'default   ' $MATCH_CRIT`
b4daa24319 Shre*1567   if test $KIND = 1 -o $KIND = 4 ; then
6418c0ec62 Jean*1568     line_1="G D M    C  T  F"
                1569     line_2="e p a R  o  L  D"
                1570   else
                1571     line_1="G D M    C  A  F"
                1572     line_2="e p a R  o  d  D"
                1573   fi
                1574     line_3="n n k u  s  G  G"
                1575     line_4="2 d e n  t  r  r"
                1576     echo >> $SUMMARY
d81415648f Jean*1577   if test $KIND = 2 ; then
                1578     line_0=`printf '%s %2i   ' 'default   ' $MATCH_CRIT`
                1579     line_0="$line_0  ----T-----  ----S-----  ----U-----  ----V-----"
                1580     line_1="$line_1        m  s        m  s        m  s        m  s"
                1581     line_2="$line_2  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."
                1582     line_3="$line_3  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"
                1583     line_4="$line_4  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."
                1584   fi
6418c0ec62 Jean*1585 fi
122c9245be Jean*1586 if test "x$CLEANUP" != xt ; then
68c34fd102 Ed H*1587     echo "$line_0" | tee -a $SUMMARY
                1588     echo "$line_1" | tee -a $SUMMARY
                1589     echo "$line_2" | tee -a $SUMMARY
                1590     echo "$line_3" | tee -a $SUMMARY
                1591     echo "$line_4" | tee -a $SUMMARY
6418c0ec62 Jean*1592     echo ""        | tee -a $SUMMARY
122c9245be Jean*1593 fi
6fcdccb64d Jean*1594 echo "-------------------------------------------------------------------------------"
6d54cf9ca1 Ed H*1595 
13cadcbe59 Oliv*1596 allpass=t
                1597 
6d54cf9ca1 Ed H*1598 #  ...and each test directory...
                1599 for dir in $TESTDIRS ; do
9750e41317 Jean*1600 
7e8ef1f316 Jean*1601     # set builddir & rundir:
                1602     builddir="build"
                1603     if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
                1604     rundir="run"
cecd4018b3 Jean*1605     pfxdir="tr_$rundir"
7e8ef1f316 Jean*1606     if test ! -d $dir/$rundir ; then
                1607         rundir=$builddir
                1608     fi
                1609     CODE_DIR=$dir/$code_dir
                1610     BUILD_DIR=$dir/$builddir
                1611 
6d54cf9ca1 Ed H*1612     #  Cleanup only!
                1613     if test "x$CLEANUP" = xt ; then
642fbd44e7 Jean*1614         echo -n '  --- dir:' $BUILD_DIR ': '
                1615         makeclean $BUILD_DIR
38c4b22527 Jean*1616         (   cd $BUILD_DIR
                1617             rm -f $EXECUTABLE *.bak
0093035fc0 Jean*1618             rm -f genmake_state genmake_*optfile genmake.log
d9ae4e2b34 Jean*1619             rm -f SIZE.h.mpi genmake.tr_log make.tr_log
e6f2a663b8 Jean*1620             rm -rf mpi_headers
38c4b22527 Jean*1621         )
9527bfb820 Jean*1622         if test -d $dir/$rundir ; then
6418c0ec62 Jean*1623             echo -n '  --- dir:' $dir/$rundir ': '
7e8ef1f316 Jean*1624             run_clean $dir/$rundir
1c1109930c Ed H*1625         fi
cecd4018b3 Jean*1626         trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')`
642fbd44e7 Jean*1627         ttd=`echo $trdir | wc -w`
                1628         if test $ttd != 0 ; then
                1629             echo '  --- rm dir:' $trdir
                1630             ( cd $dir ; rm -rf $trdir )
                1631         fi
6d54cf9ca1 Ed H*1632         continue
                1633     fi
1c1109930c Ed H*1634 
9750e41317 Jean*1635     #  Verify that the testdir exists and contains previous
6d54cf9ca1 Ed H*1636     #  results in the correct location--or skip this directory!
0d2e560266 Jean*1637     fout=$dir"/results/"$ref_outp
6418c0ec62 Jean*1638    #if test ! -r $fout ; then
                1639     if test ! -r $fout -a ! -r ${fout}.gz ; then
4619920a5f Ed H*1640         echo "can't read \"$fout\" -- skipping $dir"
6d54cf9ca1 Ed H*1641         continue
                1642     fi
2ff82eb834 Ed H*1643 
bef69cc95f Jean*1644     # Check for specific files for particular type of run
68c34fd102 Ed H*1645 
7ba778f1ca Jean*1646     if test ! -r $CODE_DIR"/SIZE.h_mpi"  -a "x$MPI" != "x0" ; then
                1647         echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
                1648         continue
                1649     fi
                1650     if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
                1651         echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
                1652         continue
                1653     fi
                1654 
d9ae4e2b34 Jean*1655     if test "x$MPI" != "x0" ; then
6c95586363 Jean*1656         ntx=1 ; nty=1
7ba778f1ca Jean*1657         if test "x$MULTI_THREAD" = "xt" ; then
54f370a421 Jean*1658           ff=$dir"/input/eedata.mth"
                1659           ntx=`grep "^ *nTx *=" $ff | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
                1660           nty=`grep "^ *nTy *=" $ff | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
                1661           if test "x$ntx" = x ; then ntx=1 ; fi
                1662           if test "x$nty" = x ; then nty=1 ; fi
d9ae4e2b34 Jean*1663         fi
7ba778f1ca Jean*1664         #- create new SIZE.h with no more than '$MPI' Procs
6c95586363 Jean*1665         mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $ntx $nty
7ba778f1ca Jean*1666         LOC_NPROC=$?
                1667         (   cd $BUILD_DIR
                1668             if test -r SIZE.h.mpi ; then
                1669                 cmp tr_size.mpi SIZE.h.mpi > /dev/null 2>&1 ; RETVAL=$?
                1670             else RETVAL=1
                1671             fi
                1672             if test "x$RETVAL" = x0 ; then
                1673                 rm -f tr_size.mpi
                1674             else
                1675                 rm -f SIZE.h.mpi ; mv tr_size.mpi SIZE.h.mpi
                1676             fi
                1677         )
bbea11a65d Jean*1678         if test "x$MPI_MFILE" != x ; then
                1679             #- create new MPI machine-file with the right number of Procs
                1680             rm -f $LOC_MFILE
                1681             cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
                1682             nl=`wc -l $LOC_MFILE | awk '{print $1}'`
                1683             if [ $nl -lt $LOC_NPROC ] ; then
                1684                 rm -f $LOC_MFILE
                1685                 cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
                1686                 #sed -n "1,$LOC_NPROC p" $MPI_MFILE > $LOC_MFILE
                1687             fi
                1688             if [ $verbose -gt 1 ]; then
                1689                 nl=`wc -l $LOC_MFILE | awk '{print $1}'`
                1690                 echo " new LOC_MFILE=$LOC_MFILE : $nl procs for LOC_NPROC=$LOC_NPROC"
                1691             fi
                1692         fi
7ba778f1ca Jean*1693         if test "x$MULTI_THREAD" = "xt" ; then
                1694             retv=`check_eedata $dir"/input/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
                1695             if test $retv != 0 ; then
                1696                 echo "input/eedata.mth tiling misfit -- skipping $dir"
                1697                 continue
                1698             fi
d9ae4e2b34 Jean*1699         fi
0179fa2c74 Jean*1700     fi
0e6cc40375 Jean*1701 
                1702     #  Check whether there are "extra runs" for this testdir
                1703     extra_runs=
ca6d5f1072 Jean*1704     if test "x$NORUN" = xf ; then
fedbb6c3d7 Jean*1705         ex_run_dirs=`( cd $dir ; ls -d $inputdir.* 2> /dev/null )`
ca6d5f1072 Jean*1706     fi
878c588496 Jean*1707     #echo "ex_run_dirs='$ex_run_dirs'"
                1708     for exd in $ex_run_dirs ; do
                1709         name=`echo $exd | sed -e "s/$inputdir\.//"`
                1710         refExOut=`echo $ref_outp | sed "s/\./.${name}./"`
                1711         outf="$dir/results/$refExOut"
6418c0ec62 Jean*1712         if test -r $outf -o -r ${outf}.gz ; then
9750e41317 Jean*1713           if test "x$MULTI_THREAD" = "xt" ; then
0179fa2c74 Jean*1714             if test -r $dir"/"$exd"/eedata.mth" ; then
d9ae4e2b34 Jean*1715               if test "x$MPI" = "x0" ; then
                1716                 extra_runs="$extra_runs $name"
                1717               else
7ba778f1ca Jean*1718                 retv=`check_eedata $dir"/"$exd"/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
0179fa2c74 Jean*1719                 if test $retv = 0 ; then
0e6cc40375 Jean*1720                     extra_runs="$extra_runs $name"
0179fa2c74 Jean*1721                 else
                1722                     echo $exd"/eedata.mth tiling misfit -- skipping $dir"
0e6cc40375 Jean*1723                 fi
0179fa2c74 Jean*1724               fi
                1725             #else echo $dir"/"$exd"/eedata.mth: not found"
0e6cc40375 Jean*1726             fi
0179fa2c74 Jean*1727           else
                1728             extra_runs="$extra_runs $name"
                1729           fi
878c588496 Jean*1730         fi
                1731     done
b0b995d6ae Ed H*1732 
                1733     echo
9750e41317 Jean*1734     if test "x$extra_runs" = "x" ; then
6418c0ec62 Jean*1735         echo "Experiment:  $dir"
0e6cc40375 Jean*1736     else
6418c0ec62 Jean*1737         echo "Experiment:  $dir ; extra_runs=$extra_runs"
0e6cc40375 Jean*1738     fi
b0b995d6ae Ed H*1739     echo
                1740     unset genmake makedepend make run
eb7e5e62ed Jean*1741     results=$EMPTY_RESULTS
b0b995d6ae Ed H*1742 
360fa2f691 Jean*1743     #  Create an output dir & summary.txt file for each tested experiment (tdir)
577d52ba66 Jean*1744     locDIR=$DRESULTS"/"$dir
                1745     mkdir $locDIR
360fa2f691 Jean*1746     #- report to this experiment local summary file ---
                1747     echo "DATE='$DATE' ; tdir='$dir'" > $locDIR"/summary.txt"
                1748     echo "MACH='$MACH'" >> $locDIR"/summary.txt"
                1749     echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
577d52ba66 Jean*1750     CDIR=`pwd`"/$locDIR"
9750e41317 Jean*1751 
ca6d5f1072 Jean*1752     if test "x$NORUN" = xt ; then
                1753             run=N
                1754         genmakemodel $dir/$builddir && genmake=Y \
                1755             && makeclean $dir/$builddir \
6418c0ec62 Jean*1756             && symlink_mpifiles $dir $code_dir $builddir \
ca6d5f1072 Jean*1757             && makedependmodel $dir/$builddir && makedepend=Y \
                1758             && makemodel $dir/$builddir && make=Y
c67b26333b Jean*1759             echo
6d54cf9ca1 Ed H*1760     else
2ff82eb834 Ed H*1761         genmakemodel $dir/$builddir && genmake=Y \
                1762             && makeclean $dir/$builddir \
6418c0ec62 Jean*1763             && symlink_mpifiles $dir $code_dir $builddir \
2ff82eb834 Ed H*1764             && makedependmodel $dir/$builddir && makedepend=Y \
                1765             && makemodel $dir/$builddir && make=Y \
6fcdccb64d Jean*1766             && run_clean $dir/$rundir \
abed800b6d Jean*1767             && linkdata $dir/$rundir $inputdir \
474019363f Ed H*1768             && runmodel $dir/$rundir && run=Y \
6d41b7da3e Jean*1769             && results=`testoutput_run $dir $rundir $ref_outp`
c67b26333b Jean*1770             echo 1>&2
6d54cf9ca1 Ed H*1771     fi
ca6d5f1072 Jean*1772     #echo "results='$results'"
6fcdccb64d Jean*1773 
4619920a5f Ed H*1774         fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
6418c0ec62 Jean*1775         echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
577d52ba66 Jean*1776         echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
13cadcbe59 Oliv*1777         if [[ ! "$fres" =~ " pass " ]]; then
                1778             allpass=f
                1779         fi
e53112a6cf Ed H*1780 
                1781         for ex in $extra_runs ; do
c6cea69b38 Jean*1782             unset run
6418c0ec62 Jean*1783             results=$EMPTY_RESULTS
7e8ef1f316 Jean*1784             #  reference output file
                1785             refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
360fa2f691 Jean*1786             #  Create an output dir & summary.txt file for each extra run (tdir.ex)
577d52ba66 Jean*1787             locDIR=$DRESULTS"/"$dir"."$ex
                1788             mkdir $locDIR
360fa2f691 Jean*1789             #- report to this experiment local summary file ---
                1790             echo "DATE='$DATE' ; tdir='$dir.$ex'" > $locDIR"/summary.txt"
                1791             #echo "MACH='$MACH'" >> $locDIR"/summary.txt"
                1792             #echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
577d52ba66 Jean*1793             CDIR=`pwd`"/$locDIR"
cecd4018b3 Jean*1794             test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
                1795             run_clean $dir/$pfxdir.$ex
                1796             linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
                1797             runmodel $dir/$pfxdir.$ex && run=Y \
                1798             && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
c67b26333b Jean*1799             echo 1>&2
cc019522d9 Jean*1800 
f561fdaba7 Jean*1801             fres=`formatresults $dir.$ex ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
c5e604105c Jean*1802             echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
577d52ba66 Jean*1803             echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
13cadcbe59 Oliv*1804             if [[ ! "$fres" =~ " pass " ]]; then
                1805                 allpass=f
                1806             fi
bbea11a65d Jean*1807             if test "x$POSTCLEAN" = x2 ; then
cecd4018b3 Jean*1808                 run_clean $dir/$pfxdir.$ex
0e6cc40375 Jean*1809             fi
e53112a6cf Ed H*1810         done
0b035b108c Ed H*1811 
6aa14c32e4 Jean*1812     if test ! -f $DRESULTS"/"genmake_state ; then
c14ab91977 Jean*1813         if test -f $dir/$builddir/Makefile ; then
                1814             mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
                1815             echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
fb06fe5592 Mart*1816 #           sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
                1817 # bsd-sed cannot do the above code
                1818             cat $dir/$builddir/Makefile | \
deb0ad3aea Mart*1819                 sed -n '/^# executed by:/{N
                1820                                           p
                1821                                           }' >> $DRESULTS/genmake_state
fe7601e9ab Jean*1822             echo " $mkOpt" >> $DRESULTS/genmake_state
935c582112 Jean*1823             if test "x$OPTFILE" = xNONE ; then
                1824                 eval $mkOpt
fb06fe5592 Mart*1825 #               sed "/^No \"OPTFILE\" was specified ; genmake2/a\  OPTFILE=${OPTFILE}"\
                1826 #                       $SUMMARY > tmp.tr_log
                1827 # bsd-sed requires a newline after "a\":
                1828                 sed "/^No \"OPTFILE\" was specified ; genmake2/a\\
                1829                          OPTFILE=${OPTFILE}" $SUMMARY > tmp.tr_log
935c582112 Jean*1830                 RETVAL=$?
ee57712ddb Jean*1831                 if test "x$RETVAL" = x0 ; then
                1832                     cp -f tmp.tr_log $SUMMARY
935c582112 Jean*1833                 fi
ee57712ddb Jean*1834                 rm -f tmp.tr_log
935c582112 Jean*1835             fi
497802755c Jean*1836             gmkLog=$dir/$builddir/genmake.log
6aa14c32e4 Jean*1837             if test -r $gmkLog ; then
                1838                 grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
                1839                 RETVAL=$?
                1840                 if test "x$RETVAL" = x0 ; then
8188c8aec7 Jean*1841                   echo -n "from '$gmkLog', "    >> $DRESULTS/genmake_state
6aa14c32e4 Jean*1842                   echo "extract compiler version:"   >> $DRESULTS/genmake_state
                1843                   sed -n '/Get compiler version/,/<-- compiler version/p' \
                1844                      $gmkLog | grep -v '^... compiler version ' > tmp.tr_log
8188c8aec7 Jean*1845                   sed -n '1p' tmp.tr_log        >> $DRESULTS/genmake_state
6aa14c32e4 Jean*1846                   sed -n '2,/^$/p' tmp.tr_log | sed '/^$/d' | sed 's/^./ &/' \
8188c8aec7 Jean*1847                                                 >> $DRESULTS/genmake_state
6aa14c32e4 Jean*1848                   rm -f tmp.tr_log
                1849                 fi
516b08a580 jm-c 1850                 grep ' set FC_CHECK=' $gmkLog   >> $DRESULTS/genmake_state
b48bc6023a Jean*1851             fi
e1cc724aa4 Jean*1852             if test $KIND = 1 -o  $KIND = 2 ; then
                1853               gmkLog=$dir/$builddir/taf_ad.log
                1854               if test $KIND = 1 ; then gmkLog=$dir/$builddir/taf_ftl.log ; fi
                1855               if test -f $gmkLog ; then
                1856                 echo -n "from '$gmkLog', get: " >> $DRESULTS/genmake_state
                1857                 head -1 $gmkLog | sed 's/^.*Algorithms in Fortran //' \
                1858                                                 >> $DRESULTS/genmake_state
                1859                 ADvers=`head -1 $gmkLog | awk '{print $7,$8}'`
                1860                 sed "s/ by TAF/ by TAF $ADvers/" $SUMMARY > tmp.tr_log
                1861                 mv -f tmp.tr_log $SUMMARY
                1862               fi
                1863             fi
                1864             if test $KIND = 4 -o  $KIND = 5 ; then
                1865               gmkLog=$dir/$builddir/make.tr_log
                1866               if test -f $gmkLog ; then
                1867                 ADtool=`grep '^Tapenade ' $gmkLog | tail -n 1`
                1868                 echo "from '$gmkLog', get: $ADtool" >> $DRESULTS/genmake_state
212a55051e Jean*1869                 ADvers=`echo $ADtool | awk '{print $2,$3}'`
                1870                 sed "s/ by Tapenade/ by Tapenade $ADvers/" $SUMMARY > tmp.tr_log
e1cc724aa4 Jean*1871                 mv -f tmp.tr_log $SUMMARY
                1872               fi
                1873             fi
b48bc6023a Jean*1874             gmkLog=$dir/$builddir/genmake_state
                1875             if test -r $gmkLog ; then
8188c8aec7 Jean*1876                 echo -n "from '$gmkLog', "      >> $DRESULTS/genmake_state
                1877                 echo "get genmake settings:"    >> $DRESULTS/genmake_state
b48bc6023a Jean*1878                 sed -n '/^HAVE_/p' $gmkLog | sed 's/^./ &/' \
                1879                                                 >> $DRESULTS/genmake_state
8188c8aec7 Jean*1880                 sed -n '/^THIS[A-Z]*=/p' $gmkLog >> $DRESULTS/genmake_state
497802755c Jean*1881             fi
c14ab91977 Jean*1882         fi
                1883     fi
0e6cc40375 Jean*1884     #postclean $dir/$builddir
bbea11a65d Jean*1885     if test "x$POSTCLEAN" = x2 ; then
6418c0ec62 Jean*1886         makeclean $dir/$builddir \
                1887             && run_clean $dir/$rundir
0e6cc40375 Jean*1888     fi
bbea11a65d Jean*1889     if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
9750e41317 Jean*1890 
6d54cf9ca1 Ed H*1891     echo "-------------------------------------------------------------------------------"
9750e41317 Jean*1892 
2ff82eb834 Ed H*1893 done
e05307b8c4 Jean*1894 grep '^HAVE_LAPACK' */$builddir/genmake_state 2> /dev/null \
                1895                         | head -1 >> $DRESULTS/genmake_state
2ff82eb834 Ed H*1896 
e53112a6cf Ed H*1897 printf "Start time:  " >> $SUMMARY
97166278cd Jean*1898 echo "$start_date" >> $SUMMARY
e53112a6cf Ed H*1899 printf "End time:    " >> $SUMMARY
e5e26554e5 Ed H*1900 date >> $SUMMARY
                1901 
002054e5e5 Ed H*1902 #  If addresses were supplied and mpack built successfully, then try
                1903 #  to send email using mpack.
                1904 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
                1905     echo "No results email was sent."
                1906 else
ee57712ddb Jean*1907     if test "x$SENDCMD" != x ; then
c908a600ca Jean*1908         sendOpt='' ; nb=`echo $SENDCMD | grep -c '\<scp\>'`
                1909         if [ $nb -eq 0 ] ; then sendOpt='-s MITgcm-test -m 3555000' ; fi
ee57712ddb Jean*1910         if [ $verbose -gt 1 ]; then
c908a600ca Jean*1911            echo " run: $SENDCMD $sendOpt ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESSES"
ee57712ddb Jean*1912         fi
                1913         tar -cf ${SAVDIR}/${DRESULTS}".tar" $DRESULTS > /dev/null 2>&1 \
                1914             && gzip ${SAVDIR}/${DRESULTS}".tar" \
c908a600ca Jean*1915             && $SENDCMD $sendOpt ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESSES
002054e5e5 Ed H*1916         RETVAL=$?
                1917         if test "x$RETVAL" != x0 ; then
                1918             echo
30f4fad812 Jean*1919             echo "Warning: The tar, gzip, & $SENDCMD step failed.  Please send email"
002054e5e5 Ed H*1920             echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
                1921             echo "  summary of results from the directory \"$DRESULTS\"."
                1922             echo
                1923         else
                1924             echo
                1925             echo "An email containing results was sent to the following addresses:"
                1926             echo "  \"$ADDRESSES\""
                1927             echo
ee57712ddb Jean*1928             test -f ${SAVDIR}/${DRESULTS}".tar" &&  rm -f ${SAVDIR}/${DRESULTS}".tar"
                1929             test -f ${SAVDIR}/${DRESULTS}".tar.gz" &&  rm -f ${SAVDIR}/${DRESULTS}".tar.gz"
002054e5e5 Ed H*1930         fi
                1931     fi
                1932 fi
                1933 
ca6d5f1072 Jean*1934 if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
                1935     rm -f tr_cmpnum.c tr_cmpnum
                1936 fi
2ff82eb834 Ed H*1937 
474019363f Ed H*1938 if test "x$CLEANUP" != xt ; then
3de6a095b5 Jean*1939     cat $SUMMARY | sed 's/ \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \. //'
54db3dc364 Ed H*1940     if test -e tr_out.txt ; then
6418c0ec62 Jean*1941         mv tr_out.txt tr_out.txt.old
5ac39639c8 Ed H*1942     fi
456c314cce Jean*1943     cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
474019363f Ed H*1944 fi
2ff82eb834 Ed H*1945 
384dccb29e Ed H*1946 if test "x$DELDIR" = xt ; then
                1947     rm -rf $DRESULTS
                1948 fi
13cadcbe59 Oliv*1949 
                1950 if test "$CHECK_PASS" = t && test "$allpass" = f; then
                1951     exit 1
                1952 fi
                1953 
122c9245be Jean*1954 echo "======== End of testreport execution ========"