source: trunk/src/project_profile.sh @ 164

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

fix for developper documentation

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