forked from pencil-code/pencil-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sourceme.csh
115 lines (101 loc) · 3.35 KB
/
sourceme.csh
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
104
105
106
107
108
109
110
111
112
113
114
115
#$Id$
#
# 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
# setenv PENCIL_HOME [...]
# set _sourceme_quiet; source $PENCIL_HOME/sourceme.csh; unset _sourceme_quiet
# into you .cshrc file
#
# set cdpath = ( . ../ ../../ ../../../ ~/ )
if (! $?PENCIL_HOME) then
unset _sourceme # tabula rasa without PENCIL_HOME
#
# Try to identify position of the code's home directory:
#
foreach _dir ( . .. ../.. ../../.. ../../../.. \
pencil pencil-code \
f90/pencil f90/pencil-code \
pencil_modular f90/pencil_modular)
if ( (-e $_dir/sourceme.csh) && \
(-d $_dir/bin) && \
(-d $_dir/doc) && \
(-d $_dir/src) && \
(-d $_dir/samples) \
) then
set back_again = `pwd`
cd $_dir; setenv PENCIL_HOME `pwd`; cd $back_again
goto found
endif
end
echo "sourceme.csh: Cannot locate home directory of pencil code."
echo " Try sourcing me from the home directory itself, or set PENCIL_HOME"
goto eof
endif
found:
if (! $?_sourceme_quiet) echo "PENCIL_HOME = <$PENCIL_HOME>"
if (! $?_sourceme) then # called for the fist time?
if (-d $PENCIL_HOME/bin) then
# Set shell path
if (! $?_sourceme_quiet) echo "Adding $PENCIL_HOME/{bin,utils{,/axel},scripts} to PATH"
set path = ( $path $PENCIL_HOME/bin \
$PENCIL_HOME/utils \
$PENCIL_HOME/utils/axel \
$PENCIL_HOME/src/scripts \
$PENCIL_HOME/remesh/bin)
# Set path for DX macros
set _dxpath = "${PENCIL_HOME}/dx/macros:${PENCIL_HOME}/dx/macros/others"
if ($?DXMACROS) then
setenv DXMACROS "${_dxpath}:$DXMACROS"
else
setenv DXMACROS "${_dxpath}"
endif
unset _dxpath
# Set IDL path
if ($?IDL_PATH) then
setenv IDL_PATH "./idl:../idl:+${PENCIL_HOME}/idl:./data:./tmp:$IDL_PATH"
else
setenv IDL_PATH "./idl:../idl:+${PENCIL_HOME}/idl:./data:./tmp:<IDL_DEFAULT>"
endif
# Set HDF5 path
if (! $?HDF5_HOME) setenv HDF5_HOME `which h5fc | sed -e 's/\/bin\/h5fc$//'`
# Set PYTHON path
if ($?PYTHONPATH) then
setenv PYTHONPATH "${PYTHONPATH}:${PENCIL_HOME}/python:${PWD}/python"
else
setenv PYTHONPATH "${PENCIL_HOME}/python:${PWD}/python"
endif
# Set library path for linker
if ($?LD_LIBRARY_PATH) then
setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:./src"
else
setenv LD_LIBRARY_PATH "./src"
endif
# # Set Perl module path [no longer needed]
# set _perl5lib = "${PENCIL_HOME}/lib/perl"
# if ($?PERL5LIB) then
# setenv PERL5LIB "${_perl5lib}:$PERL5LIB"
# else
# setenv PERL5LIB "${_perl5lib}"
# endif
# unset _perl5lib
# Remember that sourceme has been successfully run
set _sourceme = 'set'
else
echo "Not adding $PENCIL_HOME/bin to PATH: not a directory"
endif
#
# additional aliases (for Axel)
#
alias gb 'cd $gt ; set gg=$gb ; set gb=$gt ; set gt=$gg ; echo $gt "->" $gb'
alias gt 'set gt=$cwd; cd \!^ ; set gb=$cwd ; echo $gt "->" $gb'
# alias d ls -sCF
alias .. 'set pwd = $cwd ; cd ..'
# alias local 'cp -p \!:1 tmp.$$; \rm \!:1; mv tmp.$$ \!:1; chmod u+w \!:1'
endif
#
# Clean up and exit
#
eof:
unset _dir