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