source: trunk/src/tropflux_profile.sh @ 26

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

first commit with original work of Francoise Pinsard

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