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