source: trunk/src/project_profile.sh @ 151

Last change on this file since 151 was 151, checked in by pinsard, 12 years ago

draft for global processing tool

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