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