-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsource-geant4.sh
More file actions
executable file
·103 lines (78 loc) · 2.63 KB
/
source-geant4.sh
File metadata and controls
executable file
·103 lines (78 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# This bash script is part of the MEGAlib & COSItools setup procedure.
# As such it is dual licenced under Apache 2.0 for COSItools and LGPL 3.0 for MEGAlib
#
# Development lead: Andreas Zoglauer
#
# Description:
# Source all Geant4-related environment variables
# Make this script work with zsh
if [ -n "$ZSH_VERSION" ]; then emulate -L ksh; fi
# Print some help
confhelp() {
echo ""
echo "This script sources all Geant4-related environment variables"
echo " "
echo "Usage: ./source-geant4.sh --path=[full path to the Geant4 installation]";
echo " "
}
# Parse the command line
CMD=( "$@" )
__TMP_PATH=""
__TMP_HERE=$(pwd)
for C in "${CMD[@]}"; do
if [[ ${C} == *-p*=* ]]; then
__TMP_PATH=`echo ${C} | awk -F"=" '{ print $2 }'`
elif [[ ${C} == *-h ]] || [[ ${C} == *-hel* ]]; then
echo ""
confhelp
exit 0
fi
done
# Perform sanity checks
# We require an absolute path
if [[ ${__TMP_PATH} != /* ]]; then
echo ""
echo "ERROR: The Geant4 path must be an absolute path: ${__TMP_PATH}"
echo ""
return
fi
# The directory must exist
if [[ ! -d ${__TMP_PATH} ]]; then
echo ""
echo "ERROR: GEANT4 directory not found: ${__TMP_PATH}"
echo ""
return
fi
# Source the Geant4 environment depending on which version we have
if [[ -f ${__TMP_PATH}/bin/geant4.sh ]]; then
if [[ -n $ZSH_VERSION ]]; then
BASH_SOURCE=()
BASH_SOURCE[0]="${__TMP_PATH}/bin/geant4.sh" emulate ksh -c '. "${BASH_SOURCE[0]}"'
PATHTOGEANT4MAKE="${__TMP_PATH}/share/Geant4/geant4make"
BASH_SOURCE[0]="${PATHTOGEANT4MAKE}/geant4make.sh" emulate ksh -c 'source "${BASH_SOURCE[0]}"'
else
source "${__TMP_PATH}/bin/geant4.sh"
PATHTOGEANT4MAKE="${__TMP_PATH}/share/Geant4/geant4make"
source "${PATHTOGEANT4MAKE}/geant4make.sh"
fi
if [[ `uname -a` == *Darwin* ]]; then
export LD_LIBRARY_PATH=${G4LIB}/..:${LD_LIBRARY_PATH}
#export DYLD_LIBRARY_PATH=${G4INSTALL}/lib/${G4SYSTEM}/lib:${DYLD_LIBRARY_PATH}
fi
export G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION=1
elif (test -f ${__TMP_PATH}/env.sh); then
source ${__TMP_PATH}/env.sh > /dev/null
export LD_LIBRARY_PATH=${G4INSTALL}/lib/${G4SYSTEM}:${LD_LIBRARY_PATH}
if [[ `uname -a` == *Darwin* ]]; then
export DYLD_LIBRARY_PATH=${G4INSTALL}/lib/${G4SYSTEM}/lib:${LD_LIBRARY_PATH}
fi
export G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION=1
else
echo " "
echo "WARNING: geant4.sh or env.sh not found in Geant4 directory: ${__TMP_PATH}/bin"
echo " Assuming we are currently installing Geant4 otherwise make sure to run \"./Configure\" (Geant4 < 9.5) or \"cmake install\" (Geant4 >= 9.5)!"
echo ""
G4INSTALL=${__TMP_PATH}
fi
return