source: trunk/src/project_profile.sh @ 50

Last change on this file since 50 was 50, checked in by pinsard, 13 years ago

replace TROPFLUX by PROJECT

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