source: trunk/src/project_profile.sh @ 169

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

fix for developper documentation

  • 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
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#-
150system=$(uname)
151case "${system}" in
152   AIX|IRIX64)
153      echo " www : no specific posix checking"
154   ;;
155   *)
156      set -o posix
157   ;;
158esac
159unset system
160#
161set -u
162#
163LANG=C
164#
165# as this script might be launch in .profile, command is forced.
166command=project_profile.sh
167#
168usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir -idl_cmd idl_cmd"
169#
170# default
171idl_cmd=idl
172#
173while [ ${#} -gt 0 ]
174do
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
215done
216unset usage
217#
218# check for ${directory}
219if [ ! -d ${directory} ]
220then
221   echo " eee : ${directory} not found"
222   # nb : no exit because this file should be launched by login process
223fi
224#
225# check for permission on directory
226if [ ! -x ${directory} ]
227then
228   echo " eee : ${directory} not reachable"
229   # nb : no exit because this file should be launched by login process
230fi
231#
232PROJECT=${directory}
233export PROJECT
234unset drectory
235#
236# add PROJECT tools to PATH
237# if not already done
238suppath=$(echo ${PROJECT}/src | tr -s "/")
239echo ${PATH} | grep -q "${suppath}:"
240test_path=${?}
241if [ ${test_path} -ne 0 ]
242then
243   PATH=${suppath}:${PATH}
244   export PATH
245else
246   # option bavarde oui/non pas encore implantée ++
247   echo "${command} : iii : ${suppath} already in \${PATH}"
248fi
249unset test_path
250#
251# add PROJECT manuals to MANPATH
252# if not already done
253suppath=$(echo ${PROJECT}/doc/man | tr -s "/")
254echo ${MANPATH} | grep -q "${suppath}:"
255test_manpath=${?}
256if [ ${test_manpath} -ne 0 ]
257then
258   MANPATH=${suppath}:${MANPATH}
259   export MANPATH
260else
261   # option bavarde oui/non pas encore implantée ++
262   echo "${command} : iii : ${suppath} already in \${MANPATH}"
263fi
264unset test_manpath
265unset suppath
266#
267PROJECT_LOG=${tempdir}
268export PROJECT_LOG
269unset tempdir
270if [ ! -d ${PROJECT_LOG} ]
271then
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
282fi
283# check for permission on PROJECT_LOG
284if [ ! -x ${PROJECT_LOG} ]
285then
286   echo " eee : ${PROJECT_LOG} not reachable"
287   # nb : no exit because this file should be launched by login process
288fi
289#
290# check for permission on PROJECT_LOG
291if [ ! -w ${PROJECT_LOG} ]
292then
293   echo " eee : ${PROJECT_LOG} not writable"
294   # nb : no exit because this file shouldreachable be launched by login process
295fi
296#
297EDITOR=vi
298export EDITOR
299#
300# io directories
301PROJECT_ID=${indir}
302export PROJECT_ID
303unset indir
304if [ ! -d ${PROJECT_ID} ]
305then
306   mkdir -p ${PROJECT_ID}
307   echo "${command} : iii : creation of \${PROJECT_ID}"
308fi
309# check for permission on PROJECT_ID
310if [ ! -x ${PROJECT_ID} ]
311then
312   echo " eee : ${PROJECT_ID} not reachable"
313   # nb : no exit because this file should be launched by login process
314fi
315#
316PROJECT_OD=${outdir}
317export PROJECT_OD
318unset outdir
319if [ ! -d ${PROJECT_OD} ]
320then
321    mkdir -p ${PROJECT_OD}
322    echo "${command} : iii : creation of \${PROJECT_OD}"
323fi
324# check for permission on PROJECT_OD
325if [ ! -x ${PROJECT_OD} ]
326then
327   echo " eee : ${PROJECT_OD} not reachable"
328   # nb : no exit because this file should be launched by login process
329fi
330if [ ! -w ${PROJECT_OD} ]
331then
332   echo " eee : ${PROJECT_OD} not writable"
333   # nb : no exit because this file should be launched by login process
334fi
335#
336# setup for ferret
337set +u
338if [ "${FER_GO}" = "" ]
339then
340    FER_GO="${FER_DIR}/go ${FER_GO} ${PROJECT}/src"
341else
342    FER_GO="${FER_DIR}/go ${PROJECT}/src"
343fi
344set -u
345FER_GO="${FER_GO} ${PROJECT}/src/test"
346export FER_GO
347#
348# set up for idl
349IDL_CMD=${idl_cmd}
350export IDL_CMD
351unset idl_cmd
352#
353SAXO_DIR=${saxo_dir}
354export SAXO_DIR
355unset saxo_dir
356#
357# IDL startup
358IDL_STARTUP=${PROJECT}/src/project_init.pro
359export IDL_STARTUP
360#
361# end
362unset command
363# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.