2 #------------------------------------------------------------------
4 # Purpose: A general purpose larsoft batch worker script.
6 # Adapted from condor_lBdetMC.sh by E. Church.
10 # condor_lar.sh [options]
14 # -c, --config <arg> - Configuration (fcl) file (required).
15 # -s, --source <arg> - Input file (full path).
16 # -S, --source-list <arg> - Input file list (full path, one per line).
17 # -o, --output <arg> - Output file name.
18 # -T, --TFileName <arg> - TFile output file name
19 # -n, --nevts <arg> - Number of events to process.
20 # --nskip <arg> - Number of events to skip.
21 # --nfile <arg> - Number of files to process per worker.
22 # --nfile_skip <arg> - Number of files to skip (use with option -S).
23 # --inputmode <arg> - Input mode ('textfile' or '', default '')
24 # --args <args...> - Arguments for lar command line (place at end).
26 # Sam and parallel project options.
28 # --sam_user <arg> - Specify sam user (default $GRID_USER).
29 # --sam_group <arg> - Specify sam group (default --group option).
30 # --sam_station <arg> - Specify sam station (default --group option).
31 # --sam_defname <arg> - Sam dataset definition name.
32 # --sam_project <arg> - Sam project name.
33 # --sam_start - Specify that this worker should be responsible for
34 # starting and stopping the sam project.
35 # --recur - Recursive input dataset (force snapshot).
36 # --sam_schema <arg> - Use this option with argument "root" to stream files using
37 # xrootd. Leave this option out for standard file copy.
38 # --os <arg> - A copy of the os argument passed to jobsub. May be used
39 # to affect definition of UPS_OVERRIDE.
40 # --njobs <arg> - Parallel project with specified number of jobs (default one).
41 # --data_file_type - Specify data file type (default "root," repeatable).
43 # Mix input options (second input stream).
45 # --mix_defname <arg> - Specify mix input sam dataset definition.
46 # --mix_project <arg> - Specify mix input sam project.
50 # --declare - Do sam declaration.
51 # --validate - Do validation checks.
52 # --copy - Copy output files directly to FTS dropbox instead of
54 # --maintain_parentage - Recalculate sam parentage metadata for multistage jobs.
55 # (Use with --validate and --declare).
59 # --ups <arg> - Comma-separated list of top level run-time ups products.
60 # -r, --release <arg> - Release tag.
61 # -q, -b, --build <arg> - Release build qualifier (default "debug", or "prof").
62 # --localdir <arg> - Larsoft local test release directory (default none).
63 # --localtar <arg> - Tarball of local test release.
64 # --mrb - Ignored (for compatibility).
65 # --srt - Exit with error status (SRT run time no longer supported).
69 # -h, --help - Print help.
70 # -i, --interactive - For interactive use.
71 # -g, --grid - No effect (allowed for compatibility).
72 # --group <arg> - Group or experiment (required).
73 # --workdir <arg> - No effect (allowed for compatibility).
74 # --outdir <arg> - Output directory (required).
75 # --logdir <arg> - Log directory (required).
76 # --dirsize <n> - Maximum directory size.
77 # --dirlevels <n> - Number of extra directory levels.
78 # --scratch <arg> - Scratch directory (only for interactive).
79 # --cluster <arg> - Job cluster (override $CLUSTER)
80 # --process <arg> - Process within cluster (override $PROCESS).
81 # --procmap <arg> - Name of process map file (override $PROCESS).
82 # --init-script <arg> - User initialization script execute.
83 # --init-source <arg> - User initialization script to source (bash).
84 # --end-script <arg> - User end-of-job script to execute.
85 # --mid-source <arg> - User midstage initialization script to source.
86 # --mid-script <arg> - User midstage finalization script to execute.
87 # --exe <arg> - Specify art-like executable (default "lar").
88 # --init <path> - Absolute path of environment initialization script.
92 # Run time environment setup.
94 # MRB run-time environmental setup is controlled by four options:
95 # --release (-r), --build (-b, -q), --localdir, and --localtar.
97 # a) Use option --release or -r to specify version of top-level product(s).
98 # b) Use option --build or -b to specify build full qualifiers (e.g.
99 # "debug:e5" or "e5:prof").
100 # c) Options --localdir or --localtar are used to specify your local
101 # test release. Use one or the other (not both).
103 # Use --localdir to specify the location of your local install
104 # directory ($MRB_INSTALL).
106 # Use --localtar to specify thye location of a tarball of your
107 # install directory (made relative to $MRB_INSTALL).
109 # Note that --localdir is not grid-friendly.
113 # 1. Each batch worker is uniquely identified by two numbers stored
114 # in environment variables $CLUSTER and $PROCESS (the latter is
115 # a small integer that starts from zero and varies for different
116 # jobs in a parallel job group). These environment variables are
117 # normally set by the batch system, but can be overridden by options
118 # --cluster, --process, and --procmap (e.g. to rerun failed jobs).
120 # 2. The work directory must be set to an existing directory owned
121 # by the submitter and readable by the batch worker. Files from the
122 # work directory are copied to the batch worker scratch directory at
123 # the start of the job.
125 # 3. A local test release may be specified as an absolute path using
126 # --localdir, or a tarball using --localtar. The location of the tarball
127 # may be specified as an absolute path visible on the worker, or a
128 # relative path relative to the work directory.
130 # 4. The output directory must exist and be writable by the batch
131 # worker (i.e. be group-writable for grid jobs). The worker
132 # makes a new subdirectory called ${CLUSTER}_${PROCESS} in the output
133 # directory and copies all files in the batch scratch directory there
134 # at the end of the job. If the output directory is not specified, the
135 # default is /grid/data/<group>/outstage/<user> (user is defined as
136 # owner of work directory).
138 # 5. Parallel projects are specified whenever --njobs is specified to
139 # be greater than one. Parallel projects are supported for single file,
140 # file list, and sam project input.
142 # In all cases, each worker processes some number of complete files.
143 # If the number of jobs is greater than the number of input files, some
144 # workers will not have any input files to process.
146 # In any case, options --nfile and --nevts can be used to limit the
147 # number of files or events that are processed by a single worker,
148 # regardless of the way files are divided among the workers.
150 # Option --njobs is incompatible with options --nskip, and --nfile_skip.
152 # a) Non-sam (single file or file list) input.
154 # In this case, input files are preassigned to workers such that all input
155 # files are approximately evenly divided among the workers. All files
156 # preassigned to this worker are copied to the scratch directory at the
159 # b) Sam project input.
161 # In this case, files are assigned to workers in a non-deterministic
162 # manner by the sam system. The sam system fetches input files to the
163 # scratch directory and deletes processed input files during job execution.
166 # 6. Using option -n or --nevts to limit number of events processed:
168 # a) If no input files are specified (e.g. mc generation), --nevts
169 # specifies total number of events among all workers.
171 # b) If input files are specified, --nevts specifies total number of
172 # events processed by each worker or from each input file, whichever
175 # 7. The interactive option (-i or --interactive) allows this script
176 # to be run interactively by overriding some settings that are normally
177 # obtained from the batch system, including $CLUSTER, $PROCESS, and
178 # the scratch directory. Interactive jobs always set PROCESS=0 (unless
179 # overridden by --process).
181 # 8. Mix options (--mix_defname, --mix_project) are only partially handled
182 # in this script. These options are parsed and their values are stored
183 # in shell variables. It is assumed that the sam project specified
184 # by --mix_project has been started externally, unless --sam_start is
185 # also specified, in which case this script will start the project.
186 # This script does not include any provision for joining the project.
187 # Further processing of these options (joining sam project, generating
188 # command line options or fcl wrappers) should be handled by user
189 # provided initialization scripts (--init-script, --init-source).
191 # 9. Option --init <path> is optional. If specified, it should point to
192 # the absolute path of the experiment environment initialization script,
193 # which path must be visible from the batch worker (e.g. /cvmfs/...).
194 # If this option is not specified, this script will look for and source
195 # a script with hardwired name "setup_experiment.sh" in directory
196 # ${CONDIR_DIR_INPUT}.
199 # Created: H. Greenlee, 29-Aug-2012
201 #------------------------------------------------------------------
260 while [ $# -gt 0 ];
do
265 awk
'/^# Usage:/,/^# End options/{print $0}' $0 | cut -c3- | head -
n -2
271 if [ $# -gt 1 ]; then
279 if [ $# -gt 1 ]; then
287 if [ $# -gt 1 ]; then
295 if [ $# -gt 1 ]; then
303 if [ $# -gt 1 ]; then
311 if [ $# -gt 1 ]; then
319 if [ $# -gt 1 ]; then
325 # Number of events to skip.
327 if [ $# -gt 1 ]; then
333 # Number of files to process.
335 if [ $# -gt 1 ]; then
341 # Number of files to skip.
343 if [ $# -gt 1 ]; then
349 # Number of parallel jobs.
351 if [ $# -gt 1 ]; then
357 # Specify data file types (repeatable).
359 if [ $# -gt 1 ]; then
368 if [ $# -gt 1 ]; then
376 if [ $# -gt 1 ]; then
384 if [ $# -gt 1 ]; then
390 # Sam dataset definition name.
392 if [ $# -gt 1 ]; then
401 if [ $# -gt 1 ]; then
408 # Sam start/stop project flag.
420 if [ $# -gt 1 ]; then
428 if [ $# -gt 1 ]; then
434 # General arguments for lar command line.
436 if [ $# -gt 1 ]; then
443 # Top level ups products (comma-separated list).
445 if [ $# -gt 1 ]; then
453 if [ $# -gt 1 ]; then
459 # Release build qualifier.
461 if [ $# -gt 1 ]; then
467 # Local test release directory.
469 if [ $# -gt 1 ]; then
475 # Local test release tarball.
477 if [ $# -gt 1 ]; then
489 echo
"SRT run time environment is no longer supported."
498 # Grid flag (no effect).
504 if [ $# -gt 1 ]; then
512 if [ $# -gt 1 ]; then
519 if [ $# -gt 1 ]; then
527 if [ $# -gt 1 ]; then
533 # Maximum directory size.
535 if [ $# -gt 1 ]; then
541 # Number of extra directory levels.
543 if [ $# -gt 1 ]; then
551 if [ $# -gt 1 ]; then
559 if [ $# -gt 1 ]; then
565 # Process within cluster.
567 if [ $# -gt 1 ]; then
575 if [ $# -gt 1 ]; then
581 # User initialization script.
583 if [ $# -gt 1 ]; then
589 # User source initialization script.
591 if [ $# -gt 1 ]; then
597 # User end-of-job script.
599 if [ $# -gt 1 ]; then
605 # User midstage initialization source script.
607 if [ $# -gt 1 ]; then
613 # User midstage finalization script.
615 if [ $# -gt 1 ]; then
621 # Declare good output root files to SAM.
626 # Run validation steps in project.py on root outputs directly in the job.
631 # Copy Output to FTS.
636 # Mix input sam dataset.
638 if [ $# -gt 1 ]; then
645 # Mix input sam project.
647 if [ $# -gt 1 ]; then
654 # Alter the output file's parentage such that it's parent(s) are from the input list OR sam process
655 --maintain_parentage )
659 # Specify alternate art-like executable.
661 if [ $# -gt 1 ]; then
667 # Specify environment initialization script path.
669 if [ $# -gt 1 ]; then
677 echo
"Unknown option $1"
684 #echo
"INFILE=$INFILE"
685 #echo
"INLIST=$INLIST"
686 #echo
"OUTFILE=$OUTFILE"
691 #echo
"NFILE_SKIP=$NFILE_SKIP"
696 #echo
"LOCALDIR=$LOCALDIR"
697 #echo
"LOCALTAR=$LOCALTAR"
698 #echo
"INTERACTIVE=$INTERACTIVE"
700 #echo
"OUTDIR=$OUTDIR"
701 #echo
"LOGDIR=$LOGDIR"
702 #echo
"SCRATCH=$SCRATCH"
705 #echo
"INITSCRIPT=$INITSCRIPT"
706 #echo
"INITSOURCE=$INITSOURCE"
707 #echo
"ENDSCRIPT=$ENDSCRIPT"
708 #echo
"MIDSOURCE=$MIDSOURCE"
709 #echo
"MIDSCRIPT=$MIDSCRIPT"
710 #echo
"VALIDATE_IN_JOB=$VALIDATE_IN_JOB"
718 # Done with arguments.
720 echo
"Nodename: `hostname -f`"
727 if [
x$QUAL =
x ]; then
731 if [
x$SAM_GROUP =
x ]; then
735 if [
x$SAM_STATION =
x ]; then
739 # Standardize sam_schema (xrootd -> root, xroot -> root).
741 if [
x$SAM_SCHEMA = xxrootd ]; then
744 if [
x$SAM_SCHEMA = xxroot ]; then
748 # Fix for sites with newer linux kernels:
749 # Do this only if OS is exclusively requested as SL6.
751 #if [ x$OS = xSL6 ]; then
753 # 3.*) export UPS_OVERRIDE="-H Linux64bit+2.6-2.12";;
754 # 4.*) export UPS_OVERRIDE="-H Linux64bit+2.6-2.12";;
757 echo
"uname -r: `uname -r`"
758 echo
"UPS_OVERRIDE: $UPS_OVERRIDE"
760 echo
"Condor dir input: $CONDOR_DIR_INPUT"
762 # Initialize experiment ups products and mrb.
764 echo
"Initializing ups and mrb."
766 if [
x$INIT !=
x ]; then
767 if [ ! -f $INIT ]; then
768 echo
"Environment initialization script $INIT not found."
771 echo
"Sourcing $INIT"
774 echo
"Sourcing setup_experiment.sh"
775 source ${CONDOR_DIR_INPUT}/setup_experiment.sh
778 echo PRODUCTS=$PRODUCTS
779 echo
"ups flavor: `ups flavor`"
781 # Set GROUP environment variable.
784 if [
x$GRP !=
x ]; then
787 echo
"GROUP not specified."
793 # Set options for ifdh.
795 echo
"X509_USER_PROXY = $X509_USER_PROXY"
796 echo
"IFDH_OPT=$IFDH_OPT"
798 # Make sure fcl file argument was specified.
800 if [
x$FCL =
x ]; then
801 echo
"No configuration option (-c|--config) was specified."
805 # Make sure output directory exists and is writable.
807 if [
x$OUTDIR =
x ]; then
808 echo
"Output directory not specified."
811 echo
"Output directory: $OUTDIR"
813 # Make sure log directory exists and is writable.
815 if [
x$LOGDIR =
x ]; then
816 echo
"Log directory not specified."
819 echo
"Log directory: $LOGDIR"
821 # Make sure scratch directory is defined.
822 # For batch, the scratch directory is always $_CONDOR_SCRATCH_DIR
823 # For interactive, the scratch directory is specified by option
824 # --scratch or --outdir.
826 if [ $INTERACTIVE -eq 0 ]; then
829 if [
x$SCRATCH =
x ]; then
833 if [
x$SCRATCH =
x -o ! -d
"$SCRATCH" -o ! -
w "$SCRATCH" ]; then
834 echo
"Local scratch directory not defined or not writable."
838 # Create the scratch directory in the condor scratch diretory.
839 # Copied from condor_lBdetMC.sh.
840 # Scratch directory path is stored in $TMP.
841 # Scratch directory is automatically deleted when shell exits.
843 # Do not change this section.
844 # It creates a temporary working directory that automatically cleans up all
845 # leftover files at the end.
846 TMP=`mktemp -d ${SCRATCH}/working_dir.XXXXXXXXXX`
847 TMP=${TMP:-${SCRATCH}/working_dir.$$}
849 { [[ -
n "$TMP" ]] &&
mkdir -
p "$TMP"; } || \
850 { echo
"ERROR: unable to create temporary directory!" 1>&2;
exit 1; }
851 trap
"[[ -n \"$TMP\" ]] && { rm -rf \"$TMP\"; }" 0
854 # End of the section you should not change.
856 echo
"Scratch directory: $TMP"
858 # Copy files from work directory to scratch directory.
860 echo
"No longer fetching files from work directory."
861 echo
"that's now done with using jobsub -f commands"
863 cp ${CONDOR_DIR_INPUT}
2048 echo
"ifdh mkdir $IFDH_OPT $dir"
2049 ifdh
mkdir $IFDH_OPT $dir
2051 echo
"ifdh mkdir $IFDH_OPT ${LOGDIR}/$OUTPUT_SUBDIR"
2053 echo
"Done making directory ${LOGDIR}/${OUTPUT_SUBDIR}."
2057 echo
"Make directory ${OUTDIR}/${OUTPUT_SUBDIR}."
2059 subdir=$OUTPUT_SUBDIR
2061 while echo $subdir | grep -
q /;
do
2064 echo
"ifdh mkdir $IFDH_OPT $dir"
2065 ifdh
mkdir $IFDH_OPT $dir
2067 echo
"ifdh mkdir $IFDH_OPT ${OUTDIR}/$OUTPUT_SUBDIR"
2069 echo
"Done making directory ${OUTDIR}/${OUTPUT_SUBDIR}."
2073 # Transfer tarball in log subdirectory.
2078 echo
"ifdh cp -D $IFDH_OPT log/log.tar ${LOGDIR}/$OUTPUT_SUBDIR"
2079 ifdh cp -D $IFDH_OPT log/log.tar ${
LOGDIR}/$OUTPUT_SUBDIR
2082 if [ $stat -ne 0 ]; then
2084 echo
"ifdh cp failed with status ${stat}."
2087 # Transfer data files in out subdirectory.
2089 if [ $COPY_TO_FTS -eq 0 ]; then
2091 if [
"$( ls -A out )" ]; then
2092 echo
"ifdh cp -D $IFDH_OPT out/* ${OUTDIR}/$OUTPUT_SUBDIR"
2093 ifdh cp -D $IFDH_OPT out
see a below echo S(symbol in a section other than those above)
process_name opflash particleana ie x
then echo Invalid dCache scratch not copying back else ifdh ls
maintain_parentage MAINTAIN_PARENTAGE
std::vector< SelDef > types
BEGIN_PROLOG dataFFTHistosEW root
constexpr BitMask< Storage > Set(Flag_t< Storage > flag)
Returns a bit mask which sets the specified flag.
auto end(FixedBins< T, C > const &) noexcept
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
i interactive INTERACTIVE