source: trunk/src/project_profile.sh @ 70

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

fix for doc

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