[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 | #- |
---|
| 125 | system=$(uname) |
---|
| 126 | case "${system}" in |
---|
| 127 | AIX|IRIX64) |
---|
| 128 | echo " www : no specific posix checking" |
---|
| 129 | ;; |
---|
| 130 | *) |
---|
| 131 | set -o posix |
---|
| 132 | ;; |
---|
| 133 | esac |
---|
| 134 | unset system |
---|
| 135 | # |
---|
| 136 | LANG=C |
---|
| 137 | # |
---|
| 138 | # as this script might be launch in .profile, command is forced. |
---|
[50] | 139 | command=project_profile.sh |
---|
[2] | 140 | # |
---|
[45] | 141 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir" |
---|
[2] | 142 | # |
---|
| 143 | set +u |
---|
| 144 | while [ ! -z "${1}" ] |
---|
| 145 | do |
---|
| 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 |
---|
| 181 | done |
---|
| 182 | unset usage |
---|
| 183 | # |
---|
| 184 | # check for ${directory} |
---|
| 185 | if [ ! -d ${directory} ] |
---|
| 186 | then |
---|
| 187 | echo " eee : ${directory} not found" |
---|
| 188 | # nb : no exit because this file should be launched by login process |
---|
| 189 | fi |
---|
| 190 | # |
---|
| 191 | # check for permission on directory |
---|
| 192 | if [ ! -x ${directory} ] |
---|
| 193 | then |
---|
| 194 | echo " eee : ${directory} not reachable" |
---|
| 195 | # nb : no exit because this file should be launched by login process |
---|
| 196 | fi |
---|
| 197 | # |
---|
[50] | 198 | PROJECT=${directory} |
---|
| 199 | export PROJECT |
---|
[2] | 200 | unset drectory |
---|
| 201 | # |
---|
[50] | 202 | # add PROJECT tools to PATH |
---|
[2] | 203 | # if not already done |
---|
[50] | 204 | suppath=$(echo ${PROJECT}/src | tr -s "/") |
---|
[2] | 205 | echo ${PATH} | grep -q "${suppath}:" |
---|
| 206 | test_path=${?} |
---|
| 207 | if [ ${test_path} -ne 0 ] |
---|
| 208 | then |
---|
| 209 | PATH=${suppath}:${PATH} |
---|
| 210 | export PATH |
---|
| 211 | else |
---|
| 212 | # option bavarde oui/non pas encore implantée ++ |
---|
| 213 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
| 214 | fi |
---|
| 215 | unset test_path |
---|
| 216 | # |
---|
[50] | 217 | # add PROJECT manuals to MANPATH |
---|
[2] | 218 | # if not already done |
---|
[50] | 219 | suppath=$(echo ${PROJECT}/doc/man | tr -s "/") |
---|
[2] | 220 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
| 221 | test_manpath=${?} |
---|
| 222 | if [ ${test_manpath} -ne 0 ] |
---|
| 223 | then |
---|
| 224 | MANPATH=${suppath}:${MANPATH} |
---|
| 225 | export MANPATH |
---|
| 226 | else |
---|
| 227 | # option bavarde oui/non pas encore implantée ++ |
---|
| 228 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
| 229 | fi |
---|
| 230 | unset test_manpath |
---|
| 231 | unset suppath |
---|
| 232 | # |
---|
[50] | 233 | PROJECT_LOG=${tempdir} |
---|
| 234 | export PROJECT_LOG |
---|
[2] | 235 | unset tempdir |
---|
[50] | 236 | if [ ! -d ${PROJECT_LOG} ] |
---|
[2] | 237 | then |
---|
[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 |
---|
| 248 | fi |
---|
[50] | 249 | # check for permission on PROJECT_LOG |
---|
| 250 | if [ ! -x ${PROJECT_LOG} ] |
---|
[2] | 251 | then |
---|
[50] | 252 | echo " eee : ${PROJECT_LOG} not reachable" |
---|
[2] | 253 | # nb : no exit because this file should be launched by login process |
---|
| 254 | fi |
---|
| 255 | # |
---|
[50] | 256 | # check for permission on PROJECT_LOG |
---|
| 257 | if [ ! -w ${PROJECT_LOG} ] |
---|
[2] | 258 | then |
---|
[50] | 259 | echo " eee : ${PROJECT_LOG} not writable" |
---|
[2] | 260 | # nb : no exit because this file shouldreachable be launched by login process |
---|
| 261 | fi |
---|
| 262 | # |
---|
| 263 | EDITOR=vi |
---|
| 264 | export EDITOR |
---|
| 265 | # |
---|
| 266 | # io directories |
---|
[50] | 267 | PROJECT_ID=${indir} |
---|
| 268 | export PROJECT_ID |
---|
[2] | 269 | unset indir |
---|
[50] | 270 | if [ ! -d ${PROJECT_ID} ] |
---|
[2] | 271 | then |
---|
[50] | 272 | mkdir -p ${PROJECT_ID} |
---|
| 273 | echo "${command} : iii : creation of \${PROJECT_ID}" |
---|
[2] | 274 | fi |
---|
[50] | 275 | # check for permission on PROJECT_ID |
---|
| 276 | if [ ! -x ${PROJECT_ID} ] |
---|
[2] | 277 | then |
---|
[50] | 278 | echo " eee : ${PROJECT_ID} not reachable" |
---|
[2] | 279 | # nb : no exit because this file should be launched by login process |
---|
| 280 | fi |
---|
| 281 | # |
---|
[50] | 282 | PROJECT_OD=${outdir} |
---|
| 283 | export PROJECT_OD |
---|
[2] | 284 | unset outdir |
---|
[50] | 285 | if [ ! -d ${PROJECT_OD} ] |
---|
[2] | 286 | then |
---|
[50] | 287 | mkdir -p ${PROJECT_OD} |
---|
| 288 | echo "${command} : iii : creation of \${PROJECT_OD}" |
---|
[2] | 289 | fi |
---|
[50] | 290 | # check for permission on PROJECT_OD |
---|
| 291 | if [ ! -x ${PROJECT_OD} ] |
---|
[2] | 292 | then |
---|
[50] | 293 | echo " eee : ${PROJECT_OD} not reachable" |
---|
[2] | 294 | # nb : no exit because this file should be launched by login process |
---|
| 295 | fi |
---|
[50] | 296 | if [ ! -w ${PROJECT_OD} ] |
---|
[2] | 297 | then |
---|
[50] | 298 | echo " eee : ${PROJECT_OD} not writable" |
---|
[2] | 299 | # nb : no exit because this file should be launched by login process |
---|
| 300 | fi |
---|
| 301 | # |
---|
[67] | 302 | # setup for ferret |
---|
| 303 | FER_GO="${FER_GO} ${PROJECT}/src" |
---|
| 304 | export FER_GO |
---|
| 305 | # |
---|
[45] | 306 | SAXO_DIR=${saxo_dir} |
---|
| 307 | export SAXO_DIR |
---|
| 308 | unset saxo_dir |
---|
[40] | 309 | # |
---|
[50] | 310 | # IDL startup |
---|
| 311 | IDL_STARTUP=${PROJECT}/src/project_init.pro |
---|
| 312 | export IDL_STARTUP |
---|
| 313 | # |
---|
[2] | 314 | # end |
---|
| 315 | unset command |
---|
| 316 | # nb : no exit because this file should be launched by login process |
---|