forked from pencil-code/pencil-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sourceme.sh
93 lines (80 loc) · 3.33 KB
/
sourceme.sh
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
#
# This file tries to set the PENCIL_HOME environment variable if it
# doesn't exist yet, and then adds stuff to your PATH and IDL_PATH.
#
# If _sourceme_quiet is set, no output is printed, which enables you to
# put the lines
# export PENCIL_HOME=[...]
# _sourceme_quiet=1; . $PENCIL_HOME/sourceme.sh; unset _sourceme_quiet
# into your .bashrc
#
if [ -z $PENCIL_HOME ]; then
unset _sourceme # tabula rasa without PENCIL_HOME
#
# Try to identify position of the code's home directory:
#
for _dir in . .. ../.. ../../.. ../../../.. \
pencil pencil-code \
f90/pencil f90/pencil-code \
pencil_modular f90/pencil_modular ; do
if ( [ -e $_dir/sourceme.csh ] && \
[ -d $_dir/bin ] && \
[ -d $_dir/doc ] && \
[ -d $_dir/src ] && \
[ -d $_dir/samples ] \
); then
unset cd # some people are crazy enough to overload cd
PENCIL_HOME=`cd $_dir; echo $PWD`
export PENCIL_HOME
break
fi
done
unset _dir
if [ -z $PENCIL_HOME ]; then # no success
echo "sourceme.sh: Cannot locate home directory of pencil code."
echo " Try sourcing me from the home directory itself, or set PENCIL_HOME"
fi
fi
if [ -z $_sourceme_quiet ]; then echo "PENCIL_HOME = <$PENCIL_HOME>"; fi
if [ -z $_sourceme ]; then # called for the first time?
# CDPATH="./:../:../../:../../../:$HOME"
if ([ -n $PENCIL_HOME ] && [ -d $PENCIL_HOME/bin ]); then
# Set shell path
if [ -z $_sourceme_quiet ]; then echo "Adding $PENCIL_HOME/{bin,utils{,/axel},remesh/bin} to PATH"; fi
# PATH=${PATH}:$PENCIL_HOME/bin:$PENCIL_HOME/utils:$PENCIL_HOME/utils/axel:$PENCIL_HOME/remesh/bin
PATH=${PATH}:$PENCIL_HOME/bin:$PENCIL_HOME/utils:$PENCIL_HOME/utils/axel:$PENCIL_HOME/utils/xiangyu:$PENCIL_HOME/remesh/bin:$PENCIL_HOME/src/scripts
if ([ -d $PENCIL_HOME/src/astaroth/submodule/scripts ]); then
export AC_HOME=$PENCIL_HOME/src/astaroth/submodule
export PATH=${PATH}:$AC_HOME/scripts/
fi
# Set path for DX macros
DXMACROS="${PENCIL_HOME}/dx/macros${DXMACROS:+:$DXMACROS}"
# Set IDL path
IDL_PATH="./idl:../idl:+${PENCIL_HOME}/idl:./data:./tmp:${IDL_PATH=<IDL_DEFAULT>}"
# Set HDF5 path
if [ -z $HDF5_HOME ]; then HDF5_HOME=`which h5fc 2>/dev/null | sed -e 's/\/bin\/h5fc$//'`; fi
# # Set Perl module path [no longer needed]
# PERL5LIB="${PENCIL_HOME}/lib/perl${PERL5LIB:+:$PERL5LIB}"
# export PERL5LIB
# Set PYTHONPATH
if [ -z $PYTHONPATH ]; then
PYTHONPATH="$PENCIL_HOME/python:$PWD/python"
else
PYTHONPATH="$PYTHONPATH:$PENCIL_HOME/python:$PWD/python"
fi
# Set library path for linker
if [ -z $LD_LIBRARY_PATH ]; then
LD_LIBRARY_PATH="./src:./src/astaroth:./src/astaroth/submodule/build/src/core:./src/astaroth/submodule/build/src/core/kernels:./src/astaroth/submodule/build/src/utils"
else
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:./src:./src/astaroth:./src/astaroth/submodule/build/src/core:./src/astaroth/submodule/build/src/core/kernels:./src/astaroth/submodule/build/src/utils"
fi
# Remember that sourceme has been successfully run
_sourceme="set"
# export CDPATH PATH IDL_PATH
export PATH DXMACROS IDL_PATH PYTHONPATH _sourceme
else
if [ -n $PENCIL_HOME ]; then
echo "Not adding $PENCIL_HOME/bin to PATH: not a directory"
fi
fi
fi