Changeset 21
- Timestamp:
- 03/29/07 16:48:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modipsl/trunk/util/model
r13 r21 8 8 MAIL_COM=mail 9 9 #MAIL_COM=Mail 10 #- --11 # -Dirname and Basename12 #- --10 #- 11 # Dirname and Basename 12 #- 13 13 d_n=${0%/*}; b_n=${0##*/}; 14 #- --15 # -Retrieve and validate the options16 #- --17 m_n=""; m_a=" "; m_v='silencious'; no_tag='false';18 while getopts :he udrvH V14 #- 15 # Retrieve and validate the options 16 #- 17 m_n=""; m_a="checkout"; m_v='silencious'; no_tag='false'; 18 while getopts :hevH V 19 19 do 20 20 case $V in 21 21 (h) m_a='help';; 22 22 (e) m_a='checkout';; 23 (u) m_a='update';;24 (d) m_a='diff';;25 (r) m_a='remove';;26 23 (v) m_v='verbose';; 27 24 (H) no_tag='true';; … … 33 30 done 34 31 shift $(($OPTIND-1)); 35 #--- 36 #- Validate the action 37 #--- 38 [[ -z "${m_a}" ]] && { m_a='checkout'; } 39 [[ ${m_a} = help || ${m_a} = checkout || ${m_a} = update || \ 40 ${m_a} = diff || ${m_a} = remove ]] || \ 41 { echo 'Action '"${m_a}"' not supported' 1>&2; exit 4; } 42 #--- 43 #- Retrieve the model name 44 #--- 32 #- 33 # Validate the action 34 #- 35 [[ ${m_a} = help || ${m_a} = checkout ]] || \ 36 { 37 echo 'Action '"${m_a}"' not supported' 1>&2; 38 echo 'Try "'${b_n}' -h [model-name]"' 1>&2; 39 exit 4; 40 } 41 #- 42 # Retrieve the model name 43 #- 45 44 [[ ${#} -gt 1 ]] && \ 46 45 { echo 'Only one model can be specified' 1>&2; exit 3; } … … 52 51 exit 3; 53 52 } 54 #- --55 # - Test of presenceof the definition file56 #- --53 #- 54 # Test availability of the definition file 55 #- 57 56 F_DEF=${d_n}'/mod.def' 58 57 [[ ! -f "${F_DEF}" ]] && { echo "${F_DEF} unreachable ..."; exit 3; } 59 #- --60 # -Extract the names of the supported models61 #- --58 #- 59 # Extract the names of the supported models 60 #- 62 61 qi=0; 63 62 while read v0 v1 v2 … … 67 66 done <${F_DEF} 68 67 unset v0 v1 v2; 69 #- --70 # -Model name validation and data retrieving71 #- --68 #- 69 # Model name validation and data retrieving 70 #- 72 71 [[ -n "${m_n}" ]] && \ 73 72 { … … 184 183 # N/A 185 184 } 186 #- --187 # -send an email at the first use of modipsl188 # -ie directory ~/.modipsl does not exist189 #- --185 #- 186 # send an email at the first use of modipsl 187 # ie directory ~/.modipsl does not exist 188 #- 190 189 D_LOG=${HOME}/.modipsl 191 190 [[ -d "${D_LOG}" ]] || \ 192 193 194 195 191 { 192 mkdir "${D_LOG}"; 193 echo $(date +"%D %T") $(whoami) $(uname -m) \ 194 first use of model | \ 196 195 ${MAIL_COM} -s "first use of modipsl" \ 197 198 196 ${MAIL_ADDRESS} >/dev/null 2>&1; 197 echo $(date +"%D %T") creation >"${D_LOG}"/first; 199 198 } 200 #- --201 # -"help" action202 #- --199 #- 200 # "help" action 201 #- 203 202 [[ ${m_a} = 'help' ]] && \ 204 203 { … … 210 209 echo ${b_n} '[-h]'; 211 210 echo ${b_n} '[-h] model_name'; 212 echo ${b_n} '[-e /u/d/r] [-H] [-v] model_name';211 echo ${b_n} '[-e] [-H] [-v] model_name'; 213 212 echo 'h : this help'; 214 213 echo 'h model-name : help on model'; 215 echo 'e /u/d/r : extract/update/diff/removemodel';214 echo 'e : extract model'; 216 215 echo 'H : suppress the tags and take the HEAD version'; 217 216 echo 'v : verbose mode'; … … 247 246 exit 0; 248 247 } 249 #- --250 # -Record information about the action in the "log" file251 #- --248 #- 249 # Record information about the action in the "log" file 250 #- 252 251 F_LOG=${d_n}'/log' 253 252 echo "${F_LOG}" 254 253 echo $(date +"%D %T") $0 $* >>"${F_LOG}" 255 #- --256 # -Verbose mode257 #- --254 #- 255 # Verbose mode 256 #- 258 257 [ ${m_v} = 'verbose' ] && \ 259 258 { echo '--- Model : '${m_n}; 260 259 echo '--- Action : '${m_a}; 261 260 echo '--- Mode : '${m_v}; } 262 #- --263 # -Record information about the action in the "log" file264 #- --261 #- 262 # Record information about the action in the "log" file 263 #- 265 264 { echo '--- Model : '${m_n}; 266 265 echo '--- Action : '${m_a}; 267 266 echo '--- Mode : '${m_v}; 268 267 echo '--- Mail address : '${m_m}; } >>"${F_LOG}" 269 #- --270 # -Components root directory271 #- --268 #- 269 # Components root directory 270 #- 272 271 d_m=${d_n}'/..'; 273 #- --274 # -send an email at the first use of this IPSL model275 # -ie file ~/.modipsl/log.${m_n} does not exist276 #- --272 #- 273 # send an email at the first use of this IPSL model 274 # ie file ~/.modipsl/log.${m_n} does not exist 275 #- 277 276 M_LOG=${D_LOG}/log.${m_n} 278 277 [[ -f "${M_LOG}" ]] || \ … … 284 283 echo $(date +"%D %T") model ${m_n} >"${M_LOG}"; 285 284 } 286 #- --287 # -Extract the model components288 #- --285 #- 286 # Extract the model components 287 #- 289 288 qi=0; while (( ${qi} < ${#m_c[@]} )) 290 289 do … … 301 300 echo '--- Directory : '${zd}; 302 301 echo '--- Local Dir : '${zl}; } 303 #--- 304 #- 305 #--- 302 #----- 303 #---- Record information about the action in the "log" file 304 #----- 306 305 { echo '---'; 307 306 echo '--- Component : '${zc}; … … 314 313 [[ ${zp} = 'cvs' ]] && \ 315 314 { 316 case ${m_a} in 317 ( checkout | update | diff ) 318 c_c='(cd '${d_m}/${zl}'; '${zp}' -d :pserver:'${zs}' '${m_a}; 319 [[ ${m_a} = 'checkout' && ${zt} != '?' ]] && \ 320 { c_c=${c_c}' -r '${zt}; } 321 [[ ${m_a} = 'checkout' && ${zd} != '.' ]] && \ 322 { c_c=${c_c}' -d '${zd}; } 323 c_c=${c_c}' '${zc}')';; 324 ( remove ) 325 c_c='(cd '${d_m}/${zl}'; rm -rf '${zc}')';; 326 esac 315 c_c='(cd '${d_m}/${zl}'; '${zp}' -d :pserver:'${zs}' '${m_a}; 316 [[ ${zt} != '?' ]] && { c_c=${c_c}' -r '${zt}; } 317 [[ ${zd} != '.' ]] && { c_c=${c_c}' -d '${zd}; } 318 c_c=${c_c}' '${zc}')'; 327 319 grep "${zs%%/*}"'.*/'"${zs#*/}" ~/.cvspass > /dev/null; 328 320 [[ ${?} != 0 ]] && \ … … 336 328 [[ ${zp} = 'svn' ]] && \ 337 329 { 338 case ${m_a} in 339 ( checkout | update | diff ) 340 c_c='(cd '${d_m}/${zl}'; '${zp}' '${m_a}; 341 [[ ${m_a} = 'checkout' && ${zt} != '?' ]] && \ 342 { c_c=${c_c}' -r '${zt}; } 343 c_c=${c_c}' '${zs}'/'${zc}; 344 [[ ${m_a} = 'checkout' && ${zd} != '.' ]] && \ 345 { c_c=${c_c}' '${zd}; } 346 c_c=${c_c}')';; 347 ( remove ) 348 c_c='(cd '${d_m}/${zl}'; rm -rf '${zc##*/}')';; 349 esac 330 c_c='(cd '${d_m}/${zl}'; '${zp}' '${m_a}; 331 [[ ${zt} != '?' ]] && { c_c=${c_c}' -r '${zt}; } 332 c_c=${c_c}' '${zs}'/'${zc}; 333 [[ ${zd} != '.' ]] && { c_c=${c_c}' '${zd}; } 334 c_c=${c_c}')'; 350 335 } 351 336 #--- … … 353 338 eval ${c_c}; 354 339 done 355 #- --356 # -Actions related to the WORK directory for the OPA models357 #- --340 #- 341 # Actions related to the WORK directory for the OPA models 342 #- 358 343 case ${m_n} in 359 344 ( EEL* | ORCA* | OFF_TRC | IPSLCM* | ORCA_TOYATM | \ 360 345 NEMO_ORCA2_LIM | GYRE ) 361 346 d_m1=${d_m}/modeles/OPA ; 362 [ ${m_a} = 'checkout' -o ${m_a} = 'remove' ] && 363 { [ -d ${d_m1}/WORK ] && \rm -rf ${d_m1}/WORK; }; 364 [ ${m_a} = 'checkout' -o ${m_a} = 'update' ] && 365 { 366 [ -d ${d_m1}/WORK ] || mkdir ${d_m1}/WORK; 367 cd ${d_m1}/WORK; 368 # Getting the configuration files to build the Makefile 369 ln -sf ../../../*/${m_n}/scripts/BB_make AA_make; 370 ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; 371 case ${m_n} in 372 ( ORCA2_LMDZ96x71 ) 373 echo " Creation du catalogue OPA/WORK = ORCA + LIM" 374 ln -sf ../SRC_ORCA/*.[Ffh] . 375 ln -sf ../SRC_UCL/[a-z]* . 376 ln -sf ../../${m_n}/scripts/prep.sed.coupled .;; 377 ( ORCA2 | ORCA4 | ORCA05 | EEL2 | EEL6 ) 378 echo " Creation du catalogue OPA/WORK = ORCA" 379 ln -sf ../SRC_ORCA/*.[Ffh] .;; 380 ( ORCA*LIM | IPSLCM* | ORCA_TOYATM | ORCA*LMD* ) 381 [ "${m_n}" = "IPSLCM4_LOOP" ] && \ 382 echo " Creation du catalogue OPA/WORK = ORCA + LIM + TRC" || \ 383 echo " Creation du catalogue OPA/WORK = ORCA + LIM" 384 ln -sf ../SRC_ORCA/*.[Ffh] . 385 [ "${m_n}" = "IPSLCM4_LOOP" ] && \rm *.passivetrc.h 386 [ "${m_n}" = "IPSLCM4_LOOP" ] && \ 387 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] . 388 ln -sf ../SRC_UCL/[a-z]* .;; 389 ( ORCA*_LIM_TRC ) 390 echo " Creation du catalogue OPA/WORK = ORCA + LIM + TRC" 391 ln -sf ../SRC_ORCA/*.[Ffh] . 392 \rm *.passivetrc.h 393 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] . 394 ln -sf ../SRC_UCL/[a-z]* .;; 395 ( *LOBSTER1 ) 396 echo " Creation du catalogue OPA/WORK = ORCA + TRC" 397 ln -sf ../SRC_ORCA/*.[Ffh] . 398 \rm *.passivetrc.h 399 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] .;; 400 ( ORCA*_OFF_TRC ) 401 echo " Creation du catalogue OPA/WORK = TRC + OFFLINE" 402 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] . 403 ln -sf ../SRC_OFFLINE_TRC/*.[Ffh] .;; 404 esac 405 # Building the standard list of source files 406 cat >.patron <<"EOF" 347 [ -d ${d_m1}/WORK ] && \rm -rf ${d_m1}/WORK; 348 mkdir ${d_m1}/WORK; 349 cd ${d_m1}/WORK; 350 #-- Getting the configuration files to build the Makefile 351 ln -sf ../../../*/${m_n}/scripts/BB_make AA_make; 352 ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; 353 case ${m_n} in 354 ( ORCA2_LMDZ96x71 ) 355 echo " Creation du catalogue OPA/WORK = ORCA + LIM" 356 ln -sf ../SRC_ORCA/*.[Ffh] . 357 ln -sf ../SRC_UCL/[a-z]* . 358 ln -sf ../../${m_n}/scripts/prep.sed.coupled .;; 359 ( ORCA2 | ORCA4 | ORCA05 | EEL2 | EEL6 ) 360 echo " Creation du catalogue OPA/WORK = ORCA" 361 ln -sf ../SRC_ORCA/*.[Ffh] .;; 362 ( ORCA*LIM | IPSLCM* | ORCA_TOYATM | ORCA*LMD* ) 363 [ "${m_n}" = "IPSLCM4_LOOP" ] && \ 364 echo " Creation du catalogue OPA/WORK = ORCA + LIM + TRC" || \ 365 echo " Creation du catalogue OPA/WORK = ORCA + LIM" 366 ln -sf ../SRC_ORCA/*.[Ffh] . 367 [ "${m_n}" = "IPSLCM4_LOOP" ] && \rm *.passivetrc.h 368 [ "${m_n}" = "IPSLCM4_LOOP" ] && \ 369 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] . 370 ln -sf ../SRC_UCL/[a-z]* .;; 371 ( ORCA*_LIM_TRC ) 372 echo " Creation du catalogue OPA/WORK = ORCA + LIM + TRC" 373 ln -sf ../SRC_ORCA/*.[Ffh] . 374 \rm *.passivetrc.h 375 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] . 376 ln -sf ../SRC_UCL/[a-z]* .;; 377 ( *LOBSTER1 ) 378 echo " Creation du catalogue OPA/WORK = ORCA + TRC" 379 ln -sf ../SRC_ORCA/*.[Ffh] . 380 \rm *.passivetrc.h 381 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] .;; 382 ( ORCA*_OFF_TRC ) 383 echo " Creation du catalogue OPA/WORK = TRC + OFFLINE" 384 ln -sf ../SRC_TRC/*.[Ffh] ../SRC_TRC/trc_sms/*.[Ffh] . 385 ln -sf ../SRC_OFFLINE_TRC/*.[Ffh] .;; 386 esac 387 #-- Building the standard list of source files 388 cat >.patron <<"EOF" 407 389 CVS 408 390 SRC_PARAM … … 423 405 thersf.f 424 406 EOF 425 ls -1 | fgrep -v -f .patron >SRC_FILE_LIST; 426 cp SRC_FILE_LIST SRC_FILE_LIST.temp; 427 # 428 KEY=$(grep P_P AA_make.ldef); 429 [ -f "KEY_CPP" ] || echo $KEY > KEY_CPP; 430 };; 407 ls -1 | fgrep -v -f .patron >SRC_FILE_LIST; 408 cp SRC_FILE_LIST SRC_FILE_LIST.temp; 409 KEY=$(grep P_P AA_make.ldef); 410 [ -f "KEY_CPP" ] || echo $KEY > KEY_CPP; 411 ;; 431 412 esac 432 413 #---
Note: See TracChangeset
for help on using the changeset viewer.