--- MITgcm/verification/testreport 2011/08/19 22:24:26 1.166 +++ MITgcm/verification/testreport 2016/05/20 19:34:38 1.208 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.166 2011/08/19 22:24:26 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.208 2016/05/20 19:34:38 jmc Exp $ # $Name: $ # @@ -11,20 +11,23 @@ echo echo "where possible OPTIONS are:" echo " (-help|-h) print usage" + echo " ---- type of test : ----" + echo " (-tlm) perform a Tangent Linear run" + echo " (-adm|-ad) perform an adjoint run" + echo " (-oad) perform an OpenAD adjoint run" echo " (-mth) run multi-threaded (using eedata.mth)" echo " (-mpi) use MPI to compile and run on 2 processors" echo " (-MPI) NUMBER use MPI to compile and run on max NUMBER procs" echo " (-mfile|-mf) STRING MPI: file with list of possible machines to run on" + echo " (-command|-c) STRING command to run (e.g., if non-standard MPI setting)" + echo " DEF='mitgcmuv' or ='mpirun -np TR_NPROC mitgcmuv'" + echo " ---- testing options : ----" + echo " (-optfile|-of) STRING optfile to use" echo " (-fast) use optfile default for compiler flags (no '-ieee')" echo " DEF=off => use IEEE numerics option (if available)" echo " (-devel) use optfile developement flags (if available)" echo " (-gsl) compile with \"-gsl\" flag" echo " (-use_r4|-ur4) if allowed, use real*4 type for '_RS' variable" - echo " (-optfile|-of) STRING list of optfiles to use" - echo " (-addr|-a) STRING list of email recipients" - echo " (DEF=\"\" no email is sent)" - echo " (-mpackdir|-mpd) DIR location of the mpack utility" - echo " (DEF=\"../tools/mpack-1.6\")" echo " (-tdir|-t) STRING list of group and/or exp. dirs to test" echo " (recognized groups: basic, tutorials)" echo " (DEF=\"\" which test all)" @@ -32,23 +35,31 @@ echo " test THIS_EXP + all the following)" echo " (-skipdir|-skd) STRING list of exp. dirs to skip" echo " (DEF=\"\" which test all)" - echo " (-bash|-b) STRING preferred location of a \"bash\" or" - echo " Bourne-compatible \"sh\" shell" + echo " (-ts) provide timing information per timestep" + echo " (-papis) provide MFlop/s per timestep using PAPI" + echo " (-pcls) provide MFlop/s per timestep using PCL" + echo " ---- system options : ----" + echo " (-bash|-b) STRING preferred location of a \"bash\" or \"sh\" shell" echo " (DEF=\"\" for \"bash\")" - echo " (-adm|-ad) perform an adjoint run" - echo " (-oad) perform an OpenAD adjoint run" - echo " (-command|-c) STRING command to run" + echo " (-ef) STRING used as genmake2 \"-extra_flag\" argument" + echo " (-ncad) use genmake2 option \"-nocat4ad\" (-ncad)" + echo " (-small_f) make target small_f before making target all" echo " (-makedepend|-md) STRING command to use for \"makedepend\"" echo " (-make|-m) STRING command to use for \"make\"" echo " (DEF=\"make\")" - echo " (-odir) STRING used to build output directory name" - echo " (DEF=\"hostname\")" -# echo " (-ptracers|-ptr) STRING specify which ptracers to test" -# echo " (DEF=\"1 2 3 4 5\")" + echo " (-j) JOBS use \"make -j JOBS\" for parallel builds" + echo " ---- output options : ----" echo " (-match) NUMBER Matching Criteria (number of digits)" echo " (DEF=\"$MATCH_CRIT\")" - echo " (-j) JOBS use \"make -j JOBS\" for parallel builds" - echo " (-ef) STRING used as genmake2 \"-extra_flag\" argument" + echo " (-odir) STRING used to build output directory name" + echo " (DEF=\"hostname\")" + echo " (-addr|-a) STRING list of email recipients" + echo " (DEF=\"\" no email is sent)" + echo " (-send) STRING sending command (instead of using mpack)" + echo " (-savdir|-sd) STRING location to save output tar file to send (DEF='$SAVDIR')" + echo " (-mpackdir|-mpd) DIR location of the mpack utility" + echo " (DEF=\"../tools/mpack-1.6\")" + echo " -- do only some parts: --" echo " (-clean) *ONLY* run \"make CLEAN\" & clean run-dir" echo " (-norun|-nr) skip the \"runmodel\" stage (stop after make)" echo " (-obj) only produces objects (=norun & no executable)" @@ -60,9 +71,6 @@ echo " (-postclean|-pc) after each exp. test, clean build-dir & run-dir" echo " (-deloutp|-do) delete output files after successful run" echo " (-deldir|-dd) on success, delete the output directory" - echo " (-ts) provide timing information per timestep" - echo " (-papis) provide MFlop/s per timestep using PAPI" - echo " (-pcls) provide MFlop/s per timestep using PCL" echo echo "and where STRING can be a whitespace-delimited list" echo "such as:" @@ -117,66 +125,65 @@ # testoutput_var dir s1 label subdir reference_output # # compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE - # with same output from reference file $dir/results/$reference_output + # with same output from reference file $dir/$reference_output # using search strings s1 and text label if [ $debug -gt 0 ]; then echo testoutput_var: grep "$2" $1/$4/$OUTPUTFILE 1>&2 fi if [ -r $1/$4/$OUTPUTFILE ]; then - grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt - lncntA=`wc -l tmp1.txt | awk '{print $1}' ` + grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | nl > ${TMP}a.txt + lncntA=`wc -l ${TMP}a.txt | awk '{print $1}' ` if [ $lncntA -lt 2 ]; then if [ $verbose -gt 0 ]; then echo Not enough lines of output when searching for "$2" 1>&2 fi - return 99 + rm -f ${TMP}a.txt ; return 99 fi else echo testoutput_var: $OUTPUTFILE from model run was not readable 1>&2 return 99 fi if [ $debug -gt 0 ]; then - echo testoutput_var: grep "$2" $1/results/$5 1>&2 + echo testoutput_var: grep "$2" $1/$5 1>&2 fi - grep "$2" $1/results/$5 | sed 's/.*=//' | cat -n > tmp2.txt - lncntB=`wc -l tmp2.txt | awk '{print $1}' ` + grep "$2" $1/$5 | sed 's/.*=//' | nl > ${TMP}b.txt + lncntB=`wc -l ${TMP}b.txt | awk '{print $1}' ` if [ $lncntB -lt 2 ]; then if [ $verbose -gt 0 ]; then echo Not enough lines of output when searching for "$2" 1>&2 fi - return 99 + rm -f ${TMP}a.txt ${TMP}b.txt ; return 99 fi if [ $lncntA -ne $lncntB ]; then - if [ $verbose -gt 0 ]; then - echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2 - fi - return 99 + if [ $verbose -gt 0 ]; then + echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2 + fi + rm -f ${TMP}a.txt ${TMP}b.txt ; return 99 fi - has_nan=`cat tmp1.txt | grep -i nan | wc -l` + has_nan=`cat ${TMP}a.txt | grep -i nan | wc -l` if [ $has_nan -gt 0 ] ; then echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values 1>&2 - return 99 + rm -f ${TMP}a.txt ${TMP}b.txt ; return 99 fi - has_inf=`cat tmp1.txt | grep -i inf | wc -l` + has_inf=`cat ${TMP}a.txt | grep -i inf | wc -l` if [ $has_inf -gt 0 ] ; then echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values 1>&2 - return 99 + rm -f ${TMP}a.txt ${TMP}b.txt ; return 99 fi if [ $debug -gt 0 ]; then - echo testoutput_var: join tmp1.txt tmp2.txt 1>&2 + echo testoutput_var: join ${TMP}a.txt ${TMP}b.txt 1>&2 fi - join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt + # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number + join ${TMP}a.txt ${TMP}b.txt | awk '{print $1 " " $2 " " $3}' | sed -e 's|:||g' > ${TMP}c.txt if [ $debug -gt 0 ]; then echo testoutput_var: compare_lines 1>&2 fi if [ $verbose -gt 1 ]; then - cat tmp3.txt 1>&2 + cat ${TMP}c.txt 1>&2 fi - echo "-1" >> tmp3.txt - # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number - cat tmp3.txt | sed -e 's|:||g' > tmp4.txt - digits_of_similarity=`./tr_cmpnum < tmp4.txt` + echo "-1" >> ${TMP}c.txt + digits_of_similarity=`./tr_cmpnum < ${TMP}c.txt` if [ $digits_of_similarity -eq 99 ]; then if [ $verbose -gt 0 ]; then echo testoutput_var: No comparison was available for \"$3\" 1>&2 @@ -187,7 +194,7 @@ echo There were $digits_of_similarity decimal places of similarity for \"$3\" 1>&2 fi fi - rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt + rm -f ${TMP}a.txt ${TMP}b.txt ${TMP}c.txt return $digits_of_similarity } @@ -198,117 +205,160 @@ # # test output from 1 run in "directory" # --> same processing for adjoint & forward test - # default list of output variables to be checked: - # 1rst : main variable used to decide if it pass or FAIL - # others : number of matching digits to be printed in summary.txt - listChk=$DEF_CHECK_LIST + # default list of output variables to be checked: + # 1rst : main variable used to decide if it pass or FAIL + # others : number of matching digits to be printed in summary.txt + listChk=$DEF_CHECK_LIST # load experiment-specific list from file "tr_checklist" (if it exist) - if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi - sVar=`echo $listChk | awk '{print $1}'` - # remove 1rst var and expand the list: + => min max mean s.d - listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \ - | sed 's/+//g' | sed "s/^$sVar//"` + if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi + sVar=`echo $listChk | awk '{print $1}'` + # remove 1rst var and expand the list: + => min max mean s.d + listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \ + | sed 's/+//g' | sed "s/^$sVar//"` if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(I)='$listVar'" 1>&2 ; fi - # check for ptracer output in reference_output file : - outpref=$1/results/$3 - ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max" - ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd" - for ii in $PTRACERS_NUM ; do + # set ref.outp file-name and, if compressed, uncompress it into subdir + refoutp=results/$3 + if test ! -r $1/results/$3 ; then + if test -r $1/results/${3}.gz ; then + tmpNam1=$3 + tmpNam2=`echo $tmpNam1 | sed 's/\..*\././'` + if test "x$tmpNam1" = "x$tmpNam2" ; then + tmpNam1=`echo $tmpNam2 | sed 's/\./.std./'` + fi + refoutp=$2/$tmpNam1 + if [ $debug -gt 0 ]; then + echo "testoutput_run: gunzip 'results/$3.gz' into '$refoutp'" 1>&2 + fi + gzip -cd $1/results/${3}.gz > $1/$refoutp + else + echo "missing reference output file '$3' (.gz) in '$1/results/'" + fi + fi + # check for ptracer output in reference_output file : + if test $KIND = 0 ; then + ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max" + ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd" + for ii in $PTRACERS_NUM ; do ptrfound=0 for jj in $ptr_mon ; do name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"` - tst=`grep $name $outpref | wc -l | awk '{print $1}'` + tst=`grep $name $1/$refoutp | wc -l | awk '{print $1}'` if test ! "x$tst" = x0 ; then ptrfound=1 ; fi done if test $ptrfound = '1' ; then eval "HAVE_PTR0"$ii"=t" else eval "HAVE_PTR0"$ii"=f" - if test "x$ADM" = x -a "x$OADM" = x; then # remove this ptr from the list of output variable to check # echo "-- ptr test=" $tst "number of var=" `echo $listVar | awk '{print NF}'` 1>&2 listVar=`echo "$listVar" | sed "s/ pt$ii..//g"` - fi fi - # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2 - done - tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'` - if test $tst != 1 ; then - if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2 - else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi - echo "==> WARNING: in checked list:" $listVar 1>&2 - #- put it back once: - listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"` - fi + # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2 + done + fi + tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'` + if test $tst != 1 ; then + if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2 + else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi + echo "==> WARNING: in checked list:" $listVar 1>&2 + #- put it back once: + listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"` + fi if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(M)='$listVar'" 1>&2 ; fi echo "listVar='$listVar'" >> $locDIR"/summary.txt" - #--- - allargs="" - for xx in $listVar - do - case $xx in + #--- + allargs="" + for xx in $listVar + do + #ii=`echo $xx | sed 's/^pt[0-9][0-9]*..$/XXX/'` #- any ptr number + ii=`echo $xx | sed 's/^pt[1-9]..$/XXX/'` #- 1 to 9 ptr number + if test $ii != 'XXX' ; then + #- all except ptracer stats: + case $xx in 'PS') if [ $debug -gt 0 ] then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi - testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $3; yy=$? + testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $refoutp ; yy=$? if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;; - 'Cost') testoutput_var $1 "ADM precision_derivative_cost" "ADM Cost" $2 $3; yy=$? ;; - 'Grad') testoutput_var $1 "ADM precision_derivative_grad" "ADM Grad" $2 $3; yy=$? ;; - 'Tmn') testoutput_var $1 "dynstat_theta_min" "Theta minimum" $2 $3; yy=$? ;; - 'Tmx') testoutput_var $1 "dynstat_theta_max" "Theta maximum" $2 $3; yy=$? ;; - 'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean" $2 $3; yy=$? ;; - 'Tsd') testoutput_var $1 "dynstat_theta_sd" "Theta Std.Dev" $2 $3; yy=$? ;; - 'Smn') testoutput_var $1 "dynstat_salt_min" "Salt minimum" $2 $3; yy=$? ;; - 'Smx') testoutput_var $1 "dynstat_salt_max" "Salt maximum" $2 $3; yy=$? ;; - 'Sav') testoutput_var $1 "dynstat_salt_mean" "Salt mean" $2 $3; yy=$? ;; - 'Ssd') testoutput_var $1 "dynstat_salt_sd" "Salt Std.Dev" $2 $3; yy=$? ;; - 'Umn') testoutput_var $1 "dynstat_uvel_min" "U minimum" $2 $3; yy=$? ;; - 'Umx') testoutput_var $1 "dynstat_uvel_max" "U maximum" $2 $3; yy=$? ;; - 'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean" $2 $3; yy=$? ;; - 'Usd') testoutput_var $1 "dynstat_uvel_sd" "U Std.Dev" $2 $3; yy=$? ;; - 'Vmn') testoutput_var $1 "dynstat_vvel_min" "V minimum" $2 $3; yy=$? ;; - 'Vmx') testoutput_var $1 "dynstat_vvel_max" "V maximum" $2 $3; yy=$? ;; - 'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean" $2 $3; yy=$? ;; - 'Vsd') testoutput_var $1 "dynstat_vvel_sd" "V Std.Dev" $2 $3; yy=$? ;; - 'pt1mn'|'pt2mn'|'pt3mn'|'pt4mn'|'pt5mn') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'` - testoutput_var $1 "trcstat_ptracer0"$ii"_min" "p0"$ii"_min" $2 $3; yy=$? ;; - 'pt1mx'|'pt2mx'|'pt3mx'|'pt4mx'|'pt5mx') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'` - testoutput_var $1 "trcstat_ptracer0"$ii"_max" "p0"$ii"_max" $2 $3; yy=$? ;; - 'pt1av'|'pt2av'|'pt3av'|'pt4av'|'pt5av') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'` - testoutput_var $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $3; yy=$? ;; - 'pt1sd'|'pt2sd'|'pt3sd'|'pt4sd'|'pt5sd') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'` - testoutput_var $1 "trcstat_ptracer0"$ii"_sd" "p0"$ii"_StDv" $2 $3; yy=$? ;; - 'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum" $2 $3; yy=$? ;; - 'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum" $2 $3; yy=$? ;; - 'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean" $2 $3; yy=$? ;; - 'Qntsd') testoutput_var $1 "forcing_qnet_sd" "Qnet Std.Dev" $2 $3; yy=$? ;; - 'aSImn') testoutput_var $1 "seaice_area_min" "SIce Area min" $2 $3; yy=$? ;; - 'aSImx') testoutput_var $1 "seaice_area_max" "SIce Area max" $2 $3; yy=$? ;; - 'aSIav') testoutput_var $1 "seaice_area_mean" "SIce Area mean" $2 $3; yy=$? ;; - 'aSIsd') testoutput_var $1 "seaice_area_sd" "SIce Area StDv" $2 $3; yy=$? ;; - 'hSImn') testoutput_var $1 "seaice_heff_min" "SIce Heff min" $2 $3; yy=$? ;; - 'hSImx') testoutput_var $1 "seaice_heff_max" "SIce Heff max" $2 $3; yy=$? ;; - 'hSIav') testoutput_var $1 "seaice_heff_mean" "SIce Heff mean" $2 $3; yy=$? ;; - 'hSIsd') testoutput_var $1 "seaice_heff_sd" "SIce Heff StDv" $2 $3; yy=$? ;; - 'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $3; yy=$? ;; - 'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South" $2 $3; yy=$? ;; - 'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North" $2 $3; yy=$? ;; - 'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Global" $2 $3; yy=$? ;; - 'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South" $2 $3; yy=$? ;; - 'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North" $2 $3; yy=$? ;; - *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;; - esac - if test $xx = $sVar - then allargs="$allargs > $yy <" - else allargs="$allargs $yy" + 'Cost') testoutput_var $1 "ADM ref_cost_function" "ADM CostFct" $2 $refoutp ; yy=$? ;; + 'AdGrd') testoutput_var $1 "ADM adjoint_gradient" "ADM Ad Grad" $2 $refoutp ; yy=$? ;; + 'FDGrd') testoutput_var $1 "ADM finite-diff_grad" "ADM FD Grad" $2 $refoutp ; yy=$? ;; + 'tlmCst') testoutput_var $1 "TLM ref_cost_function" "TLM CostFct" $2 $refoutp ; yy=$? ;; + 'tlmGrd') testoutput_var $1 "TLM tangent-lin_grad" "TLM TL Grad" $2 $refoutp ; yy=$? ;; + 'fwdGrd') testoutput_var $1 "TLM finite-diff_grad" "TLM FD Grad" $2 $refoutp ; yy=$? ;; + 'Tmn') testoutput_var $1 "dynstat_theta_min" "Theta minimum" $2 $refoutp ; yy=$? ;; + 'Tmx') testoutput_var $1 "dynstat_theta_max" "Theta maximum" $2 $refoutp ; yy=$? ;; + 'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean" $2 $refoutp ; yy=$? ;; + 'Tsd') testoutput_var $1 "dynstat_theta_sd" "Theta Std.Dev" $2 $refoutp ; yy=$? ;; + 'Smn') testoutput_var $1 "dynstat_salt_min" "Salt minimum" $2 $refoutp ; yy=$? ;; + 'Smx') testoutput_var $1 "dynstat_salt_max" "Salt maximum" $2 $refoutp ; yy=$? ;; + 'Sav') testoutput_var $1 "dynstat_salt_mean" "Salt mean" $2 $refoutp ; yy=$? ;; + 'Ssd') testoutput_var $1 "dynstat_salt_sd" "Salt Std.Dev" $2 $refoutp ; yy=$? ;; + 'Umn') testoutput_var $1 "dynstat_uvel_min" "U minimum" $2 $refoutp ; yy=$? ;; + 'Umx') testoutput_var $1 "dynstat_uvel_max" "U maximum" $2 $refoutp ; yy=$? ;; + 'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean" $2 $refoutp ; yy=$? ;; + 'Usd') testoutput_var $1 "dynstat_uvel_sd" "U Std.Dev" $2 $refoutp ; yy=$? ;; + 'Vmn') testoutput_var $1 "dynstat_vvel_min" "V minimum" $2 $refoutp ; yy=$? ;; + 'Vmx') testoutput_var $1 "dynstat_vvel_max" "V maximum" $2 $refoutp ; yy=$? ;; + 'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean" $2 $refoutp ; yy=$? ;; + 'Vsd') testoutput_var $1 "dynstat_vvel_sd" "V Std.Dev" $2 $refoutp ; yy=$? ;; + 'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum" $2 $refoutp ; yy=$? ;; + 'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum" $2 $refoutp ; yy=$? ;; + 'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean" $2 $refoutp ; yy=$? ;; + 'Qntsd') testoutput_var $1 "forcing_qnet_sd" "Qnet Std.Dev" $2 $refoutp ; yy=$? ;; + 'aSImn') testoutput_var $1 "seaice_area_min" "SIce Area min" $2 $refoutp ; yy=$? ;; + 'aSImx') testoutput_var $1 "seaice_area_max" "SIce Area max" $2 $refoutp ; yy=$? ;; + 'aSIav') testoutput_var $1 "seaice_area_mean" "SIce Area mean" $2 $refoutp ; yy=$? ;; + 'aSIsd') testoutput_var $1 "seaice_area_sd" "SIce Area StDv" $2 $refoutp ; yy=$? ;; + 'hSImn') testoutput_var $1 "seaice_heff_min" "SIce Heff min" $2 $refoutp ; yy=$? ;; + 'hSImx') testoutput_var $1 "seaice_heff_max" "SIce Heff max" $2 $refoutp ; yy=$? ;; + 'hSIav') testoutput_var $1 "seaice_heff_mean" "SIce Heff mean" $2 $refoutp ; yy=$? ;; + 'hSIsd') testoutput_var $1 "seaice_heff_sd" "SIce Heff StDv" $2 $refoutp ; yy=$? ;; + 'uSImn') testoutput_var $1 "seaice_uice_min" "SIce Uice min" $2 $refoutp ; yy=$? ;; + 'uSImx') testoutput_var $1 "seaice_uice_max" "SIce Uice max" $2 $refoutp ; yy=$? ;; + 'uSIav') testoutput_var $1 "seaice_uice_mean" "SIce Uice mean" $2 $refoutp ; yy=$? ;; + 'uSIsd') testoutput_var $1 "seaice_uice_sd" "SIce Uice StDv" $2 $refoutp ; yy=$? ;; + 'vSImn') testoutput_var $1 "seaice_vice_min" "SIce Vice min" $2 $refoutp ; yy=$? ;; + 'vSImx') testoutput_var $1 "seaice_vice_max" "SIce Vice max" $2 $refoutp ; yy=$? ;; + 'vSIav') testoutput_var $1 "seaice_vice_mean" "SIce Vice mean" $2 $refoutp ; yy=$? ;; + 'vSIsd') testoutput_var $1 "seaice_vice_sd" "SIce Vice StDv" $2 $refoutp ; yy=$? ;; + 'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $refoutp ; yy=$? ;; + 'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South" $2 $refoutp ; yy=$? ;; + 'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North" $2 $refoutp ; yy=$? ;; + 'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Glob-ave" $2 $refoutp ; yy=$? ;; + 'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South-av" $2 $refoutp ; yy=$? ;; + 'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North-av" $2 $refoutp ; yy=$? ;; + 'HthMxS') testoutput_var $1 "thSI_IceH_max_S" "thSIc H South-max" $2 $refoutp ; yy=$? ;; + 'HthMxN') testoutput_var $1 "thSI_IceH_max_N" "thSIc H North-max" $2 $refoutp ; yy=$? ;; + 'sbo_M') testoutput_var $1 "sbo_mass" "SBO mass" $2 $refoutp ; yy=$? ;; + 'sboFW') testoutput_var $1 "sbo_mass_fw" "SBO m-FW" $2 $refoutp ; yy=$? ;; + 'sboAc') testoutput_var $1 "sbo_zoamc" "SBO AM-C" $2 $refoutp ; yy=$? ;; + 'sboAp') testoutput_var $1 "sbo_zoamp" "SBO AM-P" $2 $refoutp ; yy=$? ;; + 'StrmIc') testoutput_var $1 "STREAMICE_FP_ERR" "StreamIce Solver" $2 $refoutp ; yy=$? ;; + *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;; + esac + else + #- ptracers stats: + nn=`echo $xx | sed 's/pt//' | sed 's/..$//'` + ii=`echo $xx | sed 's/^pt[0-9]*//'` + case $ii in + 'mn') testoutput_var $1 "trcstat_ptracer0"$nn"_min" "p0"$nn"_min" $2 $refoutp ; yy=$? ;; + 'mx') testoutput_var $1 "trcstat_ptracer0"$nn"_max" "p0"$nn"_max" $2 $refoutp ; yy=$? ;; + 'av') testoutput_var $1 "trcstat_ptracer0"$nn"_mean" "p0"$nn"_mean" $2 $refoutp ; yy=$? ;; + 'sd') testoutput_var $1 "trcstat_ptracer0"$nn"_sd" "p0"$nn"_StDv" $2 $refoutp ; yy=$? ;; + esac fi - done + if test $xx = $sVar + then allargs="$allargs > $yy <" + else allargs="$allargs $yy" + fi + done nbVar=`echo $listVar | awk '{print NF}'` - if [ $nbVar -lt $LEN_CHECK_LIST ] ; then - #-- fill line (up to standard length) with dot: - adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'` + if [ $nbVar -lt $LEN_CHECK_LIST ] ; then + #-- fill line (up to standard length) with dot: + adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'` echo $allargs $adNul - else + else echo $allargs fi # <-- same processing for adjoint & forward test @@ -331,19 +381,17 @@ if test "x$MKDEPEND" != x ; then command="$command -makedepend=$MKDEPEND" fi - if test "x$ADM" = xt ; then - command="$command --mods=../code_ad" - elif test "x$OADM" = xt ; then - command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods '../code_oad ../../OpenAD/code_oad_all'" + if test $KIND = 4 ; then + command="$command -oad -mods=../$code_dir" else - command="$command -mods=../code" + command="$command -mods=../$code_dir" fi if test "x$OPTFILE" != xNONE ; then command="$command -optfile=$OPTFILE" fi if test $OptLev = 1 ; then - command="$command -ieee" - fi + command="$command -ieee" + fi if test $OptLev = 0 ; then command="$command -devel" fi @@ -363,6 +411,9 @@ if test "x$EXTRFLG" != x ; then command="$command -extra_flag $EXTRFLG" fi + if test "x$NOCATAD" = xt ; then + command="$command -nocat4ad" + fi if test "x$TS" = xt ; then command="$command -ts" fi @@ -393,7 +444,7 @@ makeclean() { # makeclean directory - if test "x$NODEPEND" = xf ; then rm -f $1/make.tr_log ; fi + if test "x$NOGENMAKE" = xf ; then rm -f $1/make.tr_log ; fi if test "x$NOCLEAN" = xt ; then echo "make Clean skipped!" else @@ -425,21 +476,23 @@ if test "x$NOCLEAN" = xt ; then echo "run_clean skipped!" else - ( - cd $1; - printf 'clean run-dir ... ' - # part of what is done after "make clean" when doing "make CLEAN" - find . -name "*.meta" -exec rm {} \; - find . -name "*.data" -exec rm {} \; - find . -name "fort.*" -exec rm {} \; - find . -type l -exec rm {} \; - #- should remove executable only if sym-link (alredy done above) - rm -f $RUNLOG *.txt STD* *diagnostics.log datetime - rm -rf mnc_test_* - rm -f *_MIT_CE_000.opt0000 costfunction*0000 - echo successful - exit 0 - ) + ( + cd $1; + printf 'clean run-dir ... ' + # part of what is done after "make clean" when doing "make CLEAN" + find . -name "*.meta" -exec rm {} \; + find . -name "*.data" -exec rm {} \; + find . -name "fort.*" -exec rm {} \; + find . -type l -exec rm {} \; + #- should remove executable only if sym-link (already done above) + rm -f $RUNLOG *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log + rm -f datetime costfinal divided.ctrl snapshot* output_adm.*.diva_* + rm -f *_MIT_CE_000.opt0000 costfunction*0000 + rm -f oad_cp.[0-9][0-9][0-9].????? + rm -rf mnc_test_* + echo successful + exit 0 + ) fi } @@ -482,18 +535,23 @@ else cd $1; if test -r Makefile ; then - printf 'make ... ' - if test "x$ADM" = xt ; then - $MAKE adall >> make.tr_log 2>&1 - elif test "x$OADM" = xt ; then - $MAKE adAll >> make.tr_log 2>&1 - else - if test "x$JOBS" = x ; then - $MAKE $TARG >> make.tr_log 2>&1 + if test "x$MKSMALLF" = xt ; then + printf 'make small_f ... ' + $MAKE_CMD small_f >> make.tr_log 2>&1 + RETVAL=$? + if test "x$RETVAL" != x0 ; then + tail make.tr_log + echo failed + cp genmake.log genmake.tr_log $CDIR + tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail" + rm -f $EXECUTABLE + mk_fail=1 else - $MAKE -j $JOBS $TARG >> make.tr_log 2>&1 + echo successful fi fi + printf 'make ... ' + $MAKE_CMD $TARG >> make.tr_log 2>&1 RETVAL=$? if test "x$RETVAL" != x0 ; then tail make.tr_log @@ -510,11 +568,19 @@ mk_fail=2 fi fi - if test "x$ADM" = xt -a -f taf_ad.log ; then - head -1 taf_ad.log >> $CDIR"/summary.txt" - nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log` - nwar=`grep -c 'TAF RECOMPUTATION *.* WARNING ' taf_ad.log` - echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \ + if test $KIND = 1 -a -f taf_ftl.log ; then + head -1 taf_ftl.log >> $CDIR"/summary.txt" + fi + if test $KIND = 2 -a -f taf_ad.log ; then + head -1 taf_ad.log >> $CDIR"/summary.txt" + nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log` + nwar=`grep -c 'TAF RECOMPUTATION *.* WARNING ' taf_ad.log` + if test -f taf_output ; then + n2er=`grep -c 'TAF *.* ERROR ' taf_output` + n3er=`grep -c '\*ERROR\* ' taf_output` + nerr=`expr $nerr + $n2er + $n3er` + fi + echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \ >> $CDIR"/summary.txt" fi if test $mk_fail != 0 ; then return $mk_fail ; fi @@ -523,31 +589,54 @@ mk_mpi_size() { - # mk_mpi_size input_file output_file proc_Nb prefer_to_split_X + # mk_mpi_size input_file output_file proc_Nb threads_Nb_X threads_Nb_Y # - # make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file) + # make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file) # for an MPI build with no more than proc_Nb processors ; - # return the effective number of processors. + # ensure that enough tiles per proc (nSx,nSy) remain for the given + # number of threads (nTx,nTy) ; + # return the effective number of processors. inp=$1 out=$2 np=$3 - dirX=$4 + tx=$4 + ty=$5 tmp=TTT.$$ + # dirX : select with direction to favor in MPI process repartition + # dirX=1 : prefer to put more proc in X direction + # dirX=0 : prefer to put more proc in Y direction + dirX=0 + px=`grep "^ & *nPx *=" $inp | sed "s/^ & *nPx *= *//" | sed 's/, *$//'` py=`grep "^ & *nPy *=" $inp | sed "s/^ & *nPy *= *//" | sed 's/, *$//'` sx=`grep "^ & *nSx *=" $inp | sed "s/^ & *nSx *= *//" | sed 's/, *$//'` sy=`grep "^ & *nSy *=" $inp | sed "s/^ & *nSy *= *//" | sed 's/, *$//'` + #- for each direction, assume # of threads is a multiple of total number of tiles + nx=$px + if [ `expr $sx % $tx` -ne 0 -a `expr $sx \* $px % $tx` -eq 0 ] ; then + nx=`expr $sx \* $px / $tx` + if [ $verbose -gt 1 ]; then + echo " change px from $px to $nx to accommodate $tx threads" + fi + fi + ny=$py + if [ `expr $sy % $ty` -ne 0 -a `expr $sy \* $py % $ty` -eq 0 ] ; then + ny=`expr $sy \* $py / $ty` + if [ $verbose -gt 1 ]; then + echo " change py from $py to $ny to accommodate $ty threads" + fi + fi #- find the largest divisor of input_file proc Nb, but not larger than $np pp=0 i=1 - while [ $i -le $px ] ; do - if [ `expr $px % $i` -eq 0 ] ; then + while [ $i -le $nx ] ; do + if [ `expr $nx % $i` -eq 0 ] ; then j=1 - while [ $j -le $py ] ; do - if [ `expr $py % $j` -eq 0 ] ; then + while [ $j -le $ny ] ; do + if [ `expr $ny % $j` -eq 0 ] ; then ij=`expr $i \* $j` if [ $ij -gt $pp ] ; then flag=1 @@ -640,10 +729,10 @@ ( cd $1 ; shift echo 'linkdata from dirs:' $* - inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')` + inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')` for xx in $inpMPI ; do if test -r "../"$1"/"$xx ; then - # found 1 _mpi sfx file in 1rst input dir and it is readable + # found 1 _mpi sfx file in 1rst input dir and it is readable yy=`echo $xx | sed 's:\.mpi$::'` if test "x$MPI" = "x0" ; then # not mpi test: remove symbolic link @@ -675,7 +764,7 @@ prevDir='NONE' for ldir in $* ; do if test -d "../"$ldir -a $ldir != $prevDir ; then - printf " ldir=${ldir}:" 1>&2 + printf " ldir=${ldir}:" 1>&2 files=`( cd "../"$ldir ; ls -1 | grep -v CVS )` for i in $files ; do if test ! -d "../"$ldir/$i ; then @@ -710,7 +799,7 @@ if test "x$MPI" != x0 ; then #- adjust the MPI run command with the right number of Procs #echo '' ; echo " COMMAND='$COMMAND'" - COMMAND=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"` + COMMAND=`echo $COMMAND | sed "s/ TR_NPROC/ $LOC_NPROC/"` if test "x$MPI_MFILE" != x ; then COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"` fi @@ -723,21 +812,38 @@ else rm -f $EXECUTABLE fi fi - if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then + if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp ln -sf "../"$builddir"/"$EXECUTABLE . fi - if test ! -x $EXECUTABLE ; then + if test ! -x $EXECUTABLE ; then rm -f $RUNLOG ; touch $RUNLOG if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi echo " no executable:" $EXECUTABLE >> $RUNLOG RETVAL=8 ENDVAL=-1 else - if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then - # output do not exist or is older than executable: + if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then + # output do not exist or is older than executable: rm -f $OUTPUTFILE $RUNLOG ; touch $RUNLOG if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi + #- Divided Adjoint Run: + # get the number of additional runs (add_DIVA_runs) from file "run_ADM_DIVA" + if test $KIND = 2 -a -f run_ADM_DIVA ; then + adm_diva_nb=`sed -n '/^ *add_DIVA_runs\>.*=/p' run_ADM_DIVA | sed 's/ //g'` + echo " Divided Adjoint Run: $adm_diva_nb" >> $RUNLOG + eval "let $adm_diva_nb" + if [ $add_DIVA_runs -ge 1 ] ; then + rm -f costf* divided.ctrl snapshot* + echo -n "(add_DIVA_runs=$add_DIVA_runs) ... " + for ii in `seq 1 $add_DIVA_runs` ; do + ( eval $COMMAND ) >> $RUNLOG 2>&1 + echo " additional DIVA run # $ii : done" >> $RUNLOG + mv -f $OUTPUTFILE ${OUTPUTFILE}.diva_${ii} + done + fi + fi + #- special DIVA processing ends here ( eval $COMMAND ) >> $RUNLOG 2>&1 RETVAL=$? ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'` @@ -751,17 +857,23 @@ ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'` touch $RUNLOG if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi - echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1 + echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1 fi fi rm -f run.log_tmp - #- in all cases where OutputFile exists, report SIZE (and AD time) + #- in all cases where OutputFile exists, report SIZE and time if test -f $OUTPUTFILE ; then grep '(PID\.TID 0000\.0001) n.. =' $OUTPUTFILE \ - | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt" - if test "x$ADM" = xt ; then - grep -A3 'Seconds in section "ALL' $OUTPUTFILE >> $CDIR"/summary.txt" - fi + | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt" +# grep -A3 'Seconds in section "ALL' $OUTPUTFILE \ +# | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt" +# some implementations of grep cannot do contextual searches so we +# replace the above with a sed command + cat $OUTPUTFILE | sed -n '/Seconds in section "ALL/{N + N + N + p + }' | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt" fi if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then @@ -863,6 +975,13 @@ fi fi printf ' %s' $nm + if test $KIND = 2 ; then + #-- apppend taf repport summary: + tafrep=`grep -c '^ TAF reports ' $CDIR/summary.txt` + if test $tafrep = 1 ; then + grep '^ TAF reports ' $CDIR/summary.txt | awk '{printf " (e=%i, w=%i)",$3,$6}' + fi + fi printf '\n' } @@ -871,7 +990,8 @@ { if [ $# -eq 1 ]; then for arg in * ; do - test -f $arg/$1 && echo $arg + #test -f $arg/$1 && echo $arg + test -f $arg/$1 -o -f $arg/$1.gz && echo $arg done else echo $* @@ -927,10 +1047,6 @@ verbose=1 NBLINES_MKLOG=16000 -IEEE=true -if test "x$MITGCM_IEEE" != x ; then - IEEE=$MITGCM_IEEE -fi OptLev=1 GSL=f @@ -951,11 +1067,14 @@ MPACKDIR="../tools/mpack-1.6" HAVE_MPACK= MPACK= +SENDCMD= +SAVDIR='.' COMMAND= MKDEPEND= if test "x$MAKE" = x ; then MAKE=make fi +MAKE_CMD= if test "x$CC" = x ; then CC=cc fi @@ -968,9 +1087,13 @@ DELDIR= USE_R4= EXTRFLG= +NOCATAD= +MKSMALLF= -ADM= -OADM= +#- type of testing (KIND): +# KIND=0 : forward (= default) ; KIND=1 : Tangent Linear with TAF ; +# KIND=2 : Adjoint with TAF ; KIND=4 : Adjoint with OpenAD +KIND=0 # list of pTracers to check for monitor output PTRACERS_NUM="1 2 3 4 5" @@ -1003,6 +1126,11 @@ -mpackdir | --mpackdir | -mpd | --mpd) ac_prev=MPACKDIR ;; -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*) MPACKDIR=$ac_optarg ;; + -send | --send ) ac_prev=SENDCMD ;; + -send=* | --send=* ) SENDCMD=$ac_optarg ;; + -savdir | --savdir | -sd | --sd ) ac_prev=SAVDIR ;; + -savdir=* | --savdir=* | -sd=* | --sd=* ) SAVDIR=$ac_optarg ;; + -tdir | --tdir | -t | --t) ac_prev=TESTDIRS ;; -tdir=* | --tdir=* | -t=* | --t=*) TESTDIRS=$ac_optarg ;; -skipdir | --skipdir | -skd | --skd) ac_prev=SKIPDIRS ;; @@ -1020,6 +1148,9 @@ -make | --make | -m | --m) ac_prev=MAKE ;; -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;; + -repl_mk | --repl_mk ) ac_prev=MAKE_CMD ;; + -repl_mk=* | --repl_mk=*) MAKE_CMD=$ac_optarg ;; + -odir | --odir) ac_prev=OUTDIR ;; -odir=* | --odir=*) OUTDIR=$ac_optarg ;; @@ -1057,13 +1188,22 @@ -mth) MULTI_THREAD=t ;; - -adm | -ad) ADM=t ;; - -oad) OADM=t; NODEPEND=t ;; + -tlm) if test $KIND = 0 ; then KIND=1 ; else + echo "Error: '-tlm', '-adm' and '-oad' are exclusive" ; usage + fi ;; + -adm | -ad) if test $KIND = 0 ; then KIND=2 ; else + echo "Error: '-tlm', '-adm' and '-oad' are exclusive" ; usage + fi ;; + -oad) if test $KIND = 0 ; then KIND=4 ; NODEPEND=t ; else + echo "Error: '-tlm', '-adm' and '-oad' are exclusive" ; usage + fi ;; + -ncad) NOCATAD=t ;; + -small_f) MKSMALLF=t ;; -ieee) echo "Warning: ignore option '-ieee' (already the default)" - printf " ... " ;; + printf " ... " ;; -noieee) echo "Warning: will use option '-fast' instead of '-noieee' (obsolete)" - printf " ... " ; OptLev=`expr $OptLev \* 2` ;; + printf " ... " ; OptLev=`expr $OptLev \* 2` ;; -fast) OptLev=`expr $OptLev \* 2` ;; -devel) OptLev=0 ;; -gsl) GSL=t ;; @@ -1078,7 +1218,7 @@ -ts) TS=t;; -papis) PAPIS=t;; - -pcls) PCL=t;; + -pcls) PCLS=t;; -*) echo "Error: unrecognized option: "$ac_option usage ;; @@ -1094,31 +1234,40 @@ NOCLEAN=t NODEPEND=t fi +if test "x$MAKE_CMD" = x ; then MAKE_CMD=$MAKE ; fi #- check length of MPI machine file: if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then if test -r $MPI_MFILE ; then nl=`wc -l $MPI_MFILE | awk '{print $1}'` if [ $nl -lt $MPI ] ; then - echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE" - usage + echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE" + usage fi if [ $verbose -gt 1 ]; then echo " MPI_MFILE=$MPI_MFILE : $nl procs for MPI=$MPI run" fi else - echo "Error: cannot access MPI_MFILE=$MPI_FILE" - usage + echo "Error: cannot access MPI_MFILE=$MPI_FILE" + usage fi fi #- setting for forward or ADM testing -if test "x$ADM" = xt ; then +if test $KIND = 1 ; then + TARG=ftlall + code_dir=code_ad + inputdir=input_ad + ref_outp="output_tlm.txt" + EXECUTABLE="mitgcmuv_ftl" +elif test $KIND = 2 ; then + if test "x$TARG" = xobj ; then TARG=adobj ; else TARG=adall ; fi code_dir=code_ad inputdir=input_ad ref_outp="output_adm.txt" EXECUTABLE="mitgcmuv_ad" -elif test "x$OADM" = xt ; then +elif test $KIND = 4 ; then + TARG=adAll code_dir=code_oad inputdir=input_oad ref_outp="output_oadm.txt" @@ -1129,6 +1278,7 @@ ref_outp="output.txt" EXECUTABLE="mitgcmuv" fi +if test "x$JOBS" != x ; then TARG="-j $JOBS $TARG" ; fi xx=`echo $TESTDIRS | awk '{print $1}'` if test "x$TESTDIRS" = x ; then @@ -1167,7 +1317,7 @@ echo ""; echo -n " -- skip \"$xx\" (not a directory !)" fi else - if test $count = 1 ; then echo -n ", \"$xx\"" + if test $count = 1 ; then echo -n ", \"$xx\"" else count=1 ; echo "" ; echo -n " skip: \"$xx\"" fi fi @@ -1175,59 +1325,75 @@ if test $count = 1 ; then echo "" ; echo -n " ... " ; fi #echo 'TESTDIRS='${TESTDIRS}'<' -if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then - OPTFILE=$MITGCM_OF -fi - LOC_MFILE='tr_mpi_mfile' RUNLOG="run.tr_log" -OUTPUTFILE=$ref_outp -if test "x$COMMAND" = x ; then - COMMAND="./$EXECUTABLE > $OUTPUTFILE" -fi -if test "x$MPI" != x0 ; then - OUTPUTFILE="STDOUT.0000" +if test "x$MPI" = x0 ; then + OUTPUTFILE=$ref_outp + if test "x$COMMAND" = x ; then COMMAND="./$EXECUTABLE > $OUTPUTFILE" ; fi +else + OUTPUTFILE="STDOUT.0000" + if test "x$COMMAND" = x ; then COMMAND="mpirun -np TR_NPROC ./$EXECUTABLE" ; fi fi -echo "OK (COMMAND= $COMMAND )" +echo "OK (COMMAND='$COMMAND')" + +#TMP=./tr_$$ +#- try to put temporary files in system-local /tmp dir +TMP=/tmp/tr_${USER}_$$ +touch $TMP ; retVal=$? +if [ $retVal -eq 0 ] ; then + if test ! -r $TMP ; then TMP=./tr_$$ ; fi +else + TMP=./tr_$$ +fi +rm -f $TMP +if [ $verbose -gt 1 ]; then echo " temp files: $TMP" ; fi # set the Default List of output variables to be checked: # (use default or load experiment-specific list from file "tr_checklist") # content : 1rst = main variable used to decide if it pass or FAIL # others = number of matching digits to be printed in summary.txt -if test "x$ADM" = x -a "x$OADM" = x; then +if test $KIND = 1 ; then + DEF_CHECK_LIST='tlmGrd tlmCst tlmGrd fwdGrd' + EMPTY_RESULTS='.. .. ..' + LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'` +elif test $KIND = 2 -o $KIND = 4 ; then + DEF_CHECK_LIST='AdGrd Cost AdGrd FDGrd' + EMPTY_RESULTS='.. .. ..' + LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'` +else DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+' EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..' LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'` ii=`echo $EMPTY_RESULTS | awk '{print NF}'` EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf " ."}}'` -else - DEF_CHECK_LIST='Grad Cost Grad' - EMPTY_RESULTS='.. ..' - LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'` fi # create the FORTRAN comparison code -if test -x tr_cmpnum ; then +if test "x$CLEANUP" = xt -o -x tr_cmpnum ; then echo "skipping comparison code build" else createcodelet fi # build the mpack utility (if ADDRESSES = NONE, do it to test the build) -if test "x$ADDRESSES" = x ; then +if test "x$ADDRESSES" = x -o "x$SENDCMD" != x ; then echo "skipping mpack build" else build_mpack + if test "x$HAVE_MPACK" = xt ; then SENDCMD=$MPACK ; fi fi # Create a uniquely named directory to store results CMDLINE=$0 for xx in "$@" ; do nw=`echo $xx | wc -w` - if test $nw = '1' ; then CMDLINE="$CMDLINE $xx" - else CMDLINE="$CMDLINE '$xx'" ; fi + if test $nw = '1' ; then CMDLINE="$CMDLINE $xx" ; else + nb=`echo $xx | grep -c '='` + if test $nb = 0 ; then CMDLINE="$CMDLINE '$xx'" + else yy=`echo "$xx'" | sed "s/=/='/"` ; + CMDLINE="$CMDLINE $yy" ; fi + fi done -#for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done MACH=`hostname` UNAMEA=`uname -a` DATE=`date +%Y%m%d` @@ -1235,7 +1401,9 @@ if test "x$OUTDIR" != x ; then BASE="tr_"$OUTDIR"_"$DATE"_" else - short_name=`hostname | sed 's/\..*$//'` + #short_name=`hostname -s | tr '[:upper:]' '[:lower:]'` + # hostname -s is not universal (does work on AIX system) + short_name=`hostname | sed 's/\..*$//' | tr '[:upper:]' '[:lower:]'` BASE="tr_"$short_name"_"$DATE"_" fi DNUM=0 @@ -1272,8 +1440,8 @@ echo >> $SUMMARY echo " OPTFILE=$OPTFILE" >> $SUMMARY else - echo | tee $SUMMARY - echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY + echo | tee -a $SUMMARY + echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee -a $SUMMARY exit 1 fi else @@ -1283,14 +1451,12 @@ fi echo echo >> $SUMMARY -if test "x$ADM" = x -a "x$OADM" = x; then - if [ $MATCH_CRIT -lt 10 ] ; - then line_0="default "$MATCH_CRIT ; - else line_0="default "$MATCH_CRIT ; fi +if test $KIND = 0 ; then + line_0=`printf '%s %2i' 'default' $MATCH_CRIT` line_0="$line_0 ----T----- ----S----- ----U----- ----V-----" line_1="G D M c m s m s m s m s" - line_2="E p a R g m m e . m m e . m m e . m m e ." - line_3="N n k u 2 i a a d i a a d i a a d i a a d" + line_2="e p a R g m m e . m m e . m m e . m m e ." + line_3="n n k u 2 i a a d i a a d i a a d i a a d" line_4="2 d e n d n x n . n x n . n x n . n x n ." for ii in $PTRACERS_NUM ; do line_0="$line_0 --PTR 0"$ii"--" @@ -1299,26 +1465,37 @@ line_3="$line_3 i a a d" line_4="$line_4 n x n ." done +else + line_0=`printf '%s %2i' 'default ' $MATCH_CRIT` + if test $KIND = 1 ; then + #echo "TANGLIN=true" >> $SUMMARY + echo "TangLin generated by TAF" >> $SUMMARY + elif test $KIND = 3 ; then + echo "TangLin generated by OpenAD" >> $SUMMARY + elif test $KIND = 2 ; then + #echo "ADJOINT=true" >> $SUMMARY + echo "Adjoint generated by TAF" >> $SUMMARY + else + echo "Adjoint generated by OpenAD" >> $SUMMARY + fi + if test $KIND = 1 -o $KIND = 3 ; then + line_1="G D M C T F" + line_2="e p a R o L D" + else + line_1="G D M C A F" + line_2="e p a R o d D" + fi + line_3="n n k u s G G" + line_4="2 d e n t r r" + echo >> $SUMMARY +fi +if test "x$CLEANUP" != xt ; then echo "$line_0" | tee -a $SUMMARY echo "$line_1" | tee -a $SUMMARY echo "$line_2" | tee -a $SUMMARY echo "$line_3" | tee -a $SUMMARY echo "$line_4" | tee -a $SUMMARY - echo " " | tee -a $SUMMARY -else - echo "ADJOINT=true" >> $SUMMARY - echo >> $SUMMARY - if [ $MATCH_CRIT -lt 10 ] ; - then line_0="default "$MATCH_CRIT ; - else line_0="default "$MATCH_CRIT ; fi - echo "$line_0" | tee -a $SUMMARY - cat << EOF | tee -a $SUMMARY -G D M C G -E p a R o r -N n k u s a -2 d e n t d - -EOF + echo "" | tee -a $SUMMARY fi echo "-------------------------------------------------------------------------------" @@ -1344,9 +1521,10 @@ rm -f $EXECUTABLE *.bak rm -f genmake_state genmake_*optfile genmake.log rm -f SIZE.h.mpi genmake.tr_log make.tr_log + rm -rf mpi_headers ) if test -d $dir/$rundir/CVS ; then - echo -n ' --- dir:' $dir/$rundir ': ' + echo -n ' --- dir:' $dir/$rundir ': ' run_clean $dir/$rundir fi trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')` @@ -1361,7 +1539,8 @@ # Verify that the testdir exists and contains previous # results in the correct location--or skip this directory! fout=$dir"/results/"$ref_outp - if test ! -r $fout ; then + #if test ! -r $fout ; then + if test ! -r $fout -a ! -r ${fout}.gz ; then echo "can't read \"$fout\" -- skipping $dir" continue fi @@ -1378,13 +1557,16 @@ fi if test "x$MPI" != "x0" ; then - prefer_X=0 + ntx=1 ; nty=1 if test "x$MULTI_THREAD" = "xt" ; then - retv=`check_eedata $dir"/input/eedata.mth"` - if test $retv = 1 ; then prefer_X=1 ; fi + ff=$dir"/input/eedata.mth" + ntx=`grep "^ *nTx *=" $ff | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"` + nty=`grep "^ *nTy *=" $ff | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"` + if test "x$ntx" = x ; then ntx=1 ; fi + if test "x$nty" = x ; then nty=1 ; fi fi #- create new SIZE.h with no more than '$MPI' Procs - mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $prefer_X + mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $ntx $nty LOC_NPROC=$? ( cd $BUILD_DIR if test -r SIZE.h.mpi ; then @@ -1424,14 +1606,14 @@ # Check whether there are "extra runs" for this testdir extra_runs= if test "x$NORUN" = xf ; then - ex_run_dirs=`( cd $dir ; echo $inputdir.* )` + ex_run_dirs=`( cd $dir ; ls -d $inputdir.* 2> /dev/null )` fi #echo "ex_run_dirs='$ex_run_dirs'" for exd in $ex_run_dirs ; do name=`echo $exd | sed -e "s/$inputdir\.//"` refExOut=`echo $ref_outp | sed "s/\./.${name}./"` outf="$dir/results/$refExOut" - if test -f $outf -a -r $outf ; then + if test -r $outf -o -r ${outf}.gz ; then if test "x$MULTI_THREAD" = "xt" ; then if test -r $dir"/"$exd"/eedata.mth" ; then if test "x$MPI" = "x0" ; then @@ -1454,9 +1636,9 @@ echo if test "x$extra_runs" = "x" ; then - echo "Experiment: $dir" + echo "Experiment: $dir" else - echo "Experiment: $dir ; extra_runs=$extra_runs" + echo "Experiment: $dir ; extra_runs=$extra_runs" fi echo unset genmake makedepend make run @@ -1475,13 +1657,13 @@ run=N genmakemodel $dir/$builddir && genmake=Y \ && makeclean $dir/$builddir \ - && symlink_mpifiles $dir $code_dir $builddir \ + && symlink_mpifiles $dir $code_dir $builddir \ && makedependmodel $dir/$builddir && makedepend=Y \ && makemodel $dir/$builddir && make=Y else genmakemodel $dir/$builddir && genmake=Y \ && makeclean $dir/$builddir \ - && symlink_mpifiles $dir $code_dir $builddir \ + && symlink_mpifiles $dir $code_dir $builddir \ && makedependmodel $dir/$builddir && makedepend=Y \ && makemodel $dir/$builddir && make=Y \ && run_clean $dir/$rundir \ @@ -1493,12 +1675,12 @@ fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` echo 1>&2 - echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /> $SUMMARY + echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /> $SUMMARY echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt" for ex in $extra_runs ; do unset run - results=$EMPTY_RESULTS + results=$EMPTY_RESULTS # reference output file refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"` # Create an output dir & summary.txt file for each extra run (tdir.ex) @@ -1514,8 +1696,7 @@ linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir runmodel $dir/$pfxdir.$ex && run=Y \ && results=`testoutput_run $dir $pfxdir.$ex $refExOut` - fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` - fres="$fres.$ex" + fres=`formatresults $dir.$ex ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` echo 1>&2 echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /> $SUMMARY echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt" @@ -1524,40 +1705,58 @@ fi done - if test -f $DRESULTS"/"genmake_state ; then : ; else + if test ! -f $DRESULTS"/"genmake_state ; then if test -f $dir/$builddir/Makefile ; then mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'` echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state - sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state +# sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state +# bsd-sed cannot do the above code + cat $dir/$builddir/Makefile | \ + sed -n '/^# executed by:/{N + p + }' >> $DRESULTS/genmake_state echo " $mkOpt" >> $DRESULTS/genmake_state if test "x$OPTFILE" = xNONE ; then eval $mkOpt - sed "/^No \"OPTFILE\" was specified ; genmake2/a\ OPTFILE=${OPTFILE}"\ - $SUMMARY > tr_0.tmp_log +# sed "/^No \"OPTFILE\" was specified ; genmake2/a\ OPTFILE=${OPTFILE}"\ +# $SUMMARY > tmp.tr_log +# bsd-sed requires a newline after "a\": + sed "/^No \"OPTFILE\" was specified ; genmake2/a\\ + OPTFILE=${OPTFILE}" $SUMMARY > tmp.tr_log RETVAL=$? - if test "x$RETVAL" = x0 ; then rm -f $SUMMARY - cp tr_0.tmp_log $SUMMARY - else rm -f tr_0.tmp_log + if test "x$RETVAL" = x0 ; then + cp -f tmp.tr_log $SUMMARY fi + rm -f tmp.tr_log fi gmkLog=$dir/$builddir/genmake.log - grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1 - RETVAL=$? - if test "x$RETVAL" = x0 ; then - echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state - sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \ - | grep -v '^... compiler version ' > tr_1.tmp_log - sed -n '1p' tr_1.tmp_log >> $DRESULTS/genmake_state - sed -n '2,/^$/p' tr_1.tmp_log | sed '/^$/d' | sed 's/^./ &/' \ - >> $DRESULTS/genmake_state - rm -f tr_1.tmp_log + if test -r $gmkLog ; then + grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then + echo -n "from '$gmkLog', " >> $DRESULTS/genmake_state + echo "extract compiler version:" >> $DRESULTS/genmake_state + sed -n '/Get compiler version/,/<-- compiler version/p' \ + $gmkLog | grep -v '^... compiler version ' > tmp.tr_log + sed -n '1p' tmp.tr_log >> $DRESULTS/genmake_state + sed -n '2,/^$/p' tmp.tr_log | sed '/^$/d' | sed 's/^./ &/' \ + >> $DRESULTS/genmake_state + rm -f tmp.tr_log + fi + fi + gmkLog=$dir/$builddir/genmake_state + if test -r $gmkLog ; then + echo -n "from '$gmkLog', " >> $DRESULTS/genmake_state + echo "get genmake settings:" >> $DRESULTS/genmake_state + sed -n '/^HAVE_/p' $gmkLog | sed 's/^./ &/' \ + >> $DRESULTS/genmake_state fi fi fi #postclean $dir/$builddir if test "x$POSTCLEAN" = x2 ; then - makeclean $dir/$builddir \ - && run_clean $dir/$rundir + makeclean $dir/$builddir \ + && run_clean $dir/$rundir fi if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi @@ -1575,10 +1774,13 @@ if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then echo "No results email was sent." else - if test "x$HAVE_MPACK" = xt ; then - tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ - && gzip $DRESULTS".tar" \ - && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES + if test "x$SENDCMD" != x ; then + if [ $verbose -gt 1 ]; then + echo " run: $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESSES" + fi + tar -cf ${SAVDIR}/${DRESULTS}".tar" $DRESULTS > /dev/null 2>&1 \ + && gzip ${SAVDIR}/${DRESULTS}".tar" \ + && $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESSES RETVAL=$? if test "x$RETVAL" != x0 ; then echo @@ -1591,8 +1793,8 @@ echo "An email containing results was sent to the following addresses:" echo " \"$ADDRESSES\"" echo - test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" - test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" + test -f ${SAVDIR}/${DRESULTS}".tar" && rm -f ${SAVDIR}/${DRESULTS}".tar" + test -f ${SAVDIR}/${DRESULTS}".tar.gz" && rm -f ${SAVDIR}/${DRESULTS}".tar.gz" fi fi fi @@ -1604,7 +1806,7 @@ if test "x$CLEANUP" != xt ; then cat $SUMMARY | sed 's/ \. \. \. \. \. \. \. \. \. \. \. \. //' if test -e tr_out.txt ; then - mv tr_out.txt tr_out.txt.old + mv tr_out.txt tr_out.txt.old fi cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt fi @@ -1612,4 +1814,4 @@ if test "x$DELDIR" = xt ; then rm -rf $DRESULTS fi - +echo "======== End of testreport execution ========"