source: trunk/src/project_profile.sh @ 4

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

import of project infrastructure (to be cont.)

  • Property svn:executable set to *
File size: 8.3 KB
Line 
1#! /bin/sh
2#+
3#
4# .. program:: project_profile.sh
5#
6# .. _project_profile.sh:
7#
8# ==================
9# project_profile.sh
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 -idl_cmd idl_cmd
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# .. option:: -idl_cmd  <idl_cmd>
32#
33# define PROJECT environment
34#
35# ${PROJECT} is the base directory of tools.
36#
37# ${PROJECT_LOG} is the directory where log files will be written.
38#
39# ${PROJECT_ID} is the directory where input files must be.
40#
41# ${PROJECT_OD} is the directory where output files will be written.
42#
43# ${SAXO_DIR} is the base directory of SAXO tools
44#
45# PATH is completed with ${PROJECT}/src/ and ${PROJECT}/adm/.
46#
47# FER_GO is completed with ${PROJECT}/src/.
48#
49# IDL_STARTUP is set to tell IDL where find tools.
50#
51# If :option:`-idl_cmd` is used, **idl_cmd** will be used as the IDL command when launched from
52# scripts. By default, ${IDL_CMD} is set to `idl`.
53#
54# MATLABPATH is initialize to tell matlab where find tools.
55#
56#
57# SEE ALSO
58# ========
59#
60# for matlab/octave environment :
61#
62# :ref:`project_startup.m`
63#
64# for IDL/gdl and SAXO environment :
65#
66# :ref:`project_init.pro`
67# :ref:`cm_project.pro`
68#
69# EXAMPLES
70# ========
71#
72# For fplod, on halios.locean-ipsl.upmc.fr with gdl::
73#
74#  cd /usr/home/fplod/incas/project/project_ws/
75#  . ./src/project_profile.sh \
76#    -d $(pwd) \
77#    -i /usr/temp/${LOGNAME}/project_d/ \
78#    -o /usr/temp/${LOGNAME}/project_d/ \
79#    -t /usr/temp/${LOGNAME}/log/ \
80#    -s /usr/home/fplod/SAXO_DIR/ \
81#    -idl_cmd gdl
82#
83# For fplod on cratos.locean-ipsl.umpc.fr with default IDL version::
84#
85#  cd ${HOME}/incas/project/project_ws/
86#  . ./src/project_profile.sh \
87#    -d $(pwd) \
88#    -i /usr/temp/${LOGNAME}/project_d/ \
89#    -o /usr/temp/${LOGNAME}/project_d/ \
90#    -t /usr/temp/${LOGNAME}/log/ \
91#    -s ${HOME}/SAXO_DIR/
92#
93# For fplod on cratos.locean-ipsl.umpc.fr with IDL version 6.4::
94#
95#  cd ${HOME}/incas/project/project_ws/
96#  . ./src/project_profile.sh \
97#    -d $(pwd) \
98#    -i /usr/temp/${LOGNAME}/project_d/ \
99#    -o /usr/temp/${LOGNAME}/project_d/ \
100#    -t /usr/temp/${LOGNAME}/log/ \
101#    -s ${HOME}/SAXO_DIR/ \
102#    -idl_cmd  /usr/local_linux/idl/idl_6.4/idl64/bin/idl
103#
104# For pinsard on camelot.ipsl.polytechnique.fr or merlin15-c.climserv::
105#
106#  cd ${HOME}/project/
107#  . ./src/project_profile.sh \
108#   -d $(pwd) \
109#   -i /homedata/${LOGNAME}/project_d/ \
110#   -o /homedata/${LOGNAME}/project_d/ \
111#   -t /homedata/${LOGNAME}/log/ \
112#   -s ${HOME}/SAXO_DIR/
113#
114# For pinsard on loholt1 to use idl 6-4::
115#
116#  cd ${HOME}/project/
117#  . ./src/project_profile.sh \
118#   -d $(pwd) \
119#   -i /homedata/${LOGNAME}/project_d/ \
120#   -o /homedata/${LOGNAME}/project_d/ \
121#   -t /homedata/${LOGNAME}/log/ \
122#   -s ${HOME}/SAXO_DIR/ \
123#   -idl_cmd /opt/idl-6.4/idl/bin/idl
124#
125# .. todo::
126#
127# ++ option bavarde
128#
129# ++ machine dependant
130#
131# ++ besoin de posix
132#
133# usage of PROJECT* instead of PROJECT* everywhere
134#
135# EVOLUTIONS
136# ==========
137#
138# $Id: project_profile.sh 532 2012-04-18 12:44:46Z pinsard $
139#
140# - fplod 20120424
141#
142#   * creation
143#
144#-
145system=$(uname)
146case "${system}" in
147   AIX|IRIX64)
148      echo " www : no specific posix checking"
149   ;;
150   *)
151      set -o posix
152   ;;
153esac
154unset system
155#
156set -u
157#
158LANG=C
159#
160# as this script might be launch in .profile, command is forced.
161command=project_profile.sh
162#
163usage="Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir [-idl_cmd idl_cmd]"
164#
165# default
166idl_cmd=idl
167#
168while [ ${#} -gt 0 ]
169do
170   case ${1} in
171      -d)
172         # directory for application choosen by user (see svn checkout command used)
173         directory=${2}
174         shift
175      ;;
176      -i)
177         # directory for inputs choosen by user
178         indir=${2}
179         shift
180      ;;
181      -o)
182         # directory for outputs choosen by user
183         outdir=${2}
184         shift
185      ;;
186      -t)
187         # directory for temporary outputs choosen by user
188         tempdir=${2}
189         shift
190      ;;
191      -s)
192         # directory for SAXO tools
193         saxo_dir=${2}
194         shift
195      ;;
196      -idl_cmd)
197         # command for idl
198         idl_cmd=${2}
199         shift
200      ;;
201      *)
202         # other choice
203         echo "eee : unknown option ${1}"
204         echo "${usage}"
205         # nb : no exit because this file should be launched by login process
206      ;;
207   esac
208   # next flag
209   shift
210done
211unset usage
212#
213# check for ${directory}
214if [ ! -d ${directory} ]
215then
216   echo " eee : ${directory} not found"
217   # nb : no exit because this file should be launched by login process
218fi
219#
220# check for permission on directory
221if [ ! -x ${directory} ]
222then
223   echo " eee : ${directory} not reachable"
224   # nb : no exit because this file should be launched by login process
225fi
226#
227PROJECT=${directory}
228export PROJECT
229unset drectory
230#
231# add PROJECT tools to PATH
232# if not already done
233suppath=$(echo ${PROJECT}/src | tr -s "/")
234echo ${PATH} | grep -q "${suppath}:"
235test_path=${?}
236if [ ${test_path} -ne 0 ]
237then
238   PATH=${suppath}:${PATH}
239   export PATH
240else
241   # option bavarde oui/non pas encore implantée ++
242   echo "${command} : iii : ${suppath} already in \${PATH}"
243fi
244unset test_path
245suppath=$(echo ${PROJECT}/adm| tr -s "/")
246echo ${PATH} | grep -q "${suppath}:"
247test_path=${?}
248if [ ${test_path} -ne 0 ]
249then
250   PATH=${suppath}:${PATH}
251   export PATH
252else
253   # option bavarde oui/non pas encore implantée ++
254   echo "${command} : iii : ${suppath} already in \${PATH}"
255fi
256unset test_path
257#
258# add PROJECT manuals to MANPATH
259# if not already done
260suppath=$(echo ${PROJECT}/doc/man | tr -s "/")
261set +u
262echo ${MANPATH} | grep -q "${suppath}:"
263test_manpath=${?}
264if [ ${test_manpath} -ne 0 ]
265then
266   MANPATH=${suppath}:${MANPATH}
267   export MANPATH
268else
269   # option bavarde oui/non pas encore implantée ++
270   echo "${command} : iii : ${suppath} already in \${MANPATH}"
271fi
272set -u
273unset test_manpath
274unset suppath
275#
276PROJECT_LOG=${tempdir}
277export PROJECT_LOG
278unset tempdir
279if [ ! -d ${PROJECT_LOG} ]
280then
281   mkdir -p ${PROJECT_LOG}
282   status=${?}
283   if [ ${status} -ne 0 ]
284   then
285      echo "${command} : eee : can not create \${PROJECT_LOG}"
286      # nb : no exit because this file should be launched by login process
287   else
288      echo "${command} : iii : creation of \${PROJECT_LOG}"
289   fi
290   unset status
291fi
292# check for permission on PROJECT_LOG
293if [ ! -x ${PROJECT_LOG} ]
294then
295   echo " eee : ${PROJECT_LOG} not reachable"
296   # nb : no exit because this file should be launched by login process
297fi
298#
299# check for permission on PROJECT_LOG
300if [ ! -w ${PROJECT_LOG} ]
301then
302   echo " eee : ${PROJECT_LOG} not writable"
303   # nb : no exit because this file shouldreachable be launched by login process
304fi
305#
306EDITOR=vi
307export EDITOR
308#
309# io directories
310PROJECT_ID=${indir}
311export PROJECT_ID
312unset indir
313if [ ! -d ${PROJECT_ID} ]
314then
315   mkdir -p ${PROJECT_ID}
316   echo "${command} : iii : creation of \${PROJECT_ID}"
317fi
318# check for permission on PROJECT_ID
319if [ ! -x ${PROJECT_ID} ]
320then
321   echo " eee : ${PROJECT_ID} not reachable"
322   # nb : no exit because this file should be launched by login process
323fi
324#
325PROJECT_OD=${outdir}
326export PROJECT_OD
327unset outdir
328if [ ! -d ${PROJECT_OD} ]
329then
330    mkdir -p ${PROJECT_OD}
331    echo "${command} : iii : creation of \${PROJECT_OD}"
332fi
333# check for permission on PROJECT_OD
334if [ ! -x ${PROJECT_OD} ]
335then
336   echo " eee : ${PROJECT_OD} not reachable"
337   # nb : no exit because this file should be launched by login process
338fi
339if [ ! -w ${PROJECT_OD} ]
340then
341   echo " eee : ${PROJECT_OD} not writable"
342   # nb : no exit because this file should be launched by login process
343fi
344#
345# setup for ferret
346set +u
347FER_GO="${FER_GO} ${PROJECT}/src"
348export FER_GO
349set -u
350#
351# setup for matlab
352MATLABPATH=${PROJECT}
353export MATLABPATH
354#
355# set up for idl
356IDL_CMD=${idl_cmd}
357export IDL_CMD
358unset idl_cmd
359#
360# SAXO environment
361SAXO_DIR=${saxo_dir}
362export SAXO_DIR
363unset saxo_dir
364#
365PROJECT=${PROJECT}
366export PROJECT
367PROJECT_ID=${PROJECT_ID}
368export PROJECT_ID
369PROJECT_OD=${PROJECT_OD}
370export PROJECT_OD
371PROJECT_LOG=${PROJECT_LOG}
372export PROJECT_LOG
373#
374# IDL startup
375IDL_STARTUP=${PROJECT}/src/project_init.pro
376export IDL_STARTUP
377#
378# end
379unset command
380set +u
381# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.