1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. program:: tropflux_profile.sh |
---|
5 | # |
---|
6 | # .. _tropflux_profile.sh: |
---|
7 | # |
---|
8 | # ================================================== |
---|
9 | # tropflux_profile.sh -- define TROPFLUX environment |
---|
10 | # ================================================== |
---|
11 | # |
---|
12 | # SYNOPSIS |
---|
13 | # ======== |
---|
14 | # |
---|
15 | # Online usage:: |
---|
16 | # |
---|
17 | # $ . ./tropflux_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
18 | # |
---|
19 | # In ${HOME}/.profile, add the following line:: |
---|
20 | # |
---|
21 | # . tropflux_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
22 | # |
---|
23 | # DESCRIPTION |
---|
24 | # =========== |
---|
25 | # |
---|
26 | # .. option:: -d <directory> |
---|
27 | # .. option:: -i <indir> |
---|
28 | # .. option:: -o <outdir> |
---|
29 | # .. option:: -t <tempdir> |
---|
30 | # |
---|
31 | # define TROPFLUX environment |
---|
32 | # |
---|
33 | # ${TROPFLUX} is the base directory of tools. |
---|
34 | # |
---|
35 | # ${TROPFLUX_LOG} is the directory where log files will be written. |
---|
36 | # |
---|
37 | # ${TROPFLUX_ID} is the directory where input files must be. |
---|
38 | # |
---|
39 | # ${TROPFLUX_OD} is the directory where output files will be written. |
---|
40 | # |
---|
41 | # PATH is completed with ${TROPFLUX}. |
---|
42 | # |
---|
43 | # SEE ALSO |
---|
44 | # ======== |
---|
45 | # |
---|
46 | # for IDL/GDL environment : |
---|
47 | # |
---|
48 | # :ref:`tropflux_startup.pro` |
---|
49 | # |
---|
50 | # EXAMPLES |
---|
51 | # ======== |
---|
52 | # |
---|
53 | # For fplod, on aedon.locean-ipsl.upmc.fr:: |
---|
54 | # |
---|
55 | # $ cd /usr/home/fplod/incas/tropflux/tropflux_ws/ |
---|
56 | # $ . ./src/tropflux_profile.sh \ |
---|
57 | # -d $(pwd) \ |
---|
58 | # -i /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
59 | # -o /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
60 | # -t /usr/temp/${LOGNAME}/log/ |
---|
61 | # |
---|
62 | # For fplod on zeus.locean-ipsl.umpc.fr:: |
---|
63 | # |
---|
64 | # $ cd ${HOME}/incas/tropflux/tropflux_ws/ |
---|
65 | # $ . ./src/tropflux_profile.sh \ |
---|
66 | # -d $(pwd) \ |
---|
67 | # -i /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
68 | # -o /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
69 | # -t /usr/temp/${LOGNAME}/log/ |
---|
70 | # |
---|
71 | # For pinsard on camelot.ipsl.polytechnique.fr or merlin15-c.climserv:: |
---|
72 | # |
---|
73 | # $ cd ${HOME}/tropflux/ |
---|
74 | # $ . ./src/tropflux_profile.sh \ |
---|
75 | # -d $(pwd) \ |
---|
76 | # -i /homedata/${LOGNAME}/tropflux_d/ \ |
---|
77 | # -o /homedata/${LOGNAME}/tropflux_d/ \ |
---|
78 | # -t /homedata/${LOGNAME}/log/ |
---|
79 | # |
---|
80 | # TODO |
---|
81 | # ==== |
---|
82 | # |
---|
83 | # ++ option bavarde |
---|
84 | # |
---|
85 | # ++ machine dependant |
---|
86 | # |
---|
87 | # ++ besoin de posix |
---|
88 | # |
---|
89 | # ++ pas de MANPATH defini par défaut sur zeus et cerbere |
---|
90 | # |
---|
91 | # define IDL startup file |
---|
92 | # |
---|
93 | # EVOLUTIONS |
---|
94 | # ========== |
---|
95 | # |
---|
96 | # - fplod 20101118T171653Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
97 | # |
---|
98 | # * creation |
---|
99 | # |
---|
100 | #- |
---|
101 | system=$(uname) |
---|
102 | case "${system}" in |
---|
103 | AIX|IRIX64) |
---|
104 | echo " www : no specific posix checking" |
---|
105 | ;; |
---|
106 | *) |
---|
107 | set -o posix |
---|
108 | ;; |
---|
109 | esac |
---|
110 | unset system |
---|
111 | # |
---|
112 | LANG=C |
---|
113 | # |
---|
114 | # as this script might be launch in .profile, command is forced. |
---|
115 | command=tropflux_profile.sh |
---|
116 | # |
---|
117 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" |
---|
118 | # |
---|
119 | set +u |
---|
120 | while [ ! -z "${1}" ] |
---|
121 | do |
---|
122 | case ${1} in |
---|
123 | -d) |
---|
124 | # directory for application choosen by user (see svn checkout command used) |
---|
125 | directory=${2} |
---|
126 | shift |
---|
127 | ;; |
---|
128 | -i) |
---|
129 | # directory for inputs choosen by user |
---|
130 | indir=${2} |
---|
131 | shift |
---|
132 | ;; |
---|
133 | -o) |
---|
134 | # directory for outputs choosen by user |
---|
135 | outdir=${2} |
---|
136 | shift |
---|
137 | ;; |
---|
138 | -t) |
---|
139 | # directory for temporary outputs choosen by user |
---|
140 | tempdir=${2} |
---|
141 | shift |
---|
142 | ;; |
---|
143 | *) |
---|
144 | # other choice |
---|
145 | echo "eee : unknown option ${1}" |
---|
146 | echo "${usage}" |
---|
147 | # nb : no exit because this file should be launched by login process |
---|
148 | ;; |
---|
149 | esac |
---|
150 | # next flag |
---|
151 | shift |
---|
152 | done |
---|
153 | unset usage |
---|
154 | # |
---|
155 | # check for ${directory} |
---|
156 | if [ ! -d ${directory} ] |
---|
157 | then |
---|
158 | echo " eee : ${directory} not found" |
---|
159 | # nb : no exit because this file should be launched by login process |
---|
160 | fi |
---|
161 | # |
---|
162 | # check for permission on directory |
---|
163 | if [ ! -x ${directory} ] |
---|
164 | then |
---|
165 | echo " eee : ${directory} not reachable" |
---|
166 | # nb : no exit because this file should be launched by login process |
---|
167 | fi |
---|
168 | # |
---|
169 | TROPFLUX=${directory} |
---|
170 | export TROPFLUX |
---|
171 | unset drectory |
---|
172 | # |
---|
173 | # add TROPFLUX tools to PATH |
---|
174 | # if not already done |
---|
175 | suppath=$(echo ${TROPFLUX}/src | tr -s "/") |
---|
176 | echo ${PATH} | grep -q "${suppath}:" |
---|
177 | test_path=${?} |
---|
178 | if [ ${test_path} -ne 0 ] |
---|
179 | then |
---|
180 | PATH=${suppath}:${PATH} |
---|
181 | export PATH |
---|
182 | else |
---|
183 | # option bavarde oui/non pas encore implantée ++ |
---|
184 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
185 | fi |
---|
186 | unset test_path |
---|
187 | # |
---|
188 | # add TROPFLUX manuals to MANPATH |
---|
189 | # if not already done |
---|
190 | suppath=$(echo ${TROPFLUX}/doc/man | tr -s "/") |
---|
191 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
192 | test_manpath=${?} |
---|
193 | if [ ${test_manpath} -ne 0 ] |
---|
194 | then |
---|
195 | MANPATH=${suppath}:${MANPATH} |
---|
196 | export MANPATH |
---|
197 | else |
---|
198 | # option bavarde oui/non pas encore implantée ++ |
---|
199 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
200 | fi |
---|
201 | unset test_manpath |
---|
202 | unset suppath |
---|
203 | # |
---|
204 | TROPFLUX_LOG=${tempdir} |
---|
205 | export TROPFLUX_LOG |
---|
206 | unset tempdir |
---|
207 | if [ ! -d ${TROPFLUX_LOG} ] |
---|
208 | then |
---|
209 | mkdir -p ${TROPFLUX_LOG} |
---|
210 | status=${?} |
---|
211 | if [ ${status} -ne 0 ] |
---|
212 | then |
---|
213 | echo "${command} : eee : can not create \${TROPFLUX_LOG}" |
---|
214 | # nb : no exit because this file should be launched by login process |
---|
215 | else |
---|
216 | echo "${command} : iii : creation of \${TROPFLUX_LOG}" |
---|
217 | fi |
---|
218 | unset status |
---|
219 | fi |
---|
220 | # check for permission on TROPFLUX_LOG |
---|
221 | if [ ! -x ${TROPFLUX_LOG} ] |
---|
222 | then |
---|
223 | echo " eee : ${TROPFLUX_LOG} not reachable" |
---|
224 | # nb : no exit because this file should be launched by login process |
---|
225 | fi |
---|
226 | # |
---|
227 | # check for permission on TROPFLUX_LOG |
---|
228 | if [ ! -w ${TROPFLUX_LOG} ] |
---|
229 | then |
---|
230 | echo " eee : ${TROPFLUX_LOG} not writable" |
---|
231 | # nb : no exit because this file shouldreachable be launched by login process |
---|
232 | fi |
---|
233 | # |
---|
234 | EDITOR=vi |
---|
235 | export EDITOR |
---|
236 | # |
---|
237 | # io directories |
---|
238 | TROPFLUX_ID=${indir} |
---|
239 | export TROPFLUX_ID |
---|
240 | unset indir |
---|
241 | if [ ! -d ${TROPFLUX_ID} ] |
---|
242 | then |
---|
243 | mkdir -p ${TROPFLUX_ID} |
---|
244 | echo "${command} : iii : creation of \${TROPFLUX_ID}" |
---|
245 | fi |
---|
246 | # check for permission on TROPFLUX_ID |
---|
247 | if [ ! -x ${TROPFLUX_ID} ] |
---|
248 | then |
---|
249 | echo " eee : ${TROPFLUX_ID} not reachable" |
---|
250 | # nb : no exit because this file should be launched by login process |
---|
251 | fi |
---|
252 | # |
---|
253 | TROPFLUX_OD=${outdir} |
---|
254 | export TROPFLUX_OD |
---|
255 | unset outdir |
---|
256 | if [ ! -d ${TROPFLUX_OD} ] |
---|
257 | then |
---|
258 | mkdir -p ${TROPFLUX_OD} |
---|
259 | echo "${command} : iii : creation of \${TROPFLUX_OD}" |
---|
260 | fi |
---|
261 | # check for permission on TROPFLUX_OD |
---|
262 | if [ ! -x ${TROPFLUX_OD} ] |
---|
263 | then |
---|
264 | echo " eee : ${TROPFLUX_OD} not reachable" |
---|
265 | # nb : no exit because this file should be launched by login process |
---|
266 | fi |
---|
267 | if [ ! -w ${TROPFLUX_OD} ] |
---|
268 | then |
---|
269 | echo " eee : ${TROPFLUX_OD} not writable" |
---|
270 | # nb : no exit because this file should be launched by login process |
---|
271 | fi |
---|
272 | # |
---|
273 | # end |
---|
274 | unset command |
---|
275 | # nb : no exit because this file should be launched by login process |
---|