source: trunk/src/project_profile.sh @ 152

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

idl version by defaut on cratos is 6.2

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