source: trunk/src/project_profile.sh @ 85

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

fix for doc

  • Property svn:executable set to *
File size: 6.9 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/.
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 20110502T155437Z aedon.locean-ipsl.upmc.fr (Darwin)
109#
110#   * complete FER_GO
111#
112# - fplod 20110429T090524Z aedon.locean-ipsl.upmc.fr (Darwin)
113#
114#   * set IDL_STARTUP
115#
116# - fplod 20110413T151541Z cratos.locean-ipsl.upmc.fr (Linux)
117#
118#   * fix uncompleted replacement SAXO_SRC by SAXO_DIR
119#
120# - fplod 20101118T171653Z aedon.locean-ipsl.upmc.fr (Darwin)
121#
122#   * creation
123#
124#-
125system=$(uname)
126case "${system}" in
127   AIX|IRIX64)
128      echo " www : no specific posix checking"
129   ;;
130   *)
131      set -o posix
132   ;;
133esac
134unset system
135#
136LANG=C
137#
138# as this script might be launch in .profile, command is forced.
139command=project_profile.sh
140#
141usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir"
142#
143set +u
144while [ ! -z "${1}" ]
145do
146   case ${1} in
147      -d)
148         # directory for application choosen by user (see svn checkout command used)
149         directory=${2}
150         shift
151      ;;
152      -i)
153         # directory for inputs choosen by user
154         indir=${2}
155         shift
156      ;;
157      -o)
158         # directory for outputs choosen by user
159         outdir=${2}
160         shift
161      ;;
162      -t)
163         # directory for temporary outputs choosen by user
164         tempdir=${2}
165         shift
166      ;;
167      -s)
168         # directory for SAXO tools
169         saxo_dir=${2}
170         shift
171      ;;
172      *)
173         # other choice
174         echo "eee : unknown option ${1}"
175         echo "${usage}"
176         # nb : no exit because this file should be launched by login process
177      ;;
178   esac
179   # next flag
180   shift
181done
182unset usage
183#
184# check for ${directory}
185if [ ! -d ${directory} ]
186then
187   echo " eee : ${directory} not found"
188   # nb : no exit because this file should be launched by login process
189fi
190#
191# check for permission on directory
192if [ ! -x ${directory} ]
193then
194   echo " eee : ${directory} not reachable"
195   # nb : no exit because this file should be launched by login process
196fi
197#
198PROJECT=${directory}
199export PROJECT
200unset drectory
201#
202# add PROJECT tools to PATH
203# if not already done
204suppath=$(echo ${PROJECT}/src | tr -s "/")
205echo ${PATH} | grep -q "${suppath}:"
206test_path=${?}
207if [ ${test_path} -ne 0 ]
208then
209   PATH=${suppath}:${PATH}
210   export PATH
211else
212   # option bavarde oui/non pas encore implantée ++
213   echo "${command} : iii : ${suppath} already in \${PATH}"
214fi
215unset test_path
216#
217# add PROJECT manuals to MANPATH
218# if not already done
219suppath=$(echo ${PROJECT}/doc/man | tr -s "/")
220echo ${MANPATH} | grep -q "${suppath}:"
221test_manpath=${?}
222if [ ${test_manpath} -ne 0 ]
223then
224   MANPATH=${suppath}:${MANPATH}
225   export MANPATH
226else
227   # option bavarde oui/non pas encore implantée ++
228   echo "${command} : iii : ${suppath} already in \${MANPATH}"
229fi
230unset test_manpath
231unset suppath
232#
233PROJECT_LOG=${tempdir}
234export PROJECT_LOG
235unset tempdir
236if [ ! -d ${PROJECT_LOG} ]
237then
238   mkdir -p ${PROJECT_LOG}
239   status=${?}
240   if [ ${status} -ne 0 ]
241   then
242      echo "${command} : eee : can not create \${PROJECT_LOG}"
243      # nb : no exit because this file should be launched by login process
244   else
245      echo "${command} : iii : creation of \${PROJECT_LOG}"
246   fi
247   unset status
248fi
249# check for permission on PROJECT_LOG
250if [ ! -x ${PROJECT_LOG} ]
251then
252   echo " eee : ${PROJECT_LOG} not reachable"
253   # nb : no exit because this file should be launched by login process
254fi
255#
256# check for permission on PROJECT_LOG
257if [ ! -w ${PROJECT_LOG} ]
258then
259   echo " eee : ${PROJECT_LOG} not writable"
260   # nb : no exit because this file shouldreachable be launched by login process
261fi
262#
263EDITOR=vi
264export EDITOR
265#
266# io directories
267PROJECT_ID=${indir}
268export PROJECT_ID
269unset indir
270if [ ! -d ${PROJECT_ID} ]
271then
272   mkdir -p ${PROJECT_ID}
273   echo "${command} : iii : creation of \${PROJECT_ID}"
274fi
275# check for permission on PROJECT_ID
276if [ ! -x ${PROJECT_ID} ]
277then
278   echo " eee : ${PROJECT_ID} not reachable"
279   # nb : no exit because this file should be launched by login process
280fi
281#
282PROJECT_OD=${outdir}
283export PROJECT_OD
284unset outdir
285if [ ! -d ${PROJECT_OD} ]
286then
287    mkdir -p ${PROJECT_OD}
288    echo "${command} : iii : creation of \${PROJECT_OD}"
289fi
290# check for permission on PROJECT_OD
291if [ ! -x ${PROJECT_OD} ]
292then
293   echo " eee : ${PROJECT_OD} not reachable"
294   # nb : no exit because this file should be launched by login process
295fi
296if [ ! -w ${PROJECT_OD} ]
297then
298   echo " eee : ${PROJECT_OD} not writable"
299   # nb : no exit because this file should be launched by login process
300fi
301#
302# setup for ferret
303FER_GO="${FER_GO} ${PROJECT}/src"
304export FER_GO
305#
306SAXO_DIR=${saxo_dir}
307export SAXO_DIR
308unset saxo_dir
309#
310# IDL startup
311IDL_STARTUP=${PROJECT}/src/project_init.pro
312export IDL_STARTUP
313#
314# end
315unset command
316# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.