source: trunk/src/project_profile.sh @ 106

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

add pkb tools for timeseries

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