[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 | #- |
---|
| 145 | system=$(uname) |
---|
| 146 | case "${system}" in |
---|
| 147 | AIX|IRIX64) |
---|
| 148 | echo " www : no specific posix checking" |
---|
| 149 | ;; |
---|
| 150 | *) |
---|
| 151 | set -o posix |
---|
| 152 | ;; |
---|
| 153 | esac |
---|
| 154 | unset system |
---|
| 155 | # |
---|
[151] | 156 | set -u |
---|
| 157 | # |
---|
[2] | 158 | LANG=C |
---|
| 159 | # |
---|
| 160 | # as this script might be launch in .profile, command is forced. |
---|
[50] | 161 | command=project_profile.sh |
---|
[2] | 162 | # |
---|
[151] | 163 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir -idl_cmd idl_cmd" |
---|
[2] | 164 | # |
---|
[151] | 165 | # default |
---|
| 166 | idl_cmd=idl |
---|
| 167 | # |
---|
| 168 | while [ ${#} -gt 0 ] |
---|
[2] | 169 | do |
---|
| 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 |
---|
| 210 | done |
---|
| 211 | unset usage |
---|
| 212 | # |
---|
| 213 | # check for ${directory} |
---|
| 214 | if [ ! -d ${directory} ] |
---|
| 215 | then |
---|
| 216 | echo " eee : ${directory} not found" |
---|
| 217 | # nb : no exit because this file should be launched by login process |
---|
| 218 | fi |
---|
| 219 | # |
---|
| 220 | # check for permission on directory |
---|
| 221 | if [ ! -x ${directory} ] |
---|
| 222 | then |
---|
| 223 | echo " eee : ${directory} not reachable" |
---|
| 224 | # nb : no exit because this file should be launched by login process |
---|
| 225 | fi |
---|
| 226 | # |
---|
[50] | 227 | PROJECT=${directory} |
---|
| 228 | export PROJECT |
---|
[2] | 229 | unset drectory |
---|
| 230 | # |
---|
[50] | 231 | # add PROJECT tools to PATH |
---|
[2] | 232 | # if not already done |
---|
[50] | 233 | suppath=$(echo ${PROJECT}/src | tr -s "/") |
---|
[2] | 234 | echo ${PATH} | grep -q "${suppath}:" |
---|
| 235 | test_path=${?} |
---|
| 236 | if [ ${test_path} -ne 0 ] |
---|
| 237 | then |
---|
| 238 | PATH=${suppath}:${PATH} |
---|
| 239 | export PATH |
---|
| 240 | else |
---|
| 241 | # option bavarde oui/non pas encore implantée ++ |
---|
| 242 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
| 243 | fi |
---|
| 244 | unset test_path |
---|
| 245 | # |
---|
[50] | 246 | # add PROJECT manuals to MANPATH |
---|
[2] | 247 | # if not already done |
---|
[50] | 248 | suppath=$(echo ${PROJECT}/doc/man | tr -s "/") |
---|
[2] | 249 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
| 250 | test_manpath=${?} |
---|
| 251 | if [ ${test_manpath} -ne 0 ] |
---|
| 252 | then |
---|
| 253 | MANPATH=${suppath}:${MANPATH} |
---|
| 254 | export MANPATH |
---|
| 255 | else |
---|
| 256 | # option bavarde oui/non pas encore implantée ++ |
---|
| 257 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
| 258 | fi |
---|
| 259 | unset test_manpath |
---|
| 260 | unset suppath |
---|
| 261 | # |
---|
[50] | 262 | PROJECT_LOG=${tempdir} |
---|
| 263 | export PROJECT_LOG |
---|
[2] | 264 | unset tempdir |
---|
[50] | 265 | if [ ! -d ${PROJECT_LOG} ] |
---|
[2] | 266 | then |
---|
[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 |
---|
| 277 | fi |
---|
[50] | 278 | # check for permission on PROJECT_LOG |
---|
| 279 | if [ ! -x ${PROJECT_LOG} ] |
---|
[2] | 280 | then |
---|
[50] | 281 | echo " eee : ${PROJECT_LOG} not reachable" |
---|
[2] | 282 | # nb : no exit because this file should be launched by login process |
---|
| 283 | fi |
---|
| 284 | # |
---|
[50] | 285 | # check for permission on PROJECT_LOG |
---|
| 286 | if [ ! -w ${PROJECT_LOG} ] |
---|
[2] | 287 | then |
---|
[50] | 288 | echo " eee : ${PROJECT_LOG} not writable" |
---|
[2] | 289 | # nb : no exit because this file shouldreachable be launched by login process |
---|
| 290 | fi |
---|
| 291 | # |
---|
| 292 | EDITOR=vi |
---|
| 293 | export EDITOR |
---|
| 294 | # |
---|
| 295 | # io directories |
---|
[50] | 296 | PROJECT_ID=${indir} |
---|
| 297 | export PROJECT_ID |
---|
[2] | 298 | unset indir |
---|
[50] | 299 | if [ ! -d ${PROJECT_ID} ] |
---|
[2] | 300 | then |
---|
[50] | 301 | mkdir -p ${PROJECT_ID} |
---|
| 302 | echo "${command} : iii : creation of \${PROJECT_ID}" |
---|
[2] | 303 | fi |
---|
[50] | 304 | # check for permission on PROJECT_ID |
---|
| 305 | if [ ! -x ${PROJECT_ID} ] |
---|
[2] | 306 | then |
---|
[50] | 307 | echo " eee : ${PROJECT_ID} not reachable" |
---|
[2] | 308 | # nb : no exit because this file should be launched by login process |
---|
| 309 | fi |
---|
| 310 | # |
---|
[50] | 311 | PROJECT_OD=${outdir} |
---|
| 312 | export PROJECT_OD |
---|
[2] | 313 | unset outdir |
---|
[50] | 314 | if [ ! -d ${PROJECT_OD} ] |
---|
[2] | 315 | then |
---|
[50] | 316 | mkdir -p ${PROJECT_OD} |
---|
| 317 | echo "${command} : iii : creation of \${PROJECT_OD}" |
---|
[2] | 318 | fi |
---|
[50] | 319 | # check for permission on PROJECT_OD |
---|
| 320 | if [ ! -x ${PROJECT_OD} ] |
---|
[2] | 321 | then |
---|
[50] | 322 | echo " eee : ${PROJECT_OD} not reachable" |
---|
[2] | 323 | # nb : no exit because this file should be launched by login process |
---|
| 324 | fi |
---|
[50] | 325 | if [ ! -w ${PROJECT_OD} ] |
---|
[2] | 326 | then |
---|
[50] | 327 | echo " eee : ${PROJECT_OD} not writable" |
---|
[2] | 328 | # nb : no exit because this file should be launched by login process |
---|
| 329 | fi |
---|
| 330 | # |
---|
[67] | 331 | # setup for ferret |
---|
[106] | 332 | set +u |
---|
| 333 | if [ "${FER_GO}" = "" ] |
---|
| 334 | then |
---|
| 335 | FER_GO="${FER_DIR}/go ${FER_GO} ${PROJECT}/src" |
---|
| 336 | else |
---|
| 337 | FER_GO="${FER_DIR}/go ${PROJECT}/src" |
---|
| 338 | fi |
---|
| 339 | set -u |
---|
| 340 | FER_GO="${FER_GO} ${PROJECT}/src/test" |
---|
[67] | 341 | export FER_GO |
---|
| 342 | # |
---|
[151] | 343 | # set up for idl |
---|
| 344 | IDL_CMD=${idl_cmd} |
---|
| 345 | export IDL_CMD |
---|
| 346 | unset idl_cmd |
---|
| 347 | # |
---|
[45] | 348 | SAXO_DIR=${saxo_dir} |
---|
| 349 | export SAXO_DIR |
---|
| 350 | unset saxo_dir |
---|
[40] | 351 | # |
---|
[50] | 352 | # IDL startup |
---|
| 353 | IDL_STARTUP=${PROJECT}/src/project_init.pro |
---|
| 354 | export IDL_STARTUP |
---|
| 355 | # |
---|
[2] | 356 | # end |
---|
| 357 | unset command |
---|
| 358 | # nb : no exit because this file should be launched by login process |
---|