source: trunk/src/project_profile.sh @ 203

Last change on this file since 203 was 203, checked in by pinsard, 10 years ago

fix thanks to coding rules

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