Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:37:06

0001 #!/bin/bash
0002 set -Euo pipefail
0003 trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
0004 IFS=$'\n\t'
0005 
0006 # check arguments
0007 if [ $# -lt 2 ] ; then
0008   echo "Usage: "
0009   echo "  $0 <template> <type> <file or url> [target hours = 2]"
0010   exit
0011 fi
0012 
0013 # Project configuration
0014 RESULTS=results/nightly/${DETECTOR_CONFIG:-epic_craterlake}/main
0015 export BASEURL="https://eicweb.phy.anl.gov/api/v4/projects/491/jobs/artifacts/${DATASET_TAG:-main}/raw/${RESULTS}/datasets/timings/"
0016 export BASEJOB="?job=collect"
0017 BKGURL="https://eicweb.phy.anl.gov/EIC/campaigns/datasets/-/raw/${DATASET_TAG:-main}/config_data"
0018 
0019 # Parse arguments
0020 # - condor template
0021 TEMPLATE=${1}
0022 shift
0023 # - type of simulation
0024 TYPE=${1}
0025 shift
0026 # - input file
0027 FILE=${1}
0028 shift
0029 # - target hours
0030 TARGET=${1:-2}
0031 shift
0032 
0033 # process csv file into jobs
0034 if [ -n "${CSV_FILE:-}" ]; then
0035   # allow to set custom csv file for job instead of fetching from web archive
0036   CSV_FILE=$(realpath -e ${CSV_FILE})
0037 else
0038   CSV_FILE=$($(dirname $0)/csv_to_chunks.sh ${FILE} ${TARGET})
0039 fi
0040 
0041 # create command line
0042 EXECUTABLE="$(dirname $0)/run.sh"
0043 ARGUMENTS="EVGEN/\$(file) \$(ext) \$(nevents) \$(ichunk)"
0044 
0045 # Set background environment variables
0046 if [ -n "${BG_FILES:-}" ]; then
0047   curl -L -O ${BKGURL}/${BG_FILES}
0048 fi
0049 
0050 # construct environment file
0051 ENVIRONMENT=environment-$(basename ${CSV_FILE} .csv).sh
0052 
0053 # extract certificate name
0054 X509_USER_PROXY_BASE=$(basename ${X509_USER_PROXY:-})
0055 
0056 sed "
0057   s|%COPYRECO%|${COPYRECO:-}|g;
0058   s|%COPYFULL%|${COPYFULL:-}|g;
0059   s|%COPYLOG%|${COPYLOG:-}|g;
0060   s|%USERUCIO%|${USERUCIO:-}|g;
0061   s|%X509_USER_PROXY%|${X509_USER_PROXY_BASE:-}|g;
0062   s|%TAG_PREFIX%|${TAG_PREFIX:-}|g;
0063   s|%TAG_SUFFIX%|${TAG_SUFFIX:-}|g;
0064   s|%DETECTOR_VERSION%|${DETECTOR_VERSION}|g;
0065   s|%DETECTOR_CONFIG%|${DETECTOR_CONFIG}|g;
0066   s|%EBEAM%|${EBEAM}|g;
0067   s|%PBEAM%|${PBEAM}|g;
0068   s|%SIGNAL_FREQ%|${SIGNAL_FREQ:-}|g;
0069   s|%SIGNAL_STATUS%|${SIGNAL_STATUS:-}|g;
0070   s|%BG_FILES%|${BG_FILES:-}|g;
0071 " templates/${TEMPLATE}.sh.in > ${ENVIRONMENT}
0072 
0073 # construct requirements
0074 REQUIREMENTS=""
0075 
0076 # construct input files
0077 INPUT_FILES=${ENVIRONMENT},${X509_USER_PROXY}
0078 INPUT_FILES="${INPUT_FILES}${BG_FILES:+,${BG_FILES}}"
0079 
0080 # construct submission file
0081 SUBMIT_FILE=$(basename ${CSV_FILE} .csv).submit
0082 sed "
0083   s|%EXECUTABLE%|${EXECUTABLE}|g;
0084   s|%ARGUMENTS%|${ARGUMENTS}|g;
0085   s|%JUG_XL_TAG%|${JUG_XL_TAG:-nightly}|g;
0086   s|%DETECTOR_VERSION%|${DETECTOR_VERSION}|g;
0087   s|%DETECTOR_CONFIG%|${DETECTOR_CONFIG}|g;
0088   s|%INPUT_FILES%|${INPUT_FILES}|g;
0089   s|%REQUIREMENTS%|${REQUIREMENTS}|g;
0090   s|%CSV_FILE%|${CSV_FILE}|g;
0091 " templates/${TEMPLATE}.submit.in > ${SUBMIT_FILE}
0092 
0093 # submit job
0094 condor_submit -verbose -file ${SUBMIT_FILE}
0095 
0096 # create log dir
0097 if [ $? -eq 0 ] ; then
0098   for i in `condor_q --batch | grep ^${USER} | tail -n1 | awk '{print($NF)}' | cut -d. -f1` ; do
0099     mkdir -p LOG/CONDOR/osg_$i/
0100   done
0101 fi