1 | #! /bin/sh -x |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. program:: project_profile.sh |
---|
5 | # |
---|
6 | # .. _project_profile.sh: |
---|
7 | # |
---|
8 | # ================== |
---|
9 | # project_profile.sh |
---|
10 | # ================== |
---|
11 | # |
---|
12 | # SYNOPSIS |
---|
13 | # ======== |
---|
14 | # |
---|
15 | # Online usage: |
---|
16 | # |
---|
17 | # .. code-block:: bash |
---|
18 | # |
---|
19 | # . ./project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir -idl_cmd idl_cmd |
---|
20 | # |
---|
21 | # In ${HOME}/.profile, add the following line: |
---|
22 | # |
---|
23 | # .. code-block:: bash |
---|
24 | # |
---|
25 | # . project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir |
---|
26 | # |
---|
27 | # DESCRIPTION |
---|
28 | # =========== |
---|
29 | # |
---|
30 | # .. option:: -d <directory> |
---|
31 | # .. option:: -i <indir> |
---|
32 | # .. option:: -o <outdir> |
---|
33 | # .. option:: -t <tempdir> |
---|
34 | # .. option:: -s <saxo_dir> |
---|
35 | # .. option:: -idl_cmd <idl_cmd> |
---|
36 | # |
---|
37 | # define PROJECT environment |
---|
38 | # |
---|
39 | # ${PROJECT} is the base directory of tools. |
---|
40 | # |
---|
41 | # ${PROJECT_LOG} is the directory where log files will be written. |
---|
42 | # |
---|
43 | # ${PROJECT_ID} is the directory where input files must be. |
---|
44 | # |
---|
45 | # ${PROJECT_OD} is the directory where output files will be written. |
---|
46 | # |
---|
47 | # ${SAXO_DIR} is the base directory of SAXO tools |
---|
48 | # |
---|
49 | # PATH is completed with ${PROJECT}/src/ and ${PROJECT}/adm/. |
---|
50 | # |
---|
51 | # PYTHONPATH is completed with ${PROJECT}/src/. |
---|
52 | # |
---|
53 | # FER_GO is completed with ${PROJECT}/src/. |
---|
54 | # |
---|
55 | # IDL_STARTUP is set to tell IDL where find tools. |
---|
56 | # |
---|
57 | # If :option:`-idl_cmd` is used, **idl_cmd** will be used as the IDL command |
---|
58 | # when launched from scripts. By default, ${IDL_CMD} is set to `idl`. |
---|
59 | # |
---|
60 | # MATLABPATH is initialize to tell matlab where find tools. |
---|
61 | # |
---|
62 | # SEE ALSO |
---|
63 | # ======== |
---|
64 | # |
---|
65 | # for matlab/octave environment : |
---|
66 | # |
---|
67 | # :ref:`project_startup.m` |
---|
68 | # |
---|
69 | # for IDL/gdl and SAXO environment : |
---|
70 | # |
---|
71 | # :ref:`project_init.pro` |
---|
72 | # :ref:`cm_project.pro` |
---|
73 | # |
---|
74 | # EXAMPLES |
---|
75 | # ======== |
---|
76 | # |
---|
77 | # For fplod, on halios.locean-ipsl.upmc.fr with gdl: |
---|
78 | # |
---|
79 | # .. code-block:: bash |
---|
80 | # |
---|
81 | # cd /usr/home/fplod/incas/project/project_ws/ |
---|
82 | # . ./src/project_profile.sh \ |
---|
83 | # -d $(pwd) \ |
---|
84 | # -i /usr/temp/${LOGNAME}/project_d/ \ |
---|
85 | # -o /usr/temp/${LOGNAME}/project_d/ \ |
---|
86 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
87 | # -s /usr/home/fplod/SAXO_DIR/ \ |
---|
88 | # -idl_cmd gdl |
---|
89 | # |
---|
90 | # For fplod on cratos.locean-ipsl.umpc.fr with default IDL version: |
---|
91 | # |
---|
92 | # .. code-block:: bash |
---|
93 | # |
---|
94 | # cd ${HOME}/incas/project/project_ws/ |
---|
95 | # . ./src/project_profile.sh \ |
---|
96 | # -d $(pwd) \ |
---|
97 | # -i /usr/temp/${LOGNAME}/project_d/ \ |
---|
98 | # -o /usr/temp/${LOGNAME}/project_d/ \ |
---|
99 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
100 | # -s ${HOME}/SAXO_DIR/ |
---|
101 | # |
---|
102 | # For fplod on cratos.locean-ipsl.umpc.fr with IDL version 6.4: |
---|
103 | # |
---|
104 | # .. code-block:: bash |
---|
105 | # |
---|
106 | # cd ${HOME}/incas/project/project_ws/ |
---|
107 | # . ./src/project_profile.sh \ |
---|
108 | # -d $(pwd) \ |
---|
109 | # -i /usr/temp/${LOGNAME}/project_d/ \ |
---|
110 | # -o /usr/temp/${LOGNAME}/project_d/ \ |
---|
111 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
112 | # -s ${HOME}/SAXO_DIR/ \ |
---|
113 | # -idl_cmd /usr/local_linux/idl/idl_6.4/idl64/bin/idl |
---|
114 | # |
---|
115 | # For pinsard on camelot.ipsl.polytechnique.fr or merlin15-c.climserv: |
---|
116 | # |
---|
117 | # .. code-block:: bash |
---|
118 | # |
---|
119 | # cd ${HOME}/project/ |
---|
120 | # . ./src/project_profile.sh \ |
---|
121 | # -d $(pwd) \ |
---|
122 | # -i /homedata/${LOGNAME}/project_d/ \ |
---|
123 | # -o /homedata/${LOGNAME}/project_d/ \ |
---|
124 | # -t /homedata/${LOGNAME}/log/ \ |
---|
125 | # -s ${HOME}/SAXO_DIR/ |
---|
126 | # |
---|
127 | # For pinsard on loholt1 to use idl 6-4: |
---|
128 | # |
---|
129 | # .. code-block:: bash |
---|
130 | # |
---|
131 | # cd ${HOME}/project/ |
---|
132 | # . ./src/project_profile.sh \ |
---|
133 | # -d $(pwd) \ |
---|
134 | # -i /homedata/${LOGNAME}/project_d/ \ |
---|
135 | # -o /homedata/${LOGNAME}/project_d/ \ |
---|
136 | # -t /homedata/${LOGNAME}/log/ \ |
---|
137 | # -s ${HOME}/SAXO_DIR/ \ |
---|
138 | # -idl_cmd /opt/idl-6.4/idl/bin/idl |
---|
139 | # |
---|
140 | # .. todo:: |
---|
141 | # |
---|
142 | # ++ option bavarde |
---|
143 | # |
---|
144 | # ++ machine dependant |
---|
145 | # |
---|
146 | # ++ besoin de posix |
---|
147 | # |
---|
148 | # usage of PROJECT* instead of PROJECT* everywhere |
---|
149 | # |
---|
150 | # EVOLUTIONS |
---|
151 | # ========== |
---|
152 | # |
---|
153 | # $Id: project_profile.sh 532 2012-04-18 12:44:46Z pinsard $ |
---|
154 | # |
---|
155 | # - fplod 20140516T091310Z callisto.locean-ipsl.upmc.fr (Linux) |
---|
156 | # |
---|
157 | # * fix because PYTHONPATH not always defined |
---|
158 | # |
---|
159 | # - fplod 20140513T101841Z callisto.locean-ipsl.upmc.fr (Linux) |
---|
160 | # |
---|
161 | # * add PYTHONPATH |
---|
162 | # |
---|
163 | # - fplod 20120424 |
---|
164 | # |
---|
165 | # * creation |
---|
166 | # |
---|
167 | #- |
---|
168 | system=$(uname) |
---|
169 | case "${system}" in |
---|
170 | AIX|IRIX64) |
---|
171 | echo " www : no specific posix checking" |
---|
172 | ;; |
---|
173 | *) |
---|
174 | set -o posix |
---|
175 | ;; |
---|
176 | esac |
---|
177 | unset system |
---|
178 | # |
---|
179 | set -u |
---|
180 | # |
---|
181 | LANG=C |
---|
182 | # |
---|
183 | # as this script might be launch in .profile, command is forced. |
---|
184 | command=project_profile.sh |
---|
185 | # |
---|
186 | usage="Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir [-idl_cmd idl_cmd]" |
---|
187 | # |
---|
188 | # default |
---|
189 | idl_cmd=idl |
---|
190 | # |
---|
191 | while [ ${#} -gt 0 ] |
---|
192 | do |
---|
193 | case ${1} in |
---|
194 | -d) |
---|
195 | # directory for application choosen by user (see svn checkout command used) |
---|
196 | directory=${2} |
---|
197 | shift |
---|
198 | ;; |
---|
199 | -i) |
---|
200 | # directory for inputs choosen by user |
---|
201 | indir=${2} |
---|
202 | shift |
---|
203 | ;; |
---|
204 | -o) |
---|
205 | # directory for outputs choosen by user |
---|
206 | outdir=${2} |
---|
207 | shift |
---|
208 | ;; |
---|
209 | -t) |
---|
210 | # directory for temporary outputs choosen by user |
---|
211 | tempdir=${2} |
---|
212 | shift |
---|
213 | ;; |
---|
214 | -s) |
---|
215 | # directory for SAXO tools |
---|
216 | saxo_dir=${2} |
---|
217 | shift |
---|
218 | ;; |
---|
219 | -idl_cmd) |
---|
220 | # command for idl |
---|
221 | idl_cmd=${2} |
---|
222 | shift |
---|
223 | ;; |
---|
224 | *) |
---|
225 | # other choice |
---|
226 | echo "eee : unknown option ${1}" |
---|
227 | echo "${usage}" |
---|
228 | # nb : no exit because this file should be launched by |
---|
229 | # login process |
---|
230 | ;; |
---|
231 | esac |
---|
232 | # next flag |
---|
233 | shift |
---|
234 | done |
---|
235 | unset usage |
---|
236 | # |
---|
237 | # check for ${directory} |
---|
238 | if [ ! -d ${directory} ] |
---|
239 | then |
---|
240 | echo " eee : ${directory} not found" |
---|
241 | # nb : no exit because this file should be launched by login process |
---|
242 | fi |
---|
243 | # |
---|
244 | # check for permission on directory |
---|
245 | if [ ! -x ${directory} ] |
---|
246 | then |
---|
247 | echo " eee : ${directory} not reachable" |
---|
248 | # nb : no exit because this file should be launched by login process |
---|
249 | fi |
---|
250 | # |
---|
251 | PROJECT=${directory} |
---|
252 | export PROJECT |
---|
253 | unset drectory |
---|
254 | # |
---|
255 | # add PROJECT tools to PATH |
---|
256 | # if not already done |
---|
257 | suppath=$(echo ${PROJECT}/src | tr -s "/") |
---|
258 | echo ${PATH} | grep -q "${suppath}:" |
---|
259 | test_path=${?} |
---|
260 | if [ ${test_path} -ne 0 ] |
---|
261 | then |
---|
262 | PATH=${suppath}:${PATH} |
---|
263 | export PATH |
---|
264 | else |
---|
265 | # option bavarde oui/non pas encore implantée ++ |
---|
266 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
267 | fi |
---|
268 | unset test_path |
---|
269 | suppath=$(echo ${PROJECT}/adm| tr -s "/") |
---|
270 | echo ${PATH} | grep -q "${suppath}:" |
---|
271 | test_path=${?} |
---|
272 | if [ ${test_path} -ne 0 ] |
---|
273 | then |
---|
274 | PATH=${suppath}:${PATH} |
---|
275 | export PATH |
---|
276 | else |
---|
277 | # option bavarde oui/non pas encore implantée ++ |
---|
278 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
279 | fi |
---|
280 | unset test_path |
---|
281 | # |
---|
282 | # add PROJECT manuals to MANPATH |
---|
283 | # if not already done |
---|
284 | suppath=$(echo ${PROJECT}/doc/man | tr -s "/") |
---|
285 | set +u |
---|
286 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
287 | test_manpath=${?} |
---|
288 | if [ ${test_manpath} -ne 0 ] |
---|
289 | then |
---|
290 | MANPATH=${suppath}:${MANPATH} |
---|
291 | export MANPATH |
---|
292 | else |
---|
293 | # option bavarde oui/non pas encore implantée ++ |
---|
294 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
295 | fi |
---|
296 | set -u |
---|
297 | unset test_manpath |
---|
298 | unset suppath |
---|
299 | # |
---|
300 | # add PROJECT tools to PYTHONPATH |
---|
301 | # if not already done |
---|
302 | set +u |
---|
303 | suppath=$(echo ${PROJECT}/src | tr -s "/") |
---|
304 | echo ${PYTHONPATH} | grep -q "${suppath}:" |
---|
305 | test_path=${?} |
---|
306 | if [ ${test_path} -ne 0 ] |
---|
307 | then |
---|
308 | PYTHONPATH=${suppath}:${PYTHONPATH} |
---|
309 | export PYTHONPATH |
---|
310 | else |
---|
311 | echo "${command} : iii : ${suppath} already in \${PYTHONPATH}" |
---|
312 | fi |
---|
313 | set -u |
---|
314 | unset test_path |
---|
315 | unset suppath |
---|
316 | # |
---|
317 | PROJECT_LOG=${tempdir} |
---|
318 | export PROJECT_LOG |
---|
319 | unset tempdir |
---|
320 | if [ ! -d ${PROJECT_LOG} ] |
---|
321 | then |
---|
322 | mkdir -p ${PROJECT_LOG} |
---|
323 | status=${?} |
---|
324 | if [ ${status} -ne 0 ] |
---|
325 | then |
---|
326 | echo "${command} : eee : can not create \${PROJECT_LOG}" |
---|
327 | # nb : no exit because this file should be launched by login process |
---|
328 | else |
---|
329 | echo "${command} : iii : creation of \${PROJECT_LOG}" |
---|
330 | fi |
---|
331 | unset status |
---|
332 | fi |
---|
333 | # check for permission on PROJECT_LOG |
---|
334 | if [ ! -x ${PROJECT_LOG} ] |
---|
335 | then |
---|
336 | echo " eee : ${PROJECT_LOG} not reachable" |
---|
337 | # nb : no exit because this file should be launched by login process |
---|
338 | fi |
---|
339 | # |
---|
340 | # check for permission on PROJECT_LOG |
---|
341 | if [ ! -w ${PROJECT_LOG} ] |
---|
342 | then |
---|
343 | echo " eee : ${PROJECT_LOG} not writable" |
---|
344 | # nb : no exit because this file shouldreachable be launched by |
---|
345 | # login process |
---|
346 | fi |
---|
347 | # |
---|
348 | EDITOR=vi |
---|
349 | export EDITOR |
---|
350 | # |
---|
351 | # io directories |
---|
352 | PROJECT_ID=${indir} |
---|
353 | export PROJECT_ID |
---|
354 | unset indir |
---|
355 | if [ ! -d ${PROJECT_ID} ] |
---|
356 | then |
---|
357 | mkdir -p ${PROJECT_ID} |
---|
358 | echo "${command} : iii : creation of \${PROJECT_ID}" |
---|
359 | fi |
---|
360 | # check for permission on PROJECT_ID |
---|
361 | if [ ! -x ${PROJECT_ID} ] |
---|
362 | then |
---|
363 | echo " eee : ${PROJECT_ID} not reachable" |
---|
364 | # nb : no exit because this file should be launched by login process |
---|
365 | fi |
---|
366 | # |
---|
367 | PROJECT_OD=${outdir} |
---|
368 | export PROJECT_OD |
---|
369 | unset outdir |
---|
370 | if [ ! -d ${PROJECT_OD} ] |
---|
371 | then |
---|
372 | mkdir -p ${PROJECT_OD} |
---|
373 | echo "${command} : iii : creation of \${PROJECT_OD}" |
---|
374 | fi |
---|
375 | # check for permission on PROJECT_OD |
---|
376 | if [ ! -x ${PROJECT_OD} ] |
---|
377 | then |
---|
378 | echo " eee : ${PROJECT_OD} not reachable" |
---|
379 | # nb : no exit because this file should be launched by login process |
---|
380 | fi |
---|
381 | if [ ! -w ${PROJECT_OD} ] |
---|
382 | then |
---|
383 | echo " eee : ${PROJECT_OD} not writable" |
---|
384 | # nb : no exit because this file should be launched by login process |
---|
385 | fi |
---|
386 | # |
---|
387 | # setup for ferret |
---|
388 | set +u |
---|
389 | FER_GO="${FER_GO} ${PROJECT}/src" |
---|
390 | export FER_GO |
---|
391 | set -u |
---|
392 | # |
---|
393 | # setup for matlab |
---|
394 | MATLABPATH=${PROJECT} |
---|
395 | export MATLABPATH |
---|
396 | # |
---|
397 | # set up for idl |
---|
398 | IDL_CMD=${idl_cmd} |
---|
399 | export IDL_CMD |
---|
400 | unset idl_cmd |
---|
401 | # |
---|
402 | # SAXO environment |
---|
403 | SAXO_DIR=${saxo_dir} |
---|
404 | export SAXO_DIR |
---|
405 | unset saxo_dir |
---|
406 | # |
---|
407 | PROJECT_ID=${PROJECT_ID} |
---|
408 | export PROJECT_ID |
---|
409 | PROJECT_OD=${PROJECT_OD} |
---|
410 | export PROJECT_OD |
---|
411 | PROJECT_LOG=${PROJECT_LOG} |
---|
412 | export PROJECT_LOG |
---|
413 | # |
---|
414 | # IDL startup |
---|
415 | IDL_STARTUP=${PROJECT}/src/project_init.pro |
---|
416 | export IDL_STARTUP |
---|
417 | # |
---|
418 | # end |
---|
419 | unset command |
---|
420 | set +u |
---|
421 | # nb : no exit because this file should be launched by login process |
---|