#!/usr/local/bin/tcsh # ----------------------------------------------------------------------------- # Script for batch execution on d0mino # This script suppose a directory structure typical of a development directory # in D0 obtained after a newrel followed by addpkg's and must be used from # this top directory. # # All rcp files are copied into the batch script, so that they can be # modified as soon as the batch has been submitted. # # The command lines arguments are the arguments to the sam submit command. # # Specific for trigsim running: # you can modify initL1L2.sh, initScriptRunner.sh and level3.sim after # send but not any of the other scripts or data files but for rcps. # ----------------------------------------------------------------------------- # top directory for you working area, all other path are relative to this dir set TOP_DIR=$PWD # bank-separated directories where there's a subdir rcp set RCP_DIRS="caltables calunpdata l3tCalUnpTool tsim_l3" # blank separated list of actions to take before execution, executed from the # copy of your top directory set PREEXEC="" # executable name (path relative to your top directory) set EXECUTABLE="bin/IRIX6-KCC_3_4/recoats" # framework rcp name (path relative to your top directory) set FRAMEWORK_RCP="framework.rcp" # framework line command options set FRAMEWORK_OPTIONS="-time -mem -num_events 1000" # post-execution actions, as one string, i.e. shell commands should be # semi-column separated set POSTEXEC="cp *.root *.ntpl *.hbook *.rtpl $TOP_DIR" # ------- you shouldn't have to modify anything beyond that point --------- echo "program top dir: $TOP_DIR" echo "directories for rcp files: $RCP_DIRS" echo "will do " echo "$PREEXEC" echo "$EXECUTABLE -rcp $FRAMEWORK_RCP $FRAMEWORK_OPTIONS" echo "$POSTEXEC" set rel=`cat $TOP_DIR/.base_release` set setup_command=" " if ( $?SETUP_D0RUNII ) then set skip=0 foreach item ( $SETUP_D0RUNII ) if ( $skip == 0 ) then if ( "A$item" == "A-z" ) then set skip=1 else set setup_command="$setup_command $item" endif else set skip=0 endif end endif set private_context=" " if ( $?SRT_PRIVATE_CONTEXT ) then set private_context=$SRT_PRIVATE_CONTEXT else set private_context=$TOP_DIR endif #time stamp set timestamp=`date +%y%m%d%H%M%S` # working directory setenv wkdir /scratch/4/$USER/$timestamp echo working directory $wkdir # remove working batch script set batchscript=r$timestamp \rm -f $batchscript touch $batchscript cat <> $batchscript #!/usr/local/bin/tcsh source /usr/local/etc/setups.csh setup n32 if ( $?SETUP_D0RUNII ) then # assume the currently setup'ed release to be the correct one setup $setup_command else # assume the .base_release is correct, there might be problems with # qualifiers or non standard release directories setup D0RunII $rel endif #setup D0RunII $rel mkdir $wkdir cd $wkdir newrel -t $rel $rel cd $rel foreach dir ( $RCP_DIRS ) mkdir \$dir mkdir \$dir/rcp end d0setwa EOF set current=$PWD foreach dir ( $RCP_DIRS ) # # save RCP files into the batch script # foreach file ( $dir/rcp/*.rcp ) cat <> $batchscript cat < $file EOF cat $file | sed 's/\$/\\\$/g' >> $batchscript cat <>$batchscript END-OF-FILE EOF end end # save also framework rcp file cat <> $batchscript cat < framework.rcp EOF cat $FRAMEWORK_RCP | sed 's/\$/\\\$/g' >> $batchscript cat <> $batchscript END-OF-FILE EOF # d0trigsim specific actions cat <> $batchscript set save_context=\$SRT_PRIVATE_CONTEXT setenv SRT_PRIVATE_CONTEXT $private_context EOF # # set up L1/L2 # cat <> $batchscript cat < initL1L2.sh EOF if (-s $SRT_PRIVATE_CONTEXT/tsim_l1l2/bin/initL1L2.sh ) then cat $SRT_PRIVATE_CONTEXT/tsim_l1l2/bin/initL1L2.sh >> $batchscript else cat $SRT_PUBLIC_CONTEXT/tsim_l1l2/bin/initL1L2.sh >> $batchscript endif cat <> $batchscript END-OF-FILE EOF # # set up L3 # cat <> $batchscript cat < initScriptRunner.sh EOF if ( -s $SRT_PRIVATE_CONTEXT/tsim_l3/bin/initScriptRunner.sh ) then cat $SRT_PRIVATE_CONTEXT/tsim_l3/bin/initScriptRunner.sh >> $batchscript else cat $SRT_PUBLIC_CONTEXT/tsim_l3/bin/initScriptRunner.sh >> $batchscript endif cat <> $batchscript END-OF-FILE EOF cat <> $batchscript cat < level3.sim EOF if ( -s $SRT_PRIVATE_CONTEXT/tsim_l3/trigger_lists/level3.sim ) then cat $SRT_PRIVATE_CONTEXT/tsim_l3/trigger_lists/level3.sim >> $batchscript else cat $SRT_PUBLIC_CONTEXT/tsim_l3/trigger_lists/level3.sim >> $batchscript endif cat <> $batchscript END-OF-FILE EOF cat <> $batchscript setenv SRT_PRIVATE_CONTEXT \$save_context EOF # do actions needed before execution foreach exe ( $PREEXEC ) cat <> $batchscript $exe EOF end # execute program and post-running actions cat <> $batchscript chmod +x ./initL1L2.sh echo execute ./initL1L2.sh ./initL1L2.sh chmod +x ./initScriptRunner.sh echo execute ./initScriptRunner.sh ./initScriptRunner.sh cp $TOP_DIR/$EXECUTABLE exe ./exe -rcp framework.rcp $FRAMEWORK_OPTIONS \rm exe $POSTEXEC exit 0 EOF chmod +x $batchscript sam submit $* --script=$batchscript --batch-system-flags="-o $batchscript.out" exit 0