source: trunk/src/project_profile.sh @ 12

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

fix thanks to coding rules + update doc

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