=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2003.03.27 17:16:49 =~=~=~=~=~=~=~=~=~=~=~= cat rfluka #!/bin/sh # #**************************************************************** # Modified March 2003 # Paul R. Higbie # New Mexico State University # phigbie@nmsu.edu # Purpose is to run may instances of rfluka on a Beowulf cluster. # Change is prepending the Calling host name to the input file # name. $CHOST:$HERE/inputfilename # where $CHOST is the name of the calling host, ":" is a token, # and $HERE is an optional directory. rfluka is called by a # script that varies the parameters in a input file template, # creates an unique inputfilename, and assigns each instance to # a Beowulf node. These changes force the directory selection # for a Beowulf cluster having a common file system. #************************************************************ # # Create a separator for rfluka output---PRH echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" # # Create a directory which is a subdirectory of the current one # and is unique # set -- `getopt e:hN:M:p: $*` if [ $? -ne 0 ] ; then cat < -N -M -p ! exit 2 fi # TARGET_MACHINE=`uname` if [ "$TARGET_MACHINE" = "Linux" ] ; then echo \$TARGET_MACHINE = $TARGET_MACHINE ECHOE="echo -e" FORT="fort" FORTD="." FORT0="" elif [ "$TARGET_MACHINE" = "OSF1" ] ; then echo \$TARGET_MACHINE = $TARGET_MACHINE ECHOE="echo" FORT="fort" FORTD="." FORT0="" elif [ "$TARGET_MACHINE" = "AIX" ] ; then echo \$TARGET_MACHINE = $TARGET_MACHINE ECHOE="echo" FORT="fort" FORTD="." FORT0="" elif [ "$TARGET_MACHINE" = "HP-UX" ] ; then echo \$TARGET_MACHINE = $TARGET_MACHINE ECHOE="echo" FORT="ftn" FORTD="" FORT0="0" else echo \$TARGET_MACHINE = undefined ECHOE="echo" FORT="fort" FORTD="." FORT0="" fi if [ -z "$FLUPRO" ] ; then echo \$FLUPRO not defined exit 1 fi echo \$FLUPRO = $FLUPRO FTOP=$FLUPRO EXE=$FTOP/flukahp NUM=0 MAX=5 PEMF=$FTOP/libec_thihecufealw_10t while [ $# -gt 0 ] ; do case $1 in -h) cat < -N -M -p -h (print this help)] rfluka runs fluka. A unique name subdirectory is created and the program is run from there. Links are created to the files in the parent directory. After a successful run of fluka all the temporary links are removed and the newly created files are copied to the parent directory with the prefix . This operation is repeated from the cycle after the one indicated on the -N option (default 0) to the one indicated on the -M option (default 5). -e name of the fluka executable to be run -N number of the previous run -M final run number -p name of the pemf file. The suffix .pemf will be added automatically. The default is /user2/fluka/libec_thihecufealw_10t. -h print this help file input file for fluka, without .inp ! exit ;; -e) EXE=${2} shift 2 ;; -N) NUM=${2} shift 2 ;; -M) MAX=${2} shift 2 ;; -p) PEMF=${2} shift 2 ;; --) shift break ;; esac done # # CURDIR=`pwd` # Omit here---PRH if [ $# -le 0 ] ; then echo An input file should be specified ! exit 2 else INPF=${1}.inp # #******************Begin modified section********************** # Check for compound filename if [ `echo $INPF | grep -c ":"` = 1 ] ; then CHOST=`echo $INPF | sed 's/\(^.*\):\(.*\)/\1/'` INPF=`echo $INPF | sed 's/\(^.*\):\(.*\)/\2/'` WHOST=`hostname` echo "Calling machine $CHOST Worker machine $WHOST" CURDIR=`dirname $INPF` else CURDIR=`pwd` fi #******************End modified section************************ # INPD=`dirname $INPF` if [ "$INPD" = "." ] ; then INPF=${CURDIR}/$INPF fi ROOF=`basename ${1}` fi # if [ ! -r $INPF ] ; then ${ECHOE} "\nInput $INPF not found !" exit 2 fi # EXED=`dirname ${EXE}` if [ "$EXED" = "." ] ; then EXE=${CURDIR}/$EXE fi # PEM=`dirname ${PEMF}` if [ "$PEM" = "." ] ; then PEMF=${CURDIR}/$PEMF fi PEMF=${PEMF}.pemf echo $PEMF # renice: renice +10 ${$} # CURSUB=fluka_${$} if [ -d $CURSUB ] ; then ${ECHOE} "\n$CURSUB exists, making a new unique one" i=0 while [ 1 ] ; do if [ $i -lt 10 ] ; then BAS=00 elif [ $i -lt 100 ] ; then BAS=0 else ${ECHOE} "\nCannot find free directory name in first 100" exit 2 fi TRY=${CURSUB}_00${i} if [ ! -d ${CURSUB}_00${i} ] ; then CURSUB=$TRY break fi i=`expr $i + 1` done fi # if [ $NUM -eq 0 ] ; then RAN1=${CURDIR}/ran${ROOF}001 if [ ! -r $RAN1 ] ; then ${ECHOE} "\nInitial seed copied from $FTOP" cp $FTOP/random.dat $RAN1 else ${ECHOE} "\nInitial seed already existing" fi fi # #***************Start modified section************************** # Force directory choice (user HOME directory is default) if [ $CHOST != $WHOST ] ; then CURSUB=${CURDIR}/$CURSUB fi #***************End modified section**************************** # mkdir $CURSUB ; cd $CURSUB ${ECHOE} "\nRunning fluka in `pwd`" # while [ $NUM -lt $MAX ] ; do NUM=`expr $NUM + 1` # Export a variable with the NUM value FLUKA_CUR_RUN="$NUM" export FLUKA_CUR_RUN if [ $NUM -lt 10 ] ; then PST=00${NUM} elif [ $NUM -lt 100 ] ; then PST=0${NUM} elif [ $NUM -lt 1000 ] ; then PST=$NUM else ${ECHOE} "\n-N #: number should be less than 998" fi NUP=`expr $NUM + 1` if [ $NUP -lt 10 ] ; then PSP=00${NUP} elif [ $NUP -lt 100 ] ; then PSP=0${NUP} elif [ $NUP -lt 1000 ] ; then PSP=$NUP else ${ECHOE} "\n-N #: number should be less than 998" fi # Start run RAN1=$CURDIR/ran${ROOF}${PST} ln -s -f $RAN1 ${FORT}${FORTD}${FORT0}1 # RAN2=ran${ROOF}${PSP} ln -s -f $RAN2 ${FORT}${FORTD}${FORT0}2 # ln -s -f $PEMF ${FORT}${FORTD}12 # DATAFILES="sigmapi.bin elasct.bin nuclear.bin fluodt.dat" XNLOANFIL="e6r1nds3.fyi jef2.fyi jendl3.fyi" # for i in $DATAFILES ; do if [ -r ${CURDIR}/${i} ] ; then ${ECHOE} "\nFile ${CURDIR}/${i} exists and it is not a link!" ln -s -f ${CURDIR}/${i} ${i} else ln -s -f ${FTOP}/${i} ${i} fi done if [ -r ${CURDIR}/neuxsc_72.bin ] ; then ${ECHOE} "\nFile ${CURDIR}/neuxsc_72.bin exists and it is not a link!" ln -s -f ${CURDIR}/neuxsc_72.bin neuxsc.bin else ln -s -f ${FTOP}/neuxsc_72.bin neuxsc.bin fi if [ -r ${CURDIR}/xnloan.dat ] ; then ${ECHOE} "\nFile ${CURDIR}/xnloan.dat exists and it is not a link!" ln -s -f ${CURDIR}/xnloan.dat xnloan.dat elif [ -r ${FTOP}/xnloan.dat ] ; then ln -s -f ${FTOP}/xnloan.dat xnloan.dat else # for i in $XNLOANFIL ; do ln -s -f ${CURDIR}/${i} ${i} done ln -s -f ${FTOP}/xnloan.dat xnloan.dat fi # ln -s /dev/null core ERRF=${ROOF}${PST}.err ln -s ${ERRF} ${FORT}${FORTD}15 OUTF=${ROOF}${PST}.out ln -s ${OUTF} ${FORT}${FORTD}11 LOGF=${ROOF}${PST}.log ${ECHOE} "\n================================ Running FLUKA for cycle # $NUM =============================================" ${EXE} < $INPF 2>$LOGF 1>$LOGF if [ ! $? -eq 0 ] ; then exit $? ; fi # remove the links we know we can remove ${ECHOE} "\nRemoving links" for i in \ ${FORT}${FORTD}${FORT0}1 ${FORT}${FORTD}${FORT0}2 ${FORT}${FORTD}11 \ ${FORT}${FORTD}12 ${FORT}${FORTD}15 \ $DATAFILES neuxsc.bin $XNLOANFIL xnloan.dat core do if [ -h $i ] ; then rm $i elif [ -r $i ] ; then ${ECHOE} "\nSomething wrong, $i a file and not a link!" exit 2 fi done # remove the temporary files we know we can remove ${ECHOE} "\nRemoving temporary files" for i in \ ${FORT}${FORTD}${FORT0}8 ${FORT}${FORTD}16 geom.scr emf.scr do if [ -f $i ] ; then rm $i elif [ -h $i ] ; then ${ECHOE} "\nSomething wrong, $i a link and not a file!" exit 2 fi done # move 'up' the files we know we have to save ${ECHOE} "\nSaving output and random number seed" for i in \ $OUTF $RAN2 $LOGF $ERRF do if [ -r $i ] ; then mv $i $CURDIR else echo " No $i generated!" fi done # move up all the other files with a name ${ECHOE} "\nSaving additional files generated" FILES=`ls -d * 2>/dev/null` if [ ! -z "$FILES" ] ; then for i in $FILES ; do echo " Moving $i to $CURDIR/${ROOF}${PST}_${i}" mv $i $CURDIR/${ROOF}${PST}_${i} done else echo " No additional files to move" fi done cd ${CURDIR} ; rmdir ${CURSUB} ${ECHOE} "\nEnd of FLUKA run" [phigbie@muromets flutil]$