source: trunk/src/project_profile.sh @ 12

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

fix thanks to coding rules + update doc

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