#!/bin/bash function lastof { if [ ! -z "$1" ]; then /bin/ls "$@" 2>/dev/null | sort | tail -1 else echo "Missing-file-name" fi } function unpack_tar_archive { if [ ! -z "${BUILD_NO_UNPACK}" ]; then echo "Build without unpacking $1" return 0 fi taropt="" if [ ! -z "${TAR_KEEP_FILES}" ]; then taropt="-k" elif [ ! -z "${TAR_KEEP_NEWER}" ]; then taropt="--keep-newer-files" elif [ ! -z "${TAR_BACKUP}" ]; then taropt="--backup=numbered" fi ext=$(echo "$1" | sed 's/.*\.\([^\.]*\)/\1/') if [ "$ext" = "gz" ]; then tar ${taropt} -z -x -f "$@" elif [ "$ext" = "bz2" ]; then tar ${taropt} -j -x -f "$@" elif [ "$ext" = "xz" ]; then tar ${taropt} -J -x -f "$@" elif [ "$ext" = "zst" ]; then ifn="$1" shift zstd -d < "$ifn" | tar ${taropt} -x -f - "$@" elif [ "$ext" = "tar" -o "$ext" = "-" ]; then tar ${taropt} -x -f "$@" else echo "No known way to unpack $1" exit 1 fi } if [ "$1" = "--help" -o "$1" = "help" ]; then echo "Syntax:" echo " ./build_all variant-name he-interaction-model [ extra options ]" echo "Example:" echo " ./build_all prod4 qgs2 native" echo "More variant examples:" echo " ./build_all {hess|hess2|hess2d} { qgs1|qgs2|sibyll|epos }" echo " ./build_all cta { qgs1|qgs2|sibyll|epos }" echo " ./build_all ultra { qgs1|qgs2|sibyll|epos }" echo " ./build_all max { qgs1|qgs2|sibyll|epos }" echo " ./build_all sc{ |2|3|4|5|6} { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{2|3|4|5|6} { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{2|3|4|5|6}-sc { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{3|4|5|6}-demo { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{3|4}-all { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{3|4}-la-palma { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{3|4}[-lp|-paranal][-sc]-baseline { qgs1|qgs2|sibyll|epos }" echo " ./build_all mini{2|3|4|5|6} { qgs1|qgs2|sibyll|epos }" echo " ./build_all mini{4|5|6}-sc { qgs1|qgs2|sibyll|epos }" echo " ./build_all prod{4|5|6}-trg { qgs1|qgs2|sibyll|epos }" echo " ./build_all max-sc { qgs1|qgs2|sibyll|epos }" echo "" echo "Valid high-energy interaction model values for CORSIKA 6.x are: qgs1|qgs2|sibyll." echo "Valid high-energy interaction model values for CORSIKA 7.x are: qgs1|qgs2|sibyll|epos." echo "" echo "Extra options recognized include 'iactext' (allows for particles in data stream)," echo "'native', 'generic', and 'debug' for code generation options, as well as 'curved'," echo "'slant', 'cerwlen', 'store-emitter', 'mark-direct', and 'iact-no-grid' for CORSIKA/IACT." echo "Option cerenkopt (cherenkopt) activates the vector-optimized Cherenkov emission implementation." echo "With 'gsl' the sim_telarray random number generator will use the GNU Scientific Library version." echo "" echo "The 'hess' variant is for H.E.S.S. (I or (early) II) simulations." echo "The 'hess2' variant is for H.E.S.S. II simulations (with old CT5 camera)." echo "The 'hess2d' variant is for H.E.S.S. II simulations (with FlashCam on CT5)." echo "The 'cta' variant (-DCTA) is for up to 99 telescopes of up to 4095 pixels (before prod-1)." echo "The 'ultra' variant (-DCTA_ULTRA) is for up to 275 telescopes but fewer pixels (prod-1)." echo "The 'max' variant (-DCTA_MAX) allows up to 500 tepescopes of up to 4095 pixels." echo "The 'sc' variant (-DCTA_SC) allows only up to 61 telescopes but with up to 14336 pixels." echo "The 'sc2' variant (-DCTA_SC=2) allows only up to 61 telescopes but with up to 11328 pixels (16-bit, single channel)." echo "The 'sc3' variant (-DCTA_SC=3) allows only up to 111 telescopes but with up to 11328 pixels (16-bit, single channel)." echo "The 'sc4' variant (-DCTA_SC=4) is like sc2 but allows for two gains (as sc2 used to be for hybrid-1)." echo "The 'prod2' variant (-DCTA_PROD2) allows up 200 telescopes with up to 2368 pixels (16-bit, single channel)." echo "The 'prod2-sc' variant (-DCTA_PROD2_SC) is equivalent to the sc3 variant." echo "The 'prod3' variant (-DCTA_PROD3) is similar to prod2 but with dual-gain channels." echo "The 'prod3-sc' variant (-DCTA_PROD3_SC) allows including SCTs in simulations (dual gain)." echo "The 'prod3-demo' variant (-DCTA_PROD3_DEMO) is with enough telescopes for demo simulation." echo "The 'prod3-paranal-baseline' variant without SCTs and a maximum of 99 telescopes (for Paranal)." echo "The 'prod3-paranal-sc-baseline' variant with SCTs and a maximum of 99 telescopes (for Paranal)." echo "The 'prod3-lp-std' is for the La Palma prod-3 simulations without SCTs." echo "The 'prod3-lp-sc' is for the La Palma prod-3 simulations with SCTs." echo "The 'prod3-lp-all' is for the La Palma prod-3b simulations including FC/NC/SCTs." echo "The 'prod3-lp-baseline' is for just the La Palma baseline layout without SCTs." echo "The 'prod3-lp-sc-baseline' is for just the La Palma baseline layout with SCTs." echo "With 'prod3-all' you will actually build multiple variants (prod3/prod3-sc/prod3-demo/max-sc/prod3-baseline)." echo "With 'prod3-la-palma' you will in addition build variants optimized for prod3n at La Palma." echo "While some build names are explicity aimed for the upcoming prod-4 configuration" echo " all prod-3 builds are generally consistent with running prod-4 simulations." echo "The 'prod4-*' builds have generally the same limits as corresponding 'prod3-* builds," echo " with a few exceptions (-DCTA_PROD4_SC, for example, has more telescopes than -DCTA_PROD3_SC)." echo "The 'prod5-*' builds are again basically like their prod4-* counterparts except with more telescopes" echo " in most cases (baseline and mini versions are exactly like prod4 counterparts)." echo "The 'prod6-*' builds, in turn, are basically like their prod5-* counterparts." echo "With 'baseline' separate versions optimized for La Palma and Paranal baseline layouts are built." echo "The 'baseline3' aims specifically for prod-3, 'baseline4' for prod-4, but are basically equivalent." echo "The 'mini2/3/4/5/6' are variants of 'prod2', 'prod3', and 'prod4/5', etc., for fewer telescopes." echo "The 'mini4/5/6-sc' also supports SCTs, for the same small number of telescopes." echo "The 'prod4/5/6-trg' accepts SCTs, with just up to four telescopes but very long traces for trigger tests." echo "The 'prod6-alpha' is for a minimal prod-6 set without SCTs, 'prod6-alpha-sc' for a minimal set with SCTs." echo "The 'max-sc' variant (-DCTA_MAX_SC) should handle all prod1/2/3/4/5/6 configurations but needs more memory." echo "" echo "The 'qgs1' option activates the QGSJET01c/URQMD interaction models." echo "The 'qgs2' option activates the QGSJET-II/URQMD interaction models." echo " You will also need the qgsdat-II-03 or qgsdat-II-04 file in that case." echo "The 'sibyll' option activates the SIBYLL/URQMD interaction models." echo "The 'epos' option activates the EPOS(-LHC)/URQMD interaction models (CORSIKA 7.x only)." echo "There is no default high-energy interaction model. You have to make a choice." echo "The low-energy interaction model selected is always URQMD." echo "" echo "Use the EXTRA_DEFINES variable for any additional sim_telarray + hessioxxx definitions." echo "Define MAXIMUM_TELESCOPES (set EXTRA_DEFINES='-DMAXIMUM_TELESCOPES=...') to override the" echo " maximum number consistently in sim_telarray and the hessio library." echo "Set the NO_CORSIKA variable to bypass building CORSIKA." echo "Set the NO_SIMTEL variable to bypass building sim_telarray." echo "Set the NO_HESSIO variable to bypass building the hessio library (implies NO_SIMTEL)." echo "Alternative variables for exclusive builds: ONLY_CORSIKA, ONLY_SIMTEL, ONLY_HESSIO." # echo "Set the NO_IACT_UPDATE variable if you want to skip the updated IACT/ATMO package (not recommended)." # echo "Set the NO_CORSIKA_PATCH variable if you want to skip any available patches for CORSIKA (not recommended)." # echo "The optional stdtools packages can be bypassed by setting NO_STDTOOLS / NO_IACTIO." echo "The optional stdtools package can be bypassed by setting NO_STDTOOLS." echo "The optional iactio package is usally bypassed. Set WITH_IACTIO to activate it." echo "Note that the build_all script is best suited for fresh installations." echo "Unpacking the (corsika,sim_telarray,hessio,...)*.tar.* packages etc. may" echo "overwrite existing files - perhaps even files modified by yourself." echo "Set the BUILD_NO_UNPACK environment variable to avoid unpacking and" echo "applying any patches. The tar unpacking can also be changed by setting" echo "environment variable TAR_KEEP_FILES, TAR_KEEP_NEWER, or TAR_BACKUP." echo "Set the CORSIKA_PATCHES environment variable if you want to apply" echo "multiple or non-standard patches to CORSIKA." exit 1 fi export NO_IACTIO=1 # ONLY_CORSIKA means no sim_telarray and not even the hessio library. if [ ! -z "${ONLY_CORSIKA}" ]; then unset NO_CORSIKA export NO_HESSIO=1 export NO_SIMTEL=1 export NO_STDTOOLS=1 export NO_IACTIO=1 fi # Similar for building only sim_telarray but no CORSIKA. if [ ! -z "${ONLY_SIMTEL}" ]; then export NO_CORSIKA=1 unset NO_HESSIO unset NO_SIMTEL export NO_STDTOOLS=1 export NO_IACTIO=1 fi # Or just building the hessio library and applications. if [ ! -z "${ONLY_HESSIO}" ]; then export NO_CORSIKA=1 unset NO_HESSIO export NO_SIMTEL=1 export NO_STDTOOLS=1 export NO_IACTIO=1 fi export CTA_PATH=$(/bin/pwd) unset HESSIO_PATH export HESSIO_PATH unset STDTOOLS_PATH export STDTOOLS_PATH unset SIMTEL_PATH export SIMTEL_PATH afile=$(/bin/ls iact-atmo-*.tar.* 2>/dev/null | sort | tail -1) avers=$(echo $afile | sed 's/iact-atmo-\(1.[0-9][0-9\.-]*\)[a-z]*.tar.[a-z2]*/\1/') bfile=$(/bin/ls bernlohr-*.tar.* 2>/dev/null | sort | tail -1) bvers=$(echo $bfile | sed 's/bernlohr-\(1.[0-9][0-9\.-]*\)[a-z]*.tar.[a-z2]*/\1/') cfile="$(/bin/ls corsika*[67]*[0-9][0-9][0-9]*.tar.* 2>/dev/null | egrep '^corsika[-]*[67][\.]*[0-9]+[a-z]*.tar.[a-z2]*' | sort | tail -1)" cvers="$(echo $cfile | sed 's/corsika[-]*\([67][\.]*[0-9]*\)[a-z]*.tar.[a-z2]*/\1/')" cvers7=$( (echo $cvers | egrep '^7' > /dev/null) && echo 1 || echo 0 ) # The corsika_simtelarray package may include an older or an updated patch/package for optimized Cherenkov emission # but automatic building needs the updated version plus IACT/ATMO package >= 1.65. ofile=$(/bin/ls corsikaOptPatch*.tar.* 2>/dev/null | sort | tail -1) overs=$(echo $ofile | sed 's/^.*_\(.*\)\.tar\..*/\1/') if [ "${overs}" = "2020-07-30" ]; then ofile=""; fi # This old version not suitable for automatic build with CERENKOPT option. noopt=$(echo $bvers | egrep '1\.([0-5].*|6[0-4].*)' | wc -l) if [ "$noopt" = "1" ]; then ofile=""; fi # Older IACT/ATMO package than 1.65 does not have the right scripts. if [ -z "$cfile" ]; then export NO_CORSIKA=1 # There is no CORSIKA available, so we don't think about building it. fi hfile=$(/bin/ls hessio*.tar.* 2>/dev/null | grep -v doc | sort | tail -1) if [ -z "$hfile" ]; then export NO_HESSIO=1 fi arraysim_package="$(/bin/ls -t -r sim_hessarray.tar.* sim_telarray.tar.* sim_*array_20*.tar.* 2>/dev/null | tail -1)" config_packages="sim_telarray_config.tar.* sim_telarray_config_*.tar.*" if [ -z "${arraysim_package}" ]; then export NO_SIMTEL=1 fi if [ -z "${NO_STDTOOLS}" ]; then ipkg="$(lastof stdtools.tar.*)" if [ -r "$ipkg" ]; then export WITH_STDTOOLS=1 fi fi if [ -z "${NO_IACTIO}" ]; then ipkg="$(lastof iactio.tar.*)" if [ -r "$ipkg" ]; then export WITH_IACTIO=1 fi fi if [ ! -z "${WITH_IACTIO}" ]; then unset NO_IACTIO export NO_IACTIO fi if [ ! -z "${WITH_STDTOOLS}" ]; then unset NO_STDTOOLS export NO_STDTOOLS fi if [ ! -z "${NO_CORSIKA}" -a ! -z "${NO_SIMTEL}" -a ! -z "${NO_HESSIO}" -a -z "${WITH_STDTOOLS}" -a -z "${WITH_IACTIO}" ]; then echo "Nothing left - either no packages available or everything was de-selected." exit 1 fi # Some parts include RPATHS into the binaries only on request rpath_opt="" if [ -z "${NO_RPATH}" -o ! -z "${WITH_RPATH}" ]; then rpath_opt="WITH_RPATH=1" else rpath_opt="NO_RPATH=1" fi if [ "$1" = "--keep" ]; then # Instruct tar not to overwrite newer locally modified files (used only for configs & example scripts) # Problem is it writes warnings also about all files which did not change on either side. keep="--keep-newer-files" export TAR_KEEP_NEWER=1 shift fi if [ "$1" = "--backup" ]; then # Instruct tar to keep existing files as backups. # Problem is it creates backups of all existing files, even if identical. keep="--backup=numbered" export TAR_BACKUP=1 shift fi # Keep book of what was asked to build. The prepare_for_examples script may adapt to that. echo "$@" >> .buildconf is_hess="$(echo $1 | egrep 'hess|HESS|phase1|phase2' | wc -l)" is_prod1="$(echo $1 | egrep 'prod1|ultra3' | wc -l)" is_prod2="$(echo $1 | egrep 'prod2|ultra5' | wc -l)" is_prod3="$(echo $1 | egrep 'prod3|mini3|baseline3|ultra6' | wc -l)" is_prod4="$(echo $1 | egrep 'prod4|mini4|baseline4' | wc -l)" is_prod5="$(echo $1 | egrep 'prod5|mini5|baseline5' | wc -l)" is_prod6="$(echo $1 | egrep 'prod6|mini6|baseline6|alpha6' | wc -l)" rm -f .is_hess .is_prod* if [ "${is_hess}" = "1" ]; then echo "$1" > .is_hess; build_type="hess"; fi if [ "${is_prod1}" = "1" ]; then echo "$1" > .is_prod1; build_type="prod1"; fi if [ "${is_prod2}" = "1" ]; then echo "$1" > .is_prod2; build_type="prod2"; fi if [ "${is_prod3}" = "1" ]; then echo "$1" > .is_prod3; build_type="prod3"; fi if [ "${is_prod4}" = "1" ]; then echo "$1" > .is_prod4; build_type="prod4"; fi if [ "${is_prod5}" = "1" ]; then echo "$1" > .is_prod5; build_type="prod5"; fi if [ "${is_prod6}" = "1" ]; then echo "$1" > .is_prod6; build_type="prod6"; fi if [ ! -e qgsdat-II-03 -a -r ../qgsdat-II-03 ]; then ln -s ../qgsdat-II-03; fi if [ ! -e qgsdat-II-04 -a -r ../qgsdat-II-04 ]; then ln -s ../qgsdat-II-04; fi if [ "$1" = "prod3-all" ]; then echo "=============================================================================" echo "Installing prod3 standard, sct, demo, baseline, merging, and max-sc versions." echo "CORSIKA only built with standard version (also usable with other versions)." echo "No sim_telarray built with merging and max-sc versions (not needed)." echo "=============================================================================" echo "" sleep 1 npatch="$(/bin/ls *.patch 2>/dev/null | wc -l)" if [ "$npatch" = "0" ]; then touch no.patch fi if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi if [ ! -d "std" ]; then (mkdir std && cd std && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi if [ ! -d "sct" ]; then (mkdir sct && cd sct && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi if [ ! -d "demo" ]; then (mkdir demo && cd demo && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi if [ ! -d "mrg" ]; then (mkdir mrg && cd mrg && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi if [ ! -d "max" ]; then (mkdir max && cd max && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi echo "=======================================" echo "Building the prod3 std variant ..." (cd std && ./build_all prod3 $2) || exit 1 (cd std && ln -s example_scripts/Prod3/* .) ln -s std/example_scripts . ln -s example_scripts/Prod3/* . ln -s std/examples_common.sh . ln -s std/prepare_for_examples . ln -s std/corsika-run . ln -s std/corsika-${cvers} . if [ -r std/qgsdat-II-03 ]; then ln -s std/qgsdat-II-03; fi if [ -r std/qgsdat-II-04 -a ! -e qgsdat-II-04 ]; then ln -s std/qgsdat-II-04; fi echo "=======================================" echo "Building the prod3 sct variant ..." (cd sct && ln -s ../std/corsika-${cvers} .) (cd sct && ln -s ../std/corsika-run .) (cd sct && ln -s ../std/example_scripts .) (cd sct && NO_CORSIKA=1 ./build_all prod3-sc $2 $3 $4 $5 $6 $7 $8) || exit 1 (cd sct && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=======================================" echo "Building the prod3 demo variant ..." (cd demo && ln -s ../std/corsika-${cvers} .) (cd demo && ln -s ../std/corsika-run .) (cd demo && ln -s ../std/example_scripts .) (cd demo && NO_CORSIKA=1 ./build_all prod3-demo $2 $3 $4 $5 $6 $7 $8) || exit 1 # (cd demo && ln -s example_scripts/Prod3/* .) || exit 1 (cd demo && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=======================================" echo "Building the prod3 mrg variant ..." (cd mrg && NO_CORSIKA=1 NO_SIMTEL=1 SAVE_MEMORY=1 ./build_all prod3-merge $2 $3 $4 $5 $6 $7 $8) || exit 1 echo "=======================================" echo "Building the prod3 max variant ..." (cd max && NO_CORSIKA=1 NO_SIMTEL=1 SAVE_MEMORY=1 ./build_all max-sc $2 $3 $4 $5 $6 $7 $8) || exit 1 if [ ! -d "pa-baseline" ]; then (mkdir pa-baseline && cd pa-baseline && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi echo "=======================================" echo "Building the prod3 paranal-baseline variant ..." (cd pa-baseline && ln -s ../std/corsika-${cvers} .) (cd pa-baseline && ln -s ../std/corsika-run .) (cd pa-baseline && ln -s ../std/example_scripts .) (cd pa-baseline && NO_CORSIKA=1 ./build_all prod3-paranal-baseline $2 $3 $4 $5 $6 $7 $8) || exit 1 # (cd pa-baseline && ln -s example_scripts/Prod3/* .) || exit 1 (cd pa-baseline && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=========== Done with the prod3-all build ===========" exit fi if [ "$1" = "baseline" -o "$1" = "baseline3" -o "$1" = "baseline4" -o "$1" = "baseline5" -o "$1" = "baseline6" ]; then PRODVERS=3 if [ "$1" = "baseline4" -o "$1" = "baseline5" ]; then PRODVERS=4 fi if [ "$1" = "baseline6" ]; then PRODVERS=6 fi echo "=============================================================================" echo "Installing versions optimized for La Palma and Paranal baseline layouts." echo "=============================================================================" echo "" sleep 1 npatch="$(/bin/ls *.patch 2>/dev/null | wc -l)" if [ "$npatch" = "0" ]; then touch no.patch fi if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi # Version for Paranal site baseline layout if [ ! -d "pa-baseline" ]; then (mkdir pa-baseline && cd pa-baseline && ln -sf ../Data . && ln -s ../*.tar.* ../*.patch ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi (cd pa-baseline && ./build_all prod${PRODVERS}-paranal-baseline $2 $3 $4 $5 $6 $7 $8) || exit 1 (cd pa-baseline && ln -s example_scripts/Prod${PRODVERS}/* .) || exit 1 ln -s pa-baseline/example_scripts . ln -s example_scripts/Prod${PRODVERS}/* . ln -s pa-baseline/examples_common.sh . ln -s pa-baseline/prepare_for_examples . ln -s pa-baseline/corsika-run . ln -s pa-baseline/corsika-${cvers} . if [ -r pa-baseline/qgsdat-II-03 ]; then ln -s pa-baseline/qgsdat-II-03; fi if [ -r pa-baseline/qgsdat-II-04 -a ! -e qgsdat-II-04 ]; then ln -s pa-baseline/qgsdat-II-04; fi if [ ! -d std ]; then ln -s pa-baseline std fi # Version for La Palma site baseline layout if [ ! -d "lp-baseline" ]; then (mkdir lp-baseline && cd lp-baseline && ln -sf ../Data . && ln -s ../*.tar.* ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi (cd lp-baseline && ln -s ../pa-baseline/corsika-${cvers} .) (cd lp-baseline && ln -s ../std/corsika-run .) (cd lp-baseline && ln -s ../std/example_scripts .) (cd lp-baseline && NO_CORSIKA=1 ./build_all prod${PRODVERS}-lp-baseline $2 $3 $4 $5 $6 $7 $8) || exit 1 # (cd lp-baseline && ln -s example_scripts/Prod${PRODVERS}/* .) || exit 1 (cd lp-baseline && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=========== Done with the $1 build ===========" exit fi # A '-DCTA' is appropriate for CTA benchmark, HESS, and 'Phase3' simulations. defs="unknown" # Use 'unknown' to force using with known to be supported setups. # A '-DCTA_MAX' is OK for all available simulations but needs LOTS of memory. # defs="-DCTA_MAX" if [ ! -z "$CTA_ULTRA" ]; then defs="-DCTA -DCTA_ULTRA" fi if [ ! -z "$CTA_MAX" ]; then defs="-DCTA -DCTA_MAX" fi if [ ! -z "$CTA_SC" ]; then defs="-DCTA -DCTA_SC=${CTA_SC}" fi if [ "$1" = "CTA" -o "$1" = "cta" ]; then defs="-DCTA" shift fi if [ "$1" = "CTA_ULTRA" -o "$1" = "cta_ultra" -o "$1" = "ultra" -o "$1" = "prod1" ]; then defs="-DCTA -DCTA_ULTRA" shift fi if [ "$1" = "CTA_MAX" -o "$1" = "cta_max" -o "$1" = "max" ]; then defs="-DCTA -DCTA_MAX" shift fi if [ "$1" = "CTA_SC" -o "$1" = "cta_sc" -o "$1" = "sc" ]; then defs="-DCTA -DCTA_SC" shift fi if [ "$1" = "CTA_SC2" -o "$1" = "cta_sc2" -o "$1" = "sc2" ]; then defs="-DCTA -DCTA_SC=2" shift fi if [ "$1" = "CTA_SC3" -o "$1" = "cta_sc3" -o "$1" = "sc3" ]; then defs="-DCTA -DCTA_SC=3" shift fi if [ "$1" = "CTA_SC4" -o "$1" = "cta_sc4" -o "$1" = "sc4" ]; then defs="-DCTA -DCTA_SC=4" shift fi if [ "$1" = "CTA_PROD2" -o "$1" = "cta_prod2" -o "$1" = "prod2" ]; then defs="-DCTA -DCTA_PROD2" shift fi if [ "$1" = "CTA_MINI2" -o "$1" = "cta_mini2" -o "$1" = "mini2" ]; then defs="-DCTA -DCTA_PROD2 -DCTA_MINI" shift fi if [ "$1" = "CTA_PROD2_SC" -o "$1" = "cta_prod2_sc" -o "$1" = "prod2-sc" ]; then defs="-DCTA -DCTA_PROD2_SC" shift fi if [ "$1" = "CTA_ULTRA5" -o "$1" = "cta_ultra5" -o "$1" = "ultra5" ]; then defs="-DCTA -DCTA_ULTRA5" shift fi if [ "$1" = "CTA_PROD3" -o "$1" = "cta_prod3" -o "$1" = "prod3" -o "$1" = "ultra6" ]; then defs="-DCTA -DCTA_PROD3 -DDSUM_DOUBLE" shift fi if [ "$1" = "prod3-baseline" -o "$1" = "prod3-paranal-baseline" -o "$1" = "baseline3" ]; then defs="-DCTA -DCTA_PROD3 -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod3-sc-baseline" -o "$1" = "prod3-paranal-sc-baseline" ]; then defs="-DCTA -DCTA_PROD3_SC -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod4-baseline" -o "$1" = "prod4-paranal-baseline" -o "$1" = "baseline4" ]; then defs="-DCTA_PROD4 -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod4-sc-baseline" -o "$1" = "prod4-paranal-sc-baseline" ]; then defs="-DCTA_PROD4_SC -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod5-baseline" -o "$1" = "prod5-paranal-baseline" -o "$1" = "baseline5" ]; then defs="-DCTA_PROD4 -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod5-sc-baseline" -o "$1" = "prod5-paranal-sc-baseline" ]; then defs="-DCTA_PROD4_SC -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod6-baseline" -o "$1" = "prod6-paranal-baseline" -o "$1" = "baseline6" ]; then defs="-DCTA_PROD6 -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "prod6-sc-baseline" -o "$1" = "prod6-paranal-sc-baseline" ]; then defs="-DCTA_PROD6_SC -DMAXIMUM_TELESCOPES=99" shift fi if [ "$1" = "CTA_MINI3" -o "$1" = "cta_mini3" -o "$1" = "mini3" ]; then defs="-DCTA -DCTA_PROD3 -DCTA_MINI -DDSUM_DOUBLE" shift fi if [ "$1" = "CTA_PROD3_SC" -o "$1" = "cta_prod3_sc" -o "$1" = "prod3-sc" ]; then defs="-DCTA -DCTA_PROD3_SC -DDSUM_DOUBLE" shift fi if [ "$1" = "CTA_PROD3_DEMO" -o "$1" = "cta_prod3_demo" -o "$1" = "prod3-demo" ]; then defs="-DCTA -DCTA_PROD3_DEMO -DDSUM_DOUBLE" shift fi if [ "$1" = "prod3-merge" ]; then defs="-DCTA_PROD3_MERGE" shift fi if [ "$1" = "prod3-lp-std" ]; then defs="-DCTA -DCTA_PROD3 -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=119 -DMAXIMUM_SECTORS=1000" shift fi if [ "$1" = "prod3-lp-sct" ]; then defs="-DCTA -DCTA_PROD3_SC -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=99 -DMAXIMUM_SLICES=80" shift fi if [ "$1" = "prod3-lp-all" ]; then defs="-DCTA -DCTA_PROD3_SC -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=125 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod3-lp-baseline" ]; then defs="-DCTA -DCTA_PROD3 -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_PIXELS=1855 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod3-lp-sc-baseline" ]; then defs="-DCTA -DCTA_PROD3_SC -DDSUM_DOUBLE -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod4-lp-baseline" ]; then defs="-DCTA_PROD4 -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_PIXELS=1855 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod5-lp-baseline" ]; then defs="-DCTA_PROD4 -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_PIXELS=1855 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod6-lp-baseline" ]; then defs="-DCTA_PROD6 -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_PIXELS=1855 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod4-lp-sc-baseline" ]; then defs="-DCTA_PROD4_SC -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "prod5-lp-sc-baseline" ]; then defs="-DCTA_PROD4_SC -DMAXIMUM_TELESCOPES=19 -DMAXIMUM_SLICES=100" shift fi if [ "$1" = "CTA_MINI4" -o "$1" = "cta_mini4" -o "$1" = "mini4" ]; then defs="-DCTA_MINI4" shift fi if [ "$1" = "CTA_MINI5" -o "$1" = "cta_mini5" -o "$1" = "mini5" ]; then defs="-DCTA_MINI4" shift fi if [ "$1" = "CTA_MINI4_SC" -o "$1" = "cta_mini4_sc" -o "$1" = "mini4-sc" ]; then defs="-DCTA_PROD4_SC -DCTA_MINI4" shift fi if [ "$1" = "CTA_MINI5_SC" -o "$1" = "cta_mini5_sc" -o "$1" = "mini5-sc" ]; then defs="-DCTA_PROD4_SC -DCTA_MINI4" shift fi if [ "$1" = "CTA_PROD4" -o "$1" = "cta_prod4" -o "$1" = "prod4" ]; then defs="-DCTA_PROD4" shift fi if [ "$1" = "CTA_PROD5" -o "$1" = "cta_prod5" -o "$1" = "prod5" ]; then defs="-DCTA_PROD4 -DMAXIMUM_TELESCOPES=180" shift fi if [ "$1" = "CTA_PROD4_SC" -o "$1" = "cta_prod4_sc" -o "$1" = "prod4-sc" ]; then defs="-DCTA_PROD4_SC" shift fi if [ "$1" = "CTA_PROD5_SC" -o "$1" = "cta_prod5_sc" -o "$1" = "prod5-sc" ]; then defs="-DCTA_PROD4_SC" shift fi if [ "$1" = "CTA_PROD4_TRG" -o "$1" = "cta_prod4_trg" -o "$1" = "prod4-trg" ]; then defs="-DCTA_PROD4_SC -DMAXIMUM_TELESCOPES=4 -DMAXIMUM_SLICES=1000" shift fi if [ "$1" = "CTA_PROD5_TRG" -o "$1" = "cta_prod5_trg" -o "$1" = "prod5-trg" ]; then defs="-DCTA_PROD4_SC -DMAXIMUM_TELESCOPES=4 -DMAXIMUM_SLICES=1000" shift fi if [ "$1" = "CTA_PROD6_TRG" -o "$1" = "cta_prod6_trg" -o "$1" = "prod6-trg" ]; then defs="-DCTA_PROD6_SC -DMAXIMUM_TELESCOPES=4 -DMAXIMUM_SLICES=1000" shift fi if [ "$1" = "prod6" -o "$1" = "PROD6" ]; then defs="-DCTA_PROD6" shift fi if [ "$1" = "prod6-alpha" -o "$1" = "prod6-paranal-alpha" -o "$1" = "alpha6" ]; then defs="-DCTA_PROD6 -DMAXIMUM_TELESCOPES=87" shift fi if [ "$1" = "prod6-alpha-sc" -o "$1" = "prod6-paranal-alpha-sc" ]; then defs="-DCTA_PROD6_SC -DMAXIMUM_TELESCOPES=106" shift fi if [ "$1" = "prod6-sc" -o "$1" = "prod6-paranal-sc" ]; then defs="-DCTA_PROD6_SC -DMAXIMUM_TELESCOPES=120" shift fi if [ "$1" = "CTA_MINI6" -o "$1" = "cta_mini6" -o "$1" = "mini6" ]; then defs="-DCTA_MINI6" shift fi if [ "$1" = "CTA_MINI6_SC" -o "$1" = "cta_mini6_sc" -o "$1" = "mini6-sc" ]; then defs="-DCTA_PROD6_SC -DCTA_MINI6" shift fi if [ "$1" = "prod3-la-palma" ]; then echo "===============================================================================" echo "Installing versions optimized for La Palma prod-3 simulation (after prod3-all)." echo "===============================================================================" echo "" sleep 1 if [ ! -d std ]; then ./build_all prod3-all $2 $3 $4 $5 $6; fi if [ ! -d "lp-std" ]; then (mkdir lp-std && cd lp-std && ln -sf ../Data . && ln -s ../*.tar.* ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi if [ ! -d "lp-sct" ]; then (mkdir lp-sct && cd lp-sct && ln -sf ../Data . && ln -s ../*.tar.* ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi if [ ! -d "lp-all" ]; then (mkdir lp-all && cd lp-all && ln -sf ../Data . && ln -s ../*.tar.* ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi echo "=======================================" echo "Building the prod3 lp-std variant ..." (cd lp-std && ln -s ../std/corsika-${cvers} .) (cd lp-std && ln -s ../std/corsika-run .) (cd lp-std && ln -s ../std/example_scripts .) (cd lp-std && NO_CORSIKA=1 ./build_all prod3-lp-std $2 $3 $4 $5 $6) || exit 1 (cd lp-std && ln -s example_scripts/Prod3/* .) || exit 1 echo "=======================================" echo "Building the prod3 lp-sct variant ..." (cd lp-sct && ln -s ../std/corsika-${cvers} .) (cd lp-sct && ln -s ../std/corsika-run .) (cd lp-sct && ln -s ../std/example_scripts .) (cd lp-sct && NO_CORSIKA=1 ./build_all prod3-lp-sct $2 $3 $4 $5 $6) || exit 1 (cd lp-sct && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=======================================" echo "Building the prod3 lp-all variant ..." (cd lp-all && ln -s ../std/corsika-${cvers} .) (cd lp-all && ln -s ../std/corsika-run .) (cd lp-all && ln -s ../std/example_scripts .) (cd lp-all && NO_CORSIKA=1 ./build_all prod3-lp-all $2 $3 $4 $5 $6) || exit 1 (cd lp-all && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=======================================" echo "Building the prod3 lp-baseline variant ..." if [ ! -d "lp-baseline" ]; then (mkdir lp-baseline && cd lp-baseline && ln -sf ../Data . && ln -s ../*.tar.* ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi (cd lp-baseline && ln -s ../std/corsika-${cvers} .) (cd lp-baseline && ln -s ../std/corsika-run .) (cd lp-baseline && ln -s ../std/example_scripts .) (cd lp-baseline && NO_CORSIKA=1 ./build_all prod3-lp-baseline $2 $3 $4 $5 $6) || exit 1 (cd lp-baseline && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) # echo "=======================================" # echo "Building the prod3 lp-sc-baseline variant ..." # if [ ! -d "lp-sc-baseline" ]; then (mkdir lp-sc-baseline && cd lp-sc-baseline && ln -sf ../Data . && ln -s ../*.tar.* ../build_all ../corsika_build_script ../init_batch_job_SGE .) || exit 1; fi # (cd lp-sc-baseline && ln -s ../std/corsika-${cvers} .) # (cd lp-sc-baseline && ln -s ../std/corsika-run .) # (cd lp-sc-baseline && ln -s ../std/example_scripts .) # (cd lp-sc-baseline && NO_CORSIKA=1 ./build_all prod3-lp-sc-baseline $2 $3 $4 $5 $6) || exit 1 # (cd lp-sc-baseline && for f in $(find example_scripts/Prod3 -maxdepth 1 -type f); do g=$(basename "$f"); if [ ! -e "$g" ]; then ln -s $f .; fi; done) echo "=========== Done with the prod3-la-palma build ===========" exit fi if [ "$1" = "CTA_MAX_SC" -o "$1" = "cta_max_sc" -o "$1" = "max_sc" -o "$1" = "max-sc" ]; then defs="-DCTA -DCTA_MAX_SC -mcmodel=large" shift fi if [ "$1" = "HESS_PHASE_2" -o "$1" = "HESS" -o "$1" = "hess" -o "$1" = "hess2" ]; then defs="-DHESS_PHASE_2" shift fi if [ "$1" = "HESS_PHASE_2D" -o "$1" = "hess2d" ]; then defs="-DHESS_PHASE_2=2" shift fi if [ ! -z "${SAVE_MEMORY}" ]; then defs="${defs} -DH_SAVE_MEMORY" fi if [ "$defs" = "unknown" ]; then echo "Unknown build_all configuration: $1" exit 1 fi if [ ! -z "${EXTRA_DEFINES}" ]; then defs="${defs} ${EXTRA_DEFINES}" fi echo "Building CORSIKA version $cvers with IACT/ATMO package version $bvers." echo "Building hessio+sim_telarray with these definitions: $defs" # bvers=1.48 # cvers=6990 # interact="qgsjet01c" interact="unknown" if [ "$1" = "sibyll" ]; then interact="sibyll" shift else if [ "$1" = "qgs2" ]; then interact="qgs2" shift else if [ "$1" = "epos" ]; then interact="epos" shift else if [ "$1" = "qgs1" ]; then interact="qgsjet01c" shift else # default high-energy interaction model # interact="qgsjet01c" interact="not-defined" echo "You need to select one of the following CORSIKA high-energy interaction models:" echo " qgs1 | qgs2 | sibyll | epos" exit 1 fi fi fi fi cextra="" generic="" if [ ! -z "${force_generic}" ]; then generic="generic" fi if [ ! -z "${force_native}" ]; then generic="native" fi debug="" if [ ! -z "${CDEBUGFLAGS}" ]; then cdebugflags="${CDEBUGFLAGS}" fi # If there are more parameters, assume they are extra definitions (max. 20): # (Using the EXTRA_DEFINES env var is the better way to go for the simtel part.) for ((i=0; i<20; i++)); do if [ ! -z "$1" ]; then case "$1" in native) generic="native" ;; generic) generic="generic" ;; debug) debug="debug"; cdebugflags="-g -O0" ;; iactext|IACTEXT) cextra="${cextra} iactext"; defs="${defs} -DIACTEXT";; curved|CURVED) cextra="${cextra} curved";; slant|SLANT) cextra="${cextra} slant";; cerwlen|CERWLEN) cextra="${cextra} cerwlen";; mark-direct) cextra="${cextra} mark-direct";; store-emitter) cextra="${cextra} store-emitter";; iact-no-grid) cextra="${cextra} iact-no-grid";; noclong) cextra="${cextra} noclong";; cherenkopt|cerenkopt) cextra="${cextra} cerenkopt"; with_cerenkopt="yes" ;; vlibm) cextra="${cextra} vlibm"; with_vlibm="yes";; gsl) defs="${defs} -DWITH_GSL -DWITH_GSL_RNG";; particles-extra) cextra="${cextra} iactext store-emitter ehistory muprod";; ehistory) cextra="${cextra} ehistory";; muprod) cextra="${cextra} muprod";; nrrext) cextra="${cextra} nrrext";; no-iactio) export NO_IACTIO=1;; iactio|with-iactio) unset NO_IACTIO; export NO_IACTIO;; no-stdtools) export NO_STDTOOLS=1;; stdtools|with-stdtools) unset NO_STDTOOLS; export NO_STDTOOLS;; *) defs="${defs} $1" ;; esac shift fi done set -x # -------------------- CORSIKA --------------------------- if [ -z "${NO_CORSIKA}" ]; then if [ "${interact}" = "unknown" ]; then echo "Choose one of the following interaction models: qgs1 qgs2 sibyll epos" exit 1 fi echo "Interaction model to be used : ${interact}" sleep 1 if [ -z "${BUILD_NO_UNPACK}" ]; then # Install the original CORSIKA code. echo "Unpacking CORSIKA version ${cvers} file ${cfile} ..." unpack_tar_archive ${cfile} || exit 1 if [ -z "${NO_IACT_UPDATE}" ]; then # The IACT/ATMO package coming with CORSIKA is (almost always) outdated. if [ -z "$afile" ]; then # Classical 'bernlohr-1.xy.tar.gz' package name echo "Using IACT/ATMO ('bernlohr') package version ${bvers} ..." (cd corsika-${cvers}/bernlohr && unpack_tar_archive $(lastof ../../bernlohr-${bvers}.tar.*) ) || exit 1 elif [ -z "$bfile" ]; then # Alternate 'iact-atmo-z.xy.tar.gz' name echo "Using IACT/ATMO ('iact-atmo') package version ${avers} ..." (cd corsika-${cvers}/bernlohr && unpack_tar_archive $(lastof ../../iact-atmo-${avers}.tar.*) ) || exit 1 elif [ "$avers" -gt "$bvers" ]; then # Oh, we have both - why that? Take higher version number. echo "Using IACT/ATMO ('iact-atmo') package version ${avers} ..." (cd corsika-${cvers}/bernlohr && unpack_tar_archive $(lastof ../../iact-atmo-${avers}.tar.*) ) || exit 1 else echo "Using IACT/ATMO ('bernlohr') package version ${bvers} ..." (cd corsika-${cvers}/bernlohr && unpack_tar_archive $(lastof ../../bernlohr-${bvers}.tar.*) ) || exit 1 fi # The new floating point exception tracking might be just too effective for CORSIKA: if [ ! -z "${NO_TRAPFPE}" ]; then rm corsika-${cvers}/bernlohr/trapfpe.c else if [ corsika-${cvers}/bernlohr/trapfpe.c -nt corsika-${cvers}/src/trapfpe.c ]; then echo "Using newer trapfpe.c from bernlohr sub-directory" cp corsika-${cvers}/bernlohr/trapfpe.c corsika-${cvers}/src/ fi fi else echo "Keeping IACT/ATMO package version provided with CORSIKA (not recommended)" fi # If the optimized Cherenkov code is to be used, we need to unpack a further package and # apply patches contained in it. if [ "${with_cerenkopt}" = "yes" -a ! -z "${ofile}" ]; then (cd corsika-${cvers} && unpack_tar_archive ../../${ofile} && ./corsika_opt_patching.sh) elif [ "${with_vlibm}" = "yes" -a ! -z "${ofile}" ]; then (cd corsika-${cvers} && unpack_tar_archive ../../${ofile} vlibm corsika_opt_patching.sh coconut.patch acinclude.m4.patch && ./corsika_opt_patching.sh vlibm) fi # There may be patches needed to get CORSIKA compiled. if [ -z "${CORSIKA_PATCHES}" ]; then CORSIKA_PATCHES="corsika-${cvers}.patch" fi for pfile in ${CORSIKA_PATCHES}; do if [ -r "$pfile" ]; then if [ -z "${NO_CORSIKA_PATCH}" ]; then echo "Applying patches from $pfile ..." (cd corsika-${cvers} && patch -b -p1 < ../"$pfile") || exit 1 else echo "Skipping patches from $pfile (not recommended)" fi fi done if [ "$cextra" = "cherenkopt" ]; then pkg="$(/bin/ls corsikaOptPatch*.tar.gz | tail -1)" if [ -z "$pkg" ]; then echo "No package provided for optimized Cherenkov emission." exit 1 fi drn="corsikaOptPatch" if [ ! -f $pkg ]; then echo "No such file: $pkg" exit 1 fi unpack_tar_archive "$pkg" pfile="corsika-${cvers}-cherenkopt.patch" if [ ! -r $pfile ]; then echo "No such file: $pfile" exit 1 fi echo "Applying patches from $pfile ..." (cd corsika-${cvers} && patch -b -p1 < ../"$pfile") || exit 1 echo "Build script is incomplete for cherenkopt option. Manual build of CORSIKA required." fi else echo "BUILD_NO_UNPACK was set. Not unpacking or patching CORSIKA sources." fi # [ -z "${BUILD_NO_UNPACK}" ] # Now go and compile CORSIKA (after a forced cleaning, if this is not a fresh build): echo "Running corsika_build_script ${interact} ${generic} ${debug} ${cextra}" "$@" (cd corsika-${cvers} && \ find . '(' -name '*.a' -o -name '*.o' ')' -delete && \ ../corsika_build_script ${interact} ${generic} ${debug} ${cextra} "$@") || \ ( if [ -x corsika-${cvers}/src/corsika ]; then \ /usr/bin/install -c corsika-${cvers}/src/corsika corsika-${cvers}/run/corsika${cvers}`uname`__ && \ echo "Tried to recover from an incomplete corsika_build_script execution." && \ echo "Check that a working CORSIKA binary (corsika${cvers}`uname`) got installed in corsika-${cvers}/run"; \ else exit 1; fi ) || \ exit 1 # Since the default interaction model is now (maybe) QGS2, we should better # have the data file, or our first example will need days rather than # minutes. # Corsika 7.x has qgsdat-II-04 included in the package, thus only relevant for 6.x: if [ "$cvers7" != "1" ]; then if [ -r qgsdat-II-03.xz -a ! -e qgsdat-II-03 ]; then unxz qgsdat-II-03.xz fi if [ -r qgsdat-II-03.gz -a ! -e qgsdat-II-03 ]; then gunzip qgsdat-II-03.gz fi if [ ! -e qgsdat-II-03 ]; then if [ -r ../qgsdat-II-03 ]; then ln -s ../qgsdat-II-03 elif [ -r ../../qgsdat-II-03 ]; then ln -s ../qgsdat-II-03 else dtn=$(/bin/ls ~/[Cc]orsika*/qgsdat-II-03 ${HESSROOT}/corsika*/qgsdat-II-03 | tail -1) if [ ! -z "$dtn" ]; then ln -s "$dtn" fi fi fi if [ -e qgsdat-II-03 -a ! -e corsika-${cvers}/run/qgsdat-II-03 ]; then (cd corsika-${cvers}/run && ln -sf ../../qgsdat-II-03) fi elif [ ! -e corsika-${cvers}/run/qgsdat-II-04 ]; then # We might want to repackage CORSIKA 7 to keep qgsdat-II-04 separate (and provide only once) if [ -r qgsdat-II-04.xz -a ! -e qgsdat-II-04 ]; then unxz qgsdat-II-04.xz fi if [ -r qgsdat-II-04.gz -a ! -e qgsdat-II-04 ]; then gunzip qgsdat-II-04.gz fi if [ ! -e qgsdat-II-04 ]; then if [ -r ../qgsdat-II-04 ]; then ln -s ../qgsdat-II-04 elif [ -r ../../qgsdat-II-04 ]; then ln -s ../qgsdat-II-04 else dtn=$(/bin/ls ~/[Cc]orsika*/qgsdat-II-04 ${HESSROOT}/corsika*/qgsdat-II-04 | tail -1) if [ ! -z "$dtn" ]; then ln -s "$dtn" fi fi fi if [ -e qgsdat-II-04 -a ! -e corsika-${cvers}/run/qgsdat-II-04 ]; then (cd corsika-${cvers}/run && ln -sf ../../qgsdat-II-04) fi fi else echo "No CORSIKA build requested." fi # [ -z "${NO_CORSIKA}" ] # -------------------- hessio ------------------------ unset HESSROOT export HESSROOT if [ -z "${NO_HESSIO}" ]; then # If the code was already there, we just clean but do not remove it. if [ -d "hessioxxx" ]; then (cd hessioxxx && make clean) fi # Install the stand-alone hessio library and client code. if [ -z "${hfile}" ]; then hfile="$(lastof hessioxxx.tar.*)" fi if [ -z "${BUILD_NO_UNPACK}" ]; then unpack_tar_archive "$hfile" || exit 1 else echo "BUILD_NO_UNPACK was set. Not unpacking hessioxxx sources." fi # Build the hessio library and programs. (cd hessioxxx && make ${rpath_opt} CDEBUGFLAGS="${cdebugflags}" DEFINES="$defs") || exit 1 elif [ -z "${NO_SIMTEL}" ]; then echo "NO_HESSIO also implies NO_SIMTEL as we cannot build sim_telarray without the hessio library." export NO_SIMTEL=1 fi # ----------------- optional libraries ---------------- if [ -z "${NO_STDTOOLS}" ]; then spkg="$(lastof stdtools.tar.*)" if [ -r "$spkg" ]; then echo "Optional package: $spkg" if [ ! -d stdtools ]; then unpack_tar_archive $spkg else if [ "$spk" -nt stdtools ]; then unpack_tar_archive "$spkg" fi fi fi if [ -d stdtools ]; then echo "Building the stdtools library" (cd stdtools && make clean) if [ ! -d lib ]; then mkdir lib; fi if [ ! -L lib/libhessio++.so ]; then (cd lib && ln -sf ../hessioxxx/lib/*.so .) fi if [ ! -d include ]; then mkdir include; fi if [ ! -L include/hessio ]; then (cd include && ln -sf ../hessioxxx/include hessio) fi if [ ! -L include/stdtools ]; then (cd include && ln -sf ../stdtools/include stdtools) fi (cd stdtools && make ${rpath_opt} CTA_PATH=${CTA_PATH} CDEBUGFLAGS="${cdebugflags}" EXTRA_DEFINES="$defs" all install) || exit 1 (cd lib && ln -sf ../stdtools/lib/*.so .) (cd hessioxxx/lib && ln -sf ../../stdtools/lib/*.so .) fi fi if [ -z "${NO_IACTIO}" ]; then ipkg="$(lastof iactio.tar.*)" if [ -r "$ipkg" ]; then echo "Optional package: $ipkg" if [ ! -d iactio ]; then unpack_tar_archive "$ipkg" else if [ "$ipkg" -nt iactio ]; then unpack_tar_archive "$ipkg" fi fi fi if [ -d iactio ]; then echo "Building the iactio library" (cd iactio && make clean) if [ ! -d lib ]; then mkdir lib; fi if [ ! -L lib/libhessio++.so ]; then (cd lib && ln -sf ../hessioxxx/lib/*.so .) fi if [ ! -d include ]; then mkdir include; fi if [ ! -L include/hessio ]; then (cd include && ln -sf ../hessioxxx/include hessio) fi if [ ! -L include/stdtools ]; then (cd include && ln -sf ../stdtools/include stdtools) fi if [ ! -L include/iactio ]; then (cd include && ln -sf ../iactio/include iactio) fi (cd iactio && make ${rpath_opt} CTA_PATH=${CTA_PATH} CDEBUGFLAGS="${cdebugflags}" EXTRA_DEFINES="$defs") || exit 1 (cd lib && ln -sf ../iactio/lib/*.so .) (cd hessioxxx/lib && ln -sf ../../iactio/lib/*.so .) fi fi # ---------------------- sim_telarray ----------------- if [ -z "${NO_SIMTEL}" ]; then # If the code was already there, we just clean but do not remove it. if [ -d "sim_telarray" ]; then (cd sim_telarray && make clean) fi # Install the sim_hessarray/sim_telarray code. if [ -z "${BUILD_NO_UNPACK}" ]; then unpack_tar_archive ${arraysim_package} || exit 1 else echo "BUILD_NO_UNPACK was set. Not unpacking sim_telarray sources." fi # Build sim_hessarray and the helper programs. (cd sim_telarray && make ${rpath_opt} CDEBUGFLAGS="${cdebugflags}" EXTRA_DEFINES="$defs" install) || exit 1 # If you do not want the configuration files to be installed, set the NO_CONFIG variable first. if [ -z "${NO_CONFIG}" ]; then for config_package in ${config_packages}; do if [ -r "${config_package}" ]; then if [ -z "${BUILD_NO_UNPACK}" ]; then echo "Unpacking configuration file package ${config_package}" # If there are newer locally modified files, try to keep them if requested unpack_tar_archive ${config_package} ${keep} || exit 1 else echo "BUILD_NO_UNPACK was set. Not unpacking ${config_package}" fi fi done fi else echo "No sim_telarray requested." fi # [ -z "${NO_SIMTEL}" ] set +x # ------------------ examples ------------------------- if [ -z "${BUILD_NO_UNPACK}" ]; then if [ -z "${NO_CORSIKA}" -o -z "${NO_SIMTEL}" ]; then # Extract example scripts and CORSIKA inputs, trying to keep newer locally modified files if requested ex_pkg="$(lastof examples-with-data.tar.*)" if [ ! -z "${ex_pkg}" ]; then unpack_tar_archive "${ex_pkg}" ${keep} fi ex_extra="$(find . -maxdepth 1 -name 'examples-with-data_*.tar.*')" for f in $ex_extra; do echo "Unpacking extra examples from $f" unpack_tar_archive "$f" ${keep} done n=$(find example_scripts -name 'example*' -executable | wc -l) echo '' echo "There are $n example scripts available in or below directory example_scripts." echo "Keep in mind that they are meant to be run in the current directory." echo "Please copy them or create symbolic links to use any of them." echo '' echo "Preparing directories needed to run the examples:" . ./examples_common.sh config_force=1 ./prepare_for_examples fi if [ -z "${NO_SIMTEL}" ]; then if [ "${build_type}" = "prod3" ]; then PRODVERS=3 if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi ln -s example_scripts/Prod${PRODVERS}/* . fi if [ "$1" = "prod4" -o "$1" = "mini4" -o "$1" = "prod4-sc" -o "${build_type}" = "prod4" ]; then PRODVERS=4 if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi ln -s example_scripts/Prod${PRODVERS}/* . fi if [ "$1" = "prod5" -o "$1" = "mini5" -o "$1" = "prod5-sc" -o "${build_type}" = "prod5" ]; then PRODVERS=4 # Yes, this is basically still Prod4 configurations. Just a few extras. if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi ln -s example_scripts/Prod${PRODVERS}/* . ln -s example_scripts/Prod5/* . fi if [ "$1" = "prod6" -o "$1" = "mini6" -o "$1" = "prod6-sc" -o "${build_type}" = "prod6" ]; then PRODVERS=6 if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi ln -s example_scripts/Prod${PRODVERS}/* . fi if [ "$1" = "hess" -o "$1" = "hess2" -o "$1" = "hess1u" -o "${build_type}" = "hess" ]; then if [ ! -e Data ]; then mkdir Data; else echo Data goes to `realpath Data/`; fi ln -s example_scripts/HESS2/* . fi fi else echo "BUILD_NO_UNPACK was set. Not unpacking any example scripts." fi # --------------------- done -------------------------- echo '' echo 'Everything built and ready to run the examples.' echo '' if [ -z "${NO_CORSIKA}" ]; then if [ "$interact" = "qgs2" ]; then if [ "$cvers7" = "1" ]; then if [ ! -r "corsika-${cvers}/run/qgsdat-II-04" ]; then echo "Warning: The data file qgsdat-II-04 is missing." echo "You should better get this file before you start with the examples." echo "Forcing CORSIKA to rebuild this file will take many hours of CPU time." echo "As an alternative you may compile CORSIKA with another interaction model." exit 1 fi else if [ ! -r "qgsdat-II-03" ]; then if [ ! -r "corsika-${cvers}/run/qgsdat-II-03" ]; then echo "Warning: The data file qgsdat-II-03 is missing." echo "You should better get this file before you start with the examples." echo "Forcing CORSIKA to rebuild this file will take many hours of CPU time." echo "As an alternative you may compile CORSIKA with another interaction model." exit 1 fi fi fi fi fi