--- MITgcm/tools/do_tst_2+2 2009/05/01 13:46:51 1.4 +++ MITgcm/tools/do_tst_2+2 2011/01/21 19:41:35 1.11 @@ -1,6 +1,6 @@ #! /usr/bin/env bash -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/do_tst_2+2,v 1.4 2009/05/01 13:46:51 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/do_tst_2+2,v 1.11 2011/01/21 19:41:35 jmc Exp $ # $Name: $ usage() @@ -14,6 +14,7 @@ echo " -skd LIST_EXP : skip experiments in LIST_EXP" echo " -exe COMMAND : use COMMAND to run the tests" echo " -mpi : run the tests using MPI" + echo " -mf STRING :(MPI) file with list of possible machines to run on" echo " -o STRING : used to build output directory name" echo " (DEF=\"hostname\")" echo " -a,-A STRING : email address to send output to" @@ -27,9 +28,10 @@ TESTDIRS= SKIPDIRS= SCRIPT='../tools/tst_2+2' +scrArg='All' COMMAND= mpi=0 -#OUTDIR=`hostname` +MPI_MFILE= OUTDIR=`hostname | sed 's/\..*$//'` SAVELOG=0 ADDRESS= @@ -49,6 +51,7 @@ -skd ) yy=SKIPDIRS ;; -exe ) yy=COMMAND ;; -mpi ) mpi=1 ;; + -mf ) yy=MPI_MFILE ;; -a ) yy=ADDRESS ;; -A ) yy=ADDRESS ; SAVELOG=1 ;; -o ) yy=OUTDIR ;; @@ -106,6 +109,12 @@ 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 +done +#for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done DATE=`date +%Y%m%d` BASE="rs_"$OUTDIR"_"$DATE"_" xx=0 @@ -125,9 +134,10 @@ printf "Start time: " > $SUMMARY date >> $SUMMARY +echo 'run:' $CMDLINE >> $SUMMARY if test -f tr_out.txt ; then echo ' using output from:' >> $SUMMARY - sed -n '2,/OPTFILE/ p' tr_out.txt >> $SUMMARY + sed -n '2,/^ OPTFILE=/ p' tr_out.txt >> $SUMMARY echo >> $SUMMARY fi echo 'test 2+2=4 summary :' >> $SUMMARY @@ -136,6 +146,7 @@ echo ' 1 2 3' >> $SUMMARY #-- For MPI test: +LOC_MFILE='tr_mpi_mfile' RUNOUTP="output.txt" if [ $mpi -ge 1 ] ; then SCRIPT="$SCRIPT -mpi" @@ -145,6 +156,31 @@ for xx in $LIST do echo ============================================================================== + if [ $mpi -le 0 ] ; then + rCommand=$COMMAND + else + LOC_NPROC=2 + mpi_size=$xx/build/SIZE.h.mpi + if test -f $mpi_size ; then + px=`grep '^ & *nPx *=' $mpi_size | sed 's/^ & *nPx *= *//' | sed 's/, *$//'` + py=`grep '^ & *nPy *=' $mpi_size | sed 's/^ & *nPy *= *//' | sed 's/, *$//'` + pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$? + if test "x$out" = x0 ; then LOC_NPROC=$pp ; fi + fi + rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"` + if test "x$MPI_MFILE" != x ; then + #- create new MPI machine-file with the right number of Procs + rm -f $LOC_MFILE + cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE + nl=`wc -l $LOC_MFILE | awk '{print $1}'` + if [ $nl -lt $LOC_NPROC ] ; then + rm -f $LOC_MFILE + cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE + fi + rCommand=`echo $rCommand | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"` + fi + fi + listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` for yy in $listD do @@ -152,8 +188,20 @@ if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'` echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state - echo $comm >> $DRESULTS/genmake_state + sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state + echo " $comm" >> $DRESULTS/genmake_state eval $comm + gmkLog=$xx/build/genmake.log + grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1 + out=$? + if test "x$out" = 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_vers.tmp_log + sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \ + >> $DRESULTS/genmake_state + rm -f tr_vers.tmp_log + fi fi if test $yy = 'run' ; then nam=$xx else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi @@ -161,13 +209,13 @@ cd $xx/$yy pwd > outp.tst_2+2.log if test "x$COMMAND" = x ; then - echo $SCRIPT All >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log - $SCRIPT All >> outp.tst_2+2.log 2>&1 + echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log + $SCRIPT $scrArg >> outp.tst_2+2.log 2>&1 out=$? else - echo "$SCRIPT All -command \"$COMMAND\"" >> outp.tst_2+2.log + echo "$SCRIPT $scrArg -command \"$rCommand\"" >> outp.tst_2+2.log echo ' ' >> outp.tst_2+2.log - $SCRIPT All -command "$COMMAND" >> outp.tst_2+2.log 2>&1 + $SCRIPT $scrArg -command "$rCommand" >> outp.tst_2+2.log 2>&1 out=$? fi case $out in @@ -191,6 +239,7 @@ cd $here fi done + if test "x$mpi" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi done printf "End time: " >> $SUMMARY date >> $SUMMARY