source: trunk/src/pomme_profile.sh @ 2

Last change on this file since 2 was 2, checked in by pinsard, 14 years ago

first commit with original work of Marina Levy and Francoise Pinsard

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