source: trunk/src/project_profile.sh @ 10

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

Consolidation of shell scripts

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