source: trunk/src/project_profile.sh @ 151

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

draft for global processing tool

  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 7.8 KB
RevLine 
[50]1#! /bin/sh
[2]2#+
3#
[50]4# .. program:: project_profile.sh
[2]5#
[50]6# .. _project_profile.sh:
[2]7#
8# ==================================================
[50]9# project_profile.sh -- define PROJECT environment
[2]10# ==================================================
11#
12# SYNOPSIS
13# ========
14#
15# Online usage::
16#
[50]17#  $ . ./project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir
[2]18# In ${HOME}/.profile, add the following line::
19#
[50]20#  . project_profile.sh -d directory  -i indir -o outdir -t tempdir -s saxo_dir
[2]21#
22# DESCRIPTION
23# ===========
24#
25# .. option:: -d  <directory>
26# .. option:: -i  <indir>
27# .. option:: -o  <outdir>
28# .. option:: -t  <tempdir>
[45]29# .. option:: -s  <saxo_dir>
[151]30# .. option:: -idl_cmd  <idl_cmd>
[2]31#
[50]32# define PROJECT environment
[2]33#
[50]34# ${PROJECT} is the base directory of tools.
[2]35#
[50]36# ${PROJECT_LOG} is the directory where log files will be written.
[2]37#
[50]38# ${PROJECT_ID} is the directory where input files must be.
[2]39#
[50]40# ${PROJECT_OD} is the directory where output files will be written.
[2]41#
[67]42# PATH is completed with ${PROJECT}/src/.
43#
[45]44# ${SAXO_DIR} is the base directory of SAXO tools
[40]45#
[50]46# IDL_STARTUP is set to tell IDL where find tools.
[2]47#
[151]48# If :option:`idl_cmd` is used, **idl_cmd** will be used as the IDL command
49# when launched from scripts.
50# By default, ${IDL_CMD} is set to `idl`.
51#
[106]52# FER_GO is completed with ${PROJECT}/src/ and ${PROJECT}/src/test/.
[50]53#
[2]54# SEE ALSO
55# ========
56#
[50]57# for IDL/gdl and SAXO environment :
[2]58#
[50]59# :ref:`project_init.pro`
60# :ref:`cm_project.pro`
[45]61#
[2]62# EXAMPLES
63# ========
64#
65# For fplod, on aedon.locean-ipsl.upmc.fr::
66#
67#  $ cd /usr/home/fplod/incas/tropflux/tropflux_ws/
[50]68#  $ . ./src/project_profile.sh \
[2]69#    -d $(pwd) \
70#    -i /usr/temp/${LOGNAME}/tropflux_d/ \
71#    -o /usr/temp/${LOGNAME}/tropflux_d/ \
[40]72#    -t /usr/temp/${LOGNAME}/log/ \
[45]73#    -s /usr/home/fplod/SAXO_DIR/
[2]74#
[40]75# For fplod on cratos.locean-ipsl.umpc.fr::
[2]76#
77#  $ cd ${HOME}/incas/tropflux/tropflux_ws/
[50]78#  $ . ./src/project_profile.sh \
[2]79#    -d $(pwd) \
80#    -i /usr/temp/${LOGNAME}/tropflux_d/ \
81#    -o /usr/temp/${LOGNAME}/tropflux_d/ \
[40]82#    -t /usr/temp/${LOGNAME}/log/ \
[45]83#    -s ${HOME}/SAXO_DIR/
[2]84#
[151]85# For pinsard on camelot.ipsl.polytechnique.fr or merlin15-c.climserv to use
86# idl6.4::
[2]87#
88#  $ cd ${HOME}/tropflux/
[50]89#  $ . ./src/project_profile.sh \
[2]90#   -d $(pwd) \
91#   -i /homedata/${LOGNAME}/tropflux_d/ \
92#   -o /homedata/${LOGNAME}/tropflux_d/ \
[151]93#   -t /homedata/${LOGNAME}/log/ \
94#   -s ${HOME}/SAXO_DIR/ \
95#   -idl_cmd /opt/idl-6.4/idl/bin/idl
[2]96#
97# TODO
98# ====
99#
100# ++ option bavarde
101#
102# ++ machine dependant
103#
104# ++ besoin de posix
105#
106# ++ pas de MANPATH defini par défaut sur zeus et cerbere
107#
108# EVOLUTIONS
109# ==========
110#
[67]111# $Id$
112#
[151]113# $URL$
114#
115# - fplod 20120305
116#
117#   * add idl_cmd option
118#   * improve with set -u
119#
[106]120# - fplod 20111104T130726Z cratos (Linux)
121#
122#   * add $PROJECT/src/test to FER_GO
123#
124# - fplod 20111010T072623Z aedon.locean-ipsl.upmc.fr (Darwin)
125#
126#   * FER_GO might be undefined
127#
[67]128# - fplod 20110502T155437Z aedon.locean-ipsl.upmc.fr (Darwin)
129#
130#   * complete FER_GO
131#
[50]132# - fplod 20110429T090524Z aedon.locean-ipsl.upmc.fr (Darwin)
133#
134#   * set IDL_STARTUP
135#
[45]136# - fplod 20110413T151541Z cratos.locean-ipsl.upmc.fr (Linux)
137#
138#   * fix uncompleted replacement SAXO_SRC by SAXO_DIR
139#
[2]140# - fplod 20101118T171653Z aedon.locean-ipsl.upmc.fr (Darwin)
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#
[151]156set -u
157#
[2]158LANG=C
159#
160# as this script might be launch in .profile, command is forced.
[50]161command=project_profile.sh
[2]162#
[151]163usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir -idl_cmd idl_cmd"
[2]164#
[151]165# default
166idl_cmd=idl
167#
168while [ ${#} -gt 0 ]
[2]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      ;;
[40]191      -s)
192         # directory for SAXO tools
[45]193         saxo_dir=${2}
[40]194         shift
195      ;;
[151]196      -idl_cmd)
197         # command for idl
198         idl_cmd=${2}
199         shift
200      ;;
[2]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#
[50]227PROJECT=${directory}
228export PROJECT
[2]229unset drectory
230#
[50]231# add PROJECT tools to PATH
[2]232# if not already done
[50]233suppath=$(echo ${PROJECT}/src | tr -s "/")
[2]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
245#
[50]246# add PROJECT manuals to MANPATH
[2]247# if not already done
[50]248suppath=$(echo ${PROJECT}/doc/man | tr -s "/")
[2]249echo ${MANPATH} | grep -q "${suppath}:"
250test_manpath=${?}
251if [ ${test_manpath} -ne 0 ]
252then
253   MANPATH=${suppath}:${MANPATH}
254   export MANPATH
255else
256   # option bavarde oui/non pas encore implantée ++
257   echo "${command} : iii : ${suppath} already in \${MANPATH}"
258fi
259unset test_manpath
260unset suppath
261#
[50]262PROJECT_LOG=${tempdir}
263export PROJECT_LOG
[2]264unset tempdir
[50]265if [ ! -d ${PROJECT_LOG} ]
[2]266then
[50]267   mkdir -p ${PROJECT_LOG}
[2]268   status=${?}
269   if [ ${status} -ne 0 ]
270   then
[50]271      echo "${command} : eee : can not create \${PROJECT_LOG}"
[2]272      # nb : no exit because this file should be launched by login process
273   else
[50]274      echo "${command} : iii : creation of \${PROJECT_LOG}"
[2]275   fi
276   unset status
277fi
[50]278# check for permission on PROJECT_LOG
279if [ ! -x ${PROJECT_LOG} ]
[2]280then
[50]281   echo " eee : ${PROJECT_LOG} not reachable"
[2]282   # nb : no exit because this file should be launched by login process
283fi
284#
[50]285# check for permission on PROJECT_LOG
286if [ ! -w ${PROJECT_LOG} ]
[2]287then
[50]288   echo " eee : ${PROJECT_LOG} not writable"
[2]289   # nb : no exit because this file shouldreachable be launched by login process
290fi
291#
292EDITOR=vi
293export EDITOR
294#
295# io directories
[50]296PROJECT_ID=${indir}
297export PROJECT_ID
[2]298unset indir
[50]299if [ ! -d ${PROJECT_ID} ]
[2]300then
[50]301   mkdir -p ${PROJECT_ID}
302   echo "${command} : iii : creation of \${PROJECT_ID}"
[2]303fi
[50]304# check for permission on PROJECT_ID
305if [ ! -x ${PROJECT_ID} ]
[2]306then
[50]307   echo " eee : ${PROJECT_ID} not reachable"
[2]308   # nb : no exit because this file should be launched by login process
309fi
310#
[50]311PROJECT_OD=${outdir}
312export PROJECT_OD
[2]313unset outdir
[50]314if [ ! -d ${PROJECT_OD} ]
[2]315then
[50]316    mkdir -p ${PROJECT_OD}
317    echo "${command} : iii : creation of \${PROJECT_OD}"
[2]318fi
[50]319# check for permission on PROJECT_OD
320if [ ! -x ${PROJECT_OD} ]
[2]321then
[50]322   echo " eee : ${PROJECT_OD} not reachable"
[2]323   # nb : no exit because this file should be launched by login process
324fi
[50]325if [ ! -w ${PROJECT_OD} ]
[2]326then
[50]327   echo " eee : ${PROJECT_OD} not writable"
[2]328   # nb : no exit because this file should be launched by login process
329fi
330#
[67]331# setup for ferret
[106]332set +u
333if [ "${FER_GO}" = "" ]
334then
335    FER_GO="${FER_DIR}/go ${FER_GO} ${PROJECT}/src"
336else
337    FER_GO="${FER_DIR}/go ${PROJECT}/src"
338fi
339set -u
340FER_GO="${FER_GO} ${PROJECT}/src/test"
[67]341export FER_GO
342#
[151]343# set up for idl
344IDL_CMD=${idl_cmd}
345export IDL_CMD
346unset idl_cmd
347#
[45]348SAXO_DIR=${saxo_dir}
349export SAXO_DIR
350unset saxo_dir
[40]351#
[50]352# IDL startup
353IDL_STARTUP=${PROJECT}/src/project_init.pro
354export IDL_STARTUP
355#
[2]356# end
357unset command
358# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.