source: trunk/src/tropflux_profile.sh @ 45

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

correction for SAXO environment

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