- Timestamp:
- 04/01/15 14:54:34 (9 years ago)
- Location:
- trunk/libIGCM/libIGCM_sys
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_sys/libIGCM_sys.ksh
r1172 r1181 85 85 # Set default umask (umask is 0027 on some machines : CCRT machine at least) 86 86 umask 0022 87 88 #D--------------------------------------------------------------------== 89 #D- 90 #D- Define IGCM_sys functions that are common on every systems 91 #D- 92 #D--------------------------------------------------------------------== 93 94 #D-#================================================== 95 #D-function IGCM_sys_RshMaster 96 #D-* Purpose: Connection to frontend machine. 97 #D-* Examples: 98 #D- 99 function IGCM_sys_RshMaster { 100 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 101 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF 102 export libIGCM=${libIGCM} 103 export DEBUG_debug=${DEBUG_debug} 104 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 105 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 106 ${@} 107 EOF 108 if [ $? -gt 0 ] ; then 109 echo "IGCM_sys_RshMaster : erreur." 110 IGCM_debug_Exit "IGCM_sys_RshMaster" 111 fi 112 IGCM_debug_PopStack "IGCM_sys_RshMaster" 113 } 114 115 #D-#================================================== 116 #D-function IGCM_sys_RshPost 117 #D-* Purpose: Post-process rsh command 118 #D-* Examples: 119 #D- 120 function IGCM_sys_RshPost { 121 IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 122 if ( $DEBUG_sys ) ; then 123 echo "IGCM_sys_RshPost :" $@ 124 fi 125 # keep standard input (stdin) for the loop onto temporary file 126 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 127 128 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 129 if [ $? -gt 0 ] ; then 130 echo "IGCM_sys_RshPost : erreur." 131 IGCM_debug_Exit "IGCM_sys_RshPost" 132 fi 133 # delete temporary file 134 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 135 136 # ============ FRONTEND END ============ # 137 138 # ============ CESIUM START ============ # 139 # typeset NB_ESSAI DELAI status i 140 # if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then 141 # #little hack so that rebuild submission is done on titane not an cesium 142 # 143 # libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' ) 144 # POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' ) 145 # sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 146 # sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 147 # sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt 148 # sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$ 149 # \mv tmp.txt tmp_IGCM_sys_RshPost_$$ 150 # 151 # echo cat tmp_IGCM_sys_RshPost_$$ AFTER 152 # cat tmp_IGCM_sys_RshPost_$$ 153 # 154 # /bin/ksh <tmp_IGCM_sys_RshPost_$$ 155 # if [ $? -gt 0 ] ; then 156 # echo "IGCM_sys_RshPost : erreur." 157 # IGCM_debug_Exit "IGCM_sys_RshPost" 158 # fi 159 # # delete temporary file 160 # \rm tmp_IGCM_sys_RshPost_$$ 161 # 162 # else 163 # # number of tentative 164 # NB_ESSAI=10 165 # # time delay between tentative 166 # DELAI=10 167 # i=0 168 # while [ $i -ne $NB_ESSAI ] ; do 169 # ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$ 170 # status=$? 171 # if [ ${status} -ne 0 ]; 172 # then 173 # sleep $DELAI 174 # else 175 # break 176 # fi 177 # let i=$i+1 178 # done 179 # # delete temporary file 180 # \rm tmp_IGCM_sys_RshPost_$$ 181 # 182 # if [ ${status} -gt 0 ] ; then 183 # echo "IGCM_sys_RshPost : erreur." 184 # IGCM_debug_Exit "IGCM_sys_RshPost" 185 # fi 186 # fi 187 188 # ============ CESIUM END ============ # 189 190 IGCM_debug_PopStack "IGCM_sys_RshPost" 191 } 192 193 #D-#================================================== 194 #D-function IGCM_sys_SendMail 195 #D-* Purpose: Send mail when simulation is over 196 #D-* Examples: 197 #D- 198 function IGCM_sys_SendMail { 199 IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 200 if ( $DEBUG_sys ) ; then 201 echo "IGCM_sys_SendMail :" $@ 202 fi 203 204 if [ X${1} = XAccounting ] ; then 205 status=Accounting 206 mailText=jobAccounting.mail 207 elif ( ${ExitFlag} ) ; then 208 status=failed 209 mailText=jobEnd.mail 210 else 211 status=completed 212 mailText=jobEnd.mail 213 fi 214 215 # Update selected mail template 216 while read -r line; do 217 eval echo $line >> mail.txt ; 218 done < ${libIGCM}/libIGCM_sys/${mailText} 219 220 if [ ! -z ${config_UserChoices_MailName} ] ; then 221 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt 222 elif [ -f ~/.forward ] ; then 223 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt 224 else 225 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt 226 fi 227 228 sleep 10 229 rm -f mail.txt 230 231 IGCM_debug_PopStack "IGCM_sys_SendMail" 232 } 233 234 #D-#================================================== 235 #D-function IGCM_sys_Mkdir 236 #D-* Purpose: Master locale mkdir command 237 #D-* Examples: 238 #D- 239 function IGCM_sys_Mkdir { 240 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 241 if ( $DEBUG_sys ) ; then 242 echo "IGCM_sys_Mkdir :" $@ 243 fi 244 if [ ! -d ${1} ]; then 245 \mkdir -p $1 246 if [ $? -gt 0 ] ; then 247 echo "IGCM_sys_Mkdir : erreur." 248 IGCM_debug_Exit "IGCM_sys_Mkdir" 249 fi 250 fi 251 # vérification : 252 if [ ! -d ${1} ] ; then 253 echo "IGCM_sys_Mkdir : erreur." 254 IGCM_debug_Exit "IGCM_sys_Mkdir" 255 fi 256 IGCM_debug_PopStack "IGCM_sys_Mkdir" 257 } 258 259 #D-#================================================== 260 #D-function IGCM_sys_MkdirWork 261 #D-* Purpose: Mkdir on Work 262 #D-* Examples: 263 #D- 264 function IGCM_sys_MkdirWork { 265 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 266 if ( $DEBUG_sys ) ; then 267 echo "IGCM_sys_MkdirWork :" $@ 268 fi 269 #- creation de repertoire sur le serveur fichier 270 if [ ! -d ${1} ]; then 271 \mkdir -p $1 272 if [ $? -gt 0 ] ; then 273 echo "IGCM_sys_MkdirWork : erreur." 274 IGCM_debug_Exit "IGCM_sys_MkdirWork" 275 fi 276 fi 277 IGCM_debug_PopStack "IGCM_sys_MkdirWork" 278 } 279 280 #D-#================================================== 281 #D-function IGCM_sys_Cd 282 #D-* Purpose: master cd command 283 #D-* Examples: 284 #D- 285 function IGCM_sys_Cd { 286 IGCM_debug_PushStack "IGCM_sys_Cd" $@ 287 if ( $DEBUG_sys ) ; then 288 echo "IGCM_sys_Cd :" $@ 289 fi 290 \cd $1 291 if [ $? -gt 0 ] ; then 292 echo "IGCM_sys_Cd : erreur." 293 IGCM_debug_Exit "IGCM_sys_Cd" 294 fi 295 IGCM_debug_PopStack "IGCM_sys_Cd" 296 } 297 298 #D-#================================================== 299 #D-function IGCM_sys_Chmod 300 #D-* Purpose: Chmod 301 #D-* Examples: 302 #D- 303 function IGCM_sys_Chmod { 304 IGCM_debug_PushStack "IGCM_sys_Chmod" $@ 305 if ( $DEBUG_sys ) ; then 306 echo "IGCM_sys_Chmod :" $@ 307 fi 308 \chmod $@ 309 if [ $? -gt 0 ] ; then 310 echo "IGCM_sys_Chmod : erreur." 311 IGCM_debug_Exit "IGCM_sys_Chmod" 312 fi 313 IGCM_debug_PopStack "IGCM_sys_Chmod" 314 } 315 316 #D-#================================================== 317 #D-function IGCM_sys_FileSize 318 #D-* Purpose: Filesize 319 #D-* Examples: 320 #D- 321 function IGCM_sys_FileSize { 322 IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 323 324 typeset sizeF 325 set +A sizeF -- $( ls -la ${1} ) 326 if [ $? -gt 0 ] ; then 327 IGCM_debug_Exit "IGCM_sys_FileSize" 328 fi 329 eval ${2}=${sizeF[4]} 330 331 IGCM_debug_PopStack "IGCM_sys_FileSize" 332 } 333 334 #D-#================================================== 335 #D-function IGCM_sys_TestDir 336 #D-* Purpose: Test Directory that must exists 337 #D-* Examples: 338 #D- 339 function IGCM_sys_TestDir { 340 IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 341 if ( $DEBUG_sys ) ; then 342 echo "IGCM_sys_TestDir :" $@ 343 fi 344 typeset ExistFlag 345 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 346 IGCM_debug_PopStack "IGCM_sys_TestDir" 347 348 return ${ExistFlag} 349 } 350 351 #D-#================================================== 352 #D-function IGCM_sys_TestFileBuffer 353 #D-* Purpose: Test file that must NOT EXISTS on Buffer 354 #D-* Examples: 355 #D- 356 function IGCM_sys_TestFileBuffer { 357 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 358 typeset ExistFlag 359 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 360 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 361 362 return ${ExistFlag} 363 } 364 365 #D-#================================================== 366 #D-function IGCM_sys_CountFileBuffer 367 #D-* Purpose: Count files on Scratch filesystem 368 #D-* Examples: 369 #D- 370 function IGCM_sys_CountFileBuffer { 371 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 372 ls ${@} 2>/dev/null | wc -l 373 if [ $? -gt 0 ] ; then 374 echo "IGCM_sys_CountFileBuffer : erreur." 375 fi 376 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 377 } 378 379 #D-#================================================== 380 #D-function IGCM_sys_Tar 381 #D-* Purpose: master tar command 382 #D-* Examples: 383 #D- 384 function IGCM_sys_Tar { 385 IGCM_debug_PushStack "IGCM_sys_Tar" $@ 386 if ( $DEBUG_sys ) ; then 387 echo "IGCM_sys_Tar :" $@ 388 fi 389 \tar cf $@ 390 if [ $? -gt 0 ] ; then 391 echo "IGCM_sys_Tar : erreur." 392 IGCM_debug_Exit "IGCM_sys_Tar" 393 fi 394 IGCM_debug_PopStack "IGCM_sys_Tar" 395 } 396 397 #D-#================================================== 398 #D-function IGCM_sys_UnTar 399 #D-* Purpose: master un-tar command 400 #D-* Examples: 401 #D- 402 function IGCM_sys_UnTar { 403 IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 404 if ( $DEBUG_sys ) ; then 405 echo "IGCM_sys_UnTar :" $@ 406 fi 407 \tar xvf $1 408 if [ $? -gt 0 ] ; then 409 echo "IGCM_sys_UnTar : erreur." 410 IGCM_debug_Exit "IGCM_sys_UnTar" 411 fi 412 IGCM_debug_PopStack "IGCM_sys_UnTar" 413 } 414 415 #D-************************* 416 #D- File transfer functions 417 #D-************************* 418 #D- 419 420 #D-#================================================== 421 #D-function IGCM_sys_Rsync_out 422 #D-* Purpose: treat return val of rsync 423 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync 424 #D- Error values and explanations can depend on your system version. 425 function IGCM_sys_Rsync_out { 426 IGCM_debug_PushStack "IGCM_sys_Rsync_out" $@ 427 if ( $DEBUG_sys ) ; then 428 echo "IGCM_sys_UnTar :" $@ 429 fi 430 431 typeset status 432 status=$1 433 434 if [ ! $status ] ; then 435 IGCM_debug_Print 1 "IGCM_sys_Rsync_out need an argument" 436 IGCM_debug_PopStack "IGCM_sys_Rsync_out" 437 return 438 fi 439 440 case $status in 441 0) ;; 442 1) IGCM_debug_Print 1 "rsync error RERR_SYNTAX : Syntax or usage error";; 443 2) IGCM_debug_Print 1 "rsync error RERR_PROTOCOL : Protocol incompatibility";; 444 3) IGCM_debug_Print 1 "rsync error RERR_FILESELECT : Errors selecting input/output files, dirs";; 445 4) IGCM_debug_Print 1 "rsync error RERR_UNSUPPORTED : Requested action not supported." 446 IGCM_debug_Print 1 "An attempt was made to manipulate 64-bit files on a platform that cannot support them" 447 IGCM_debug_Print 1 "Or an option was specified that is supported by the client and not by the server.";; 448 5) IGCM_debug_Print 1 "rsync error : Error starting client-server protocol";; 449 10) IGCM_debug_Print 1 "rsync error RERR_SOCKETIO : Error in socket I/O";; 450 11) IGCM_debug_Print 1 "rsync error RERR_FILEIO: Error in file I/O";; 451 12) IGCM_debug_Print 1 "rsync error RERR_STREAMIO : Error in rsync protocol data stream";; 452 13) IGCM_debug_Print 1 "rsync error RERR_MESSAGEIO : Errors with program diagnostics";; 453 14) IGCM_debug_Print 1 "rsync error RERR_IPC : Error in IPC code";; 454 20) IGCM_debug_Print 1 "rsync error RERR_SIGNAL : Received SIGUSR1 or SIGINT";; 455 21) IGCM_debug_Print 1 "rsync error RERR_WAITCHILD : Some error returned by waitpid()";; 456 22) IGCM_debug_Print 1 "rsync error RERR_MALLOC : Error allocating core memory buffers";; 457 23) IGCM_debug_Print 1 "rsync error : Partial transfer due to error";; 458 24) IGCM_debug_Print 1 "rsync error : Partial transfer due to vanished source files";; 459 30) IGCM_debug_Print 1 "rsync error : Timeout in data send/receive";; 460 *) IGCM_debug_Print 1 "rsync error : return code of rsync unknown :" $status;; 461 esac 462 463 IGCM_debug_PopStack "IGCM_sys_Rsync_out" 464 } 465 466 #D-#================================================== 467 #D-function IGCM_sys_Miror_libIGCM 468 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 469 #D-* Examples: 470 #D- 471 function IGCM_sys_Mirror_libIGCM { 472 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 473 if ( $DEBUG_sys ) ; then 474 echo "IGCM_sys_Mirror_libIGCM" 475 fi 476 477 typeset status 478 479 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 480 481 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 482 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 483 status=$? 484 485 if [ ${status} -gt 0 ] ; then 486 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 487 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 488 fi 489 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 490 } 491 492 #D-#================================================== 493 #D-function IGCM_sys_Cp 494 #D-* Purpose: generic cp 495 #D-* Examples: 496 #D- 497 function IGCM_sys_Cp { 498 IGCM_debug_PushStack "IGCM_sys_Cp" $@ 499 if ( $DEBUG_sys ) ; then 500 echo "IGCM_sys_Cp :" $@ 501 fi 502 503 typeset status 504 505 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 506 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 507 status=$? 508 509 if [ ${status} -gt 0 ] ; then 510 echo "IGCM_sys_Cp : error code ${status}" 511 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 512 IGCM_debug_Exit "IGCM_sys_Cp" 513 else 514 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 515 fi 516 IGCM_debug_PopStack "IGCM_sys_Cp" 517 } 518 519 #D-#================================================== 520 #D-function IGCM_sys_Rm 521 #D-* Purpose: generic rm 522 #D-* Examples: 523 #D- 524 function IGCM_sys_Rm { 525 IGCM_debug_PushStack "IGCM_sys_Rm" $@ 526 if ( $DEBUG_sys ) ; then 527 echo "IGCM_sys_Rm :" $@ 528 fi 529 530 typeset status 531 532 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 533 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 534 status=$? 535 536 if [ ${status} -gt 0 ] ; then 537 echo "IGCM_sys_Rm : error code ${status}" 538 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 539 IGCM_debug_Exit "IGCM_sys_Rm" 540 else 541 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 542 fi 543 IGCM_debug_PopStack "IGCM_sys_Rm" 544 } 545 546 #D-#================================================== 547 #D-function IGCM_sys_Mv 548 #D-* Purpose: generic move 549 #D-* Examples: 550 #D- 551 function IGCM_sys_Mv { 552 IGCM_debug_PushStack "IGCM_sys_Mv" $@ 553 if ( $DEBUG_sys ) ; then 554 echo "IGCM_sys_Mv :" $@ 555 fi 556 557 if [ $DRYRUN = 0 ]; then 558 559 typeset status 560 561 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 562 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 563 status=$? 564 565 if [ ${status} -gt 0 ] ; then 566 echo "IGCM_sys_Mv : error code ${status}" 567 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 568 IGCM_debug_Exit "IGCM_sys_Mv" 569 else 570 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 571 fi 572 fi 573 IGCM_debug_PopStack "IGCM_sys_Mv" 574 } 575 576 #D-#================================================== 577 #D-function IGCM_sys_Get_Master 578 #D-* Purpose: Copy a complete directory from MASTER filesystem 579 #D-* Examples: 580 #D- 581 function IGCM_sys_Get_Master { 582 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 583 if ( $DEBUG_sys ) ; then 584 echo "IGCM_sys_Get_Master :" $@ 585 fi 586 if [ $DRYRUN = 0 ]; then 587 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 588 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 589 IGCM_debug_PopStack "IGCM_sys_Get_Master" 590 return 591 fi 592 593 typeset NB_ESSAI DELAI status i 594 # number of tentative 595 NB_ESSAI=3 596 # time delay between tentative 597 DELAI=2 598 599 i=0 600 while [ $i -lt $NB_ESSAI ] ; do 601 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 602 status=$? 603 if [ ${status} -gt 0 ]; then 604 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 605 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 606 sleep $DELAI 607 else 608 break 609 fi 610 (( i = i + 1 )) 611 done 612 613 if [ ${status} -gt 0 ] ; then 614 echo "IGCM_sys_Get_Master : error." 615 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 616 IGCM_debug_Exit "IGCM_sys_Get_Master" 617 else 618 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 619 fi 620 fi 621 IGCM_debug_PopStack "IGCM_sys_Get_Master" 622 } 623 624 #==================================================== 625 #- Call IGCM_sys_Mirror_libIGCM now ! 626 if ( $MirrorlibIGCM ) ; then 627 IGCM_sys_Mirror_libIGCM 628 fi 629 630 #D-#================================================== 631 #D-function IGCM_sys_PutBuffer_Rest 632 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 633 #D- File and target directory must exist. 634 #D-* Examples: 635 #D- 636 function IGCM_sys_PutBuffer_Rest { 637 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 638 if ( $DEBUG_sys ) ; then 639 echo "IGCM_sys_PutBuffer_Rest :" $@ 640 fi 641 if [ $DRYRUN = 0 ]; then 642 if [ ! -f ${1} ] ; then 643 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 644 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 645 fi 646 647 typeset status 648 # 649 # USUAL WAY 650 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 651 status=$? 652 653 if [ ${status} -gt 0 ] ; then 654 echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 655 [ -f ${2} ] && ls -l ${2} 656 [ -f ${2}/${1} ] && ls -l ${2}/${1} 657 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 658 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 659 else 660 661 if [ X${JobType} = XRUN ] ; then 662 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 663 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 664 fi 665 666 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 667 fi 668 fi 669 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 670 } 671 672 #D-#================================================== 673 #D-function IGCM_sys_PrepareTaredRestart 674 #D-* Purpose: Prepare tared restart to be access by computing job. 675 #D-* Examples: 676 #D- 677 function IGCM_sys_PrepareTaredRestart { 678 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@ 679 if [ $DRYRUN = 0 ]; then 680 [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 . 681 fi 682 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart" 683 } 684 685 #D-#================================================== 686 #D-function IGCM_sys_PutBuffer_Out 687 #D-* Purpose: Copy a file on the buffer filesystem after having chmod it in readonly 688 #D-* Examples: 689 #D- 690 function IGCM_sys_PutBuffer_Out { 691 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 692 if ( $DEBUG_sys ) ; then 693 echo "IGCM_sys_PutBuffer_Out :" $@ 694 fi 695 696 typeset NB_ESSAI DELAI status i exist skip 697 698 # number of tentative 699 NB_ESSAI=3 700 # time delay between tentative 701 DELAI=2 702 703 if [ $DRYRUN = 0 ]; then 704 if [ ! -f ${1} ] ; then 705 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 706 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 707 return 1 708 fi 709 # 710 IGCM_sys_Mkdir $( dirname $2 ) 711 # 712 713 exist=false 714 skip=false 715 if [ -f $2 ] ; then 716 IGCM_debug_Print 1 "$2 already exist" 717 exist=true 718 if [ "X$( diff $1 $2 )" = X ] ; then 719 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 720 status=0 721 skip=true 722 else 723 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 724 skip=false 725 fi 726 fi 727 # 728 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 729 IGCM_sys_Chmod u+w $2 730 fi 731 732 if [ X${skip} = Xfalse ] ; then 733 i=0 734 while [ $i -lt $NB_ESSAI ] ; do 735 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then 736 # USUAL WAY 737 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 738 status=$? 739 else 740 # NOT SO USUAL WAY 741 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 742 status=$? 743 fi 744 if [ ${status} -gt 0 ]; then 745 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 746 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 747 [ -f ${2} ] && ls -l ${2} 748 [ -f ${2}/${1} ] && ls -l ${2}/${1} 749 sleep $DELAI 750 else 751 break 752 fi 753 (( i = i + 1 )) 754 done 755 fi 756 757 if [ ${status} -gt 0 ] ; then 758 echo "IGCM_sys_PutBuffer_Out : error." 759 [ -f ${2} ] && ls -l ${2} 760 [ -f ${2}/${1} ] && ls -l ${2}/${1} 761 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 762 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 763 else 764 765 if [ X${JobType} = XRUN ] ; then 766 if [ X${3} = X ] ; then 767 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 768 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 769 fi 770 fi 771 772 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 773 fi 774 fi 775 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 776 return 0 777 } 778 779 #D-#================================================== 780 #D-function IGCM_sys_GetBuffer 781 #D-* Purpose: Get a file from ${SCRATCHDIR} 782 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 783 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 784 function IGCM_sys_GetBuffer { 785 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 786 787 typeset DEST buf_liste target file_work 788 typeset NB_ESSAI DELAI status i 789 790 if ( $DEBUG_sys ) ; then 791 echo "IGCM_sys_GetBuffer :" $@ 792 fi 793 794 # number of tentative 795 NB_ESSAI=3 796 # time delay between tentative 797 DELAI=2 798 799 if [ $DRYRUN -le 2 ]; then 800 if [ X${1} = X'/l' ] ; then 801 eval set +A buf_liste \${${2}} 802 else 803 eval set +A buf_liste ${1} 804 fi 805 eval DEST=\${${#}} 806 807 #USUAL WAY 808 if [ X${1} = X'/l' ] ; then 809 for target in ${buf_liste[*]} ; do 810 local_file=$( basename ${target} ) 811 i=0 812 while [ $i -lt $NB_ESSAI ] ; do 813 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 814 status=$? 815 if [ ${status} -gt 0 ]; then 816 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 817 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 818 sleep $DELAI 819 else 820 break 821 fi 822 (( i = i + 1 )) 823 done 824 if [ ${status} -gt 0 ] ; then 825 echo "IGCM_sys_Get : error" 826 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 827 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 828 IGCM_debug_Exit "IGCM_sys_GetBuffer" 829 else 830 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 831 fi 832 done 833 else 834 i=0 835 while [ $i -lt $NB_ESSAI ] ; do 836 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 837 status=$? 838 if [ ${status} -gt 0 ]; then 839 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 840 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 841 sleep $DELAI 842 else 843 break 844 fi 845 (( i = i + 1 )) 846 done 847 if [ ${status} -gt 0 ] ; then 848 echo "IGCM_sys_Get : error" 849 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 850 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 851 IGCM_debug_Exit "IGCM_sys_GetBuffer" 852 else 853 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 854 fi 855 fi 856 fi 857 IGCM_debug_PopStack "IGCM_sys_GetBuffer" 858 } 859 860 #D-#================================================== 861 #D-function IGCM_sys_GetDate_FichWork 862 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK 863 #D-* Examples: 864 #D- 865 function IGCM_sys_GetDate_FichWork { 866 IGCM_debug_PushStack "IGCM_sys_GetDate_FichWork" $@ 867 if ( $DEBUG_sys ) ; then 868 echo "IGCM_sys_GetDate_FichWork :" $@ 869 fi 870 871 if [ $# -ge 3 ] ; then 872 mode=$3 873 TimeStyle=$4 874 else 875 mode="default" 876 TimeStyle="%Y%m%d%H%M%S" 877 fi 878 879 typeset dateF 880 set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} ) 881 882 case $mode in 883 "default") 884 eval ${2}=${dateF[5]} 885 ;; 886 "SplitFields") 887 eval ${2}="${dateF[5]}\ ${dateF[6]}" 888 ;; 889 esac 890 891 # donne la date filesys d'un fichier sur la machine work 892 IGCM_debug_PopStack "IGCM_sys_GetDate_FichWork" 893 } 894 895 #D-#================================================== 896 #D-function IGCM_sys_rebuild 897 #D-* Purpose: rebuild parallel files 898 #D-* Examples: 899 #D- 900 function IGCM_sys_rebuild { 901 IGCM_debug_PushStack "IGCM_sys_rebuild" $@ 902 if ( $DEBUG_sys ) ; then 903 echo "IGCM_sys_rebuild :" $@ 904 fi 905 906 typeset NB_ESSAI DELAI status i firstArg 907 # number of tentative 908 NB_ESSAI=3 909 # time delay between tentative 910 DELAI=2 911 912 i=0 913 while [ $i -lt $NB_ESSAI ] ; do 914 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 915 status=$? 916 if [ ${status} -gt 0 ] ; then 917 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 918 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 919 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 920 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 921 firstArg=${1} 922 \rm ${firstArg} 923 sleep $DELAI 924 else 925 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 926 break 927 fi 928 (( i = i + 1 )) 929 done 930 931 if [ ${status} -gt 0 ] ; then 932 echo "IGCM_sys_rebuild : rebuild error code is ${status}" 933 IGCM_debug_Exit "rebuild" 934 fi 935 936 IGCM_debug_PopStack "IGCM_sys_rebuild" 937 } 938 939 #D-#================================================== 940 #D-function IGCM_sys_rebuild_station 941 #D-* Purpose: rebuild parallel files describing station 942 #D-* Examples: 943 #D- 944 function IGCM_sys_rebuild_station { 945 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@ 946 typeset i list_opt file_in file_out prefix_invert list_invert 947 if ( $DEBUG_sys ) ; then 948 echo "IGCM_sys_rebuild_station :" $@ 949 fi 950 951 # Station re-ordering is too expansive to be run within libIGCM 952 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 953 # This re-ordering must be done "in memory" by the cmorization process 954 955 # Only LMDZ text output contains the exact ordering of the station. 956 # We isolate this in the code below: 957 # 0 38 -157.5000000000000 70.98591549295774 958 # 0 54 27.49999999999999 67.18309859154928 959 # 0 56 -62.50000000000001 82.39436619718309 960 # 0 79 12.49999999999999 78.59154929577466 961 # 0 116 -165.0000000000000 76.05633802816901 962 # 0 117 130.0000000000000 70.98591549295774 963 # 0 118 110.0000000000000 87.46478873239437 964 # 1 40 4.999999999999995 51.97183098591550 965 966 list_opt=$@ 967 968 # Invert Axis : t,x -> x,t 969 # t,pres,x -> x,t,pres 970 # So that we can concatenate along x 971 i=0 972 for file_in in ${list_opt} ; do 973 (( i = i + 1)) 974 [ ${i} = 1 ] && file_out=${file_in} && continue 975 # detect time counter and do the job only if present 976 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') 977 if [ X${var_unlim} = Xtime_counter ] ; then 978 prefix_invert=$( basename ${file_in} .nc ) 979 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 980 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 981 fi 982 done 983 984 # Concatenate 985 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 986 987 # Re-ivert file 988 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 989 990 IGCM_debug_PopStack "IGCM_sys_rebuild_station" 991 } 992 993 ############################################################## 994 # NCO OPERATOR 995 996 #D-#================================================== 997 #D-function IGCM_sys_ncap2 998 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 999 #D-* Examples: 1000 #D- 1001 function IGCM_sys_ncap2 { 1002 IGCM_debug_PushStack "IGCM_sys_ncap2" $@ 1003 if ( $DEBUG_sys ) ; then 1004 echo "IGCM_sys_ncap2 :" $@ 1005 fi 1006 1007 typeset NB_ESSAI DELAI status i 1008 # number of tentative 1009 NB_ESSAI=3 1010 # time delay between tentative 1011 DELAI=2 1012 1013 i=0 1014 while [ $i -lt $NB_ESSAI ] ; do 1015 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1016 status=$? 1017 if [ ${status} -gt 0 ] ; then 1018 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 1019 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1020 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1021 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1022 sleep $DELAI 1023 else 1024 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1025 break 1026 fi 1027 (( i = i + 1 )) 1028 done 1029 1030 if [ ${status} -gt 0 ] ; then 1031 echo "IGCM_sys_ncap2 : ncap2 error" 1032 IGCM_debug_Exit "ncap2" 1033 fi 1034 1035 IGCM_debug_PopStack "IGCM_sys_ncap2" 1036 } 1037 1038 #D-#================================================== 1039 #D-function IGCM_sys_ncatted 1040 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 1041 #D-* Examples: 1042 #D- 1043 function IGCM_sys_ncatted { 1044 IGCM_debug_PushStack "IGCM_sys_ncatted" $@ 1045 if ( $DEBUG_sys ) ; then 1046 echo "IGCM_sys_ncatted :" $@ 1047 fi 1048 1049 typeset NB_ESSAI DELAI status i 1050 # number of tentative 1051 NB_ESSAI=3 1052 # time delay between tentative 1053 DELAI=2 1054 1055 i=0 1056 while [ $i -lt $NB_ESSAI ] ; do 1057 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1058 status=$? 1059 if [ ${status} -gt 0 ] ; then 1060 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 1061 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1062 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1063 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1064 sleep $DELAI 1065 else 1066 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1067 break 1068 fi 1069 (( i = i + 1 )) 1070 done 1071 1072 if [ ${status} -gt 0 ] ; then 1073 echo "IGCM_sys_ncatted : ncatted error" 1074 IGCM_debug_Exit "ncatted" 1075 fi 1076 1077 IGCM_debug_PopStack "IGCM_sys_ncatted" 1078 } 1079 1080 #D-#================================================== 1081 #D-function IGCM_sys_ncbo 1082 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 1083 #D-* Examples: 1084 #D- 1085 function IGCM_sys_ncbo { 1086 IGCM_debug_PushStack "IGCM_sys_ncbo" $@ 1087 if ( $DEBUG_sys ) ; then 1088 echo "IGCM_sys_ncbo :" $@ 1089 fi 1090 1091 typeset NB_ESSAI DELAI status i 1092 # number of tentative 1093 NB_ESSAI=3 1094 # time delay between tentative 1095 DELAI=2 1096 1097 i=0 1098 while [ $i -lt $NB_ESSAI ] ; do 1099 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1100 status=$? 1101 if [ ${status} -gt 0 ] ; then 1102 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 1103 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1104 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1105 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1106 sleep $DELAI 1107 else 1108 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1109 break 1110 fi 1111 (( i = i + 1 )) 1112 done 1113 1114 if [ ${status} -gt 0 ] ; then 1115 echo "IGCM_sys_ncbo : ncbo error" 1116 IGCM_debug_Exit "ncbo" 1117 fi 1118 1119 IGCM_debug_PopStack "IGCM_sys_ncbo" 1120 } 1121 1122 #D-#================================================== 1123 #D-function IGCM_sys_ncdif 1124 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 1125 #D-* Examples: 1126 #D- 1127 function IGCM_sys_ncdiff { 1128 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@ 1129 if ( $DEBUG_sys ) ; then 1130 echo "IGCM_sys_ncdiff :" $@ 1131 fi 1132 1133 typeset NB_ESSAI DELAI status i 1134 # number of tentative 1135 NB_ESSAI=3 1136 # time delay between tentative 1137 DELAI=2 1138 1139 i=0 1140 while [ $i -lt $NB_ESSAI ] ; do 1141 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1142 status=$? 1143 if [ ${status} -gt 0 ] ; then 1144 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 1145 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1146 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1147 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1148 sleep $DELAI 1149 else 1150 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1151 break 1152 fi 1153 (( i = i + 1 )) 1154 done 1155 1156 if [ ${status} -gt 0 ] ; then 1157 echo "IGCM_sys_ncdiff : ncdiff error" 1158 IGCM_debug_Exit "ncdiff" 1159 fi 1160 1161 IGCM_debug_PopStack "IGCM_sys_ncdiff" 1162 } 1163 1164 #D-#================================================== 1165 #D-function IGCM_sys_ncea 1166 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 1167 #D-* Examples: 1168 #D- 1169 function IGCM_sys_ncea { 1170 IGCM_debug_PushStack "IGCM_sys_ncea" $@ 1171 if ( $DEBUG_sys ) ; then 1172 echo "IGCM_sys_ncea :" $@ 1173 fi 1174 1175 typeset NB_ESSAI DELAI status i 1176 # number of tentative 1177 NB_ESSAI=3 1178 # time delay between tentative 1179 DELAI=2 1180 1181 i=0 1182 while [ $i -lt $NB_ESSAI ] ; do 1183 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1184 status=$? 1185 if [ ${status} -gt 0 ] ; then 1186 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 1187 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1188 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1189 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1190 sleep $DELAI 1191 else 1192 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1193 break 1194 fi 1195 (( i = i + 1 )) 1196 done 1197 1198 if [ ${status} -gt 0 ] ; then 1199 echo "IGCM_sys_ncea : ncea error" 1200 IGCM_debug_Exit "ncea" 1201 fi 1202 1203 IGCM_debug_PopStack "IGCM_sys_ncea" 1204 } 1205 1206 #D-#================================================== 1207 #D-function IGCM_sys_ncecat 1208 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 1209 #D-* Examples: 1210 #D- 1211 function IGCM_sys_ncecat { 1212 IGCM_debug_PushStack "IGCM_sys_ncecat" $@ 1213 if ( $DEBUG_sys ) ; then 1214 echo "IGCM_sys_ncecat :" $@ 1215 fi 1216 1217 typeset NB_ESSAI DELAI status i 1218 # number of tentative 1219 NB_ESSAI=3 1220 # time delay between tentative 1221 DELAI=2 1222 1223 i=0 1224 while [ $i -lt $NB_ESSAI ] ; do 1225 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1226 status=$? 1227 if [ ${status} -gt 0 ] ; then 1228 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 1229 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1230 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1231 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1232 sleep $DELAI 1233 else 1234 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1235 break 1236 fi 1237 (( i = i + 1 )) 1238 done 1239 1240 if [ ${status} -gt 0 ] ; then 1241 echo "IGCM_sys_ncecat : ncecat error" 1242 IGCM_debug_Exit "ncecat" 1243 fi 1244 1245 IGCM_debug_PopStack "IGCM_sys_ncecat" 1246 } 1247 1248 #D-#================================================== 1249 #D-function IGCM_sys_ncflint 1250 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 1251 #D-* Examples: 1252 #D- 1253 function IGCM_sys_ncflint { 1254 IGCM_debug_PushStack "IGCM_sys_ncflint" $@ 1255 if ( $DEBUG_sys ) ; then 1256 echo "IGCM_sys_ncflint :" $@ 1257 fi 1258 1259 typeset NB_ESSAI DELAI status i 1260 # number of tentative 1261 NB_ESSAI=3 1262 # time delay between tentative 1263 DELAI=2 1264 1265 i=0 1266 while [ $i -lt $NB_ESSAI ] ; do 1267 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1268 status=$? 1269 if [ ${status} -gt 0 ] ; then 1270 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 1271 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1272 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1273 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1274 sleep $DELAI 1275 else 1276 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1277 break 1278 fi 1279 (( i = i + 1 )) 1280 done 1281 1282 if [ ${status} -gt 0 ] ; then 1283 echo "IGCM_sys_ncflint : ncflint error" 1284 IGCM_debug_Exit "ncflint" 1285 fi 1286 1287 IGCM_debug_PopStack "IGCM_sys_ncflint" 1288 } 1289 1290 #D-#================================================== 1291 #D-function IGCM_sys_ncks 1292 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 1293 #D-* Examples: 1294 #D- 1295 function IGCM_sys_ncks { 1296 IGCM_debug_PushStack "IGCM_sys_ncks" $@ 1297 if ( $DEBUG_sys ) ; then 1298 echo "IGCM_sys_ncks :" $@ 1299 fi 1300 1301 typeset NB_ESSAI DELAI status i 1302 # number of tentative 1303 NB_ESSAI=3 1304 # time delay between tentative 1305 DELAI=2 1306 1307 i=0 1308 while [ $i -lt $NB_ESSAI ] ; do 1309 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1310 status=$? 1311 if [ ${status} -gt 0 ] ; then 1312 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 1313 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1314 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1315 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1316 sleep $DELAI 1317 else 1318 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1319 break 1320 fi 1321 (( i = i + 1 )) 1322 done 1323 1324 if [ ${status} -gt 0 ] ; then 1325 echo "IGCM_sys_ncks : ncks error" 1326 IGCM_debug_Exit "ncks" 1327 fi 1328 1329 IGCM_debug_PopStack "IGCM_sys_ncks" 1330 } 1331 1332 #D-#================================================== 1333 #D-function IGCM_sys_ncpdq 1334 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 1335 #D-* Examples: 1336 #D- 1337 function IGCM_sys_ncpdq { 1338 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@ 1339 if ( $DEBUG_sys ) ; then 1340 echo "IGCM_sys_ncpdq :" $@ 1341 fi 1342 1343 typeset NB_ESSAI DELAI status i 1344 # number of tentative 1345 NB_ESSAI=3 1346 # time delay between tentative 1347 DELAI=2 1348 1349 i=0 1350 while [ $i -lt $NB_ESSAI ] ; do 1351 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1352 status=$? 1353 if [ ${status} -gt 0 ] ; then 1354 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 1355 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1356 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1357 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1358 sleep $DELAI 1359 else 1360 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1361 break 1362 fi 1363 (( i = i + 1 )) 1364 done 1365 1366 if [ ${status} -gt 0 ] ; then 1367 echo "IGCM_sys_ncpdq : ncpdq error" 1368 IGCM_debug_Exit "ncpdq" 1369 fi 1370 1371 IGCM_debug_PopStack "IGCM_sys_ncpdq" 1372 } 1373 1374 #D-#================================================== 1375 #D-function IGCM_sys_ncra 1376 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 1377 #D-* Examples: 1378 #D- 1379 function IGCM_sys_ncra { 1380 IGCM_debug_PushStack "IGCM_sys_ncra" $@ 1381 if ( $DEBUG_sys ) ; then 1382 echo "IGCM_sys_ncra :" $@ 1383 fi 1384 1385 typeset NB_ESSAI DELAI status i 1386 # number of tentative 1387 NB_ESSAI=3 1388 # time delay between tentative 1389 DELAI=2 1390 1391 i=0 1392 while [ $i -lt $NB_ESSAI ] ; do 1393 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1394 status=$? 1395 if [ ${status} -gt 0 ] ; then 1396 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 1397 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1398 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1399 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1400 sleep $DELAI 1401 else 1402 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1403 break 1404 fi 1405 (( i = i + 1 )) 1406 done 1407 1408 if [ ${status} -gt 0 ] ; then 1409 echo "IGCM_sys_ncra : ncra error" 1410 IGCM_debug_Exit "ncra" 1411 fi 1412 1413 IGCM_debug_PopStack "IGCM_sys_ncra" 1414 } 1415 1416 #D-#================================================== 1417 #D-function IGCM_sys_ncrcat 1418 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 1419 #D-* Examples: 1420 #D- 1421 function IGCM_sys_ncrcat { 1422 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@ 1423 if ( $DEBUG_sys ) ; then 1424 echo "IGCM_sys_ncrcat :" $@ 1425 fi 1426 1427 typeset NB_ESSAI DELAI status i lastArg 1428 # number of tentative 1429 NB_ESSAI=3 1430 # time delay between tentative 1431 DELAI=2 1432 1433 i=0 1434 while [ $i -lt $NB_ESSAI ] ; do 1435 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1436 status=$? 1437 if [ ${status} -gt 0 ] ; then 1438 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 1439 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1440 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1441 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1442 sleep $DELAI 1443 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then 1444 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 1445 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1446 # remove files having corrupted time axis 1447 eval lastArg=\${$#} 1448 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 1449 \rm ${lastArg} 1450 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1451 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1452 sleep $DELAI 1453 else 1454 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1455 break 1456 fi 1457 (( i = i + 1 )) 1458 done 1459 1460 if [ ${status} -gt 0 ] ; then 1461 echo "IGCM_sys_ncrcat : ncrcat error" 1462 #IGCM_debug_Exit "ncrcat" 1463 fi 1464 1465 IGCM_debug_PopStack "IGCM_sys_ncrcat" 1466 } 1467 1468 #D-#================================================== 1469 #D-function IGCM_sys_ncrename 1470 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 1471 #D-* Examples: 1472 #D- 1473 function IGCM_sys_ncrename { 1474 IGCM_debug_PushStack "IGCM_sys_ncrename" $@ 1475 if ( $DEBUG_sys ) ; then 1476 echo "IGCM_sys_ncrename :" $@ 1477 fi 1478 1479 typeset NB_ESSAI DELAI status i 1480 # number of tentative 1481 NB_ESSAI=3 1482 # time delay between tentative 1483 DELAI=2 1484 1485 i=0 1486 while [ $i -lt $NB_ESSAI ] ; do 1487 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1488 status=$? 1489 if [ ${status} -gt 0 ] ; then 1490 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 1491 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1492 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1493 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1494 sleep $DELAI 1495 else 1496 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1497 break 1498 fi 1499 (( i = i + 1 )) 1500 done 1501 1502 if [ ${status} -gt 0 ] ; then 1503 echo "IGCM_sys_ncrename : ncrename error" 1504 IGCM_debug_Exit "ncrename" 1505 fi 1506 1507 IGCM_debug_PopStack "IGCM_sys_ncrename" 1508 } 1509 1510 #D-#================================================== 1511 #D-function IGCM_sys_ncwa 1512 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 1513 #D-* Examples: 1514 #D- 1515 function IGCM_sys_ncwa { 1516 IGCM_debug_PushStack "IGCM_sys_ncwa" $@ 1517 if ( $DEBUG_sys ) ; then 1518 echo "IGCM_sys_ncwa :" $@ 1519 fi 1520 1521 typeset NB_ESSAI DELAI status i 1522 # number of tentative 1523 NB_ESSAI=3 1524 # time delay between tentative 1525 DELAI=2 1526 1527 i=0 1528 while [ $i -lt $NB_ESSAI ] ; do 1529 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1530 status=$? 1531 if [ ${status} -gt 0 ] ; then 1532 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 1533 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1534 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1535 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1536 sleep $DELAI 1537 else 1538 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1539 break 1540 fi 1541 (( i = i + 1 )) 1542 done 1543 1544 if [ ${status} -gt 0 ] ; then 1545 echo "IGCM_sys_ncwa : ncwa error" 1546 IGCM_debug_Exit "ncwa" 1547 fi 1548 1549 IGCM_debug_PopStack "IGCM_sys_ncwa" 1550 } 1551 1552 ############################################################## 1553 # CDO OPERATOR 1554 1555 #D-#================================================== 1556 #D-function IGCM_sys_cdo 1557 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 1558 #D-* Examples: 1559 #D- 1560 function IGCM_sys_cdo { 1561 IGCM_debug_PushStack "IGCM_sys_cdo" $@ 1562 if ( $DEBUG_sys ) ; then 1563 echo "IGCM_sys_cdo :" $@ 1564 fi 1565 1566 typeset status 1567 1568 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1 1569 status=$? 1570 if [ ${status} -gt 0 ] ; then 1571 echo "IGCM_sys_cdo : error code ${status}" 1572 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1573 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 1574 IGCM_debug_PopStack "IGCM_sys_cdo" 1575 return 1 1576 else 1577 IGCM_debug_PopStack "IGCM_sys_cdo" 1578 return 0 1579 fi 1580 1581 IGCM_debug_PopStack "IGCM_sys_cdo" 1582 } 1583 1584 # -
trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh
r1180 r1181 219 219 220 220 #D-#================================================== 221 #D-function IGCM_sys_RshMaster222 #D-* Purpose: Connection to frontend machine.223 #D-* Examples:224 #D-225 function IGCM_sys_RshMaster {226 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@227 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF228 export libIGCM=${libIGCM}229 export DEBUG_debug=${DEBUG_debug}230 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh231 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh232 ${@}233 EOF234 if [ $? -gt 0 ] ; then235 echo "IGCM_sys_RshMaster : erreur."236 IGCM_debug_Exit "IGCM_sys_RshMaster"237 fi238 IGCM_debug_PopStack "IGCM_sys_RshMaster"239 }240 241 #D-#==================================================242 221 #D-function IGCM_sys_RshArchive 243 222 #D-* Purpose: Archive rsh command … … 287 266 288 267 #D-#================================================== 289 #D-function IGCM_sys_RshPost290 #D-* Purpose: Post-process rsh command291 #D-* Examples:292 #D-293 function IGCM_sys_RshPost {294 IGCM_debug_PushStack "IGCM_sys_RshPost" $@295 if ( $DEBUG_sys ) ; then296 echo "IGCM_sys_RshPost :" $@297 fi298 # keep standard input (stdin) for the loop onto temporary file299 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}300 301 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}302 if [ $? -gt 0 ] ; then303 echo "IGCM_sys_RshPost : erreur."304 IGCM_debug_Exit "IGCM_sys_RshPost"305 fi306 # delete temporary file307 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}308 309 IGCM_debug_PopStack "IGCM_sys_RshPost"310 }311 312 #D-#==================================================313 #D-function IGCM_sys_SendMail314 #D-* Purpose: Send mail when simulation is over315 #D-* Examples:316 #D-317 function IGCM_sys_SendMail {318 IGCM_debug_PushStack "IGCM_sys_SendMail" $@319 if ( $DEBUG_sys ) ; then320 echo "IGCM_sys_SendMail :" $@321 fi322 323 if [ X${1} = XAccounting ] ; then324 status=Accounting325 mailText=jobAccounting.mail326 elif ( ${ExitFlag} ) ; then327 status=failed328 mailText=jobEnd.mail329 else330 status=completed331 mailText=jobEnd.mail332 fi333 334 # Update selected mail template335 while read -r line; do336 eval echo $line >> mail.txt ;337 done < ${libIGCM}/libIGCM_sys/${mailText}338 339 if [ ! -z ${config_UserChoices_MailName} ] ; then340 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt341 elif [ -f ~/.forward ] ; then342 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt343 else344 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt345 fi346 347 sleep 10348 rm -f mail.txt349 350 IGCM_debug_PopStack "IGCM_sys_SendMail"351 }352 353 #D-#==================================================354 #D-function IGCM_sys_Mkdir355 #D-* Purpose: Master locale mkdir command356 #D-* Examples:357 #D-358 function IGCM_sys_Mkdir {359 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@360 if ( $DEBUG_sys ) ; then361 echo "IGCM_sys_Mkdir :" $@362 fi363 if [ ! -d ${1} ]; then364 \mkdir -p $1365 if [ $? -gt 0 ] ; then366 echo "IGCM_sys_Mkdir : erreur."367 IGCM_debug_Exit "IGCM_sys_Mkdir"368 fi369 fi370 # vérification :371 if [ ! -d ${1} ] ; then372 echo "IGCM_sys_Mkdir : erreur."373 IGCM_debug_Exit "IGCM_sys_Mkdir"374 fi375 IGCM_debug_PopStack "IGCM_sys_Mkdir"376 }377 378 #D-#==================================================379 268 #D-function IGCM_sys_MkdirArchive 380 269 #D-* Purpose: Mkdir on Archive … … 404 293 405 294 #D-#================================================== 406 #D-function IGCM_sys_MkdirWork407 #D-* Purpose: Mkdir on Work408 #D-* Examples:409 #D-410 function IGCM_sys_MkdirWork {411 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@412 if ( $DEBUG_sys ) ; then413 echo "IGCM_sys_MkdirWork :" $@414 fi415 #- creation de repertoire sur le serveur fichier416 if [ ! -d ${1} ]; then417 \mkdir -p $1418 if [ $? -gt 0 ] ; then419 echo "IGCM_sys_MkdirWork : erreur."420 IGCM_debug_Exit "IGCM_sys_MkdirWork"421 fi422 fi423 IGCM_debug_PopStack "IGCM_sys_MkdirWork"424 }425 426 #D-#==================================================427 #D-function IGCM_sys_Cd428 #D-* Purpose: master cd command429 #D-* Examples:430 #D-431 function IGCM_sys_Cd {432 IGCM_debug_PushStack "IGCM_sys_Cd" $@433 if ( $DEBUG_sys ) ; then434 echo "IGCM_sys_Cd :" $@435 fi436 \cd $1437 if [ $? -gt 0 ] ; then438 echo "IGCM_sys_Cd : erreur."439 IGCM_debug_Exit "IGCM_sys_Cd"440 fi441 IGCM_debug_PopStack "IGCM_sys_Cd"442 }443 444 #D-#==================================================445 #D-function IGCM_sys_Chmod446 #D-* Purpose: Chmod447 #D-* Examples:448 #D-449 function IGCM_sys_Chmod {450 IGCM_debug_PushStack "IGCM_sys_Chmod" $@451 if ( $DEBUG_sys ) ; then452 echo "IGCM_sys_Chmod :" $@453 fi454 \chmod $@455 if [ $? -gt 0 ] ; then456 echo "IGCM_sys_Chmod : erreur."457 IGCM_debug_Exit "IGCM_sys_Chmod"458 fi459 IGCM_debug_PopStack "IGCM_sys_Chmod"460 }461 462 #D-#==================================================463 #D-function IGCM_sys_FileSize464 #D-* Purpose: Filesize465 #D-* Examples:466 #D-467 function IGCM_sys_FileSize {468 IGCM_debug_PushStack "IGCM_sys_FileSize" $@469 470 typeset sizeF471 set +A sizeF -- $( ls -la ${1} )472 if [ $? -gt 0 ] ; then473 IGCM_debug_Exit "IGCM_sys_FileSize"474 fi475 eval ${2}=${sizeF[4]}476 477 IGCM_debug_PopStack "IGCM_sys_FileSize"478 }479 480 #D-#==================================================481 #D-function IGCM_sys_TestDir482 #D-* Purpose: Test Directory that must exists483 #D-* Examples:484 #D-485 function IGCM_sys_TestDir {486 IGCM_debug_PushStack "IGCM_sys_TestDir" $@487 if ( $DEBUG_sys ) ; then488 echo "IGCM_sys_TestDir :" $@489 fi490 typeset ExistFlag491 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )492 IGCM_debug_PopStack "IGCM_sys_TestDir"493 494 return ${ExistFlag}495 }496 497 #D-#==================================================498 295 #D-function IGCM_sys_TestDirArchive 499 296 #D-* Purpose: Test Directory that must exists on Archive … … 544 341 ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 545 342 IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 546 547 return ${ExistFlag}548 }549 550 #D-#==================================================551 #D-function IGCM_sys_TestFileBuffer552 #D-* Purpose: Test file that must NOT EXISTS on Buffer553 #D-* Examples:554 #D-555 function IGCM_sys_TestFileBuffer {556 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@557 typeset ExistFlag558 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )559 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"560 343 561 344 return ${ExistFlag} … … 585 368 586 369 #D-#================================================== 587 #D-function IGCM_sys_CountFileBuffer588 #D-* Purpose: Count files on Scratch filesystem589 #D-* Examples:590 #D-591 function IGCM_sys_CountFileBuffer {592 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@593 ls ${@} 2>/dev/null | wc -l594 if [ $? -gt 0 ] ; then595 echo "IGCM_sys_CountFileBuffer : erreur."596 fi597 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"598 }599 600 #D-#==================================================601 370 #D-function IGCM_sys_Tree 602 371 #D-* Purpose: Tree directories with files on ${ARCHIVE} … … 612 381 613 382 IGCM_debug_PopStack "IGCM_sys_Tree" 614 }615 616 #D-#==================================================617 #D-function IGCM_sys_Tar618 #D-* Purpose: master tar command619 #D-* Examples:620 #D-621 function IGCM_sys_Tar {622 IGCM_debug_PushStack "IGCM_sys_Tar" $@623 if ( $DEBUG_sys ) ; then624 echo "IGCM_sys_Tar :" $@625 fi626 \tar cf $@627 if [ $? -gt 0 ] ; then628 echo "IGCM_sys_Tar : erreur."629 IGCM_debug_Exit "IGCM_sys_Tar"630 fi631 IGCM_debug_PopStack "IGCM_sys_Tar"632 }633 634 #D-#==================================================635 #D-function IGCM_sys_UnTar636 #D-* Purpose: master un-tar command637 #D-* Examples:638 #D-639 function IGCM_sys_UnTar {640 IGCM_debug_PushStack "IGCM_sys_UnTar" $@641 if ( $DEBUG_sys ) ; then642 echo "IGCM_sys_UnTar :" $@643 fi644 \tar xvf $1645 if [ $? -gt 0 ] ; then646 echo "IGCM_sys_UnTar : erreur."647 IGCM_debug_Exit "IGCM_sys_UnTar"648 fi649 IGCM_debug_PopStack "IGCM_sys_UnTar"650 383 } 651 384 … … 720 453 721 454 #D-#================================================== 722 #D-function IGCM_sys_Rsync_out723 #D-* Purpose: treat return val of rsync724 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync725 #D- Error values and explanations can depend on your system version.726 function IGCM_sys_Rsync_out {727 status=$1728 if [ ! $status ] ; then729 echo "rsync error !"730 fi731 732 if [ $MYLANG = "fr" ]; then733 case $status in734 0) return ;;735 1) echo "Erreur de rsync ; RERR_SYNTAX : "736 echo "Erreur de syntaxe ou d'utilisation."737 return;;738 2) echo "Erreur de rsync ; RERR_PROTOCOL : "739 echo "Incompatibilité de protocole."740 return;;741 3) echo "Erreur de rsync ; RERR_FILESELECT 3"742 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et"743 echo "répertoires"744 return;;745 4) echo "Erreur de rsync ; RERR_UNSUPPORTED"746 echo "Action demandée non supportée : une tentative de manipulation de"747 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a"748 echo "été faite ; ou une option qui est supportée par le client mais"749 echo "pas par le serveur a été spécifiée."750 return;;751 10) echo "Erreur de rsync ; RERR_SOCKETIO"752 echo "Erreur dans le socket d'entrée sortie"753 return;;754 11) echo "Erreur de rsync ; RERR_FILEIO"755 echo "Erreur d'entrée sortie fichier"756 return;;757 12) echo "Erreur de rsync ; RERR_STREAMIO"758 echo "Erreur dans flux de donnée du protocole rsync"759 return;;760 13) echo "Erreur de rsync ; RERR_MESSAGEIO"761 echo "Erreur avec les diagnostics du programme"762 return;;763 14) echo "Erreur de rsync ; RERR_IPC"764 echo "Erreur dans le code IPC"765 return;;766 20) echo "Erreur de rsync ; RERR_SIGNAL"767 echo "SIGUSR1 ou SIGINT reçu"768 return;;769 21) echo "Erreur de rsync ; RERR_WAITCHILD"770 echo "Une erreur retournée par waitpid()"771 return;;772 22) echo "Erreur de rsync ; RERR_MALLOC"773 echo "Erreur lors de l'allocation des tampons de mémoire de coeur"774 return;;775 23) echo ""776 echo "Erreur fichier inexistant"777 return;;778 30) echo "Erreur de rsync ; RERR_TIMEOUT"779 echo "Temps d'attente écoulé dans l'envoi/réception de données"780 return;;781 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status782 return;;783 esac784 elif [ $MYLANG = "en" ] ; then785 case $status in786 0) return;;787 1) echo "rsync error : Syntax or usage error "788 return;;789 2) echo "rsync error : Protocol incompatibility "790 return;;791 3) echo "rsync error : Errors selecting input/output files, dirs"792 return;;793 4) echo "rsync error : Requested action not supported: an attempt"794 echo "was made to manipulate 64-bit files on a platform that cannot support"795 echo "them; or an option was specified that is supported by the client and"796 echo "not by the server."797 return;;798 5) echo "rsync error : Error starting client-server protocol"799 return;;800 10) echo "rsync error : Error in socket I/O "801 return;;802 11) echo "rsync error : Error in file I/O "803 return;;804 12) echo "rsync error : Error in rsync protocol data stream "805 return;;806 13) echo "rsync error : Errors with program diagnostics "807 return;;808 14) echo "rsync error : Error in IPC code "809 return;;810 20) echo "rsync error : Received SIGUSR1 or SIGINT "811 return;;812 21) echo "rsync error : Some error returned by waitpid() "813 return;;814 22) echo "rsync error : Error allocating core memory buffers "815 return;;816 23) echo "rsync error : Partial transfer due to error"817 return;;818 24) echo "rsync error : Partial transfer due to vanished source files"819 return;;820 30) echo "rsync error : Timeout in data send/receive "821 return;;822 *) echo "rsync error : return code of rsync unknown :" $status823 return;;824 esac825 else826 echo "unknown language $MYLANG."827 return828 fi829 }830 831 #D-#==================================================832 #D-function IGCM_sys_Miror_libIGCM833 #D-* Purpose: Mirror libIGCM PATH and lib to frontend834 #D-* Examples:835 #D-836 function IGCM_sys_Mirror_libIGCM {837 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"838 if ( $DEBUG_sys ) ; then839 echo "IGCM_sys_Mirror_libIGCM"840 fi841 842 typeset status843 844 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}845 846 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1847 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1848 status=$?849 850 if [ ${status} -gt 0 ] ; then851 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."852 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$853 fi854 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"855 }856 857 #D-#==================================================858 #D-function IGCM_sys_Cp859 #D-* Purpose: generic cp860 #D-* Examples:861 #D-862 function IGCM_sys_Cp {863 IGCM_debug_PushStack "IGCM_sys_Cp" $@864 if ( $DEBUG_sys ) ; then865 echo "IGCM_sys_Cp :" $@866 fi867 868 typeset status869 870 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1871 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1872 status=$?873 874 if [ ${status} -gt 0 ] ; then875 echo "IGCM_sys_Cp : error code ${status}"876 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$877 IGCM_debug_Exit "IGCM_sys_Cp"878 else879 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$880 fi881 IGCM_debug_PopStack "IGCM_sys_Cp"882 }883 884 #D-#==================================================885 #D-function IGCM_sys_Rm886 #D-* Purpose: generic rm887 #D-* Examples:888 #D-889 function IGCM_sys_Rm {890 IGCM_debug_PushStack "IGCM_sys_Rm" $@891 if ( $DEBUG_sys ) ; then892 echo "IGCM_sys_Rm :" $@893 fi894 895 typeset status896 897 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1898 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1899 status=$?900 901 if [ ${status} -gt 0 ] ; then902 echo "IGCM_sys_Rm : error code ${status}"903 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$904 IGCM_debug_Exit "IGCM_sys_Rm"905 else906 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$907 fi908 IGCM_debug_PopStack "IGCM_sys_Rm"909 }910 911 #D-#==================================================912 455 #D-function IGCM_sys_RmRunDir 913 456 #D-* Purpose: rm tmpdir (dummy function most of the time batch … … 922 465 fi 923 466 IGCM_debug_PopStack "IGCM_sys_RmRunDir" 924 }925 926 #D-#==================================================927 #D-function IGCM_sys_Mv928 #D-* Purpose: generic move929 #D-* Examples:930 #D-931 function IGCM_sys_Mv {932 IGCM_debug_PushStack "IGCM_sys_Mv" $@933 if ( $DEBUG_sys ) ; then934 echo "IGCM_sys_Mv :" $@935 fi936 937 if [ $DRYRUN = 0 ]; then938 939 typeset status940 941 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1942 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1943 status=$?944 945 if [ ${status} -gt 0 ] ; then946 echo "IGCM_sys_Mv : error code ${status}"947 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$948 IGCM_debug_Exit "IGCM_sys_Mv"949 else950 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$951 fi952 fi953 IGCM_debug_PopStack "IGCM_sys_Mv"954 467 } 955 468 … … 1058 571 1059 572 #D-#================================================== 1060 #D-function IGCM_sys_Get_Master1061 #D-* Purpose: Copy a complete directory from MASTER filesystem1062 #D-* Examples:1063 #D-1064 function IGCM_sys_Get_Master {1065 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@1066 if ( $DEBUG_sys ) ; then1067 echo "IGCM_sys_Get_Master :" $@1068 fi1069 if [ $DRYRUN = 0 ]; then1070 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then1071 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."1072 IGCM_debug_PopStack "IGCM_sys_Get_Master"1073 return1074 fi1075 1076 typeset NB_ESSAI DELAI status i1077 # number of tentative1078 NB_ESSAI=31079 # time delay between tentative1080 DELAI=21081 1082 i=01083 while [ $i -lt $NB_ESSAI ] ; do1084 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11085 status=$?1086 if [ ${status} -gt 0 ]; then1087 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"1088 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."1089 sleep $DELAI1090 else1091 break1092 fi1093 (( i = i + 1 ))1094 done1095 1096 if [ ${status} -gt 0 ] ; then1097 echo "IGCM_sys_Get_Master : error."1098 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1099 IGCM_debug_Exit "IGCM_sys_Get_Master"1100 else1101 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1102 fi1103 fi1104 IGCM_debug_PopStack "IGCM_sys_Get_Master"1105 }1106 1107 #====================================================1108 #- Call IGCM_sys_Mirror_libIGCM now !1109 if ( $MirrorlibIGCM ) ; then1110 IGCM_sys_Mirror_libIGCM1111 fi1112 1113 #D-#==================================================1114 573 #D-function IGCM_sys_Put_Rest 1115 574 #D-* Purpose: Put computied restarts on ${ARCHIVE}. … … 1173 632 1174 633 #D-#================================================== 1175 #D-function IGCM_sys_PutBuffer_Rest1176 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}.1177 #D- File and target directory must exist.1178 #D-* Examples:1179 #D-1180 function IGCM_sys_PutBuffer_Rest {1181 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@1182 if ( $DEBUG_sys ) ; then1183 echo "IGCM_sys_PutBuffer_Rest :" $@1184 fi1185 if [ $DRYRUN = 0 ]; then1186 if [ ! -f ${1} ] ; then1187 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."1188 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1189 fi1190 1191 typeset status1192 #1193 # USUAL WAY1194 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11195 status=$?1196 1197 if [ ${status} -gt 0 ] ; then1198 echo "IGCM_sys_PutBuffer_Rest : error code ${status}"1199 [ -f ${2} ] && ls -l ${2}1200 [ -f ${2}/${1} ] && ls -l ${2}/${1}1201 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1202 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1203 else1204 1205 if [ X${JobType} = XRUN ] ; then1206 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1207 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1208 fi1209 1210 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1211 fi1212 fi1213 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"1214 }1215 1216 #D-#==================================================1217 #D-function IGCM_sys_PrepareTaredRestart1218 #D-* Purpose: Prepare tared restart to be access by computing job.1219 #D-* Examples:1220 #D-1221 function IGCM_sys_PrepareTaredRestart {1222 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@1223 if [ $DRYRUN = 0 ]; then1224 [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 .1225 fi1226 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"1227 }1228 1229 #D-#==================================================1230 634 #D-function IGCM_sys_Put_Out 1231 635 #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly … … 1293 697 1294 698 #D-#================================================== 1295 #D-function IGCM_sys_PutBuffer_Out1296 #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly1297 #D-* Examples:1298 #D-1299 function IGCM_sys_PutBuffer_Out {1300 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@1301 if ( $DEBUG_sys ) ; then1302 echo "IGCM_sys_PutBuffer_Out :" $@1303 fi1304 1305 typeset NB_ESSAI DELAI status i exist skip1306 1307 # number of tentative1308 NB_ESSAI=31309 # time delay between tentative1310 DELAI=21311 1312 if [ $DRYRUN = 0 ]; then1313 if [ ! -f ${1} ] ; then1314 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."1315 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1316 return 11317 fi1318 #1319 IGCM_sys_Mkdir $( dirname $2 )1320 #1321 1322 exist=false1323 skip=false1324 if [ -f $2 ] ; then1325 IGCM_debug_Print 1 "$2 already exist"1326 exist=true1327 if [ "X$( diff $1 $2 )" = X ] ; then1328 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"1329 status=01330 skip=true1331 else1332 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"1333 skip=false1334 fi1335 fi1336 #1337 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then1338 IGCM_sys_Chmod u+w $21339 fi1340 1341 if [ X${skip} = Xfalse ] ; then1342 i=01343 while [ $i -lt $NB_ESSAI ] ; do1344 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then1345 # USUAL WAY1346 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11347 status=$?1348 else1349 # NOT SO USUAL WAY1350 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11351 status=$?1352 fi1353 if [ ${status} -gt 0 ]; then1354 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"1355 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."1356 [ -f ${2} ] && ls -l ${2}1357 [ -f ${2}/${1} ] && ls -l ${2}/${1}1358 sleep $DELAI1359 else1360 break1361 fi1362 (( i = i + 1 ))1363 done1364 fi1365 1366 if [ ${status} -gt 0 ] ; then1367 echo "IGCM_sys_PutBuffer_Out : error."1368 [ -f ${2} ] && ls -l ${2}1369 [ -f ${2}/${1} ] && ls -l ${2}/${1}1370 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1371 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"1372 else1373 1374 if [ X${JobType} = XRUN ] ; then1375 if [ X${3} = X ] ; then1376 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1377 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1378 fi1379 fi1380 1381 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1382 fi1383 fi1384 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1385 return 01386 }1387 1388 #D-#==================================================1389 699 #D-function IGCM_sys_Get 1390 700 #D-* Purpose: Get a file from ${ARCHIVE} … … 1456 766 fi 1457 767 IGCM_debug_PopStack "IGCM_sys_Get" 1458 }1459 1460 #D-#==================================================1461 #D-function IGCM_sys_GetBuffer1462 #D-* Purpose: Get a file from ${SCRATCHDIR}1463 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX1464 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/1465 function IGCM_sys_GetBuffer {1466 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@1467 1468 typeset DEST buf_liste target file_work1469 typeset NB_ESSAI DELAI status i1470 1471 if ( $DEBUG_sys ) ; then1472 echo "IGCM_sys_GetBuffer :" $@1473 fi1474 1475 # number of tentative1476 NB_ESSAI=31477 # time delay between tentative1478 DELAI=21479 1480 if [ $DRYRUN -le 2 ]; then1481 if [ X${1} = X'/l' ] ; then1482 eval set +A buf_liste \${${2}}1483 else1484 eval set +A buf_liste ${1}1485 fi1486 eval DEST=\${${#}}1487 1488 #USUAL WAY1489 if [ X${1} = X'/l' ] ; then1490 for target in ${buf_liste[*]} ; do1491 local_file=$( basename ${target} )1492 i=01493 while [ $i -lt $NB_ESSAI ] ; do1494 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11495 status=$?1496 if [ ${status} -gt 0 ]; then1497 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1498 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1499 sleep $DELAI1500 else1501 break1502 fi1503 (( i = i + 1 ))1504 done1505 if [ ${status} -gt 0 ] ; then1506 echo "IGCM_sys_Get : error"1507 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1508 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1509 IGCM_debug_Exit "IGCM_sys_GetBuffer"1510 else1511 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1512 fi1513 done1514 else1515 i=01516 while [ $i -lt $NB_ESSAI ] ; do1517 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11518 status=$?1519 if [ ${status} -gt 0 ]; then1520 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1521 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1522 sleep $DELAI1523 else1524 break1525 fi1526 (( i = i + 1 ))1527 done1528 if [ ${status} -gt 0 ] ; then1529 echo "IGCM_sys_Get : error"1530 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1531 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1532 IGCM_debug_Exit "IGCM_sys_GetBuffer"1533 else1534 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1535 fi1536 fi1537 fi1538 IGCM_debug_PopStack "IGCM_sys_GetBuffer"1539 }1540 1541 #D-#==================================================1542 #D-function IGCM_sys_GetDate_FichWork1543 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK1544 #D-* Examples:1545 #D-1546 function IGCM_sys_GetDate_FichWork {1547 IGCM_debug_PushStack "IGCM_sys_FichWork" $@1548 if ( $DEBUG_sys ) ; then1549 echo "IGCM_sys_GetDate_FichWork :" $@1550 fi1551 1552 if [ $# -ge 3 ] ; then1553 mode=$31554 TimeStyle=$41555 else1556 mode="default"1557 TimeStyle="%Y%m%d%H%M%S"1558 fi1559 1560 typeset dateF1561 set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )1562 1563 case $mode in1564 "default")1565 eval ${2}=${dateF[5]}1566 ;;1567 "SplitFields")1568 eval ${2}="${dateF[5]}\ ${dateF[6]}"1569 ;;1570 esac1571 1572 1573 # donne la date filesys d'un fichier sur la machine work1574 IGCM_debug_PopStack "IGCM_sys_FichWork"1575 }1576 1577 #D-#==================================================1578 #D-function IGCM_sys_GetDate_FichArchive1579 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE1580 #D-* Examples:1581 #D-1582 function IGCM_sys_GetDate_FichArchive {1583 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@1584 if ( $DEBUG_sys ) ; then1585 echo "IGCM_sys_GetDate_FichArchive :" $@1586 fi1587 typeset dateF1588 set +A dateF -- $( rsh ${STOREHOST} -n ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )1589 eval ${2}=${dateF[5]}1590 1591 IGCM_debug_PopStack "IGCM_sys_FichArchive"1592 768 } 1593 769 … … 1668 844 fi 1669 845 IGCM_debug_PopStack "IGCM_sys_sync" 1670 }1671 1672 #D-#==================================================1673 #D-function IGCM_sys_rebuild1674 #D-* Purpose: rebuild parallel files1675 #D-* Examples:1676 #D-1677 function IGCM_sys_rebuild {1678 IGCM_debug_PushStack "IGCM_sys_rebuild" $@1679 if ( $DEBUG_sys ) ; then1680 echo "IGCM_sys_rebuild :" $@1681 fi1682 1683 typeset NB_ESSAI DELAI status i firstArg1684 # number of tentative1685 NB_ESSAI=31686 # time delay between tentative1687 DELAI=21688 1689 i=01690 while [ $i -lt $NB_ESSAI ] ; do1691 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11692 status=$?1693 if [ ${status} -gt 0 ] ; then1694 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"1695 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1696 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1697 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1698 firstArg=${1}1699 \rm ${firstArg}1700 sleep $DELAI1701 else1702 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1703 break1704 fi1705 (( i = i + 1 ))1706 done1707 1708 if [ ${status} -gt 0 ] ; then1709 echo "IGCM_sys_rebuild : rebuild error code is ${status}"1710 IGCM_debug_Exit "rebuild"1711 fi1712 1713 IGCM_debug_PopStack "IGCM_sys_rebuild"1714 }1715 1716 #D-#==================================================1717 #D-function IGCM_sys_rebuild_station1718 #D-* Purpose: rebuild parallel files describing station1719 #D-* Examples:1720 #D-1721 function IGCM_sys_rebuild_station {1722 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@1723 typeset i list_opt file_in file_out prefix_invert list_invert1724 if ( $DEBUG_sys ) ; then1725 echo "IGCM_sys_rebuild_station :" $@1726 fi1727 list_opt=$@1728 1729 # Invert Axis : t,x -> x,t1730 # t,pres,x -> x,t,pres1731 # So that we can concatenate along x1732 i=01733 for file_in in ${list_opt} ; do1734 (( i = i + 1))1735 [ ${i} = 1 ] && file_out=${file_in} && continue1736 # detect time counter and do the job only if present1737 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')1738 if [ X${var_unlim} = Xtime_counter ] ; then1739 prefix_invert=$( basename ${file_in} .nc )1740 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc1741 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc1742 fi1743 done1744 1745 # Concatenate1746 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc1747 1748 # Re-ivert file1749 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}1750 1751 # Station re-ordering is too expansive to be run within libIGCM1752 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.1753 # This re-ordering must be done "in memory" by the cmorization process1754 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)1755 # BEGIN reordering1756 1757 # Only LMDZ text output contains the exact ordering of the station.1758 # We isolate this in the code below:1759 # 0 38 -157.5000000000000 70.985915492957741760 # 0 54 27.49999999999999 67.183098591549281761 # 0 56 -62.50000000000001 82.394366197183091762 # 0 79 12.49999999999999 78.591549295774661763 # 0 116 -165.0000000000000 76.056338028169011764 # 0 117 130.0000000000000 70.985915492957741765 # 0 118 110.0000000000000 87.464788732394371766 # 1 40 4.999999999999995 51.971830985915501767 1768 # typeset iStation iProc list_opt file_in file_out prefix_invert1769 # typeset -Z4 j41770 # typeset -Z3 j31771 1772 # unset list_opt1773 # set +A list_opt $@1774 1775 # Filename after rebuild1776 # file_out=${list_opt[0]}1777 # Prefix of output files1778 # prefix_invert=$( basename ${file_out} .nc )1779 # Number of procs1780 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )1781 1782 # iProc=01783 # while [ ${iProc} -lt ${num_proc} ] ; do1784 # Array containing Station as a number1785 # unset proc_stn1786 # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )1787 # Number of stations produced by processor proc1788 # stationLast=${#proc_stn[*]}1789 # Proc number on 4 digits1790 # j4=${iProc}1791 # Init1792 # iStation=01793 # while [ ${iStation} -lt ${stationLast} ] ; do1794 # Station number on 3 digits1795 # j3=${proc_stn[${iStation}]}1796 # Extract station1797 # Invert Axis : t,x -> x,t1798 # t,pres,x -> x,t,pres1799 # So that we can concatenate along x1800 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc1801 # (( iStation = iStation + 1 ))1802 # done1803 # (( iProc = iProc + 1 ))1804 # done1805 1806 # Concatenate all station along x1807 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc1808 1809 # Re-invert file1810 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}1811 1812 # END reordering1813 1814 IGCM_debug_PopStack "IGCM_sys_rebuild_station"1815 846 } 1816 847 … … 2145 1176 IGCM_debug_PopStack "IGCM_sys_ListJobInQueue" 2146 1177 } 2147 2148 ##############################################################2149 # NCO OPERATOR2150 2151 #D-#==================================================2152 #D-function IGCM_sys_ncap22153 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry2154 #D-* Examples:2155 #D-2156 function IGCM_sys_ncap2 {2157 IGCM_debug_PushStack "IGCM_sys_ncap2" $@2158 if ( $DEBUG_sys ) ; then2159 echo "IGCM_sys_ncap2 :" $@2160 fi2161 2162 typeset NB_ESSAI DELAI status i2163 # number of tentative2164 NB_ESSAI=32165 # time delay between tentative2166 DELAI=22167 2168 i=02169 while [ $i -lt $NB_ESSAI ] ; do2170 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12171 status=$?2172 if [ ${status} -gt 0 ] ; then2173 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"2174 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2175 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2176 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2177 sleep $DELAI2178 else2179 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2180 break2181 fi2182 (( i = i + 1 ))2183 done2184 2185 if [ ${status} -gt 0 ] ; then2186 echo "IGCM_sys_ncap2 : ncap2 error"2187 IGCM_debug_Exit "ncap2"2188 fi2189 2190 IGCM_debug_PopStack "IGCM_sys_ncap2"2191 }2192 2193 #D-#==================================================2194 #D-function IGCM_sys_ncatted2195 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry2196 #D-* Examples:2197 #D-2198 function IGCM_sys_ncatted {2199 IGCM_debug_PushStack "IGCM_sys_ncatted" $@2200 if ( $DEBUG_sys ) ; then2201 echo "IGCM_sys_ncatted :" $@2202 fi2203 2204 typeset NB_ESSAI DELAI status i2205 # number of tentative2206 NB_ESSAI=32207 # time delay between tentative2208 DELAI=22209 2210 i=02211 while [ $i -lt $NB_ESSAI ] ; do2212 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12213 status=$?2214 if [ ${status} -gt 0 ] ; then2215 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"2216 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2217 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2218 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2219 sleep $DELAI2220 else2221 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2222 break2223 fi2224 (( i = i + 1 ))2225 done2226 2227 if [ ${status} -gt 0 ] ; then2228 echo "IGCM_sys_ncatted : ncatted error"2229 IGCM_debug_Exit "ncatted"2230 fi2231 2232 IGCM_debug_PopStack "IGCM_sys_ncatted"2233 }2234 2235 #D-#==================================================2236 #D-function IGCM_sys_ncbo2237 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry2238 #D-* Examples:2239 #D-2240 function IGCM_sys_ncbo {2241 IGCM_debug_PushStack "IGCM_sys_ncbo" $@2242 if ( $DEBUG_sys ) ; then2243 echo "IGCM_sys_ncbo :" $@2244 fi2245 2246 typeset NB_ESSAI DELAI status i2247 # number of tentative2248 NB_ESSAI=32249 # time delay between tentative2250 DELAI=22251 2252 i=02253 while [ $i -lt $NB_ESSAI ] ; do2254 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12255 status=$?2256 if [ ${status} -gt 0 ] ; then2257 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"2258 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2259 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2260 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2261 sleep $DELAI2262 else2263 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2264 break2265 fi2266 (( i = i + 1 ))2267 done2268 2269 if [ ${status} -gt 0 ] ; then2270 echo "IGCM_sys_ncbo : ncbo error"2271 IGCM_debug_Exit "ncbo"2272 fi2273 2274 IGCM_debug_PopStack "IGCM_sys_ncbo"2275 }2276 2277 #D-#==================================================2278 #D-function IGCM_sys_ncdif2279 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry2280 #D-* Examples:2281 #D-2282 function IGCM_sys_ncdiff {2283 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@2284 if ( $DEBUG_sys ) ; then2285 echo "IGCM_sys_ncdiff :" $@2286 fi2287 2288 typeset NB_ESSAI DELAI status i2289 # number of tentative2290 NB_ESSAI=32291 # time delay between tentative2292 DELAI=22293 2294 i=02295 while [ $i -lt $NB_ESSAI ] ; do2296 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12297 status=$?2298 if [ ${status} -gt 0 ] ; then2299 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"2300 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2301 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2302 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2303 sleep $DELAI2304 else2305 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2306 break2307 fi2308 (( i = i + 1 ))2309 done2310 2311 if [ ${status} -gt 0 ] ; then2312 echo "IGCM_sys_ncdiff : ncdiff error"2313 IGCM_debug_Exit "ncdiff"2314 fi2315 2316 IGCM_debug_PopStack "IGCM_sys_ncdiff"2317 }2318 2319 #D-#==================================================2320 #D-function IGCM_sys_ncea2321 #D-* Purpose: encapsulate ncea call so as to manage error code and retry2322 #D-* Examples:2323 #D-2324 function IGCM_sys_ncea {2325 IGCM_debug_PushStack "IGCM_sys_ncea" $@2326 if ( $DEBUG_sys ) ; then2327 echo "IGCM_sys_ncea :" $@2328 fi2329 2330 typeset NB_ESSAI DELAI status i2331 # number of tentative2332 NB_ESSAI=32333 # time delay between tentative2334 DELAI=22335 2336 i=02337 while [ $i -lt $NB_ESSAI ] ; do2338 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12339 status=$?2340 if [ ${status} -gt 0 ] ; then2341 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"2342 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2343 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2344 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2345 sleep $DELAI2346 else2347 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2348 break2349 fi2350 (( i = i + 1 ))2351 done2352 2353 if [ ${status} -gt 0 ] ; then2354 echo "IGCM_sys_ncea : ncea error"2355 IGCM_debug_Exit "ncea"2356 fi2357 2358 IGCM_debug_PopStack "IGCM_sys_ncea"2359 }2360 2361 #D-#==================================================2362 #D-function IGCM_sys_ncecat2363 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry2364 #D-* Examples:2365 #D-2366 function IGCM_sys_ncecat {2367 IGCM_debug_PushStack "IGCM_sys_ncecat" $@2368 if ( $DEBUG_sys ) ; then2369 echo "IGCM_sys_ncecat :" $@2370 fi2371 2372 typeset NB_ESSAI DELAI status i2373 # number of tentative2374 NB_ESSAI=32375 # time delay between tentative2376 DELAI=22377 2378 i=02379 while [ $i -lt $NB_ESSAI ] ; do2380 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12381 status=$?2382 if [ ${status} -gt 0 ] ; then2383 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"2384 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2385 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2386 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2387 sleep $DELAI2388 else2389 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2390 break2391 fi2392 (( i = i + 1 ))2393 done2394 2395 if [ ${status} -gt 0 ] ; then2396 echo "IGCM_sys_ncecat : ncecat error"2397 IGCM_debug_Exit "ncecat"2398 fi2399 2400 IGCM_debug_PopStack "IGCM_sys_ncecat"2401 }2402 2403 #D-#==================================================2404 #D-function IGCM_sys_ncflint2405 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry2406 #D-* Examples:2407 #D-2408 function IGCM_sys_ncflint {2409 IGCM_debug_PushStack "IGCM_sys_ncflint" $@2410 if ( $DEBUG_sys ) ; then2411 echo "IGCM_sys_ncflint :" $@2412 fi2413 2414 typeset NB_ESSAI DELAI status i2415 # number of tentative2416 NB_ESSAI=32417 # time delay between tentative2418 DELAI=22419 2420 i=02421 while [ $i -lt $NB_ESSAI ] ; do2422 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12423 status=$?2424 if [ ${status} -gt 0 ] ; then2425 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"2426 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2427 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2428 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2429 sleep $DELAI2430 else2431 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2432 break2433 fi2434 (( i = i + 1 ))2435 done2436 2437 if [ ${status} -gt 0 ] ; then2438 echo "IGCM_sys_ncflint : ncflint error"2439 IGCM_debug_Exit "ncflint"2440 fi2441 2442 IGCM_debug_PopStack "IGCM_sys_ncflint"2443 }2444 2445 #D-#==================================================2446 #D-function IGCM_sys_ncks2447 #D-* Purpose: encapsulate ncks call so as to manage error code and retry2448 #D-* Examples:2449 #D-2450 function IGCM_sys_ncks {2451 IGCM_debug_PushStack "IGCM_sys_ncks" $@2452 if ( $DEBUG_sys ) ; then2453 echo "IGCM_sys_ncks :" $@2454 fi2455 2456 typeset NB_ESSAI DELAI status i2457 # number of tentative2458 NB_ESSAI=32459 # time delay between tentative2460 DELAI=22461 2462 i=02463 while [ $i -lt $NB_ESSAI ] ; do2464 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12465 status=$?2466 if [ ${status} -gt 0 ] ; then2467 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"2468 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2469 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2470 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2471 sleep $DELAI2472 else2473 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2474 break2475 fi2476 (( i = i + 1 ))2477 done2478 2479 if [ ${status} -gt 0 ] ; then2480 echo "IGCM_sys_ncks : ncks error"2481 IGCM_debug_Exit "ncks"2482 fi2483 2484 IGCM_debug_PopStack "IGCM_sys_ncks"2485 }2486 2487 #D-#==================================================2488 #D-function IGCM_sys_ncpdq2489 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry2490 #D-* Examples:2491 #D-2492 function IGCM_sys_ncpdq {2493 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@2494 if ( $DEBUG_sys ) ; then2495 echo "IGCM_sys_ncpdq :" $@2496 fi2497 2498 typeset NB_ESSAI DELAI status i2499 # number of tentative2500 NB_ESSAI=32501 # time delay between tentative2502 DELAI=22503 2504 i=02505 while [ $i -lt $NB_ESSAI ] ; do2506 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12507 status=$?2508 if [ ${status} -gt 0 ] ; then2509 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"2510 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2511 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2512 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2513 sleep $DELAI2514 else2515 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2516 break2517 fi2518 (( i = i + 1 ))2519 done2520 2521 if [ ${status} -gt 0 ] ; then2522 echo "IGCM_sys_ncpdq : ncpdq error"2523 IGCM_debug_Exit "ncpdq"2524 fi2525 2526 IGCM_debug_PopStack "IGCM_sys_ncpdq"2527 }2528 2529 #D-#==================================================2530 #D-function IGCM_sys_ncra2531 #D-* Purpose: encapsulate ncra call so as to manage error code and retry2532 #D-* Examples:2533 #D-2534 function IGCM_sys_ncra {2535 IGCM_debug_PushStack "IGCM_sys_ncra" $@2536 if ( $DEBUG_sys ) ; then2537 echo "IGCM_sys_ncra :" $@2538 fi2539 2540 typeset NB_ESSAI DELAI status i2541 # number of tentative2542 NB_ESSAI=32543 # time delay between tentative2544 DELAI=22545 2546 i=02547 while [ $i -lt $NB_ESSAI ] ; do2548 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12549 status=$?2550 if [ ${status} -gt 0 ] ; then2551 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"2552 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2553 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2554 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2555 sleep $DELAI2556 else2557 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2558 break2559 fi2560 (( i = i + 1 ))2561 done2562 2563 if [ ${status} -gt 0 ] ; then2564 echo "IGCM_sys_ncra : ncra error"2565 IGCM_debug_Exit "ncra"2566 fi2567 2568 IGCM_debug_PopStack "IGCM_sys_ncra"2569 }2570 2571 #D-#==================================================2572 #D-function IGCM_sys_ncrcat2573 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry2574 #D-* Examples:2575 #D-2576 function IGCM_sys_ncrcat {2577 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@2578 if ( $DEBUG_sys ) ; then2579 echo "IGCM_sys_ncrcat :" $@2580 fi2581 2582 typeset NB_ESSAI DELAI status i lastArg2583 # number of tentative2584 NB_ESSAI=32585 # time delay between tentative2586 DELAI=22587 2588 i=02589 while [ $i -lt $NB_ESSAI ] ; do2590 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12591 status=$?2592 if [ ${status} -gt 0 ] ; then2593 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"2594 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2595 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2596 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2597 sleep $DELAI2598 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then2599 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"2600 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2601 # remove files having corrupted time axis2602 eval lastArg=\${$#}2603 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"2604 \rm ${lastArg}2605 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2606 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2607 sleep $DELAI2608 else2609 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2610 break2611 fi2612 (( i = i + 1 ))2613 done2614 2615 if [ ${status} -gt 0 ] ; then2616 echo "IGCM_sys_ncrcat : ncrcat error"2617 #IGCM_debug_Exit "ncrcat"2618 fi2619 2620 IGCM_debug_PopStack "IGCM_sys_ncrcat"2621 }2622 2623 #D-#==================================================2624 #D-function IGCM_sys_ncrename2625 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry2626 #D-* Examples:2627 #D-2628 function IGCM_sys_ncrename {2629 IGCM_debug_PushStack "IGCM_sys_ncrename" $@2630 if ( $DEBUG_sys ) ; then2631 echo "IGCM_sys_ncrename :" $@2632 fi2633 2634 typeset NB_ESSAI DELAI status i2635 # number of tentative2636 NB_ESSAI=32637 # time delay between tentative2638 DELAI=22639 2640 i=02641 while [ $i -lt $NB_ESSAI ] ; do2642 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12643 status=$?2644 if [ ${status} -gt 0 ] ; then2645 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"2646 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2647 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2648 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2649 sleep $DELAI2650 else2651 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2652 break2653 fi2654 (( i = i + 1 ))2655 done2656 2657 if [ ${status} -gt 0 ] ; then2658 echo "IGCM_sys_ncrename : ncrename error"2659 IGCM_debug_Exit "ncrename"2660 fi2661 2662 IGCM_debug_PopStack "IGCM_sys_ncrename"2663 }2664 2665 #D-#==================================================2666 #D-function IGCM_sys_ncwa2667 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry2668 #D-* Examples:2669 #D-2670 function IGCM_sys_ncwa {2671 IGCM_debug_PushStack "IGCM_sys_ncwa" $@2672 if ( $DEBUG_sys ) ; then2673 echo "IGCM_sys_ncwa :" $@2674 fi2675 2676 typeset NB_ESSAI DELAI status i2677 # number of tentative2678 NB_ESSAI=32679 # time delay between tentative2680 DELAI=22681 2682 i=02683 while [ $i -lt $NB_ESSAI ] ; do2684 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12685 status=$?2686 if [ ${status} -gt 0 ] ; then2687 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"2688 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2689 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2690 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2691 sleep $DELAI2692 else2693 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2694 break2695 fi2696 (( i = i + 1 ))2697 done2698 2699 if [ ${status} -gt 0 ] ; then2700 echo "IGCM_sys_ncwa : ncwa error"2701 IGCM_debug_Exit "ncwa"2702 fi2703 2704 IGCM_debug_PopStack "IGCM_sys_ncwa"2705 }2706 2707 ##############################################################2708 # CDO OPERATOR2709 2710 #D-#==================================================2711 #D-function IGCM_sys_cdo2712 #D-* Purpose: encapsulate cdo call so as to manage error code and retry2713 #D-* Examples:2714 #D-2715 function IGCM_sys_cdo {2716 IGCM_debug_PushStack "IGCM_sys_cdo" $@2717 if ( $DEBUG_sys ) ; then2718 echo "IGCM_sys_cdo :" $@2719 fi2720 2721 typeset status2722 2723 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12724 status=$?2725 if [ ${status} -gt 0 ] ; then2726 echo "IGCM_sys_cdo : error code ${status}"2727 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2728 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2729 IGCM_debug_PopStack "IGCM_sys_cdo"2730 return 12731 else2732 IGCM_debug_PopStack "IGCM_sys_cdo"2733 return 02734 fi2735 2736 IGCM_debug_PopStack "IGCM_sys_cdo"2737 } -
trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh
r1180 r1181 256 256 257 257 #D-#================================================== 258 #D-function IGCM_sys_RshMaster259 #D-* Purpose: Connection to frontend machine.260 #D-* Examples:261 #D-262 function IGCM_sys_RshMaster {263 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@264 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF265 export libIGCM=${libIGCM}266 export DEBUG_debug=${DEBUG_debug}267 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh268 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh269 ${@}270 EOF271 if [ $? -gt 0 ] ; then272 echo "IGCM_sys_RshMaster : erreur."273 IGCM_debug_Exit "IGCM_sys_RshMaster"274 fi275 IGCM_debug_PopStack "IGCM_sys_RshMaster"276 }277 278 #D-#==================================================279 258 #D-function IGCM_sys_RshArchive 280 259 #D-* Purpose: Archive rsh command … … 303 282 IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 304 283 /bin/ksh <<-EOF 305 ${@} 2> \dev\null284 ${@} 2> /dev/null 306 285 EOF 307 286 IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 308 }309 310 #D-#==================================================311 #D-function IGCM_sys_RshPost312 #D-* Purpose: Post-process rsh command313 #D-* Examples:314 #D-315 function IGCM_sys_RshPost {316 IGCM_debug_PushStack "IGCM_sys_RshPost" $@317 if ( $DEBUG_sys ) ; then318 echo "IGCM_sys_RshPost :" $@319 fi320 # keep standard input (stdin) for the loop onto temporary file321 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}322 323 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}324 if [ $? -gt 0 ] ; then325 echo "IGCM_sys_RshPost : erreur."326 IGCM_debug_Exit "IGCM_sys_RshPost"327 fi328 # delete temporary file329 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}330 331 # ============ FRONTEND END ============ #332 333 # ============ CESIUM START ============ #334 # typeset NB_ESSAI DELAI status i335 # if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then336 # #little hack so that rebuild submission is done on titane not an cesium337 #338 # libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' )339 # POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' )340 # sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt341 # sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$342 # sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt343 # sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$344 # \mv tmp.txt tmp_IGCM_sys_RshPost_$$345 #346 # echo cat tmp_IGCM_sys_RshPost_$$ AFTER347 # cat tmp_IGCM_sys_RshPost_$$348 #349 # /bin/ksh <tmp_IGCM_sys_RshPost_$$350 # if [ $? -gt 0 ] ; then351 # echo "IGCM_sys_RshPost : erreur."352 # IGCM_debug_Exit "IGCM_sys_RshPost"353 # fi354 # # delete temporary file355 # \rm tmp_IGCM_sys_RshPost_$$356 #357 # else358 # # number of tentative359 # NB_ESSAI=10360 # # time delay between tentative361 # DELAI=10362 # i=0363 # while [ $i -ne $NB_ESSAI ] ; do364 # ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$365 # status=$?366 # if [ ${status} -ne 0 ];367 # then368 # sleep $DELAI369 # else370 # break371 # fi372 # let i=$i+1373 # done374 # # delete temporary file375 # \rm tmp_IGCM_sys_RshPost_$$376 #377 # if [ ${status} -gt 0 ] ; then378 # echo "IGCM_sys_RshPost : erreur."379 # IGCM_debug_Exit "IGCM_sys_RshPost"380 # fi381 # fi382 383 # ============ CESIUM END ============ #384 385 IGCM_debug_PopStack "IGCM_sys_RshPost"386 }387 388 #D-#==================================================389 #D-function IGCM_sys_SendMail390 #D-* Purpose: Send mail when simulation is over391 #D-* Examples:392 #D-393 function IGCM_sys_SendMail {394 IGCM_debug_PushStack "IGCM_sys_SendMail" $@395 if ( $DEBUG_sys ) ; then396 echo "IGCM_sys_SendMail :" $@397 fi398 399 if [ X${1} = XAccounting ] ; then400 status=Accounting401 mailText=jobAccounting.mail402 elif ( ${ExitFlag} ) ; then403 status=failed404 mailText=jobEnd.mail405 else406 status=completed407 mailText=jobEnd.mail408 fi409 410 # Update selected mail template411 while read -r line; do412 eval echo $line >> mail.txt ;413 done < ${libIGCM}/libIGCM_sys/${mailText}414 415 if [ ! -z ${config_UserChoices_MailName} ] ; then416 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt417 elif [ -f ~/.forward ] ; then418 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt419 else420 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt421 fi422 423 sleep 10424 rm -f mail.txt425 426 IGCM_debug_PopStack "IGCM_sys_SendMail"427 }428 429 #D-#==================================================430 #D-function IGCM_sys_Mkdir431 #D-* Purpose: Master locale mkdir command432 #D-* Examples:433 #D-434 function IGCM_sys_Mkdir {435 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@436 if ( $DEBUG_sys ) ; then437 echo "IGCM_sys_Mkdir :" $@438 fi439 if [ ! -d ${1} ]; then440 \mkdir -p $1441 if [ $? -gt 0 ] ; then442 echo "IGCM_sys_Mkdir : erreur."443 IGCM_debug_Exit "IGCM_sys_Mkdir"444 fi445 fi446 # vérification :447 if [ ! -d ${1} ] ; then448 echo "IGCM_sys_Mkdir : erreur."449 IGCM_debug_Exit "IGCM_sys_Mkdir"450 fi451 IGCM_debug_PopStack "IGCM_sys_Mkdir"452 287 } 453 288 … … 473 308 fi 474 309 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 475 }476 477 #D-#==================================================478 #D-function IGCM_sys_MkdirWork479 #D-* Purpose: Mkdir on Work480 #D-* Examples:481 #D-482 function IGCM_sys_MkdirWork {483 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@484 if ( $DEBUG_sys ) ; then485 echo "IGCM_sys_MkdirWork :" $@486 fi487 #- creation de repertoire sur le serveur fichier488 if [ ! -d ${1} ]; then489 \mkdir -p $1490 if [ $? -gt 0 ] ; then491 echo "IGCM_sys_MkdirWork : erreur."492 IGCM_debug_Exit "IGCM_sys_MkdirWork"493 fi494 fi495 IGCM_debug_PopStack "IGCM_sys_MkdirWork"496 }497 498 #D-#==================================================499 #D-function IGCM_sys_Cd500 #D-* Purpose: master cd command501 #D-* Examples:502 #D-503 function IGCM_sys_Cd {504 IGCM_debug_PushStack "IGCM_sys_Cd" $@505 if ( $DEBUG_sys ) ; then506 echo "IGCM_sys_Cd :" $@507 fi508 \cd $1509 if [ $? -gt 0 ] ; then510 echo "IGCM_sys_Cd : erreur."511 IGCM_debug_Exit "IGCM_sys_Cd"512 fi513 IGCM_debug_PopStack "IGCM_sys_Cd"514 }515 516 #D-#==================================================517 #D-function IGCM_sys_Chmod518 #D-* Purpose: Chmod519 #D-* Examples:520 #D-521 function IGCM_sys_Chmod {522 IGCM_debug_PushStack "IGCM_sys_Chmod" $@523 if ( $DEBUG_sys ) ; then524 echo "IGCM_sys_Chmod :" $@525 fi526 \chmod $@527 if [ $? -gt 0 ] ; then528 echo "IGCM_sys_Chmod : erreur."529 IGCM_debug_Exit "IGCM_sys_Chmod"530 fi531 IGCM_debug_PopStack "IGCM_sys_Chmod"532 }533 534 #D-#==================================================535 #D-function IGCM_sys_FileSize536 #D-* Purpose: Filesize537 #D-* Examples:538 #D-539 function IGCM_sys_FileSize {540 IGCM_debug_PushStack "IGCM_sys_FileSize" $@541 542 typeset sizeF543 set +A sizeF -- $( ls -la ${1} )544 if [ $? -gt 0 ] ; then545 IGCM_debug_Exit "IGCM_sys_FileSize"546 fi547 eval ${2}=${sizeF[4]}548 549 IGCM_debug_PopStack "IGCM_sys_FileSize"550 }551 552 #D-#==================================================553 #D-function IGCM_sys_TestDir554 #D-* Purpose: Test Directory that must exists555 #D-* Examples:556 #D-557 function IGCM_sys_TestDir {558 IGCM_debug_PushStack "IGCM_sys_TestDir" $@559 if ( $DEBUG_sys ) ; then560 echo "IGCM_sys_TestDir :" $@561 fi562 typeset ExistFlag563 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )564 IGCM_debug_PopStack "IGCM_sys_TestDir"565 566 return ${ExistFlag}567 310 } 568 311 … … 615 358 616 359 #D-#================================================== 617 #D-function IGCM_sys_TestFileBuffer618 #D-* Purpose: Test file that must NOT EXISTS on Buffer619 #D-* Examples:620 #D-621 function IGCM_sys_TestFileBuffer {622 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@623 typeset ExistFlag624 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )625 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"626 627 return ${ExistFlag}628 }629 630 #D-#==================================================631 360 #D-function IGCM_sys_CountFileArchive 632 361 #D-* Purpose: Count files on Archive filesystem … … 643 372 644 373 #D-#================================================== 645 #D-function IGCM_sys_CountFileBuffer646 #D-* Purpose: Count files on Scratch filesystem647 #D-* Examples:648 #D-649 function IGCM_sys_CountFileBuffer {650 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@651 ls ${@} 2>/dev/null | wc -l652 if [ $? -gt 0 ] ; then653 echo "IGCM_sys_CountFileBuffer : erreur."654 fi655 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"656 }657 658 #D-#==================================================659 374 #D-function IGCM_sys_Tree 660 375 #D-* Purpose: Tree directories with files on ${ARCHIVE} … … 670 385 671 386 IGCM_debug_PopStack "IGCM_sys_Tree" 672 }673 674 #D-#==================================================675 #D-function IGCM_sys_Tar676 #D-* Purpose: master tar command677 #D-* Examples:678 #D-679 function IGCM_sys_Tar {680 IGCM_debug_PushStack "IGCM_sys_Tar" $@681 if ( $DEBUG_sys ) ; then682 echo "IGCM_sys_Tar :" $@683 fi684 \tar cf $@685 if [ $? -gt 0 ] ; then686 echo "IGCM_sys_Tar : erreur."687 IGCM_debug_Exit "IGCM_sys_Tar"688 fi689 IGCM_debug_PopStack "IGCM_sys_Tar"690 }691 692 #D-#==================================================693 #D-function IGCM_sys_UnTar694 #D-* Purpose: master un-tar command695 #D-* Examples:696 #D-697 function IGCM_sys_UnTar {698 IGCM_debug_PushStack "IGCM_sys_UnTar" $@699 if ( $DEBUG_sys ) ; then700 echo "IGCM_sys_UnTar :" $@701 fi702 \tar xvf $1703 if [ $? -gt 0 ] ; then704 echo "IGCM_sys_UnTar : erreur."705 IGCM_debug_Exit "IGCM_sys_UnTar"706 fi707 IGCM_debug_PopStack "IGCM_sys_UnTar"708 387 } 709 388 … … 774 453 775 454 #D-#================================================== 776 #D-function IGCM_sys_Rsync_out777 #D-* Purpose: treat return val of rsync778 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync779 #D- Error values and explanations can depend on your system version.780 function IGCM_sys_Rsync_out {781 status=$1782 if [ ! $status ] ; then783 echo "rsync error !"784 fi785 786 if [ $MYLANG = "fr" ]; then787 case $status in788 0) return ;;789 1) echo "Erreur de rsync ; RERR_SYNTAX : "790 echo "Erreur de syntaxe ou d'utilisation."791 return;;792 2) echo "Erreur de rsync ; RERR_PROTOCOL : "793 echo "Incompatibilité de protocole."794 return;;795 3) echo "Erreur de rsync ; RERR_FILESELECT 3"796 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et"797 echo "répertoires"798 return;;799 4) echo "Erreur de rsync ; RERR_UNSUPPORTED"800 echo "Action demandée non supportée : une tentative de manipulation de"801 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a"802 echo "été faite ; ou une option qui est supportée par le client mais"803 echo "pas par le serveur a été spécifiée."804 return;;805 10) echo "Erreur de rsync ; RERR_SOCKETIO"806 echo "Erreur dans le socket d'entrée sortie"807 return;;808 11) echo "Erreur de rsync ; RERR_FILEIO"809 echo "Erreur d'entrée sortie fichier"810 return;;811 12) echo "Erreur de rsync ; RERR_STREAMIO"812 echo "Erreur dans flux de donnée du protocole rsync"813 return;;814 13) echo "Erreur de rsync ; RERR_MESSAGEIO"815 echo "Erreur avec les diagnostics du programme"816 return;;817 14) echo "Erreur de rsync ; RERR_IPC"818 echo "Erreur dans le code IPC"819 return;;820 20) echo "Erreur de rsync ; RERR_SIGNAL"821 echo "SIGUSR1 ou SIGINT reçu"822 return;;823 21) echo "Erreur de rsync ; RERR_WAITCHILD"824 echo "Une erreur retournée par waitpid()"825 return;;826 22) echo "Erreur de rsync ; RERR_MALLOC"827 echo "Erreur lors de l'allocation des tampons de mémoire de coeur"828 return;;829 23) echo ""830 echo "Erreur fichier inexistant"831 return;;832 30) echo "Erreur de rsync ; RERR_TIMEOUT"833 echo "Temps d'attente écoulé dans l'envoi/réception de données"834 return;;835 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status836 return;;837 esac838 elif [ $MYLANG = "en" ] ; then839 case $status in840 0) return;;841 1) echo "rsync error : Syntax or usage error "842 return;;843 2) echo "rsync error : Protocol incompatibility "844 return;;845 3) echo "rsync error : Errors selecting input/output files, dirs"846 return;;847 4) echo "rsync error : Requested action not supported: an attempt"848 echo "was made to manipulate 64-bit files on a platform that cannot support"849 echo "them; or an option was specified that is supported by the client and"850 echo "not by the server."851 return;;852 5) echo "rsync error : Error starting client-server protocol"853 return;;854 10) echo "rsync error : Error in socket I/O "855 return;;856 11) echo "rsync error : Error in file I/O "857 return;;858 12) echo "rsync error : Error in rsync protocol data stream "859 return;;860 13) echo "rsync error : Errors with program diagnostics "861 return;;862 14) echo "rsync error : Error in IPC code "863 return;;864 20) echo "rsync error : Received SIGUSR1 or SIGINT "865 return;;866 21) echo "rsync error : Some error returned by waitpid() "867 return;;868 22) echo "rsync error : Error allocating core memory buffers "869 return;;870 23) echo "rsync error : Partial transfer due to error"871 return;;872 24) echo "rsync error : Partial transfer due to vanished source files"873 return;;874 30) echo "rsync error : Timeout in data send/receive "875 return;;876 *) echo "rsync error : return code of rsync unknown :" $status877 return;;878 esac879 else880 echo "unknown language $MYLANG."881 return882 fi883 }884 885 #D-#==================================================886 #D-function IGCM_sys_Miror_libIGCM887 #D-* Purpose: Mirror libIGCM PATH and lib to frontend888 #D-* Examples:889 #D-890 function IGCM_sys_Mirror_libIGCM {891 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"892 if ( $DEBUG_sys ) ; then893 echo "IGCM_sys_Mirror_libIGCM"894 fi895 896 typeset status897 898 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}899 900 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1901 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1902 status=$?903 904 if [ ${status} -gt 0 ] ; then905 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."906 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$907 fi908 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"909 }910 911 #D-#==================================================912 #D-function IGCM_sys_Cp913 #D-* Purpose: generic cp914 #D-* Examples:915 #D-916 function IGCM_sys_Cp {917 IGCM_debug_PushStack "IGCM_sys_Cp" $@918 if ( $DEBUG_sys ) ; then919 echo "IGCM_sys_Cp :" $@920 fi921 922 typeset status923 924 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1925 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1926 status=$?927 928 if [ ${status} -gt 0 ] ; then929 echo "IGCM_sys_Cp : error code ${status}"930 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$931 IGCM_debug_Exit "IGCM_sys_Cp"932 else933 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$934 fi935 IGCM_debug_PopStack "IGCM_sys_Cp"936 }937 938 #D-#==================================================939 #D-function IGCM_sys_Rm940 #D-* Purpose: generic rm941 #D-* Examples:942 #D-943 function IGCM_sys_Rm {944 IGCM_debug_PushStack "IGCM_sys_Rm" $@945 if ( $DEBUG_sys ) ; then946 echo "IGCM_sys_Rm :" $@947 fi948 949 typeset status950 951 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1952 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1953 status=$?954 955 if [ ${status} -gt 0 ] ; then956 echo "IGCM_sys_Rm : error code ${status}"957 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$958 IGCM_debug_Exit "IGCM_sys_Rm"959 else960 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$961 fi962 IGCM_debug_PopStack "IGCM_sys_Rm"963 }964 965 #D-#==================================================966 455 #D-function IGCM_sys_RmRunDir 967 456 #D-* Purpose: rm tmpdir (dummy function most of the time batch … … 989 478 fi 990 479 IGCM_debug_PopStack "IGCM_sys_RmRunDir" 991 }992 993 #D-#==================================================994 #D-function IGCM_sys_Mv995 #D-* Purpose: generic move996 #D-* Examples:997 #D-998 function IGCM_sys_Mv {999 IGCM_debug_PushStack "IGCM_sys_Mv" $@1000 if ( $DEBUG_sys ) ; then1001 echo "IGCM_sys_Mv :" $@1002 fi1003 1004 if [ $DRYRUN = 0 ]; then1005 1006 typeset status1007 1008 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11009 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11010 status=$?1011 1012 if [ ${status} -gt 0 ] ; then1013 echo "IGCM_sys_Mv : error code ${status}"1014 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1015 IGCM_debug_Exit "IGCM_sys_Mv"1016 else1017 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1018 fi1019 fi1020 IGCM_debug_PopStack "IGCM_sys_Mv"1021 480 } 1022 481 … … 1106 565 1107 566 #D-#================================================== 1108 #D-function IGCM_sys_Get_Master1109 #D-* Purpose: Copy a complete directory from MASTER filesystem1110 #D-* Examples:1111 #D-1112 function IGCM_sys_Get_Master {1113 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@1114 if ( $DEBUG_sys ) ; then1115 echo "IGCM_sys_Get_Master :" $@1116 fi1117 if [ $DRYRUN = 0 ]; then1118 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then1119 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."1120 IGCM_debug_PopStack "IGCM_sys_Get_Master"1121 return1122 fi1123 1124 typeset NB_ESSAI DELAI status i1125 # number of tentative1126 NB_ESSAI=31127 # time delay between tentative1128 DELAI=21129 1130 i=01131 while [ $i -lt $NB_ESSAI ] ; do1132 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11133 status=$?1134 if [ ${status} -gt 0 ]; then1135 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"1136 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."1137 sleep $DELAI1138 else1139 break1140 fi1141 (( i = i + 1 ))1142 done1143 1144 if [ ${status} -gt 0 ] ; then1145 echo "IGCM_sys_Get_Master : error."1146 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1147 IGCM_debug_Exit "IGCM_sys_Get_Master"1148 else1149 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1150 fi1151 fi1152 IGCM_debug_PopStack "IGCM_sys_Get_Master"1153 }1154 1155 #====================================================1156 #- Call IGCM_sys_Mirror_libIGCM now !1157 if ( $MirrorlibIGCM ) ; then1158 IGCM_sys_Mirror_libIGCM1159 fi1160 1161 #D-#==================================================1162 567 #D-function IGCM_sys_Put_Rest 1163 568 #D-* Purpose: Put computied restarts on ${ARCHIVE}. … … 1214 619 fi 1215 620 IGCM_debug_PopStack "IGCM_sys_Put_Rest" 1216 }1217 1218 #D-#==================================================1219 #D-function IGCM_sys_PutBuffer_Rest1220 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}.1221 #D- File and target directory must exist.1222 #D-* Examples:1223 #D-1224 function IGCM_sys_PutBuffer_Rest {1225 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@1226 if ( $DEBUG_sys ) ; then1227 echo "IGCM_sys_PutBuffer_Rest :" $@1228 fi1229 if [ $DRYRUN = 0 ]; then1230 if [ ! -f ${1} ] ; then1231 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."1232 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1233 fi1234 1235 typeset status1236 #1237 # USUAL WAY1238 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11239 status=$?1240 1241 if [ ${status} -gt 0 ] ; then1242 echo "IGCM_sys_PutBuffer_Rest : error code ${status}"1243 [ -f ${2} ] && ls -l ${2}1244 [ -f ${2}/${1} ] && ls -l ${2}/${1}1245 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1246 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1247 else1248 1249 if [ X${JobType} = XRUN ] ; then1250 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1251 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1252 fi1253 1254 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1255 fi1256 fi1257 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"1258 }1259 1260 #D-#==================================================1261 #D-function IGCM_sys_PrepareTaredRestart1262 #D-* Purpose: Prepare tared restart to be access by computing job.1263 #D-* Examples:1264 #D-1265 function IGCM_sys_PrepareTaredRestart {1266 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@1267 if [ $DRYRUN = 0 ]; then1268 [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 .1269 fi1270 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"1271 621 } 1272 622 … … 1377 727 fi 1378 728 IGCM_debug_PopStack "IGCM_sys_Put_Out" 1379 return 01380 }1381 1382 #D-#==================================================1383 #D-function IGCM_sys_PutBuffer_Out1384 #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly1385 #D-* Examples:1386 #D-1387 function IGCM_sys_PutBuffer_Out {1388 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@1389 if ( $DEBUG_sys ) ; then1390 echo "IGCM_sys_PutBuffer_Out :" $@1391 fi1392 1393 typeset NB_ESSAI DELAI status i exist skip1394 1395 # number of tentative1396 NB_ESSAI=31397 # time delay between tentative1398 DELAI=21399 1400 if [ $DRYRUN = 0 ]; then1401 if [ ! -f ${1} ] ; then1402 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."1403 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1404 return 11405 fi1406 #1407 IGCM_sys_Mkdir $( dirname $2 )1408 #1409 1410 exist=false1411 skip=false1412 if [ -f $2 ] ; then1413 IGCM_debug_Print 1 "$2 already exist"1414 exist=true1415 if [ "X$( diff $1 $2 )" = X ] ; then1416 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"1417 status=01418 skip=true1419 else1420 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"1421 skip=false1422 fi1423 fi1424 #1425 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then1426 IGCM_sys_Chmod u+w $21427 fi1428 1429 if [ X${skip} = Xfalse ] ; then1430 i=01431 while [ $i -lt $NB_ESSAI ] ; do1432 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then1433 # USUAL WAY1434 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11435 status=$?1436 else1437 # NOT SO USUAL WAY1438 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11439 status=$?1440 fi1441 if [ ${status} -gt 0 ]; then1442 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"1443 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."1444 [ -f ${2} ] && ls -l ${2}1445 [ -f ${2}/${1} ] && ls -l ${2}/${1}1446 sleep $DELAI1447 else1448 break1449 fi1450 (( i = i + 1 ))1451 done1452 fi1453 1454 if [ ${status} -gt 0 ] ; then1455 echo "IGCM_sys_PutBuffer_Out : error."1456 [ -f ${2} ] && ls -l ${2}1457 [ -f ${2}/${1} ] && ls -l ${2}/${1}1458 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1459 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"1460 else1461 1462 if [ X${JobType} = XRUN ] ; then1463 if [ X${3} = X ] ; then1464 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1465 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1466 fi1467 fi1468 1469 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1470 fi1471 fi1472 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1473 729 return 0 1474 730 } … … 1613 869 1614 870 #D-#================================================== 1615 #D-function IGCM_sys_GetBuffer1616 #D-* Purpose: Get a file from ${SCRATCHDIR}1617 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX1618 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/1619 function IGCM_sys_GetBuffer {1620 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@1621 1622 typeset DEST buf_liste target file_work1623 typeset NB_ESSAI DELAI status i1624 1625 if ( $DEBUG_sys ) ; then1626 echo "IGCM_sys_GetBuffer :" $@1627 fi1628 1629 # number of tentative1630 NB_ESSAI=31631 # time delay between tentative1632 DELAI=21633 1634 if [ $DRYRUN -le 2 ]; then1635 if [ X${1} = X'/l' ] ; then1636 eval set +A buf_liste \${${2}}1637 else1638 eval set +A buf_liste ${1}1639 fi1640 eval DEST=\${${#}}1641 1642 #USUAL WAY1643 if [ X${1} = X'/l' ] ; then1644 for target in ${buf_liste[*]} ; do1645 local_file=$( basename ${target} )1646 i=01647 while [ $i -lt $NB_ESSAI ] ; do1648 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11649 status=$?1650 if [ ${status} -gt 0 ]; then1651 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1652 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1653 sleep $DELAI1654 else1655 break1656 fi1657 (( i = i + 1 ))1658 done1659 if [ ${status} -gt 0 ] ; then1660 echo "IGCM_sys_Get : error"1661 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1662 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1663 IGCM_debug_Exit "IGCM_sys_GetBuffer"1664 else1665 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1666 fi1667 done1668 else1669 i=01670 while [ $i -lt $NB_ESSAI ] ; do1671 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11672 status=$?1673 if [ ${status} -gt 0 ]; then1674 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1675 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1676 sleep $DELAI1677 else1678 break1679 fi1680 (( i = i + 1 ))1681 done1682 if [ ${status} -gt 0 ] ; then1683 echo "IGCM_sys_Get : error"1684 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1685 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1686 IGCM_debug_Exit "IGCM_sys_GetBuffer"1687 else1688 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1689 fi1690 fi1691 fi1692 IGCM_debug_PopStack "IGCM_sys_GetBuffer"1693 }1694 1695 #D-#==================================================1696 #D-function IGCM_sys_GetDate_FichWork1697 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK1698 #D-* Examples:1699 #D-1700 function IGCM_sys_GetDate_FichWork {1701 IGCM_debug_PushStack "IGCM_sys_FichWork" $@1702 if ( $DEBUG_sys ) ; then1703 echo "IGCM_sys_GetDate_FichWork :" $@1704 fi1705 1706 if [ $# -ge 3 ] ; then1707 mode=$31708 TimeStyle=$41709 else1710 mode="default"1711 TimeStyle="%Y%m%d%H%M%S"1712 fi1713 1714 typeset dateF1715 set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )1716 1717 case $mode in1718 "default")1719 eval ${2}=${dateF[5]}1720 ;;1721 "SplitFields")1722 eval ${2}="${dateF[5]}\ ${dateF[6]}"1723 ;;1724 esac1725 1726 1727 # donne la date filesys d'un fichier sur la machine work1728 IGCM_debug_PopStack "IGCM_sys_FichWork"1729 }1730 1731 #D-#==================================================1732 #D-function IGCM_sys_GetDate_FichArchive1733 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE1734 #D-* Examples:1735 #D-1736 function IGCM_sys_GetDate_FichArchive {1737 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@1738 if ( $DEBUG_sys ) ; then1739 echo "IGCM_sys_GetDate_FichArchive :" $@1740 fi1741 typeset dateF1742 set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )1743 eval ${2}=${dateF[5]}1744 1745 IGCM_debug_PopStack "IGCM_sys_FichArchive"1746 }1747 1748 #D-#==================================================1749 871 #D-function IGCM_sys_GetDate_Monitoring 1750 872 #D-* Purpose: get the last year for which the monitoring has been computed … … 1891 1013 1892 1014 IGCM_debug_PopStack "IGCM_sys_sync" 1893 }1894 1895 #D-#==================================================1896 #D-function IGCM_sys_rebuild1897 #D-* Purpose: rebuild parallel files1898 #D-* Examples:1899 #D-1900 function IGCM_sys_rebuild {1901 IGCM_debug_PushStack "IGCM_sys_rebuild" $@1902 if ( $DEBUG_sys ) ; then1903 echo "IGCM_sys_rebuild :" $@1904 fi1905 1906 typeset NB_ESSAI DELAI status i firstArg1907 # number of tentative1908 NB_ESSAI=31909 # time delay between tentative1910 DELAI=21911 1912 i=01913 while [ $i -lt $NB_ESSAI ] ; do1914 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11915 status=$?1916 if [ ${status} -gt 0 ] ; then1917 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"1918 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1919 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1920 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1921 firstArg=${1}1922 \rm ${firstArg}1923 sleep $DELAI1924 else1925 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1926 break1927 fi1928 (( i = i + 1 ))1929 done1930 1931 if [ ${status} -gt 0 ] ; then1932 echo "IGCM_sys_rebuild : rebuild error code is ${status}"1933 IGCM_debug_Exit "rebuild"1934 fi1935 1936 IGCM_debug_PopStack "IGCM_sys_rebuild"1937 }1938 1939 #D-#==================================================1940 #D-function IGCM_sys_rebuild_station1941 #D-* Purpose: rebuild parallel files describing station1942 #D-* Examples:1943 #D-1944 function IGCM_sys_rebuild_station {1945 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@1946 typeset i list_opt file_in file_out prefix_invert list_invert1947 if ( $DEBUG_sys ) ; then1948 echo "IGCM_sys_rebuild_station :" $@1949 fi1950 list_opt=$@1951 1952 # Invert Axis : t,x -> x,t1953 # t,pres,x -> x,t,pres1954 # So that we can concatenate along x1955 i=01956 for file_in in ${list_opt} ; do1957 (( i = i + 1))1958 [ ${i} = 1 ] && file_out=${file_in} && continue1959 # detect time counter and do the job only if present1960 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')1961 if [ X${var_unlim} = Xtime_counter ] ; then1962 prefix_invert=$( basename ${file_in} .nc )1963 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc1964 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc1965 fi1966 done1967 1968 # Concatenate1969 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc1970 1971 # Re-ivert file1972 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}1973 1974 # Station re-ordering is too expansive to be run within libIGCM1975 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.1976 # This re-ordering must be done "in memory" by the cmorization process1977 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)1978 # BEGIN reordering1979 1980 # Only LMDZ text output contains the exact ordering of the station.1981 # We isolate this in the code below:1982 # 0 38 -157.5000000000000 70.985915492957741983 # 0 54 27.49999999999999 67.183098591549281984 # 0 56 -62.50000000000001 82.394366197183091985 # 0 79 12.49999999999999 78.591549295774661986 # 0 116 -165.0000000000000 76.056338028169011987 # 0 117 130.0000000000000 70.985915492957741988 # 0 118 110.0000000000000 87.464788732394371989 # 1 40 4.999999999999995 51.971830985915501990 1991 # typeset iStation iProc list_opt file_in file_out prefix_invert1992 # typeset -Z4 j41993 # typeset -Z3 j31994 1995 # unset list_opt1996 # set +A list_opt $@1997 1998 # Filename after rebuild1999 # file_out=${list_opt[0]}2000 # Prefix of output files2001 # prefix_invert=$( basename ${file_out} .nc )2002 # Number of procs2003 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )2004 2005 # iProc=02006 # while [ ${iProc} -lt ${num_proc} ] ; do2007 # Array containing Station as a number2008 # unset proc_stn2009 # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )2010 # Number of stations produced by processor proc2011 # stationLast=${#proc_stn[*]}2012 # Proc number on 4 digits2013 # j4=${iProc}2014 # Init2015 # iStation=02016 # while [ ${iStation} -lt ${stationLast} ] ; do2017 # Station number on 3 digits2018 # j3=${proc_stn[${iStation}]}2019 # Extract station2020 # Invert Axis : t,x -> x,t2021 # t,pres,x -> x,t,pres2022 # So that we can concatenate along x2023 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc2024 # (( iStation = iStation + 1 ))2025 # done2026 # (( iProc = iProc + 1 ))2027 # done2028 2029 # Concatenate all station along x2030 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc2031 2032 # Re-invert file2033 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}2034 2035 # END reordering2036 2037 IGCM_debug_PopStack "IGCM_sys_rebuild_station"2038 1015 } 2039 1016 … … 2567 1544 IGCM_debug_PopStack "IGCM_sys_ListJobInQueue" 2568 1545 } 2569 2570 ##############################################################2571 # NCO OPERATOR2572 2573 #D-#==================================================2574 #D-function IGCM_sys_ncap22575 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry2576 #D-* Examples:2577 #D-2578 function IGCM_sys_ncap2 {2579 IGCM_debug_PushStack "IGCM_sys_ncap2" $@2580 if ( $DEBUG_sys ) ; then2581 echo "IGCM_sys_ncap2 :" $@2582 fi2583 2584 typeset NB_ESSAI DELAI status i2585 # number of tentative2586 NB_ESSAI=32587 # time delay between tentative2588 DELAI=22589 2590 i=02591 while [ $i -lt $NB_ESSAI ] ; do2592 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12593 status=$?2594 if [ ${status} -gt 0 ] ; then2595 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"2596 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2597 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2598 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2599 sleep $DELAI2600 else2601 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2602 break2603 fi2604 (( i = i + 1 ))2605 done2606 2607 if [ ${status} -gt 0 ] ; then2608 echo "IGCM_sys_ncap2 : ncap2 error"2609 IGCM_debug_Exit "ncap2"2610 fi2611 2612 IGCM_debug_PopStack "IGCM_sys_ncap2"2613 }2614 2615 #D-#==================================================2616 #D-function IGCM_sys_ncatted2617 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry2618 #D-* Examples:2619 #D-2620 function IGCM_sys_ncatted {2621 IGCM_debug_PushStack "IGCM_sys_ncatted" $@2622 if ( $DEBUG_sys ) ; then2623 echo "IGCM_sys_ncatted :" $@2624 fi2625 2626 typeset NB_ESSAI DELAI status i2627 # number of tentative2628 NB_ESSAI=32629 # time delay between tentative2630 DELAI=22631 2632 i=02633 while [ $i -lt $NB_ESSAI ] ; do2634 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12635 status=$?2636 if [ ${status} -gt 0 ] ; then2637 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"2638 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2639 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2640 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2641 sleep $DELAI2642 else2643 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2644 break2645 fi2646 (( i = i + 1 ))2647 done2648 2649 if [ ${status} -gt 0 ] ; then2650 echo "IGCM_sys_ncatted : ncatted error"2651 IGCM_debug_Exit "ncatted"2652 fi2653 2654 IGCM_debug_PopStack "IGCM_sys_ncatted"2655 }2656 2657 #D-#==================================================2658 #D-function IGCM_sys_ncbo2659 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry2660 #D-* Examples:2661 #D-2662 function IGCM_sys_ncbo {2663 IGCM_debug_PushStack "IGCM_sys_ncbo" $@2664 if ( $DEBUG_sys ) ; then2665 echo "IGCM_sys_ncbo :" $@2666 fi2667 2668 typeset NB_ESSAI DELAI status i2669 # number of tentative2670 NB_ESSAI=32671 # time delay between tentative2672 DELAI=22673 2674 i=02675 while [ $i -lt $NB_ESSAI ] ; do2676 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12677 status=$?2678 if [ ${status} -gt 0 ] ; then2679 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"2680 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2681 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2682 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2683 sleep $DELAI2684 else2685 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2686 break2687 fi2688 (( i = i + 1 ))2689 done2690 2691 if [ ${status} -gt 0 ] ; then2692 echo "IGCM_sys_ncbo : ncbo error"2693 IGCM_debug_Exit "ncbo"2694 fi2695 2696 IGCM_debug_PopStack "IGCM_sys_ncbo"2697 }2698 2699 #D-#==================================================2700 #D-function IGCM_sys_ncdif2701 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry2702 #D-* Examples:2703 #D-2704 function IGCM_sys_ncdiff {2705 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@2706 if ( $DEBUG_sys ) ; then2707 echo "IGCM_sys_ncdiff :" $@2708 fi2709 2710 typeset NB_ESSAI DELAI status i2711 # number of tentative2712 NB_ESSAI=32713 # time delay between tentative2714 DELAI=22715 2716 i=02717 while [ $i -lt $NB_ESSAI ] ; do2718 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12719 status=$?2720 if [ ${status} -gt 0 ] ; then2721 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"2722 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2723 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2724 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2725 sleep $DELAI2726 else2727 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2728 break2729 fi2730 (( i = i + 1 ))2731 done2732 2733 if [ ${status} -gt 0 ] ; then2734 echo "IGCM_sys_ncdiff : ncdiff error"2735 IGCM_debug_Exit "ncdiff"2736 fi2737 2738 IGCM_debug_PopStack "IGCM_sys_ncdiff"2739 }2740 2741 #D-#==================================================2742 #D-function IGCM_sys_ncea2743 #D-* Purpose: encapsulate ncea call so as to manage error code and retry2744 #D-* Examples:2745 #D-2746 function IGCM_sys_ncea {2747 IGCM_debug_PushStack "IGCM_sys_ncea" $@2748 if ( $DEBUG_sys ) ; then2749 echo "IGCM_sys_ncea :" $@2750 fi2751 2752 typeset NB_ESSAI DELAI status i2753 # number of tentative2754 NB_ESSAI=32755 # time delay between tentative2756 DELAI=22757 2758 i=02759 while [ $i -lt $NB_ESSAI ] ; do2760 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12761 status=$?2762 if [ ${status} -gt 0 ] ; then2763 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"2764 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2765 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2766 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2767 sleep $DELAI2768 else2769 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2770 break2771 fi2772 (( i = i + 1 ))2773 done2774 2775 if [ ${status} -gt 0 ] ; then2776 echo "IGCM_sys_ncea : ncea error"2777 IGCM_debug_Exit "ncea"2778 fi2779 2780 IGCM_debug_PopStack "IGCM_sys_ncea"2781 }2782 2783 #D-#==================================================2784 #D-function IGCM_sys_ncecat2785 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry2786 #D-* Examples:2787 #D-2788 function IGCM_sys_ncecat {2789 IGCM_debug_PushStack "IGCM_sys_ncecat" $@2790 if ( $DEBUG_sys ) ; then2791 echo "IGCM_sys_ncecat :" $@2792 fi2793 2794 typeset NB_ESSAI DELAI status i2795 # number of tentative2796 NB_ESSAI=32797 # time delay between tentative2798 DELAI=22799 2800 i=02801 while [ $i -lt $NB_ESSAI ] ; do2802 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12803 status=$?2804 if [ ${status} -gt 0 ] ; then2805 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"2806 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2807 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2808 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2809 sleep $DELAI2810 else2811 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2812 break2813 fi2814 (( i = i + 1 ))2815 done2816 2817 if [ ${status} -gt 0 ] ; then2818 echo "IGCM_sys_ncecat : ncecat error"2819 IGCM_debug_Exit "ncecat"2820 fi2821 2822 IGCM_debug_PopStack "IGCM_sys_ncecat"2823 }2824 2825 #D-#==================================================2826 #D-function IGCM_sys_ncflint2827 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry2828 #D-* Examples:2829 #D-2830 function IGCM_sys_ncflint {2831 IGCM_debug_PushStack "IGCM_sys_ncflint" $@2832 if ( $DEBUG_sys ) ; then2833 echo "IGCM_sys_ncflint :" $@2834 fi2835 2836 typeset NB_ESSAI DELAI status i2837 # number of tentative2838 NB_ESSAI=32839 # time delay between tentative2840 DELAI=22841 2842 i=02843 while [ $i -lt $NB_ESSAI ] ; do2844 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12845 status=$?2846 if [ ${status} -gt 0 ] ; then2847 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"2848 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2849 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2850 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2851 sleep $DELAI2852 else2853 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2854 break2855 fi2856 (( i = i + 1 ))2857 done2858 2859 if [ ${status} -gt 0 ] ; then2860 echo "IGCM_sys_ncflint : ncflint error"2861 IGCM_debug_Exit "ncflint"2862 fi2863 2864 IGCM_debug_PopStack "IGCM_sys_ncflint"2865 }2866 2867 #D-#==================================================2868 #D-function IGCM_sys_ncks2869 #D-* Purpose: encapsulate ncks call so as to manage error code and retry2870 #D-* Examples:2871 #D-2872 function IGCM_sys_ncks {2873 IGCM_debug_PushStack "IGCM_sys_ncks" $@2874 if ( $DEBUG_sys ) ; then2875 echo "IGCM_sys_ncks :" $@2876 fi2877 2878 typeset NB_ESSAI DELAI status i2879 # number of tentative2880 NB_ESSAI=32881 # time delay between tentative2882 DELAI=22883 2884 i=02885 while [ $i -lt $NB_ESSAI ] ; do2886 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12887 status=$?2888 if [ ${status} -gt 0 ] ; then2889 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"2890 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2891 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2892 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2893 sleep $DELAI2894 else2895 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2896 break2897 fi2898 (( i = i + 1 ))2899 done2900 2901 if [ ${status} -gt 0 ] ; then2902 echo "IGCM_sys_ncks : ncks error"2903 IGCM_debug_Exit "ncks"2904 fi2905 2906 IGCM_debug_PopStack "IGCM_sys_ncks"2907 }2908 2909 #D-#==================================================2910 #D-function IGCM_sys_ncpdq2911 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry2912 #D-* Examples:2913 #D-2914 function IGCM_sys_ncpdq {2915 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@2916 if ( $DEBUG_sys ) ; then2917 echo "IGCM_sys_ncpdq :" $@2918 fi2919 2920 typeset NB_ESSAI DELAI status i2921 # number of tentative2922 NB_ESSAI=32923 # time delay between tentative2924 DELAI=22925 2926 i=02927 while [ $i -lt $NB_ESSAI ] ; do2928 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12929 status=$?2930 if [ ${status} -gt 0 ] ; then2931 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"2932 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2933 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2934 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2935 sleep $DELAI2936 else2937 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2938 break2939 fi2940 (( i = i + 1 ))2941 done2942 2943 if [ ${status} -gt 0 ] ; then2944 echo "IGCM_sys_ncpdq : ncpdq error"2945 IGCM_debug_Exit "ncpdq"2946 fi2947 2948 IGCM_debug_PopStack "IGCM_sys_ncpdq"2949 }2950 2951 #D-#==================================================2952 #D-function IGCM_sys_ncra2953 #D-* Purpose: encapsulate ncra call so as to manage error code and retry2954 #D-* Examples:2955 #D-2956 function IGCM_sys_ncra {2957 IGCM_debug_PushStack "IGCM_sys_ncra" $@2958 if ( $DEBUG_sys ) ; then2959 echo "IGCM_sys_ncra :" $@2960 fi2961 2962 typeset NB_ESSAI DELAI status i2963 # number of tentative2964 NB_ESSAI=32965 # time delay between tentative2966 DELAI=22967 2968 i=02969 while [ $i -lt $NB_ESSAI ] ; do2970 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12971 status=$?2972 if [ ${status} -gt 0 ] ; then2973 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"2974 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2975 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2976 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2977 sleep $DELAI2978 else2979 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2980 break2981 fi2982 (( i = i + 1 ))2983 done2984 2985 if [ ${status} -gt 0 ] ; then2986 echo "IGCM_sys_ncra : ncra error"2987 IGCM_debug_Exit "ncra"2988 fi2989 2990 IGCM_debug_PopStack "IGCM_sys_ncra"2991 }2992 2993 #D-#==================================================2994 #D-function IGCM_sys_ncrcat2995 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry2996 #D-* Examples:2997 #D-2998 function IGCM_sys_ncrcat {2999 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@3000 if ( $DEBUG_sys ) ; then3001 echo "IGCM_sys_ncrcat :" $@3002 fi3003 3004 typeset NB_ESSAI DELAI status i lastArg3005 # number of tentative3006 NB_ESSAI=33007 # time delay between tentative3008 DELAI=23009 3010 i=03011 while [ $i -lt $NB_ESSAI ] ; do3012 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&13013 status=$?3014 if [ ${status} -gt 0 ] ; then3015 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"3016 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3017 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3018 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."3019 sleep $DELAI3020 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then3021 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"3022 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3023 # remove files having corrupted time axis3024 eval lastArg=\${$#}3025 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"3026 \rm ${lastArg}3027 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3028 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."3029 sleep $DELAI3030 else3031 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3032 break3033 fi3034 (( i = i + 1 ))3035 done3036 3037 if [ ${status} -gt 0 ] ; then3038 echo "IGCM_sys_ncrcat : ncrcat error"3039 #IGCM_debug_Exit "ncrcat"3040 fi3041 3042 IGCM_debug_PopStack "IGCM_sys_ncrcat"3043 }3044 3045 #D-#==================================================3046 #D-function IGCM_sys_ncrename3047 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry3048 #D-* Examples:3049 #D-3050 function IGCM_sys_ncrename {3051 IGCM_debug_PushStack "IGCM_sys_ncrename" $@3052 if ( $DEBUG_sys ) ; then3053 echo "IGCM_sys_ncrename :" $@3054 fi3055 3056 typeset NB_ESSAI DELAI status i3057 # number of tentative3058 NB_ESSAI=33059 # time delay between tentative3060 DELAI=23061 3062 i=03063 while [ $i -lt $NB_ESSAI ] ; do3064 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&13065 status=$?3066 if [ ${status} -gt 0 ] ; then3067 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"3068 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3069 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3070 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."3071 sleep $DELAI3072 else3073 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3074 break3075 fi3076 (( i = i + 1 ))3077 done3078 3079 if [ ${status} -gt 0 ] ; then3080 echo "IGCM_sys_ncrename : ncrename error"3081 IGCM_debug_Exit "ncrename"3082 fi3083 3084 IGCM_debug_PopStack "IGCM_sys_ncrename"3085 }3086 3087 #D-#==================================================3088 #D-function IGCM_sys_ncwa3089 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry3090 #D-* Examples:3091 #D-3092 function IGCM_sys_ncwa {3093 IGCM_debug_PushStack "IGCM_sys_ncwa" $@3094 if ( $DEBUG_sys ) ; then3095 echo "IGCM_sys_ncwa :" $@3096 fi3097 3098 typeset NB_ESSAI DELAI status i3099 # number of tentative3100 NB_ESSAI=33101 # time delay between tentative3102 DELAI=23103 3104 i=03105 while [ $i -lt $NB_ESSAI ] ; do3106 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&13107 status=$?3108 if [ ${status} -gt 0 ] ; then3109 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"3110 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3111 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3112 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."3113 sleep $DELAI3114 else3115 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3116 break3117 fi3118 (( i = i + 1 ))3119 done3120 3121 if [ ${status} -gt 0 ] ; then3122 echo "IGCM_sys_ncwa : ncwa error"3123 IGCM_debug_Exit "ncwa"3124 fi3125 3126 IGCM_debug_PopStack "IGCM_sys_ncwa"3127 }3128 3129 ##############################################################3130 # CDO OPERATOR3131 3132 #D-#==================================================3133 #D-function IGCM_sys_cdo3134 #D-* Purpose: encapsulate cdo call so as to manage error code and retry3135 #D-* Examples:3136 #D-3137 function IGCM_sys_cdo {3138 IGCM_debug_PushStack "IGCM_sys_cdo" $@3139 if ( $DEBUG_sys ) ; then3140 echo "IGCM_sys_cdo :" $@3141 fi3142 3143 typeset status3144 3145 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&13146 status=$?3147 if [ ${status} -gt 0 ] ; then3148 echo "IGCM_sys_cdo : error code ${status}"3149 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3150 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$3151 IGCM_debug_PopStack "IGCM_sys_cdo"3152 return 13153 else3154 IGCM_debug_PopStack "IGCM_sys_cdo"3155 return 03156 fi3157 3158 IGCM_debug_PopStack "IGCM_sys_cdo"3159 } -
trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh
r1180 r1181 204 204 205 205 #D-#================================================== 206 #D-function IGCM_sys_RshMaster207 #D-* Purpose: Connection to frontend machine.208 #D-* Examples:209 #D-210 function IGCM_sys_RshMaster {211 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@212 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF213 export libIGCM=${libIGCM}214 export DEBUG_debug=${DEBUG_debug}215 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh216 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh217 ${@}218 EOF219 if [ $? -gt 0 ] ; then220 echo "IGCM_sys_RshMaster : erreur."221 IGCM_debug_Exit "IGCM_sys_RshMaster"222 fi223 IGCM_debug_PopStack "IGCM_sys_RshMaster"224 }225 226 #D-#==================================================227 206 #D-function IGCM_sys_RshArchive 228 207 #D-* Purpose: Archive rsh command … … 251 230 IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 252 231 /bin/ksh <<-EOF 253 ${@} 2> \dev\null232 ${@} 2> /dev/null 254 233 EOF 255 234 IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 256 }257 258 #D-#==================================================259 #D-function IGCM_sys_RshPost260 #D-* Purpose: Post-process rsh command261 #D-* Examples:262 #D-263 function IGCM_sys_RshPost {264 IGCM_debug_PushStack "IGCM_sys_RshPost" $@265 if ( $DEBUG_sys ) ; then266 echo "IGCM_sys_RshPost :" $@267 fi268 # keep standard input (stdin) for the loop onto temporary file269 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}270 271 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}272 if [ $? -gt 0 ] ; then273 echo "IGCM_sys_RshPost : erreur."274 IGCM_debug_Exit "IGCM_sys_RshPost"275 fi276 # delete temporary file277 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}278 IGCM_debug_PopStack "IGCM_sys_RshPost"279 }280 281 #D-#==================================================282 #D-function IGCM_sys_SendMail283 #D-* Purpose: Send mail when simulation is over284 #D-* Examples:285 #D-286 function IGCM_sys_SendMail {287 IGCM_debug_PushStack "IGCM_sys_SendMail" $@288 if ( $DEBUG_sys ) ; then289 echo "IGCM_sys_SendMail :" $@290 fi291 292 if [ X${1} = XAccounting ] ; then293 status=Accounting294 mailText=jobAccounting.mail295 elif ( ${ExitFlag} ) ; then296 status=failed297 mailText=jobEnd.mail298 else299 status=completed300 mailText=jobEnd.mail301 fi302 303 # Update selected mail template304 while read -r line; do305 eval echo $line >> mail.txt ;306 done < ${libIGCM}/libIGCM_sys/${mailText}307 308 if [ ! -z ${config_UserChoices_MailName} ] ; then309 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt310 elif [ -f ~/.forward ] ; then311 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt312 else313 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt314 fi315 316 sleep 10317 rm -f mail.txt318 319 IGCM_debug_PopStack "IGCM_sys_SendMail"320 }321 322 #D-#==================================================323 #D-function IGCM_sys_Mkdir324 #D-* Purpose: Master locale mkdir command325 #D-* Examples:326 #D-327 function IGCM_sys_Mkdir {328 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@329 if ( $DEBUG_sys ) ; then330 echo "IGCM_sys_Mkdir :" $@331 fi332 if [ ! -d ${1} ]; then333 \mkdir -p $1334 if [ $? -gt 0 ] ; then335 echo "IGCM_sys_Mkdir : erreur."336 IGCM_debug_Exit "IGCM_sys_Mkdir"337 fi338 fi339 # vérification :340 if [ ! -d ${1} ] ; then341 echo "IGCM_sys_Mkdir : erreur."342 IGCM_debug_Exit "IGCM_sys_Mkdir"343 fi344 IGCM_debug_PopStack "IGCM_sys_Mkdir"345 235 } 346 236 … … 366 256 fi 367 257 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 368 }369 370 #D-#==================================================371 #D-function IGCM_sys_MkdirWork372 #D-* Purpose: Mkdir on Work373 #D-* Examples:374 #D-375 function IGCM_sys_MkdirWork {376 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@377 if ( $DEBUG_sys ) ; then378 echo "IGCM_sys_MkdirWork :" $@379 fi380 #- creation de repertoire sur le serveur fichier381 if [ ! -d ${1} ]; then382 \mkdir -p $1383 if [ $? -gt 0 ] ; then384 echo "IGCM_sys_MkdirWork : erreur."385 IGCM_debug_Exit "IGCM_sys_MkdirWork"386 fi387 fi388 IGCM_debug_PopStack "IGCM_sys_MkdirWork"389 }390 391 #D-#==================================================392 #D-function IGCM_sys_Cd393 #D-* Purpose: master cd command394 #D-* Examples:395 #D-396 function IGCM_sys_Cd {397 IGCM_debug_PushStack "IGCM_sys_Cd" $@398 if ( $DEBUG_sys ) ; then399 echo "IGCM_sys_Cd :" $@400 fi401 \cd $1402 if [ $? -gt 0 ] ; then403 echo "IGCM_sys_Cd : erreur."404 IGCM_debug_Exit "IGCM_sys_Cd"405 fi406 IGCM_debug_PopStack "IGCM_sys_Cd"407 }408 409 #D-#==================================================410 #D-function IGCM_sys_Chmod411 #D-* Purpose: Chmod412 #D-* Examples:413 #D-414 function IGCM_sys_Chmod {415 IGCM_debug_PushStack "IGCM_sys_Chmod" $@416 if ( $DEBUG_sys ) ; then417 echo "IGCM_sys_Chmod :" $@418 fi419 \chmod $@420 if [ $? -gt 0 ] ; then421 echo "IGCM_sys_Chmod : erreur."422 IGCM_debug_Exit "IGCM_sys_Chmod"423 fi424 IGCM_debug_PopStack "IGCM_sys_Chmod"425 }426 427 #D-#==================================================428 #D-function IGCM_sys_FileSize429 #D-* Purpose: Filesize430 #D-* Examples:431 #D-432 function IGCM_sys_FileSize {433 IGCM_debug_PushStack "IGCM_sys_FileSize" $@434 435 typeset sizeF436 set +A sizeF -- $( ls -la ${1} )437 if [ $? -gt 0 ] ; then438 IGCM_debug_Exit "IGCM_sys_FileSize"439 fi440 eval ${2}=${sizeF[4]}441 442 IGCM_debug_PopStack "IGCM_sys_FileSize"443 }444 445 #D-#==================================================446 #D-function IGCM_sys_TestDir447 #D-* Purpose: Test Directory that must exists448 #D-* Examples:449 #D-450 function IGCM_sys_TestDir {451 IGCM_debug_PushStack "IGCM_sys_TestDir" $@452 if ( $DEBUG_sys ) ; then453 echo "IGCM_sys_TestDir :" $@454 fi455 typeset ExistFlag456 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )457 IGCM_debug_PopStack "IGCM_sys_TestDir"458 459 return ${ExistFlag}460 258 } 461 259 … … 509 307 510 308 #D-#================================================== 511 #D-function IGCM_sys_TestFileBuffer512 #D-* Purpose: Test file that must NOT EXISTS on Buffer513 #D-* Examples:514 #D-515 function IGCM_sys_TestFileBuffer {516 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@517 typeset ExistFlag518 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )519 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"520 521 return ${ExistFlag}522 }523 524 #D-#==================================================525 309 #D-function IGCM_sys_CountFileArchive 526 310 #D-* Purpose: Count files on Archive filesystem … … 537 321 538 322 #D-#================================================== 539 #D-function IGCM_sys_CountFileBuffer540 #D-* Purpose: Count files on Scratch filesystem541 #D-* Examples:542 #D-543 function IGCM_sys_CountFileBuffer {544 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@545 ls ${@} 2>/dev/null | wc -l546 if [ $? -gt 0 ] ; then547 echo "IGCM_sys_CountFileBuffer : erreur."548 fi549 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"550 }551 552 #D-#==================================================553 323 #D-function IGCM_sys_Tree 554 324 #D-* Purpose: Tree directories with files on ${ARCHIVE} … … 564 334 565 335 IGCM_debug_PopStack "IGCM_sys_Tree" 566 }567 568 #D-#==================================================569 #D-function IGCM_sys_Tar570 #D-* Purpose: master tar command571 #D-* Examples:572 #D-573 function IGCM_sys_Tar {574 IGCM_debug_PushStack "IGCM_sys_Tar" $@575 if ( $DEBUG_sys ) ; then576 echo "IGCM_sys_Tar :" $@577 fi578 \tar cf $@579 if [ $? -gt 0 ] ; then580 echo "IGCM_sys_Tar : erreur."581 IGCM_debug_Exit "IGCM_sys_Tar"582 fi583 IGCM_debug_PopStack "IGCM_sys_Tar"584 }585 586 #D-#==================================================587 #D-function IGCM_sys_UnTar588 #D-* Purpose: master un-tar command589 #D-* Examples:590 #D-591 function IGCM_sys_UnTar {592 IGCM_debug_PushStack "IGCM_sys_UnTar" $@593 if ( $DEBUG_sys ) ; then594 echo "IGCM_sys_UnTar :" $@595 fi596 \tar xvf $1597 if [ $? -gt 0 ] ; then598 echo "IGCM_sys_UnTar : erreur."599 IGCM_debug_Exit "IGCM_sys_UnTar"600 fi601 IGCM_debug_PopStack "IGCM_sys_UnTar"602 336 } 603 337 … … 646 380 647 381 #D-#================================================== 648 #D-function IGCM_sys_Rsync_out649 #D-* Purpose: treat return val of rsync650 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync651 #D- Error values and explanations can depend on your system version.652 function IGCM_sys_Rsync_out {653 status=$1654 if [ ! $status ] ; then655 echo "rsync error !"656 fi657 658 if [ $MYLANG = "fr" ]; then659 case $status in660 0) return ;;661 1) echo "Erreur de rsync ; RERR_SYNTAX : "662 echo "Erreur de syntaxe ou d'utilisation."663 return;;664 2) echo "Erreur de rsync ; RERR_PROTOCOL : "665 echo "Incompatibilité de protocole."666 return;;667 3) echo "Erreur de rsync ; RERR_FILESELECT 3"668 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et"669 echo "répertoires"670 return;;671 4) echo "Erreur de rsync ; RERR_UNSUPPORTED"672 echo "Action demandée non supportée : une tentative de manipulation de"673 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a"674 echo "été faite ; ou une option qui est supportée par le client mais"675 echo "pas par le serveur a été spécifiée."676 return;;677 10) echo "Erreur de rsync ; RERR_SOCKETIO"678 echo "Erreur dans le socket d'entrée sortie"679 return;;680 11) echo "Erreur de rsync ; RERR_FILEIO"681 echo "Erreur d'entrée sortie fichier"682 return;;683 12) echo "Erreur de rsync ; RERR_STREAMIO"684 echo "Erreur dans flux de donnée du protocole rsync"685 return;;686 13) echo "Erreur de rsync ; RERR_MESSAGEIO"687 echo "Erreur avec les diagnostics du programme"688 return;;689 14) echo "Erreur de rsync ; RERR_IPC"690 echo "Erreur dans le code IPC"691 return;;692 20) echo "Erreur de rsync ; RERR_SIGNAL"693 echo "SIGUSR1 ou SIGINT reçu"694 return;;695 21) echo "Erreur de rsync ; RERR_WAITCHILD"696 echo "Une erreur retournée par waitpid()"697 return;;698 22) echo "Erreur de rsync ; RERR_MALLOC"699 echo "Erreur lors de l'allocation des tampons de mémoire de coeur"700 return;;701 23) echo ""702 echo "Erreur fichier inexistant"703 return;;704 30) echo "Erreur de rsync ; RERR_TIMEOUT"705 echo "Temps d'attente écoulé dans l'envoi/réception de données"706 return;;707 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status708 return;;709 esac710 elif [ $MYLANG = "en" ] ; then711 case $status in712 0) return;;713 1) echo "rsync error : Syntax or usage error "714 return;;715 2) echo "rsync error : Protocol incompatibility "716 return;;717 3) echo "rsync error : Errors selecting input/output files, dirs"718 return;;719 4) echo "rsync error : Requested action not supported: an attempt"720 echo "was made to manipulate 64-bit files on a platform that cannot support"721 echo "them; or an option was specified that is supported by the client and"722 echo "not by the server."723 return;;724 5) echo "rsync error : Error starting client-server protocol"725 return;;726 10) echo "rsync error : Error in socket I/O "727 return;;728 11) echo "rsync error : Error in file I/O "729 return;;730 12) echo "rsync error : Error in rsync protocol data stream "731 return;;732 13) echo "rsync error : Errors with program diagnostics "733 return;;734 14) echo "rsync error : Error in IPC code "735 return;;736 20) echo "rsync error : Received SIGUSR1 or SIGINT "737 return;;738 21) echo "rsync error : Some error returned by waitpid() "739 return;;740 22) echo "rsync error : Error allocating core memory buffers "741 return;;742 23) echo "rsync error : Partial transfer due to error"743 return;;744 24) echo "rsync error : Partial transfer due to vanished source files"745 return;;746 30) echo "rsync error : Timeout in data send/receive "747 return;;748 *) echo "rsync error : return code of rsync unknown :" $status749 return;;750 esac751 else752 echo "unknown language $MYLANG."753 return754 fi755 }756 757 #D-#==================================================758 #D-function IGCM_sys_Miror_libIGCM759 #D-* Purpose: Mirror libIGCM PATH and lib to frontend760 #D-* Examples:761 #D-762 function IGCM_sys_Mirror_libIGCM {763 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"764 if ( $DEBUG_sys ) ; then765 echo "IGCM_sys_Mirror_libIGCM"766 fi767 768 typeset status769 770 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}771 772 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1773 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1774 status=$?775 776 if [ ${status} -gt 0 ] ; then777 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."778 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$779 fi780 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"781 }782 783 #D-#==================================================784 #D-function IGCM_sys_Cp785 #D-* Purpose: generic cp786 #D-* Examples:787 #D-788 function IGCM_sys_Cp {789 IGCM_debug_PushStack "IGCM_sys_Cp" $@790 if ( $DEBUG_sys ) ; then791 echo "IGCM_sys_Cp :" $@792 fi793 794 typeset status795 796 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1797 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1798 status=$?799 800 if [ ${status} -gt 0 ] ; then801 echo "IGCM_sys_Cp : error code ${status}"802 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$803 IGCM_debug_Exit "IGCM_sys_Cp"804 else805 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$806 fi807 IGCM_debug_PopStack "IGCM_sys_Cp"808 }809 810 #D-#==================================================811 #D-function IGCM_sys_Rm812 #D-* Purpose: generic rm813 #D-* Examples:814 #D-815 function IGCM_sys_Rm {816 IGCM_debug_PushStack "IGCM_sys_Rm" $@817 if ( $DEBUG_sys ) ; then818 echo "IGCM_sys_Rm :" $@819 fi820 821 typeset status822 823 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1824 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1825 status=$?826 827 if [ ${status} -gt 0 ] ; then828 echo "IGCM_sys_Rm : error code ${status}"829 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$830 IGCM_debug_Exit "IGCM_sys_Rm"831 else832 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$833 fi834 IGCM_debug_PopStack "IGCM_sys_Rm"835 }836 837 #D-#==================================================838 382 #D-function IGCM_sys_RmRunDir 839 383 #D-* Purpose: rm tmpdir (dummy function most of the time batch … … 849 393 fi 850 394 IGCM_debug_PopStack "IGCM_sys_RmRunDir" 851 }852 853 #D-#==================================================854 #D-function IGCM_sys_Mv855 #D-* Purpose: generic move856 #D-* Examples:857 #D-858 function IGCM_sys_Mv {859 IGCM_debug_PushStack "IGCM_sys_Mv" $@860 if ( $DEBUG_sys ) ; then861 echo "IGCM_sys_Mv :" $@862 fi863 864 if [ $DRYRUN = 0 ]; then865 866 typeset status867 868 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1869 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1870 status=$?871 872 if [ ${status} -gt 0 ] ; then873 echo "IGCM_sys_Mv : error code ${status}"874 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$875 IGCM_debug_Exit "IGCM_sys_Mv"876 else877 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$878 fi879 fi880 IGCM_debug_PopStack "IGCM_sys_Mv"881 395 } 882 396 … … 963 477 964 478 #D-#================================================== 965 #D-function IGCM_sys_Get_Master966 #D-* Purpose: Copy a complete directory from MASTER filesystem967 #D-* Examples:968 #D-969 function IGCM_sys_Get_Master {970 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@971 if ( $DEBUG_sys ) ; then972 echo "IGCM_sys_Get_Master :" $@973 fi974 if [ $DRYRUN = 0 ]; then975 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then976 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."977 IGCM_debug_PopStack "IGCM_sys_Get_Master"978 return979 fi980 981 typeset NB_ESSAI DELAI status i982 # number of tentative983 NB_ESSAI=3984 # time delay between tentative985 DELAI=2986 987 i=0988 while [ $i -lt $NB_ESSAI ] ; do989 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1990 status=$?991 if [ ${status} -gt 0 ]; then992 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"993 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."994 sleep $DELAI995 else996 break997 fi998 (( i = i + 1 ))999 done1000 1001 if [ ${status} -gt 0 ] ; then1002 echo "IGCM_sys_Get_Master : error."1003 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1004 IGCM_debug_Exit "IGCM_sys_Get_Master"1005 else1006 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1007 fi1008 fi1009 IGCM_debug_PopStack "IGCM_sys_Get_Master"1010 }1011 1012 #====================================================1013 #- Call IGCM_sys_Mirror_libIGCM now !1014 if ( $MirrorlibIGCM ) ; then1015 IGCM_sys_Mirror_libIGCM1016 fi1017 1018 #D-#==================================================1019 479 #D-function IGCM_sys_Put_Rest 1020 480 #D-* Purpose: Put computied restarts on ${ARCHIVE}. … … 1074 534 1075 535 #D-#================================================== 1076 #D-function IGCM_sys_PutBuffer_Rest1077 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}.1078 #D- File and target directory must exist.1079 #D-* Examples:1080 #D-1081 function IGCM_sys_PutBuffer_Rest {1082 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@1083 if ( $DEBUG_sys ) ; then1084 echo "IGCM_sys_PutBuffer_Rest :" $@1085 fi1086 if [ $DRYRUN = 0 ]; then1087 if [ ! -f ${1} ] ; then1088 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."1089 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1090 fi1091 1092 typeset status1093 #1094 # USUAL WAY1095 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11096 status=$?1097 1098 if [ ${status} -gt 0 ] ; then1099 echo "IGCM_sys_PutBuffer_Rest : error code ${status}"1100 [ -f ${2} ] && ls -l ${2}1101 [ -f ${2}/${1} ] && ls -l ${2}/${1}1102 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1103 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1104 else1105 1106 if [ X${JobType} = XRUN ] ; then1107 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1108 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1109 fi1110 1111 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1112 fi1113 fi1114 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"1115 }1116 1117 #D-#==================================================1118 #D-function IGCM_sys_PrepareTaredRestart1119 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here.1120 #D-* Examples:1121 #D-1122 function IGCM_sys_PrepareTaredRestart {1123 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@1124 1125 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"1126 }1127 1128 #D-#==================================================1129 536 #D-function IGCM_sys_Put_Out 1130 537 #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly … … 1176 583 1177 584 #D-#================================================== 1178 #D-function IGCM_sys_PutBuffer_Out1179 #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly1180 #D-* Examples:1181 #D-1182 function IGCM_sys_PutBuffer_Out {1183 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@1184 if ( $DEBUG_sys ) ; then1185 echo "IGCM_sys_PutBuffer_Out :" $@1186 fi1187 1188 typeset NB_ESSAI DELAI status i exist skip1189 1190 # number of tentative1191 NB_ESSAI=31192 # time delay between tentative1193 DELAI=21194 1195 if [ $DRYRUN = 0 ]; then1196 if [ ! -f ${1} ] ; then1197 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."1198 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1199 return 11200 fi1201 #1202 IGCM_sys_Mkdir $( dirname $2 )1203 #1204 1205 exist=false1206 skip=false1207 if [ -f $2 ] ; then1208 IGCM_debug_Print 1 "$2 already exist"1209 exist=true1210 if [ "X$( diff $1 $2 )" = X ] ; then1211 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"1212 status=01213 skip=true1214 else1215 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"1216 skip=false1217 fi1218 fi1219 #1220 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then1221 IGCM_sys_Chmod u+w $21222 fi1223 1224 if [ X${skip} = Xfalse ] ; then1225 i=01226 while [ $i -lt $NB_ESSAI ] ; do1227 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then1228 # USUAL WAY1229 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11230 status=$?1231 else1232 # NOT SO USUAL WAY1233 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11234 status=$?1235 fi1236 if [ ${status} -gt 0 ]; then1237 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"1238 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."1239 [ -f ${2} ] && ls -l ${2}1240 [ -f ${2}/${1} ] && ls -l ${2}/${1}1241 sleep $DELAI1242 else1243 break1244 fi1245 (( i = i + 1 ))1246 done1247 fi1248 1249 if [ ${status} -gt 0 ] ; then1250 echo "IGCM_sys_PutBuffer_Out : error."1251 [ -f ${2} ] && ls -l ${2}1252 [ -f ${2}/${1} ] && ls -l ${2}/${1}1253 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1254 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"1255 else1256 1257 if [ X${JobType} = XRUN ] ; then1258 if [ X${3} = X ] ; then1259 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1260 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1261 fi1262 fi1263 1264 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1265 fi1266 fi1267 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1268 return 01269 }1270 1271 #D-#==================================================1272 585 #D-function IGCM_sys_Get 1273 586 #D-* Purpose: Get a file from ${ARCHIVE} … … 1315 628 1316 629 #D-#================================================== 1317 #D-function IGCM_sys_GetBuffer1318 #D-* Purpose: Get a file from ${SCRATCHDIR}1319 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX1320 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/1321 function IGCM_sys_GetBuffer {1322 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@1323 1324 typeset DEST buf_liste target file_work1325 typeset NB_ESSAI DELAI status i1326 1327 if ( $DEBUG_sys ) ; then1328 echo "IGCM_sys_GetBuffer :" $@1329 fi1330 1331 # number of tentative1332 NB_ESSAI=31333 # time delay between tentative1334 DELAI=21335 1336 if [ $DRYRUN -le 2 ]; then1337 if [ X${1} = X'/l' ] ; then1338 eval set +A buf_liste \${${2}}1339 else1340 eval set +A buf_liste ${1}1341 fi1342 eval DEST=\${${#}}1343 1344 #USUAL WAY1345 if [ X${1} = X'/l' ] ; then1346 for target in ${buf_liste[*]} ; do1347 local_file=$( basename ${target} )1348 i=01349 while [ $i -lt $NB_ESSAI ] ; do1350 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11351 status=$?1352 if [ ${status} -gt 0 ]; then1353 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1354 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1355 sleep $DELAI1356 else1357 break1358 fi1359 (( i = i + 1 ))1360 done1361 if [ ${status} -gt 0 ] ; then1362 echo "IGCM_sys_Get : error"1363 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1364 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1365 IGCM_debug_Exit "IGCM_sys_GetBuffer"1366 else1367 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1368 fi1369 done1370 else1371 i=01372 while [ $i -lt $NB_ESSAI ] ; do1373 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11374 status=$?1375 if [ ${status} -gt 0 ]; then1376 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1377 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1378 sleep $DELAI1379 else1380 break1381 fi1382 (( i = i + 1 ))1383 done1384 if [ ${status} -gt 0 ] ; then1385 echo "IGCM_sys_Get : error"1386 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1387 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1388 IGCM_debug_Exit "IGCM_sys_GetBuffer"1389 else1390 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1391 fi1392 fi1393 fi1394 IGCM_debug_PopStack "IGCM_sys_GetBuffer"1395 }1396 1397 #D-#==================================================1398 #D-function IGCM_sys_GetDate_FichWork1399 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK1400 #D-* Examples:1401 #D-1402 function IGCM_sys_GetDate_FichWork {1403 IGCM_debug_PushStack "IGCM_sys_FichWork" $@1404 if ( $DEBUG_sys ) ; then1405 echo "IGCM_sys_GetDate_FichWork :" $@1406 fi1407 1408 if [ $# -ge 3 ] ; then1409 mode=$31410 TimeStyle=$41411 else1412 mode="default"1413 TimeStyle="%Y%m%d%H%M%S"1414 fi1415 1416 typeset dateF1417 set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )1418 1419 case $mode in1420 "default")1421 eval ${2}=${dateF[5]}1422 ;;1423 "SplitFields")1424 eval ${2}="${dateF[5]}\ ${dateF[6]}"1425 ;;1426 esac1427 1428 1429 # donne la date filesys d'un fichier sur la machine work1430 IGCM_debug_PopStack "IGCM_sys_FichWork"1431 }1432 1433 #D-#==================================================1434 #D-function IGCM_sys_GetDate_FichArchive1435 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE1436 #D-* Examples:1437 #D-1438 function IGCM_sys_GetDate_FichArchive {1439 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@1440 if ( $DEBUG_sys ) ; then1441 echo "IGCM_sys_GetDate_FichArchive :" $@1442 fi1443 typeset dateF1444 set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )1445 eval ${2}=${dateF[5]}1446 1447 IGCM_debug_PopStack "IGCM_sys_FichArchive"1448 }1449 1450 #D-#==================================================1451 630 #D-function IGCM_sys_GetDate_Monitoring 1452 631 #D-* Purpose: get the last year for which the monitoring has been computed … … 1516 695 fi 1517 696 IGCM_debug_PopStack "IGCM_sys_sync" 1518 }1519 1520 #D-#==================================================1521 #D-function IGCM_sys_rebuild1522 #D-* Purpose: rebuild parallel files1523 #D-* Examples:1524 #D-1525 function IGCM_sys_rebuild {1526 IGCM_debug_PushStack "IGCM_sys_rebuild" $@1527 if ( $DEBUG_sys ) ; then1528 echo "IGCM_sys_rebuild :" $@1529 fi1530 1531 typeset NB_ESSAI DELAI status i firstArg1532 # number of tentative1533 NB_ESSAI=31534 # time delay between tentative1535 DELAI=21536 1537 i=01538 while [ $i -lt $NB_ESSAI ] ; do1539 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11540 status=$?1541 if [ ${status} -gt 0 ] ; then1542 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"1543 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1544 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1545 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1546 firstArg=${1}1547 \rm ${firstArg}1548 sleep $DELAI1549 else1550 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1551 break1552 fi1553 (( i = i + 1 ))1554 done1555 1556 if [ ${status} -gt 0 ] ; then1557 echo "IGCM_sys_rebuild : rebuild error code is ${status}"1558 IGCM_debug_Exit "rebuild"1559 fi1560 1561 IGCM_debug_PopStack "IGCM_sys_rebuild"1562 }1563 1564 #D-#==================================================1565 #D-function IGCM_sys_rebuild_station1566 #D-* Purpose: rebuild parallel files describing station1567 #D-* Examples:1568 #D-1569 function IGCM_sys_rebuild_station {1570 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@1571 typeset i list_opt file_in file_out prefix_invert list_invert1572 if ( $DEBUG_sys ) ; then1573 echo "IGCM_sys_rebuild_station :" $@1574 fi1575 list_opt=$@1576 1577 # Invert Axis : t,x -> x,t1578 # t,pres,x -> x,t,pres1579 # So that we can concatenate along x1580 i=01581 for file_in in ${list_opt} ; do1582 (( i = i + 1))1583 [ ${i} = 1 ] && file_out=${file_in} && continue1584 # detect time counter and do the job only if present1585 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')1586 if [ X${var_unlim} = Xtime_counter ] ; then1587 prefix_invert=$( basename ${file_in} .nc )1588 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc1589 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc1590 fi1591 done1592 1593 # Concatenate1594 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc1595 1596 # Re-ivert file1597 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}1598 1599 # Station re-ordering is too expansive to be run within libIGCM1600 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.1601 # This re-ordering must be done "in memory" by the cmorization process1602 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)1603 # BEGIN reordering1604 1605 # Only LMDZ text output contains the exact ordering of the station.1606 # We isolate this in the code below:1607 # 0 38 -157.5000000000000 70.985915492957741608 # 0 54 27.49999999999999 67.183098591549281609 # 0 56 -62.50000000000001 82.394366197183091610 # 0 79 12.49999999999999 78.591549295774661611 # 0 116 -165.0000000000000 76.056338028169011612 # 0 117 130.0000000000000 70.985915492957741613 # 0 118 110.0000000000000 87.464788732394371614 # 1 40 4.999999999999995 51.971830985915501615 1616 # typeset iStation iProc list_opt file_in file_out prefix_invert1617 # typeset -Z4 j41618 # typeset -Z3 j31619 1620 # unset list_opt1621 # set +A list_opt $@1622 1623 # Filename after rebuild1624 # file_out=${list_opt[0]}1625 # Prefix of output files1626 # prefix_invert=$( basename ${file_out} .nc )1627 # Number of procs1628 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )1629 1630 # iProc=01631 # while [ ${iProc} -lt ${num_proc} ] ; do1632 # Array containing Station as a number1633 # unset proc_stn1634 # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )1635 # Number of stations produced by processor proc1636 # stationLast=${#proc_stn[*]}1637 # Proc number on 4 digits1638 # j4=${iProc}1639 # Init1640 # iStation=01641 # while [ ${iStation} -lt ${stationLast} ] ; do1642 # Station number on 3 digits1643 # j3=${proc_stn[${iStation}]}1644 # Extract station1645 # Invert Axis : t,x -> x,t1646 # t,pres,x -> x,t,pres1647 # So that we can concatenate along x1648 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc1649 # (( iStation = iStation + 1 ))1650 # done1651 # (( iProc = iProc + 1 ))1652 # done1653 1654 # Concatenate all station along x1655 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc1656 1657 # Re-invert file1658 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}1659 1660 # END reordering1661 1662 IGCM_debug_PopStack "IGCM_sys_rebuild_station"1663 697 } 1664 698 … … 2042 1076 IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 2043 1077 } 2044 2045 ##############################################################2046 # NCO OPERATOR2047 2048 #D-#==================================================2049 #D-function IGCM_sys_ncap22050 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry2051 #D-* Examples:2052 #D-2053 function IGCM_sys_ncap2 {2054 IGCM_debug_PushStack "IGCM_sys_ncap2" $@2055 if ( $DEBUG_sys ) ; then2056 echo "IGCM_sys_ncap2 :" $@2057 fi2058 2059 typeset NB_ESSAI DELAI status i2060 # number of tentative2061 NB_ESSAI=32062 # time delay between tentative2063 DELAI=22064 2065 i=02066 while [ $i -lt $NB_ESSAI ] ; do2067 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12068 status=$?2069 if [ ${status} -gt 0 ] ; then2070 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"2071 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2072 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2073 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2074 sleep $DELAI2075 else2076 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2077 break2078 fi2079 (( i = i + 1 ))2080 done2081 2082 if [ ${status} -gt 0 ] ; then2083 echo "IGCM_sys_ncap2 : ncap2 error"2084 IGCM_debug_Exit "ncap2"2085 fi2086 2087 IGCM_debug_PopStack "IGCM_sys_ncap2"2088 }2089 2090 #D-#==================================================2091 #D-function IGCM_sys_ncatted2092 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry2093 #D-* Examples:2094 #D-2095 function IGCM_sys_ncatted {2096 IGCM_debug_PushStack "IGCM_sys_ncatted" $@2097 if ( $DEBUG_sys ) ; then2098 echo "IGCM_sys_ncatted :" $@2099 fi2100 2101 typeset NB_ESSAI DELAI status i2102 # number of tentative2103 NB_ESSAI=32104 # time delay between tentative2105 DELAI=22106 2107 i=02108 while [ $i -lt $NB_ESSAI ] ; do2109 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12110 status=$?2111 if [ ${status} -gt 0 ] ; then2112 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"2113 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2114 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2115 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2116 sleep $DELAI2117 else2118 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2119 break2120 fi2121 (( i = i + 1 ))2122 done2123 2124 if [ ${status} -gt 0 ] ; then2125 echo "IGCM_sys_ncatted : ncatted error"2126 IGCM_debug_Exit "ncatted"2127 fi2128 2129 IGCM_debug_PopStack "IGCM_sys_ncatted"2130 }2131 2132 #D-#==================================================2133 #D-function IGCM_sys_ncbo2134 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry2135 #D-* Examples:2136 #D-2137 function IGCM_sys_ncbo {2138 IGCM_debug_PushStack "IGCM_sys_ncbo" $@2139 if ( $DEBUG_sys ) ; then2140 echo "IGCM_sys_ncbo :" $@2141 fi2142 2143 typeset NB_ESSAI DELAI status i2144 # number of tentative2145 NB_ESSAI=32146 # time delay between tentative2147 DELAI=22148 2149 i=02150 while [ $i -lt $NB_ESSAI ] ; do2151 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12152 status=$?2153 if [ ${status} -gt 0 ] ; then2154 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"2155 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2156 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2157 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2158 sleep $DELAI2159 else2160 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2161 break2162 fi2163 (( i = i + 1 ))2164 done2165 2166 if [ ${status} -gt 0 ] ; then2167 echo "IGCM_sys_ncbo : ncbo error"2168 IGCM_debug_Exit "ncbo"2169 fi2170 2171 IGCM_debug_PopStack "IGCM_sys_ncbo"2172 }2173 2174 #D-#==================================================2175 #D-function IGCM_sys_ncdif2176 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry2177 #D-* Examples:2178 #D-2179 function IGCM_sys_ncdiff {2180 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@2181 if ( $DEBUG_sys ) ; then2182 echo "IGCM_sys_ncdiff :" $@2183 fi2184 2185 typeset NB_ESSAI DELAI status i2186 # number of tentative2187 NB_ESSAI=32188 # time delay between tentative2189 DELAI=22190 2191 i=02192 while [ $i -lt $NB_ESSAI ] ; do2193 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12194 status=$?2195 if [ ${status} -gt 0 ] ; then2196 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"2197 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2198 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2199 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2200 sleep $DELAI2201 else2202 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2203 break2204 fi2205 (( i = i + 1 ))2206 done2207 2208 if [ ${status} -gt 0 ] ; then2209 echo "IGCM_sys_ncdiff : ncdiff error"2210 IGCM_debug_Exit "ncdiff"2211 fi2212 2213 IGCM_debug_PopStack "IGCM_sys_ncdiff"2214 }2215 2216 #D-#==================================================2217 #D-function IGCM_sys_ncea2218 #D-* Purpose: encapsulate ncea call so as to manage error code and retry2219 #D-* Examples:2220 #D-2221 function IGCM_sys_ncea {2222 IGCM_debug_PushStack "IGCM_sys_ncea" $@2223 if ( $DEBUG_sys ) ; then2224 echo "IGCM_sys_ncea :" $@2225 fi2226 2227 typeset NB_ESSAI DELAI status i2228 # number of tentative2229 NB_ESSAI=32230 # time delay between tentative2231 DELAI=22232 2233 i=02234 while [ $i -lt $NB_ESSAI ] ; do2235 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12236 status=$?2237 if [ ${status} -gt 0 ] ; then2238 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"2239 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2240 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2241 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2242 sleep $DELAI2243 else2244 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2245 break2246 fi2247 (( i = i + 1 ))2248 done2249 2250 if [ ${status} -gt 0 ] ; then2251 echo "IGCM_sys_ncea : ncea error"2252 IGCM_debug_Exit "ncea"2253 fi2254 2255 IGCM_debug_PopStack "IGCM_sys_ncea"2256 }2257 2258 #D-#==================================================2259 #D-function IGCM_sys_ncecat2260 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry2261 #D-* Examples:2262 #D-2263 function IGCM_sys_ncecat {2264 IGCM_debug_PushStack "IGCM_sys_ncecat" $@2265 if ( $DEBUG_sys ) ; then2266 echo "IGCM_sys_ncecat :" $@2267 fi2268 2269 typeset NB_ESSAI DELAI status i2270 # number of tentative2271 NB_ESSAI=32272 # time delay between tentative2273 DELAI=22274 2275 i=02276 while [ $i -lt $NB_ESSAI ] ; do2277 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12278 status=$?2279 if [ ${status} -gt 0 ] ; then2280 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"2281 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2282 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2283 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2284 sleep $DELAI2285 else2286 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2287 break2288 fi2289 (( i = i + 1 ))2290 done2291 2292 if [ ${status} -gt 0 ] ; then2293 echo "IGCM_sys_ncecat : ncecat error"2294 IGCM_debug_Exit "ncecat"2295 fi2296 2297 IGCM_debug_PopStack "IGCM_sys_ncecat"2298 }2299 2300 #D-#==================================================2301 #D-function IGCM_sys_ncflint2302 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry2303 #D-* Examples:2304 #D-2305 function IGCM_sys_ncflint {2306 IGCM_debug_PushStack "IGCM_sys_ncflint" $@2307 if ( $DEBUG_sys ) ; then2308 echo "IGCM_sys_ncflint :" $@2309 fi2310 2311 typeset NB_ESSAI DELAI status i2312 # number of tentative2313 NB_ESSAI=32314 # time delay between tentative2315 DELAI=22316 2317 i=02318 while [ $i -lt $NB_ESSAI ] ; do2319 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12320 status=$?2321 if [ ${status} -gt 0 ] ; then2322 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"2323 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2324 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2325 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2326 sleep $DELAI2327 else2328 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2329 break2330 fi2331 (( i = i + 1 ))2332 done2333 2334 if [ ${status} -gt 0 ] ; then2335 echo "IGCM_sys_ncflint : ncflint error"2336 IGCM_debug_Exit "ncflint"2337 fi2338 2339 IGCM_debug_PopStack "IGCM_sys_ncflint"2340 }2341 2342 #D-#==================================================2343 #D-function IGCM_sys_ncks2344 #D-* Purpose: encapsulate ncks call so as to manage error code and retry2345 #D-* Examples:2346 #D-2347 function IGCM_sys_ncks {2348 IGCM_debug_PushStack "IGCM_sys_ncks" $@2349 if ( $DEBUG_sys ) ; then2350 echo "IGCM_sys_ncks :" $@2351 fi2352 2353 typeset NB_ESSAI DELAI status i2354 # number of tentative2355 NB_ESSAI=32356 # time delay between tentative2357 DELAI=22358 2359 i=02360 while [ $i -lt $NB_ESSAI ] ; do2361 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12362 status=$?2363 if [ ${status} -gt 0 ] ; then2364 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"2365 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2366 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2367 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2368 sleep $DELAI2369 else2370 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2371 break2372 fi2373 (( i = i + 1 ))2374 done2375 2376 if [ ${status} -gt 0 ] ; then2377 echo "IGCM_sys_ncks : ncks error"2378 IGCM_debug_Exit "ncks"2379 fi2380 2381 IGCM_debug_PopStack "IGCM_sys_ncks"2382 }2383 2384 #D-#==================================================2385 #D-function IGCM_sys_ncpdq2386 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry2387 #D-* Examples:2388 #D-2389 function IGCM_sys_ncpdq {2390 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@2391 if ( $DEBUG_sys ) ; then2392 echo "IGCM_sys_ncpdq :" $@2393 fi2394 2395 typeset NB_ESSAI DELAI status i2396 # number of tentative2397 NB_ESSAI=32398 # time delay between tentative2399 DELAI=22400 2401 i=02402 while [ $i -lt $NB_ESSAI ] ; do2403 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12404 status=$?2405 if [ ${status} -gt 0 ] ; then2406 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"2407 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2408 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2409 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2410 sleep $DELAI2411 else2412 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2413 break2414 fi2415 (( i = i + 1 ))2416 done2417 2418 if [ ${status} -gt 0 ] ; then2419 echo "IGCM_sys_ncpdq : ncpdq error"2420 IGCM_debug_Exit "ncpdq"2421 fi2422 2423 IGCM_debug_PopStack "IGCM_sys_ncpdq"2424 }2425 2426 #D-#==================================================2427 #D-function IGCM_sys_ncra2428 #D-* Purpose: encapsulate ncra call so as to manage error code and retry2429 #D-* Examples:2430 #D-2431 function IGCM_sys_ncra {2432 IGCM_debug_PushStack "IGCM_sys_ncra" $@2433 if ( $DEBUG_sys ) ; then2434 echo "IGCM_sys_ncra :" $@2435 fi2436 2437 typeset NB_ESSAI DELAI status i2438 # number of tentative2439 NB_ESSAI=32440 # time delay between tentative2441 DELAI=22442 2443 i=02444 while [ $i -lt $NB_ESSAI ] ; do2445 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12446 status=$?2447 if [ ${status} -gt 0 ] ; then2448 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"2449 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2450 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2451 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2452 sleep $DELAI2453 else2454 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2455 break2456 fi2457 (( i = i + 1 ))2458 done2459 2460 if [ ${status} -gt 0 ] ; then2461 echo "IGCM_sys_ncra : ncra error"2462 IGCM_debug_Exit "ncra"2463 fi2464 2465 IGCM_debug_PopStack "IGCM_sys_ncra"2466 }2467 2468 #D-#==================================================2469 #D-function IGCM_sys_ncrcat2470 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry2471 #D-* Examples:2472 #D-2473 function IGCM_sys_ncrcat {2474 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@2475 if ( $DEBUG_sys ) ; then2476 echo "IGCM_sys_ncrcat :" $@2477 fi2478 2479 typeset NB_ESSAI DELAI status i lastArg2480 # number of tentative2481 NB_ESSAI=32482 # time delay between tentative2483 DELAI=22484 2485 i=02486 while [ $i -lt $NB_ESSAI ] ; do2487 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12488 status=$?2489 if [ ${status} -gt 0 ] ; then2490 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"2491 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2492 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2493 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2494 sleep $DELAI2495 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then2496 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"2497 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2498 # remove files having corrupted time axis2499 eval lastArg=\${$#}2500 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"2501 \rm ${lastArg}2502 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2503 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2504 sleep $DELAI2505 else2506 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2507 break2508 fi2509 (( i = i + 1 ))2510 done2511 2512 if [ ${status} -gt 0 ] ; then2513 echo "IGCM_sys_ncrcat : ncrcat error"2514 #IGCM_debug_Exit "ncrcat"2515 fi2516 2517 IGCM_debug_PopStack "IGCM_sys_ncrcat"2518 }2519 2520 #D-#==================================================2521 #D-function IGCM_sys_ncrename2522 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry2523 #D-* Examples:2524 #D-2525 function IGCM_sys_ncrename {2526 IGCM_debug_PushStack "IGCM_sys_ncrename" $@2527 if ( $DEBUG_sys ) ; then2528 echo "IGCM_sys_ncrename :" $@2529 fi2530 2531 typeset NB_ESSAI DELAI status i2532 # number of tentative2533 NB_ESSAI=32534 # time delay between tentative2535 DELAI=22536 2537 i=02538 while [ $i -lt $NB_ESSAI ] ; do2539 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12540 status=$?2541 if [ ${status} -gt 0 ] ; then2542 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"2543 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2544 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2545 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2546 sleep $DELAI2547 else2548 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2549 break2550 fi2551 (( i = i + 1 ))2552 done2553 2554 if [ ${status} -gt 0 ] ; then2555 echo "IGCM_sys_ncrename : ncrename error"2556 IGCM_debug_Exit "ncrename"2557 fi2558 2559 IGCM_debug_PopStack "IGCM_sys_ncrename"2560 }2561 2562 #D-#==================================================2563 #D-function IGCM_sys_ncwa2564 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry2565 #D-* Examples:2566 #D-2567 function IGCM_sys_ncwa {2568 IGCM_debug_PushStack "IGCM_sys_ncwa" $@2569 if ( $DEBUG_sys ) ; then2570 echo "IGCM_sys_ncwa :" $@2571 fi2572 2573 typeset NB_ESSAI DELAI status i2574 # number of tentative2575 NB_ESSAI=32576 # time delay between tentative2577 DELAI=22578 2579 i=02580 while [ $i -lt $NB_ESSAI ] ; do2581 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12582 status=$?2583 if [ ${status} -gt 0 ] ; then2584 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"2585 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2586 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2587 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2588 sleep $DELAI2589 else2590 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2591 break2592 fi2593 (( i = i + 1 ))2594 done2595 2596 if [ ${status} -gt 0 ] ; then2597 echo "IGCM_sys_ncwa : ncwa error"2598 IGCM_debug_Exit "ncwa"2599 fi2600 2601 IGCM_debug_PopStack "IGCM_sys_ncwa"2602 }2603 2604 ##############################################################2605 # CDO OPERATOR2606 2607 #D-#==================================================2608 #D-function IGCM_sys_cdo2609 #D-* Purpose: encapsulate cdo call so as to manage error code and retry2610 #D-* Examples:2611 #D-2612 function IGCM_sys_cdo {2613 IGCM_debug_PushStack "IGCM_sys_cdo" $@2614 if ( $DEBUG_sys ) ; then2615 echo "IGCM_sys_cdo :" $@2616 fi2617 2618 typeset status2619 2620 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12621 status=$?2622 if [ ${status} -gt 0 ] ; then2623 echo "IGCM_sys_cdo : error code ${status}"2624 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2625 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2626 IGCM_debug_PopStack "IGCM_sys_cdo"2627 return 12628 else2629 IGCM_debug_PopStack "IGCM_sys_cdo"2630 return 02631 fi2632 2633 IGCM_debug_PopStack "IGCM_sys_cdo"2634 } -
trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
r1180 r1181 205 205 206 206 #D-#================================================== 207 #D-function IGCM_sys_RshMaster208 #D-* Purpose: Connection to frontend machine.209 #D-* Examples:210 #D-211 function IGCM_sys_RshMaster {212 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@213 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF214 export libIGCM=${libIGCM}215 export DEBUG_debug=${DEBUG_debug}216 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh217 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh218 ${@}219 EOF220 if [ $? -gt 0 ] ; then221 echo "IGCM_sys_RshMaster : erreur."222 IGCM_debug_Exit "IGCM_sys_RshMaster"223 fi224 IGCM_debug_PopStack "IGCM_sys_RshMaster"225 }226 227 #D-#==================================================228 207 #D-function IGCM_sys_RshArchive 229 208 #D-* Purpose: Archive rsh command … … 258 237 259 238 #D-#================================================== 260 #D-function IGCM_sys_RshPost261 #D-* Purpose: Post-process rsh command262 #D-* Examples:263 #D-264 function IGCM_sys_RshPost {265 IGCM_debug_PushStack "IGCM_sys_RshPost" $@266 if ( $DEBUG_sys ) ; then267 echo "IGCM_sys_RshPost :" $@268 fi269 # keep standard input (stdin) for the loop onto temporary file270 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}271 272 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}273 if [ $? -gt 0 ] ; then274 echo "IGCM_sys_RshPost : erreur."275 IGCM_debug_Exit "IGCM_sys_RshPost"276 fi277 # delete temporary file278 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}279 280 IGCM_debug_PopStack "IGCM_sys_RshPost"281 }282 283 #D-#==================================================284 #D-function IGCM_sys_SendMail285 #D-* Purpose: Send mail when simulation is over286 #D-* Examples:287 #D-288 function IGCM_sys_SendMail {289 IGCM_debug_PushStack "IGCM_sys_SendMail" $@290 if ( $DEBUG_sys ) ; then291 echo "IGCM_sys_SendMail :" $@292 fi293 294 if [ X${1} = XAccounting ] ; then295 status=Accounting296 mailText=jobAccounting.mail297 elif ( ${ExitFlag} ) ; then298 status=failed299 mailText=jobEnd.mail300 else301 status=completed302 mailText=jobEnd.mail303 fi304 305 # Update selected mail template306 while read -r line; do307 eval echo $line >> mail.txt ;308 done < ${libIGCM}/libIGCM_sys/${mailText}309 310 if [ ! -z ${config_UserChoices_MailName} ] ; then311 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt312 elif [ -f ~/.forward ] ; then313 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt314 else315 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt316 fi317 318 sleep 10319 rm -f mail.txt320 321 IGCM_debug_PopStack "IGCM_sys_SendMail"322 }323 324 #D-#==================================================325 #D-function IGCM_sys_Mkdir326 #D-* Purpose: Master locale mkdir command327 #D-* Examples:328 #D-329 function IGCM_sys_Mkdir {330 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@331 if ( $DEBUG_sys ) ; then332 echo "IGCM_sys_Mkdir :" $@333 fi334 if [ ! -d ${1} ]; then335 \mkdir -p $1336 if [ $? -gt 0 ] ; then337 echo "IGCM_sys_Mkdir : erreur."338 IGCM_debug_Exit "IGCM_sys_Mkdir"339 fi340 fi341 # vérification :342 if [ ! -d ${1} ] ; then343 echo "IGCM_sys_Mkdir : erreur."344 IGCM_debug_Exit "IGCM_sys_Mkdir"345 fi346 IGCM_debug_PopStack "IGCM_sys_Mkdir"347 }348 349 #D-#==================================================350 239 #D-function IGCM_sys_MkdirArchive 351 240 #D-* Purpose: Mkdir on Archive … … 368 257 fi 369 258 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 370 }371 372 #D-#==================================================373 #D-function IGCM_sys_MkdirWork374 #D-* Purpose: Mkdir on Work375 #D-* Examples:376 #D-377 function IGCM_sys_MkdirWork {378 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@379 if ( $DEBUG_sys ) ; then380 echo "IGCM_sys_MkdirWork :" $@381 fi382 #- creation de repertoire sur le serveur fichier383 if [ ! -d ${1} ]; then384 \mkdir -p $1385 if [ $? -gt 0 ] ; then386 echo "IGCM_sys_MkdirWork : erreur."387 IGCM_debug_Exit "IGCM_sys_MkdirWork"388 fi389 fi390 IGCM_debug_PopStack "IGCM_sys_MkdirWork"391 }392 393 #D-#==================================================394 #D-function IGCM_sys_Cd395 #D-* Purpose: master cd command396 #D-* Examples:397 #D-398 function IGCM_sys_Cd {399 IGCM_debug_PushStack "IGCM_sys_Cd" $@400 if ( $DEBUG_sys ) ; then401 echo "IGCM_sys_Cd :" $@402 fi403 \cd $1404 if [ $? -gt 0 ] ; then405 echo "IGCM_sys_Cd : erreur."406 IGCM_debug_Exit "IGCM_sys_Cd"407 fi408 IGCM_debug_PopStack "IGCM_sys_Cd"409 }410 411 #D-#==================================================412 #D-function IGCM_sys_Chmod413 #D-* Purpose: Chmod414 #D-* Examples:415 #D-416 function IGCM_sys_Chmod {417 IGCM_debug_PushStack "IGCM_sys_Chmod" $@418 if ( $DEBUG_sys ) ; then419 echo "IGCM_sys_Chmod :" $@420 fi421 \chmod $@422 if [ $? -gt 0 ] ; then423 echo "IGCM_sys_Chmod : erreur."424 IGCM_debug_Exit "IGCM_sys_Chmod"425 fi426 IGCM_debug_PopStack "IGCM_sys_Chmod"427 }428 429 #D-#==================================================430 #D-function IGCM_sys_FileSize431 #D-* Purpose: Filesize432 #D-* Examples:433 #D-434 function IGCM_sys_FileSize {435 IGCM_debug_PushStack "IGCM_sys_FileSize" $@436 437 typeset sizeF438 set +A sizeF -- $( ls -la ${1} )439 if [ $? -gt 0 ] ; then440 IGCM_debug_Exit "IGCM_sys_FileSize"441 fi442 eval ${2}=${sizeF[4]}443 444 IGCM_debug_PopStack "IGCM_sys_FileSize"445 }446 447 #D-#==================================================448 #D-function IGCM_sys_TestDir449 #D-* Purpose: Test Directory that must exists450 #D-* Examples:451 #D-452 function IGCM_sys_TestDir {453 IGCM_debug_PushStack "IGCM_sys_TestDir" $@454 if ( $DEBUG_sys ) ; then455 echo "IGCM_sys_TestDir :" $@456 fi457 typeset ExistFlag458 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )459 IGCM_debug_PopStack "IGCM_sys_TestDir"460 461 return ${ExistFlag}462 259 } 463 260 … … 505 302 ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 506 303 IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 507 508 return ${ExistFlag}509 }510 511 #D-#==================================================512 #D-function IGCM_sys_TestFileBuffer513 #D-* Purpose: Test file that must NOT EXISTS on Buffer514 #D-* Examples:515 #D-516 function IGCM_sys_TestFileBuffer {517 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@518 typeset ExistFlag519 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )520 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"521 304 522 305 return ${ExistFlag} … … 546 329 547 330 #D-#================================================== 548 #D-function IGCM_sys_CountFileBuffer549 #D-* Purpose: Count files on Scratch filesystem550 #D-* Examples:551 #D-552 function IGCM_sys_CountFileBuffer {553 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@554 ls ${@} 2>/dev/null | wc -l555 if [ $? -gt 0 ] ; then556 echo "IGCM_sys_CountFileBuffer : erreur."557 fi558 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"559 }560 561 #D-#==================================================562 #D-function IGCM_sys_Tree563 #D-* Purpose: Tree directories with files on ${ARCHIVE}564 #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}565 #D-566 function IGCM_sys_Tree {567 IGCM_debug_PushStack "IGCM_sys_Tree" $@568 if ( $DEBUG_sys ) ; then569 echo "IGCM_sys_Tree :" $@570 fi571 572 \tree -f $@573 574 IGCM_debug_PopStack "IGCM_sys_Tree"575 }576 577 #D-#==================================================578 #D-function IGCM_sys_Tar579 #D-* Purpose: master tar command580 #D-* Examples:581 #D-582 function IGCM_sys_Tar {583 IGCM_debug_PushStack "IGCM_sys_Tar" $@584 if ( $DEBUG_sys ) ; then585 echo "IGCM_sys_Tar :" $@586 fi587 \tar cf $@588 if [ $? -gt 0 ] ; then589 echo "IGCM_sys_Tar : erreur."590 IGCM_debug_Exit "IGCM_sys_Tar"591 fi592 IGCM_debug_PopStack "IGCM_sys_Tar"593 }594 595 #D-#==================================================596 #D-function IGCM_sys_UnTar597 #D-* Purpose: master un-tar command598 #D-* Examples:599 #D-600 function IGCM_sys_UnTar {601 IGCM_debug_PushStack "IGCM_sys_UnTar" $@602 if ( $DEBUG_sys ) ; then603 echo "IGCM_sys_UnTar :" $@604 fi605 \tar xvf $1606 if [ $? -gt 0 ] ; then607 echo "IGCM_sys_UnTar : erreur."608 IGCM_debug_Exit "IGCM_sys_UnTar"609 fi610 IGCM_debug_PopStack "IGCM_sys_UnTar"611 }612 613 #D-#==================================================614 331 #D-function IGCM_sys_Qsub 615 332 #D-* Purpose: Qsub new job … … 683 400 684 401 #D-#================================================== 685 #D-function IGCM_sys_Rsync_out686 #D-* Purpose: treat return val of rsync687 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync688 #D- Error values and explanations can depend on your system version.689 function IGCM_sys_Rsync_out {690 status=$1691 if [ ! $status ] ; then692 echo "rsync error !"693 fi694 695 if [ $MYLANG = "fr" ]; then696 case $status in697 0) return ;;698 1) echo "Erreur de rsync ; RERR_SYNTAX : "699 echo "Erreur de syntaxe ou d'utilisation."700 return;;701 2) echo "Erreur de rsync ; RERR_PROTOCOL : "702 echo "Incompatibilité de protocole."703 return;;704 3) echo "Erreur de rsync ; RERR_FILESELECT 3"705 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et"706 echo "répertoires"707 return;;708 4) echo "Erreur de rsync ; RERR_UNSUPPORTED"709 echo "Action demandée non supportée : une tentative de manipulation de"710 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a"711 echo "été faite ; ou une option qui est supportée par le client mais"712 echo "pas par le serveur a été spécifiée."713 return;;714 10) echo "Erreur de rsync ; RERR_SOCKETIO"715 echo "Erreur dans le socket d'entrée sortie"716 return;;717 11) echo "Erreur de rsync ; RERR_FILEIO"718 echo "Erreur d'entrée sortie fichier"719 return;;720 12) echo "Erreur de rsync ; RERR_STREAMIO"721 echo "Erreur dans flux de donnée du protocole rsync"722 return;;723 13) echo "Erreur de rsync ; RERR_MESSAGEIO"724 echo "Erreur avec les diagnostics du programme"725 return;;726 14) echo "Erreur de rsync ; RERR_IPC"727 echo "Erreur dans le code IPC"728 return;;729 20) echo "Erreur de rsync ; RERR_SIGNAL"730 echo "SIGUSR1 ou SIGINT reçu"731 return;;732 21) echo "Erreur de rsync ; RERR_WAITCHILD"733 echo "Une erreur retournée par waitpid()"734 return;;735 22) echo "Erreur de rsync ; RERR_MALLOC"736 echo "Erreur lors de l'allocation des tampons de mémoire de coeur"737 return;;738 23) echo ""739 echo "Erreur fichier inexistant"740 return;;741 30) echo "Erreur de rsync ; RERR_TIMEOUT"742 echo "Temps d'attente écoulé dans l'envoi/réception de données"743 return;;744 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status745 return;;746 esac747 elif [ $MYLANG = "en" ] ; then748 case $status in749 0) return;;750 1) echo "rsync error : Syntax or usage error "751 return;;752 2) echo "rsync error : Protocol incompatibility "753 return;;754 3) echo "rsync error : Errors selecting input/output files, dirs"755 return;;756 4) echo "rsync error : Requested action not supported: an attempt"757 echo "was made to manipulate 64-bit files on a platform that cannot support"758 echo "them; or an option was specified that is supported by the client and"759 echo "not by the server."760 return;;761 5) echo "rsync error : Error starting client-server protocol"762 return;;763 10) echo "rsync error : Error in socket I/O "764 return;;765 11) echo "rsync error : Error in file I/O "766 return;;767 12) echo "rsync error : Error in rsync protocol data stream "768 return;;769 13) echo "rsync error : Errors with program diagnostics "770 return;;771 14) echo "rsync error : Error in IPC code "772 return;;773 20) echo "rsync error : Received SIGUSR1 or SIGINT "774 return;;775 21) echo "rsync error : Some error returned by waitpid() "776 return;;777 22) echo "rsync error : Error allocating core memory buffers "778 return;;779 23) echo "rsync error : Partial transfer due to error"780 return;;781 24) echo "rsync error : Partial transfer due to vanished source files"782 return;;783 30) echo "rsync error : Timeout in data send/receive "784 return;;785 *) echo "rsync error : return code of rsync unknown :" $status786 return;;787 esac788 else789 echo "unknown language $MYLANG."790 return791 fi792 }793 794 #D-#==================================================795 #D-function IGCM_sys_Miror_libIGCM796 #D-* Purpose: Mirror libIGCM PATH and lib to frontend797 #D-* Examples:798 #D-799 function IGCM_sys_Mirror_libIGCM {800 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"801 if ( $DEBUG_sys ) ; then802 echo "IGCM_sys_Mirror_libIGCM"803 fi804 805 typeset status806 807 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}808 809 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1810 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1811 status=$?812 813 if [ ${status} -gt 0 ] ; then814 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."815 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$816 fi817 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"818 }819 820 #D-#==================================================821 #D-function IGCM_sys_Cp822 #D-* Purpose: generic cp823 #D-* Examples:824 #D-825 function IGCM_sys_Cp {826 IGCM_debug_PushStack "IGCM_sys_Cp" $@827 if ( $DEBUG_sys ) ; then828 echo "IGCM_sys_Cp :" $@829 fi830 831 typeset status832 833 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1834 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1835 status=$?836 837 if [ ${status} -gt 0 ] ; then838 echo "IGCM_sys_Cp : error code ${status}"839 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$840 IGCM_debug_Exit "IGCM_sys_Cp"841 else842 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$843 fi844 IGCM_debug_PopStack "IGCM_sys_Cp"845 }846 847 #D-#==================================================848 #D-function IGCM_sys_Rm849 #D-* Purpose: generic rm850 #D-* Examples:851 #D-852 function IGCM_sys_Rm {853 IGCM_debug_PushStack "IGCM_sys_Rm" $@854 if ( $DEBUG_sys ) ; then855 echo "IGCM_sys_Rm :" $@856 fi857 858 typeset status859 860 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1861 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1862 status=$?863 864 if [ ${status} -gt 0 ] ; then865 echo "IGCM_sys_Rm : error code ${status}"866 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$867 IGCM_debug_Exit "IGCM_sys_Rm"868 else869 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$870 fi871 IGCM_debug_PopStack "IGCM_sys_Rm"872 }873 874 #D-#==================================================875 402 #D-function IGCM_sys_RmRunDir 876 403 #D-* Purpose: rm tmpdir (dummy function most of the time batch … … 901 428 902 429 #D-#================================================== 903 #D-function IGCM_sys_Mv904 #D-* Purpose: generic move905 #D-* Examples:906 #D-907 function IGCM_sys_Mv {908 IGCM_debug_PushStack "IGCM_sys_Mv" $@909 if ( $DEBUG_sys ) ; then910 echo "IGCM_sys_Mv :" $@911 fi912 913 if [ $DRYRUN = 0 ]; then914 915 typeset status916 917 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1918 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1919 status=$?920 921 if [ ${status} -gt 0 ] ; then922 echo "IGCM_sys_Mv : error code ${status}"923 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$924 IGCM_debug_Exit "IGCM_sys_Mv"925 else926 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$927 fi928 fi929 IGCM_debug_PopStack "IGCM_sys_Mv"930 }931 932 #D-#==================================================933 430 #D-function IGCM_sys_Put_Dir 934 431 #D-* Purpose: Copy a complete directory on $(ARCHIVE) … … 1000 497 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 1001 498 } 1002 1003 #D-#==================================================1004 #D-function IGCM_sys_Get_Master1005 #D-* Purpose: Copy a complete directory from MASTER filesystem1006 #D-* Examples:1007 #D-1008 function IGCM_sys_Get_Master {1009 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@1010 if ( $DEBUG_sys ) ; then1011 echo "IGCM_sys_Get_Master :" $@1012 fi1013 if [ $DRYRUN = 0 ]; then1014 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then1015 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."1016 IGCM_debug_PopStack "IGCM_sys_Get_Master"1017 return1018 fi1019 1020 typeset NB_ESSAI DELAI status i1021 # number of tentative1022 NB_ESSAI=31023 # time delay between tentative1024 DELAI=21025 1026 i=01027 while [ $i -lt $NB_ESSAI ] ; do1028 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11029 status=$?1030 if [ ${status} -gt 0 ]; then1031 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"1032 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."1033 sleep $DELAI1034 else1035 break1036 fi1037 (( i = i + 1 ))1038 done1039 1040 if [ ${status} -gt 0 ] ; then1041 echo "IGCM_sys_Get_Master : error."1042 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1043 IGCM_debug_Exit "IGCM_sys_Get_Master"1044 else1045 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1046 fi1047 fi1048 IGCM_debug_PopStack "IGCM_sys_Get_Master"1049 }1050 1051 #====================================================1052 #- Call IGCM_sys_Mirror_libIGCM now !1053 if ( $MirrorlibIGCM ) ; then1054 IGCM_sys_Mirror_libIGCM1055 fi1056 499 1057 500 #D-#================================================== … … 1097 540 1098 541 #D-#================================================== 1099 #D-function IGCM_sys_PutBuffer_Rest1100 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}.1101 #D- File and target directory must exist.1102 #D-* Examples:1103 #D-1104 function IGCM_sys_PutBuffer_Rest {1105 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@1106 if ( $DEBUG_sys ) ; then1107 echo "IGCM_sys_PutBuffer_Rest :" $@1108 fi1109 if [ $DRYRUN = 0 ]; then1110 if [ ! -f ${1} ] ; then1111 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."1112 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1113 fi1114 1115 typeset status1116 #1117 if [ X${JobType} = XRUN ] ; then1118 IGCM_sys_Chmod 444 ${1}1119 fi1120 1121 #1122 # USUAL WAY1123 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11124 status=$?1125 1126 if [ ${status} -gt 0 ] ; then1127 echo "IGCM_sys_PutBuffer_Rest : error code ${status}"1128 [ -f ${2} ] && ls -l ${2}1129 [ -f ${2}/${1} ] && ls -l ${2}/${1}1130 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1131 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1132 else1133 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1134 fi1135 fi1136 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"1137 }1138 1139 #D-#==================================================1140 #D-function IGCM_sys_PrepareTaredRestart1141 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here.1142 #D-* Examples:1143 #D-1144 function IGCM_sys_PrepareTaredRestart {1145 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@1146 1147 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"1148 }1149 1150 #D-#==================================================1151 542 #D-function IGCM_sys_Put_Out 1152 543 #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly … … 1189 580 fi 1190 581 IGCM_debug_PopStack "IGCM_sys_Put_Out" 1191 return 01192 }1193 1194 #D-#==================================================1195 #D-function IGCM_sys_PutBuffer_Out1196 #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly1197 #D-* Examples:1198 #D-1199 function IGCM_sys_PutBuffer_Out {1200 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@1201 if ( $DEBUG_sys ) ; then1202 echo "IGCM_sys_PutBuffer_Out :" $@1203 fi1204 1205 typeset NB_ESSAI DELAI status i exist skip1206 1207 # number of tentative1208 NB_ESSAI=31209 # time delay between tentative1210 DELAI=21211 1212 if [ $DRYRUN = 0 ]; then1213 if [ ! -f ${1} ] ; then1214 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."1215 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1216 return 11217 fi1218 #1219 IGCM_sys_Mkdir $( dirname $2 )1220 #1221 1222 exist=false1223 skip=false1224 if [ -f $2 ] ; then1225 IGCM_debug_Print 1 "$2 already exist"1226 exist=true1227 if [ "X$( diff $1 $2 )" = X ] ; then1228 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"1229 status=01230 skip=true1231 else1232 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"1233 skip=false1234 fi1235 fi1236 #1237 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then1238 IGCM_sys_Chmod u+w $21239 fi1240 1241 if [ X${skip} = Xfalse ] ; then1242 i=01243 while [ $i -lt $NB_ESSAI ] ; do1244 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then1245 # USUAL WAY1246 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11247 status=$?1248 else1249 # NOT SO USUAL WAY1250 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11251 status=$?1252 fi1253 if [ ${status} -gt 0 ]; then1254 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"1255 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."1256 [ -f ${2} ] && ls -l ${2}1257 [ -f ${2}/${1} ] && ls -l ${2}/${1}1258 sleep $DELAI1259 else1260 break1261 fi1262 (( i = i + 1 ))1263 done1264 fi1265 1266 if [ ${status} -gt 0 ] ; then1267 echo "IGCM_sys_PutBuffer_Out : error."1268 [ -f ${2} ] && ls -l ${2}1269 [ -f ${2}/${1} ] && ls -l ${2}/${1}1270 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1271 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"1272 else1273 1274 if [ X${JobType} = XRUN ] ; then1275 if [ X${3} = X ] ; then1276 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1277 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1278 fi1279 fi1280 1281 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1282 fi1283 fi1284 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1285 582 return 0 1286 583 } … … 1339 636 1340 637 #D-#================================================== 1341 #D-function IGCM_sys_GetBuffer1342 #D-* Purpose: Get a file from ${SCRATCHDIR}1343 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX1344 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/1345 function IGCM_sys_GetBuffer {1346 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@1347 1348 typeset DEST buf_liste target file_work1349 typeset NB_ESSAI DELAI status i1350 1351 if ( $DEBUG_sys ) ; then1352 echo "IGCM_sys_GetBuffer :" $@1353 fi1354 1355 # number of tentative1356 NB_ESSAI=31357 # time delay between tentative1358 DELAI=21359 1360 if [ $DRYRUN -le 2 ]; then1361 if [ X${1} = X'/l' ] ; then1362 eval set +A buf_liste \${${2}}1363 else1364 eval set +A buf_liste ${1}1365 fi1366 eval DEST=\${${#}}1367 1368 #USUAL WAY1369 if [ X${1} = X'/l' ] ; then1370 for target in ${buf_liste[*]} ; do1371 local_file=$( basename ${target} )1372 i=01373 while [ $i -lt $NB_ESSAI ] ; do1374 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11375 status=$?1376 if [ ${status} -gt 0 ]; then1377 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1378 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1379 sleep $DELAI1380 else1381 break1382 fi1383 (( i = i + 1 ))1384 done1385 if [ ${status} -gt 0 ] ; then1386 echo "IGCM_sys_Get : error"1387 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1388 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1389 IGCM_debug_Exit "IGCM_sys_GetBuffer"1390 else1391 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1392 fi1393 done1394 else1395 i=01396 while [ $i -lt $NB_ESSAI ] ; do1397 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11398 status=$?1399 if [ ${status} -gt 0 ]; then1400 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1401 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1402 sleep $DELAI1403 else1404 break1405 fi1406 (( i = i + 1 ))1407 done1408 if [ ${status} -gt 0 ] ; then1409 echo "IGCM_sys_Get : error"1410 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1411 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1412 IGCM_debug_Exit "IGCM_sys_GetBuffer"1413 else1414 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1415 fi1416 fi1417 fi1418 IGCM_debug_PopStack "IGCM_sys_GetBuffer"1419 }1420 1421 #D-#==================================================1422 #D-function IGCM_sys_GetDate_FichWork1423 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK1424 #D-* Examples:1425 #D-1426 function IGCM_sys_GetDate_FichWork {1427 IGCM_debug_PushStack "IGCM_sys_FichWork" $@1428 if ( $DEBUG_sys ) ; then1429 echo "IGCM_sys_GetDate_FichWork :" $@1430 fi1431 # donne la date filesys d'un fichier sur la machine work1432 IGCM_debug_PopStack "IGCM_sys_FichWork"1433 }1434 1435 #D-#==================================================1436 #D-function IGCM_sys_GetDate_FichArchive1437 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE1438 #D-* Examples:1439 #D-1440 function IGCM_sys_GetDate_FichArchive {1441 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@1442 if ( $DEBUG_sys ) ; then1443 echo "IGCM_sys_GetDate_FichArchive :" $@1444 fi1445 IGCM_debug_PopStack "IGCM_sys_FichArchive"1446 }1447 1448 #D-#==================================================1449 638 #D-function IGCM_sys_Dods_Rm 1450 639 #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. … … 1498 687 fi 1499 688 IGCM_debug_PopStack "IGCM_sys_sync" 1500 }1501 1502 #D-#==================================================1503 #D-function IGCM_sys_rebuild1504 #D-* Purpose: rebuild parallel files1505 #D-* Examples:1506 #D-1507 function IGCM_sys_rebuild {1508 IGCM_debug_PushStack "IGCM_sys_rebuild" $@1509 if ( $DEBUG_sys ) ; then1510 echo "IGCM_sys_rebuild :" $@1511 fi1512 1513 typeset NB_ESSAI DELAI status i firstArg1514 # number of tentative1515 NB_ESSAI=31516 # time delay between tentative1517 DELAI=21518 1519 i=01520 while [ $i -lt $NB_ESSAI ] ; do1521 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11522 status=$?1523 if [ ${status} -gt 0 ] ; then1524 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"1525 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1526 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1527 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1528 firstArg=${1}1529 \rm ${firstArg}1530 sleep $DELAI1531 else1532 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1533 break1534 fi1535 (( i = i + 1 ))1536 done1537 1538 if [ ${status} -gt 0 ] ; then1539 echo "IGCM_sys_rebuild : rebuild error code is ${status}"1540 IGCM_debug_Exit "rebuild"1541 fi1542 1543 IGCM_debug_PopStack "IGCM_sys_rebuild"1544 }1545 1546 #D-#==================================================1547 #D-function IGCM_sys_rebuild_station1548 #D-* Purpose: rebuild parallel files describing station1549 #D-* Examples:1550 #D-1551 function IGCM_sys_rebuild_station {1552 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@1553 typeset i list_opt file_in file_out prefix_invert list_invert1554 if ( $DEBUG_sys ) ; then1555 echo "IGCM_sys_rebuild_station :" $@1556 fi1557 list_opt=$@1558 1559 # Invert Axis : t,x -> x,t1560 # t,pres,x -> x,t,pres1561 # So that we can concatenate along x1562 i=01563 for file_in in ${list_opt} ; do1564 (( i = i + 1))1565 [ ${i} = 1 ] && file_out=${file_in} && continue1566 # detect time counter and do the job only if present1567 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')1568 if [ X${var_unlim} = Xtime_counter ] ; then1569 prefix_invert=$( basename ${file_in} .nc )1570 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc1571 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc1572 fi1573 done1574 1575 # Concatenate1576 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc1577 1578 # Re-ivert file1579 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}1580 1581 # Station re-ordering is too expansive to be run within libIGCM1582 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.1583 # This re-ordering must be done "in memory" by the cmorization process1584 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)1585 # BEGIN reordering1586 1587 # Only LMDZ text output contains the exact ordering of the station.1588 # We isolate this in the code below:1589 # 0 38 -157.5000000000000 70.985915492957741590 # 0 54 27.49999999999999 67.183098591549281591 # 0 56 -62.50000000000001 82.394366197183091592 # 0 79 12.49999999999999 78.591549295774661593 # 0 116 -165.0000000000000 76.056338028169011594 # 0 117 130.0000000000000 70.985915492957741595 # 0 118 110.0000000000000 87.464788732394371596 # 1 40 4.999999999999995 51.971830985915501597 1598 # typeset iStation iProc list_opt file_in file_out prefix_invert1599 # typeset -Z4 j41600 # typeset -Z3 j31601 1602 # unset list_opt1603 # set +A list_opt $@1604 1605 # Filename after rebuild1606 # file_out=${list_opt[0]}1607 # Prefix of output files1608 # prefix_invert=$( basename ${file_out} .nc )1609 # Number of procs1610 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )1611 1612 # iProc=01613 # while [ ${iProc} -lt ${num_proc} ] ; do1614 # Array containing Station as a number1615 # unset proc_stn1616 # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )1617 # Number of stations produced by processor proc1618 # stationLast=${#proc_stn[*]}1619 # Proc number on 4 digits1620 # j4=${iProc}1621 # Init1622 # iStation=01623 # while [ ${iStation} -lt ${stationLast} ] ; do1624 # Station number on 3 digits1625 # j3=${proc_stn[${iStation}]}1626 # Extract station1627 # Invert Axis : t,x -> x,t1628 # t,pres,x -> x,t,pres1629 # So that we can concatenate along x1630 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc1631 # (( iStation = iStation + 1 ))1632 # done1633 # (( iProc = iProc + 1 ))1634 # done1635 1636 # Concatenate all station along x1637 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc1638 1639 # Re-invert file1640 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}1641 1642 # END reordering1643 1644 IGCM_debug_PopStack "IGCM_sys_rebuild_station"1645 689 } 1646 690 … … 1925 969 IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 1926 970 } 1927 1928 ##############################################################1929 # NCO OPERATOR1930 1931 #D-#==================================================1932 #D-function IGCM_sys_ncap21933 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry1934 #D-* Examples:1935 #D-1936 function IGCM_sys_ncap2 {1937 IGCM_debug_PushStack "IGCM_sys_ncap2" $@1938 if ( $DEBUG_sys ) ; then1939 echo "IGCM_sys_ncap2 :" $@1940 fi1941 1942 typeset NB_ESSAI DELAI status i1943 # number of tentative1944 NB_ESSAI=31945 # time delay between tentative1946 DELAI=21947 1948 i=01949 while [ $i -lt $NB_ESSAI ] ; do1950 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11951 status=$?1952 if [ ${status} -gt 0 ] ; then1953 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"1954 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1955 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1956 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1957 sleep $DELAI1958 else1959 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1960 break1961 fi1962 (( i = i + 1 ))1963 done1964 1965 if [ ${status} -gt 0 ] ; then1966 echo "IGCM_sys_ncap2 : ncap2 error"1967 IGCM_debug_Exit "ncap2"1968 fi1969 1970 IGCM_debug_PopStack "IGCM_sys_ncap2"1971 }1972 1973 #D-#==================================================1974 #D-function IGCM_sys_ncatted1975 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry1976 #D-* Examples:1977 #D-1978 function IGCM_sys_ncatted {1979 IGCM_debug_PushStack "IGCM_sys_ncatted" $@1980 if ( $DEBUG_sys ) ; then1981 echo "IGCM_sys_ncatted :" $@1982 fi1983 1984 typeset NB_ESSAI DELAI status i1985 # number of tentative1986 NB_ESSAI=31987 # time delay between tentative1988 DELAI=21989 1990 i=01991 while [ $i -lt $NB_ESSAI ] ; do1992 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11993 status=$?1994 if [ ${status} -gt 0 ] ; then1995 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"1996 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1997 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1998 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1999 sleep $DELAI2000 else2001 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2002 break2003 fi2004 (( i = i + 1 ))2005 done2006 2007 if [ ${status} -gt 0 ] ; then2008 echo "IGCM_sys_ncatted : ncatted error"2009 IGCM_debug_Exit "ncatted"2010 fi2011 2012 IGCM_debug_PopStack "IGCM_sys_ncatted"2013 }2014 2015 #D-#==================================================2016 #D-function IGCM_sys_ncbo2017 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry2018 #D-* Examples:2019 #D-2020 function IGCM_sys_ncbo {2021 IGCM_debug_PushStack "IGCM_sys_ncbo" $@2022 if ( $DEBUG_sys ) ; then2023 echo "IGCM_sys_ncbo :" $@2024 fi2025 2026 typeset NB_ESSAI DELAI status i2027 # number of tentative2028 NB_ESSAI=32029 # time delay between tentative2030 DELAI=22031 2032 i=02033 while [ $i -lt $NB_ESSAI ] ; do2034 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12035 status=$?2036 if [ ${status} -gt 0 ] ; then2037 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"2038 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2039 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2040 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2041 sleep $DELAI2042 else2043 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2044 break2045 fi2046 (( i = i + 1 ))2047 done2048 2049 if [ ${status} -gt 0 ] ; then2050 echo "IGCM_sys_ncbo : ncbo error"2051 IGCM_debug_Exit "ncbo"2052 fi2053 2054 IGCM_debug_PopStack "IGCM_sys_ncbo"2055 }2056 2057 #D-#==================================================2058 #D-function IGCM_sys_ncdif2059 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry2060 #D-* Examples:2061 #D-2062 function IGCM_sys_ncdiff {2063 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@2064 if ( $DEBUG_sys ) ; then2065 echo "IGCM_sys_ncdiff :" $@2066 fi2067 2068 typeset NB_ESSAI DELAI status i2069 # number of tentative2070 NB_ESSAI=32071 # time delay between tentative2072 DELAI=22073 2074 i=02075 while [ $i -lt $NB_ESSAI ] ; do2076 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12077 status=$?2078 if [ ${status} -gt 0 ] ; then2079 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"2080 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2081 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2082 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2083 sleep $DELAI2084 else2085 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2086 break2087 fi2088 (( i = i + 1 ))2089 done2090 2091 if [ ${status} -gt 0 ] ; then2092 echo "IGCM_sys_ncdiff : ncdiff error"2093 IGCM_debug_Exit "ncdiff"2094 fi2095 2096 IGCM_debug_PopStack "IGCM_sys_ncdiff"2097 }2098 2099 #D-#==================================================2100 #D-function IGCM_sys_ncea2101 #D-* Purpose: encapsulate ncea call so as to manage error code and retry2102 #D-* Examples:2103 #D-2104 function IGCM_sys_ncea {2105 IGCM_debug_PushStack "IGCM_sys_ncea" $@2106 if ( $DEBUG_sys ) ; then2107 echo "IGCM_sys_ncea :" $@2108 fi2109 2110 typeset NB_ESSAI DELAI status i2111 # number of tentative2112 NB_ESSAI=32113 # time delay between tentative2114 DELAI=22115 2116 i=02117 while [ $i -lt $NB_ESSAI ] ; do2118 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12119 status=$?2120 if [ ${status} -gt 0 ] ; then2121 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"2122 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2123 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2124 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2125 sleep $DELAI2126 else2127 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2128 break2129 fi2130 (( i = i + 1 ))2131 done2132 2133 if [ ${status} -gt 0 ] ; then2134 echo "IGCM_sys_ncea : ncea error"2135 IGCM_debug_Exit "ncea"2136 fi2137 2138 IGCM_debug_PopStack "IGCM_sys_ncea"2139 }2140 2141 #D-#==================================================2142 #D-function IGCM_sys_ncecat2143 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry2144 #D-* Examples:2145 #D-2146 function IGCM_sys_ncecat {2147 IGCM_debug_PushStack "IGCM_sys_ncecat" $@2148 if ( $DEBUG_sys ) ; then2149 echo "IGCM_sys_ncecat :" $@2150 fi2151 2152 typeset NB_ESSAI DELAI status i2153 # number of tentative2154 NB_ESSAI=32155 # time delay between tentative2156 DELAI=22157 2158 i=02159 while [ $i -lt $NB_ESSAI ] ; do2160 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12161 status=$?2162 if [ ${status} -gt 0 ] ; then2163 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"2164 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2165 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2166 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2167 sleep $DELAI2168 else2169 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2170 break2171 fi2172 (( i = i + 1 ))2173 done2174 2175 if [ ${status} -gt 0 ] ; then2176 echo "IGCM_sys_ncecat : ncecat error"2177 IGCM_debug_Exit "ncecat"2178 fi2179 2180 IGCM_debug_PopStack "IGCM_sys_ncecat"2181 }2182 2183 #D-#==================================================2184 #D-function IGCM_sys_ncflint2185 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry2186 #D-* Examples:2187 #D-2188 function IGCM_sys_ncflint {2189 IGCM_debug_PushStack "IGCM_sys_ncflint" $@2190 if ( $DEBUG_sys ) ; then2191 echo "IGCM_sys_ncflint :" $@2192 fi2193 2194 typeset NB_ESSAI DELAI status i2195 # number of tentative2196 NB_ESSAI=32197 # time delay between tentative2198 DELAI=22199 2200 i=02201 while [ $i -lt $NB_ESSAI ] ; do2202 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12203 status=$?2204 if [ ${status} -gt 0 ] ; then2205 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"2206 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2207 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2208 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2209 sleep $DELAI2210 else2211 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2212 break2213 fi2214 (( i = i + 1 ))2215 done2216 2217 if [ ${status} -gt 0 ] ; then2218 echo "IGCM_sys_ncflint : ncflint error"2219 IGCM_debug_Exit "ncflint"2220 fi2221 2222 IGCM_debug_PopStack "IGCM_sys_ncflint"2223 }2224 2225 #D-#==================================================2226 #D-function IGCM_sys_ncks2227 #D-* Purpose: encapsulate ncks call so as to manage error code and retry2228 #D-* Examples:2229 #D-2230 function IGCM_sys_ncks {2231 IGCM_debug_PushStack "IGCM_sys_ncks" $@2232 if ( $DEBUG_sys ) ; then2233 echo "IGCM_sys_ncks :" $@2234 fi2235 2236 typeset NB_ESSAI DELAI status i2237 # number of tentative2238 NB_ESSAI=32239 # time delay between tentative2240 DELAI=22241 2242 i=02243 while [ $i -lt $NB_ESSAI ] ; do2244 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12245 status=$?2246 if [ ${status} -gt 0 ] ; then2247 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"2248 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2249 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2250 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2251 sleep $DELAI2252 else2253 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2254 break2255 fi2256 (( i = i + 1 ))2257 done2258 2259 if [ ${status} -gt 0 ] ; then2260 echo "IGCM_sys_ncks : ncks error"2261 IGCM_debug_Exit "ncks"2262 fi2263 2264 IGCM_debug_PopStack "IGCM_sys_ncks"2265 }2266 2267 #D-#==================================================2268 #D-function IGCM_sys_ncpdq2269 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry2270 #D-* Examples:2271 #D-2272 function IGCM_sys_ncpdq {2273 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@2274 if ( $DEBUG_sys ) ; then2275 echo "IGCM_sys_ncpdq :" $@2276 fi2277 2278 typeset NB_ESSAI DELAI status i2279 # number of tentative2280 NB_ESSAI=32281 # time delay between tentative2282 DELAI=22283 2284 i=02285 while [ $i -lt $NB_ESSAI ] ; do2286 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12287 status=$?2288 if [ ${status} -gt 0 ] ; then2289 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"2290 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2291 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2292 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2293 sleep $DELAI2294 else2295 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2296 break2297 fi2298 (( i = i + 1 ))2299 done2300 2301 if [ ${status} -gt 0 ] ; then2302 echo "IGCM_sys_ncpdq : ncpdq error"2303 IGCM_debug_Exit "ncpdq"2304 fi2305 2306 IGCM_debug_PopStack "IGCM_sys_ncpdq"2307 }2308 2309 #D-#==================================================2310 #D-function IGCM_sys_ncra2311 #D-* Purpose: encapsulate ncra call so as to manage error code and retry2312 #D-* Examples:2313 #D-2314 function IGCM_sys_ncra {2315 IGCM_debug_PushStack "IGCM_sys_ncra" $@2316 if ( $DEBUG_sys ) ; then2317 echo "IGCM_sys_ncra :" $@2318 fi2319 2320 typeset NB_ESSAI DELAI status i2321 # number of tentative2322 NB_ESSAI=32323 # time delay between tentative2324 DELAI=22325 2326 i=02327 while [ $i -lt $NB_ESSAI ] ; do2328 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12329 status=$?2330 if [ ${status} -gt 0 ] ; then2331 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"2332 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2333 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2334 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2335 sleep $DELAI2336 else2337 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2338 break2339 fi2340 (( i = i + 1 ))2341 done2342 2343 if [ ${status} -gt 0 ] ; then2344 echo "IGCM_sys_ncra : ncra error"2345 IGCM_debug_Exit "ncra"2346 fi2347 2348 IGCM_debug_PopStack "IGCM_sys_ncra"2349 }2350 2351 #D-#==================================================2352 #D-function IGCM_sys_ncrcat2353 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry2354 #D-* Examples:2355 #D-2356 function IGCM_sys_ncrcat {2357 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@2358 if ( $DEBUG_sys ) ; then2359 echo "IGCM_sys_ncrcat :" $@2360 fi2361 2362 typeset NB_ESSAI DELAI status i lastArg2363 # number of tentative2364 NB_ESSAI=32365 # time delay between tentative2366 DELAI=22367 2368 i=02369 while [ $i -lt $NB_ESSAI ] ; do2370 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12371 status=$?2372 if [ ${status} -gt 0 ] ; then2373 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"2374 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2375 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2376 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2377 sleep $DELAI2378 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then2379 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"2380 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2381 # remove files having corrupted time axis2382 eval lastArg=\${$#}2383 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"2384 \rm ${lastArg}2385 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2386 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2387 sleep $DELAI2388 else2389 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2390 break2391 fi2392 (( i = i + 1 ))2393 done2394 2395 if [ ${status} -gt 0 ] ; then2396 echo "IGCM_sys_ncrcat : ncrcat error"2397 #IGCM_debug_Exit "ncrcat"2398 fi2399 2400 IGCM_debug_PopStack "IGCM_sys_ncrcat"2401 }2402 2403 #D-#==================================================2404 #D-function IGCM_sys_ncrename2405 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry2406 #D-* Examples:2407 #D-2408 function IGCM_sys_ncrename {2409 IGCM_debug_PushStack "IGCM_sys_ncrename" $@2410 if ( $DEBUG_sys ) ; then2411 echo "IGCM_sys_ncrename :" $@2412 fi2413 2414 typeset NB_ESSAI DELAI status i2415 # number of tentative2416 NB_ESSAI=32417 # time delay between tentative2418 DELAI=22419 2420 i=02421 while [ $i -lt $NB_ESSAI ] ; do2422 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12423 status=$?2424 if [ ${status} -gt 0 ] ; then2425 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"2426 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2427 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2428 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2429 sleep $DELAI2430 else2431 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2432 break2433 fi2434 (( i = i + 1 ))2435 done2436 2437 if [ ${status} -gt 0 ] ; then2438 echo "IGCM_sys_ncrename : ncrename error"2439 IGCM_debug_Exit "ncrename"2440 fi2441 2442 IGCM_debug_PopStack "IGCM_sys_ncrename"2443 }2444 2445 #D-#==================================================2446 #D-function IGCM_sys_ncwa2447 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry2448 #D-* Examples:2449 #D-2450 function IGCM_sys_ncwa {2451 IGCM_debug_PushStack "IGCM_sys_ncwa" $@2452 if ( $DEBUG_sys ) ; then2453 echo "IGCM_sys_ncwa :" $@2454 fi2455 2456 typeset NB_ESSAI DELAI status i2457 # number of tentative2458 NB_ESSAI=32459 # time delay between tentative2460 DELAI=22461 2462 i=02463 while [ $i -lt $NB_ESSAI ] ; do2464 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12465 status=$?2466 if [ ${status} -gt 0 ] ; then2467 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"2468 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2469 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2470 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2471 sleep $DELAI2472 else2473 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2474 break2475 fi2476 (( i = i + 1 ))2477 done2478 2479 if [ ${status} -gt 0 ] ; then2480 echo "IGCM_sys_ncwa : ncwa error"2481 IGCM_debug_Exit "ncwa"2482 fi2483 2484 IGCM_debug_PopStack "IGCM_sys_ncwa"2485 }2486 2487 ##############################################################2488 # CDO OPERATOR2489 2490 #D-#==================================================2491 #D-function IGCM_sys_cdo2492 #D-* Purpose: encapsulate cdo call so as to manage error code and retry2493 #D-* Examples:2494 #D-2495 function IGCM_sys_cdo {2496 IGCM_debug_PushStack "IGCM_sys_cdo" $@2497 if ( $DEBUG_sys ) ; then2498 echo "IGCM_sys_cdo :" $@2499 fi2500 2501 typeset status2502 2503 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12504 status=$?2505 if [ ${status} -gt 0 ] ; then2506 echo "IGCM_sys_cdo : error code ${status}"2507 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2508 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2509 IGCM_debug_PopStack "IGCM_sys_cdo"2510 return 12511 else2512 IGCM_debug_PopStack "IGCM_sys_cdo"2513 return 02514 fi2515 2516 IGCM_debug_PopStack "IGCM_sys_cdo"2517 } -
trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh
r1180 r1181 217 217 218 218 #D-#================================================== 219 #D-function IGCM_sys_RshMaster220 #D-* Purpose: Connection to frontend machine.221 #D-* Examples:222 #D-223 function IGCM_sys_RshMaster {224 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@225 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF226 export libIGCM=${libIGCM}227 export DEBUG_debug=${DEBUG_debug}228 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh229 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh230 ${@}231 EOF232 if [ $? -gt 0 ] ; then233 echo "IGCM_sys_RshMaster : erreur."234 IGCM_debug_Exit "IGCM_sys_RshMaster"235 fi236 IGCM_debug_PopStack "IGCM_sys_RshMaster"237 }238 239 #D-#==================================================240 219 #D-function IGCM_sys_RshArchive 241 220 #D-* Purpose: Archive rsh command … … 264 243 IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@ 265 244 /bin/ksh <<-EOF 266 ${@} 2> \dev\null245 ${@} 2> /dev/null 267 246 EOF 268 247 IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError" 269 }270 271 #D-#==================================================272 #D-function IGCM_sys_RshPost273 #D-* Purpose: Post-process rsh command274 #D-* Examples:275 #D-276 function IGCM_sys_RshPost {277 IGCM_debug_PushStack "IGCM_sys_RshPost" $@278 if ( $DEBUG_sys ) ; then279 echo "IGCM_sys_RshPost :" $@280 fi281 # keep standard input (stdin) for the loop onto temporary file282 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}283 284 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}285 if [ $? -gt 0 ] ; then286 echo "IGCM_sys_RshPost : erreur."287 IGCM_debug_Exit "IGCM_sys_RshPost"288 fi289 # delete temporary file290 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}291 IGCM_debug_PopStack "IGCM_sys_RshPost"292 }293 294 #D-#==================================================295 #D-function IGCM_sys_SendMail296 #D-* Purpose: Send mail when simulation is over297 #D-* Examples:298 #D-299 function IGCM_sys_SendMail {300 IGCM_debug_PushStack "IGCM_sys_SendMail" $@301 if ( $DEBUG_sys ) ; then302 echo "IGCM_sys_SendMail :" $@303 fi304 305 if [ X${1} = XAccounting ] ; then306 status=Accounting307 mailText=jobAccounting.mail308 elif ( ${ExitFlag} ) ; then309 status=failed310 mailText=jobEnd.mail311 else312 status=completed313 mailText=jobEnd.mail314 fi315 316 # Update selected mail template317 while read -r line; do318 eval echo $line >> mail.txt ;319 done < ${libIGCM}/libIGCM_sys/${mailText}320 321 if [ ! -z ${config_UserChoices_MailName} ] ; then322 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt323 elif [ -f ~/.forward ] ; then324 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt325 else326 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt327 fi328 329 sleep 10330 rm -f mail.txt331 332 IGCM_debug_PopStack "IGCM_sys_SendMail"333 }334 335 #D-#==================================================336 #D-function IGCM_sys_Mkdir337 #D-* Purpose: Master locale mkdir command338 #D-* Examples:339 #D-340 function IGCM_sys_Mkdir {341 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@342 if ( $DEBUG_sys ) ; then343 echo "IGCM_sys_Mkdir :" $@344 fi345 if [ ! -d ${1} ]; then346 \mkdir -p $1347 if [ $? -gt 0 ] ; then348 echo "IGCM_sys_Mkdir : erreur."349 IGCM_debug_Exit "IGCM_sys_Mkdir"350 fi351 fi352 # vérification :353 if [ ! -d ${1} ] ; then354 echo "IGCM_sys_Mkdir : erreur."355 IGCM_debug_Exit "IGCM_sys_Mkdir"356 fi357 IGCM_debug_PopStack "IGCM_sys_Mkdir"358 248 } 359 249 … … 379 269 fi 380 270 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 381 }382 383 #D-#==================================================384 #D-function IGCM_sys_MkdirWork385 #D-* Purpose: Mkdir on Work386 #D-* Examples:387 #D-388 function IGCM_sys_MkdirWork {389 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@390 if ( $DEBUG_sys ) ; then391 echo "IGCM_sys_MkdirWork :" $@392 fi393 #- creation de repertoire sur le serveur fichier394 if [ ! -d ${1} ]; then395 \mkdir -p $1396 if [ $? -gt 0 ] ; then397 echo "IGCM_sys_MkdirWork : erreur."398 IGCM_debug_Exit "IGCM_sys_MkdirWork"399 fi400 fi401 IGCM_debug_PopStack "IGCM_sys_MkdirWork"402 }403 404 #D-#==================================================405 #D-function IGCM_sys_Cd406 #D-* Purpose: master cd command407 #D-* Examples:408 #D-409 function IGCM_sys_Cd {410 IGCM_debug_PushStack "IGCM_sys_Cd" $@411 if ( $DEBUG_sys ) ; then412 echo "IGCM_sys_Cd :" $@413 fi414 \cd $1415 if [ $? -gt 0 ] ; then416 echo "IGCM_sys_Cd : erreur."417 IGCM_debug_Exit "IGCM_sys_Cd"418 fi419 IGCM_debug_PopStack "IGCM_sys_Cd"420 }421 422 #D-#==================================================423 #D-function IGCM_sys_Chmod424 #D-* Purpose: Chmod425 #D-* Examples:426 #D-427 function IGCM_sys_Chmod {428 IGCM_debug_PushStack "IGCM_sys_Chmod" $@429 if ( $DEBUG_sys ) ; then430 echo "IGCM_sys_Chmod :" $@431 fi432 \chmod $@433 if [ $? -gt 0 ] ; then434 echo "IGCM_sys_Chmod : erreur."435 IGCM_debug_Exit "IGCM_sys_Chmod"436 fi437 IGCM_debug_PopStack "IGCM_sys_Chmod"438 }439 440 #D-#==================================================441 #D-function IGCM_sys_FileSize442 #D-* Purpose: Filesize443 #D-* Examples:444 #D-445 function IGCM_sys_FileSize {446 IGCM_debug_PushStack "IGCM_sys_FileSize" $@447 448 typeset sizeF449 set +A sizeF -- $( ls -la ${1} )450 if [ $? -gt 0 ] ; then451 IGCM_debug_Exit "IGCM_sys_FileSize"452 fi453 eval ${2}=${sizeF[4]}454 455 IGCM_debug_PopStack "IGCM_sys_FileSize"456 }457 458 #D-#==================================================459 #D-function IGCM_sys_TestDir460 #D-* Purpose: Test Directory that must exists461 #D-* Examples:462 #D-463 function IGCM_sys_TestDir {464 IGCM_debug_PushStack "IGCM_sys_TestDir" $@465 if ( $DEBUG_sys ) ; then466 echo "IGCM_sys_TestDir :" $@467 fi468 typeset ExistFlag469 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )470 IGCM_debug_PopStack "IGCM_sys_TestDir"471 472 return ${ExistFlag}473 271 } 474 272 … … 522 320 523 321 #D-#================================================== 524 #D-function IGCM_sys_TestFileBuffer525 #D-* Purpose: Test file that must NOT EXISTS on Buffer526 #D-* Examples:527 #D-528 function IGCM_sys_TestFileBuffer {529 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@530 typeset ExistFlag531 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )532 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"533 534 return ${ExistFlag}535 }536 537 #D-#==================================================538 322 #D-function IGCM_sys_CountFileArchive 539 323 #D-* Purpose: Count files on Archive filesystem … … 550 334 551 335 #D-#================================================== 552 #D-function IGCM_sys_CountFileBuffer553 #D-* Purpose: Count files on Scratch filesystem554 #D-* Examples:555 #D-556 function IGCM_sys_CountFileBuffer {557 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@558 ls ${@} 2>/dev/null | wc -l559 if [ $? -gt 0 ] ; then560 echo "IGCM_sys_CountFileBuffer : erreur."561 fi562 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"563 }564 565 #D-#==================================================566 336 #D-function IGCM_sys_Tree 567 337 #D-* Purpose: Tree directories with files on ${ARCHIVE} … … 577 347 578 348 IGCM_debug_PopStack "IGCM_sys_Tree" 579 }580 581 #D-#==================================================582 #D-function IGCM_sys_Tar583 #D-* Purpose: master tar command584 #D-* Examples:585 #D-586 function IGCM_sys_Tar {587 IGCM_debug_PushStack "IGCM_sys_Tar" $@588 if ( $DEBUG_sys ) ; then589 echo "IGCM_sys_Tar :" $@590 fi591 \tar cf $@592 if [ $? -gt 0 ] ; then593 echo "IGCM_sys_Tar : erreur."594 IGCM_debug_Exit "IGCM_sys_Tar"595 fi596 IGCM_debug_PopStack "IGCM_sys_Tar"597 }598 599 #D-#==================================================600 #D-function IGCM_sys_UnTar601 #D-* Purpose: master un-tar command602 #D-* Examples:603 #D-604 function IGCM_sys_UnTar {605 IGCM_debug_PushStack "IGCM_sys_UnTar" $@606 if ( $DEBUG_sys ) ; then607 echo "IGCM_sys_UnTar :" $@608 fi609 \tar xvf $1610 if [ $? -gt 0 ] ; then611 echo "IGCM_sys_UnTar : erreur."612 IGCM_debug_Exit "IGCM_sys_UnTar"613 fi614 IGCM_debug_PopStack "IGCM_sys_UnTar"615 349 } 616 350 … … 671 405 672 406 #D-#================================================== 673 #D-function IGCM_sys_Rsync_out674 #D-* Purpose: treat return val of rsync675 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync676 #D- Error values and explanations can depend on your system version.677 function IGCM_sys_Rsync_out {678 status=$1679 if [ ! $status ] ; then680 echo "rsync error !"681 fi682 683 if [ $MYLANG = "fr" ]; then684 case $status in685 0) return ;;686 1) echo "Erreur de rsync ; RERR_SYNTAX : "687 echo "Erreur de syntaxe ou d'utilisation."688 return;;689 2) echo "Erreur de rsync ; RERR_PROTOCOL : "690 echo "Incompatibilité de protocole."691 return;;692 3) echo "Erreur de rsync ; RERR_FILESELECT 3"693 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et"694 echo "répertoires"695 return;;696 4) echo "Erreur de rsync ; RERR_UNSUPPORTED"697 echo "Action demandée non supportée : une tentative de manipulation de"698 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a"699 echo "été faite ; ou une option qui est supportée par le client mais"700 echo "pas par le serveur a été spécifiée."701 return;;702 10) echo "Erreur de rsync ; RERR_SOCKETIO"703 echo "Erreur dans le socket d'entrée sortie"704 return;;705 11) echo "Erreur de rsync ; RERR_FILEIO"706 echo "Erreur d'entrée sortie fichier"707 return;;708 12) echo "Erreur de rsync ; RERR_STREAMIO"709 echo "Erreur dans flux de donnée du protocole rsync"710 return;;711 13) echo "Erreur de rsync ; RERR_MESSAGEIO"712 echo "Erreur avec les diagnostics du programme"713 return;;714 14) echo "Erreur de rsync ; RERR_IPC"715 echo "Erreur dans le code IPC"716 return;;717 20) echo "Erreur de rsync ; RERR_SIGNAL"718 echo "SIGUSR1 ou SIGINT reçu"719 return;;720 21) echo "Erreur de rsync ; RERR_WAITCHILD"721 echo "Une erreur retournée par waitpid()"722 return;;723 22) echo "Erreur de rsync ; RERR_MALLOC"724 echo "Erreur lors de l'allocation des tampons de mémoire de coeur"725 return;;726 23) echo ""727 echo "Erreur fichier inexistant"728 return;;729 30) echo "Erreur de rsync ; RERR_TIMEOUT"730 echo "Temps d'attente écoulé dans l'envoi/réception de données"731 return;;732 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status733 return;;734 esac735 elif [ $MYLANG = "en" ] ; then736 case $status in737 0) return;;738 1) echo "rsync error : Syntax or usage error "739 return;;740 2) echo "rsync error : Protocol incompatibility "741 return;;742 3) echo "rsync error : Errors selecting input/output files, dirs"743 return;;744 4) echo "rsync error : Requested action not supported: an attempt"745 echo "was made to manipulate 64-bit files on a platform that cannot support"746 echo "them; or an option was specified that is supported by the client and"747 echo "not by the server."748 return;;749 5) echo "rsync error : Error starting client-server protocol"750 return;;751 10) echo "rsync error : Error in socket I/O "752 return;;753 11) echo "rsync error : Error in file I/O "754 return;;755 12) echo "rsync error : Error in rsync protocol data stream "756 return;;757 13) echo "rsync error : Errors with program diagnostics "758 return;;759 14) echo "rsync error : Error in IPC code "760 return;;761 20) echo "rsync error : Received SIGUSR1 or SIGINT "762 return;;763 21) echo "rsync error : Some error returned by waitpid() "764 return;;765 22) echo "rsync error : Error allocating core memory buffers "766 return;;767 23) echo "rsync error : Partial transfer due to error"768 return;;769 24) echo "rsync error : Partial transfer due to vanished source files"770 return;;771 30) echo "rsync error : Timeout in data send/receive "772 return;;773 *) echo "rsync error : return code of rsync unknown :" $status774 return;;775 esac776 else777 echo "unknown language $MYLANG."778 return779 fi780 }781 782 #D-#==================================================783 #D-function IGCM_sys_Miror_libIGCM784 #D-* Purpose: Mirror libIGCM PATH and lib to frontend785 #D-* Examples:786 #D-787 function IGCM_sys_Mirror_libIGCM {788 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"789 if ( $DEBUG_sys ) ; then790 echo "IGCM_sys_Mirror_libIGCM"791 fi792 793 typeset status794 795 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}796 797 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1798 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1799 status=$?800 801 if [ ${status} -gt 0 ] ; then802 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."803 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$804 fi805 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"806 }807 808 #D-#==================================================809 #D-function IGCM_sys_Cp810 #D-* Purpose: generic cp811 #D-* Examples:812 #D-813 function IGCM_sys_Cp {814 IGCM_debug_PushStack "IGCM_sys_Cp" $@815 if ( $DEBUG_sys ) ; then816 echo "IGCM_sys_Cp :" $@817 fi818 819 typeset status820 821 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1822 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1823 status=$?824 825 if [ ${status} -gt 0 ] ; then826 echo "IGCM_sys_Cp : error code ${status}"827 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$828 IGCM_debug_Exit "IGCM_sys_Cp"829 else830 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$831 fi832 IGCM_debug_PopStack "IGCM_sys_Cp"833 }834 835 #D-#==================================================836 #D-function IGCM_sys_Rm837 #D-* Purpose: generic rm838 #D-* Examples:839 #D-840 function IGCM_sys_Rm {841 IGCM_debug_PushStack "IGCM_sys_Rm" $@842 if ( $DEBUG_sys ) ; then843 echo "IGCM_sys_Rm :" $@844 fi845 846 typeset status847 848 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1849 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1850 status=$?851 852 if [ ${status} -gt 0 ] ; then853 echo "IGCM_sys_Rm : error code ${status}"854 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$855 IGCM_debug_Exit "IGCM_sys_Rm"856 else857 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$858 fi859 IGCM_debug_PopStack "IGCM_sys_Rm"860 }861 862 #D-#==================================================863 407 #D-function IGCM_sys_RmRunDir 864 408 #D-* Purpose: rm tmpdir (dummy function most of the time batch … … 873 417 fi 874 418 IGCM_debug_PopStack "IGCM_sys_RmRunDir" 875 }876 877 #D-#==================================================878 #D-function IGCM_sys_Mv879 #D-* Purpose: generic move880 #D-* Examples:881 #D-882 function IGCM_sys_Mv {883 IGCM_debug_PushStack "IGCM_sys_Mv" $@884 if ( $DEBUG_sys ) ; then885 echo "IGCM_sys_Mv :" $@886 fi887 888 if [ $DRYRUN = 0 ]; then889 890 typeset status891 892 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1893 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1894 status=$?895 896 if [ ${status} -gt 0 ] ; then897 echo "IGCM_sys_Mv : error code ${status}"898 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$899 IGCM_debug_Exit "IGCM_sys_Mv"900 else901 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$902 fi903 fi904 IGCM_debug_PopStack "IGCM_sys_Mv"905 419 } 906 420 … … 987 501 988 502 #D-#================================================== 989 #D-function IGCM_sys_Get_Master990 #D-* Purpose: Copy a complete directory from MASTER filesystem991 #D-* Examples:992 #D-993 function IGCM_sys_Get_Master {994 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@995 if ( $DEBUG_sys ) ; then996 echo "IGCM_sys_Get_Master :" $@997 fi998 if [ $DRYRUN = 0 ]; then999 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then1000 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."1001 IGCM_debug_PopStack "IGCM_sys_Get_Master"1002 return1003 fi1004 1005 typeset NB_ESSAI DELAI status i1006 # number of tentative1007 NB_ESSAI=31008 # time delay between tentative1009 DELAI=21010 1011 i=01012 while [ $i -lt $NB_ESSAI ] ; do1013 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11014 status=$?1015 if [ ${status} -gt 0 ]; then1016 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"1017 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."1018 sleep $DELAI1019 else1020 break1021 fi1022 (( i = i + 1 ))1023 done1024 1025 if [ ${status} -gt 0 ] ; then1026 echo "IGCM_sys_Get_Master : error."1027 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1028 IGCM_debug_Exit "IGCM_sys_Get_Master"1029 else1030 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1031 fi1032 fi1033 IGCM_debug_PopStack "IGCM_sys_Get_Master"1034 }1035 1036 #====================================================1037 #- Call IGCM_sys_Mirror_libIGCM now !1038 if ( $MirrorlibIGCM ) ; then1039 IGCM_sys_Mirror_libIGCM1040 fi1041 1042 #D-#==================================================1043 503 #D-function IGCM_sys_Put_Rest 1044 504 #D-* Purpose: Put computied restarts on ${ARCHIVE}. … … 1098 558 1099 559 #D-#================================================== 1100 #D-function IGCM_sys_PutBuffer_Rest1101 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}.1102 #D- File and target directory must exist.1103 #D-* Examples:1104 #D-1105 function IGCM_sys_PutBuffer_Rest {1106 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@1107 if ( $DEBUG_sys ) ; then1108 echo "IGCM_sys_PutBuffer_Rest :" $@1109 fi1110 if [ $DRYRUN = 0 ]; then1111 if [ ! -f ${1} ] ; then1112 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."1113 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1114 fi1115 1116 typeset status1117 #1118 # USUAL WAY1119 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11120 status=$?1121 1122 if [ ${status} -gt 0 ] ; then1123 echo "IGCM_sys_PutBuffer_Rest : error code ${status}"1124 [ -f ${2} ] && ls -l ${2}1125 [ -f ${2}/${1} ] && ls -l ${2}/${1}1126 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1127 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1128 else1129 1130 if [ X${JobType} = XRUN ] ; then1131 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1132 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1133 fi1134 1135 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1136 fi1137 fi1138 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"1139 }1140 1141 #D-#==================================================1142 #D-function IGCM_sys_PrepareTaredRestart1143 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here.1144 #D-* Examples:1145 #D-1146 function IGCM_sys_PrepareTaredRestart {1147 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@1148 1149 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"1150 }1151 1152 #D-#==================================================1153 560 #D-function IGCM_sys_Put_Out 1154 561 #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly … … 1200 607 1201 608 #D-#================================================== 1202 #D-function IGCM_sys_PutBuffer_Out1203 #D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly1204 #D-* Examples:1205 #D-1206 function IGCM_sys_PutBuffer_Out {1207 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@1208 if ( $DEBUG_sys ) ; then1209 echo "IGCM_sys_PutBuffer_Out :" $@1210 fi1211 1212 typeset NB_ESSAI DELAI status i exist skip1213 1214 # number of tentative1215 NB_ESSAI=31216 # time delay between tentative1217 DELAI=21218 1219 if [ $DRYRUN = 0 ]; then1220 if [ ! -f ${1} ] ; then1221 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."1222 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1223 return 11224 fi1225 #1226 IGCM_sys_Mkdir $( dirname $2 )1227 #1228 1229 exist=false1230 skip=false1231 if [ -f $2 ] ; then1232 IGCM_debug_Print 1 "$2 already exist"1233 exist=true1234 if [ "X$( diff $1 $2 )" = X ] ; then1235 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"1236 status=01237 skip=true1238 else1239 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"1240 skip=false1241 fi1242 fi1243 #1244 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then1245 IGCM_sys_Chmod u+w $21246 fi1247 1248 if [ X${skip} = Xfalse ] ; then1249 i=01250 while [ $i -lt $NB_ESSAI ] ; do1251 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then1252 # USUAL WAY1253 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11254 status=$?1255 else1256 # NOT SO USUAL WAY1257 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11258 status=$?1259 fi1260 if [ ${status} -gt 0 ]; then1261 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"1262 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."1263 [ -f ${2} ] && ls -l ${2}1264 [ -f ${2}/${1} ] && ls -l ${2}/${1}1265 sleep $DELAI1266 else1267 break1268 fi1269 (( i = i + 1 ))1270 done1271 fi1272 1273 if [ ${status} -gt 0 ] ; then1274 echo "IGCM_sys_PutBuffer_Out : error."1275 [ -f ${2} ] && ls -l ${2}1276 [ -f ${2}/${1} ] && ls -l ${2}/${1}1277 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1278 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"1279 else1280 1281 if [ X${JobType} = XRUN ] ; then1282 if [ X${3} = X ] ; then1283 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1284 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1285 fi1286 fi1287 1288 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1289 fi1290 fi1291 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1292 return 01293 }1294 1295 #D-#==================================================1296 609 #D-function IGCM_sys_Get 1297 610 #D-* Purpose: Get a file from ${ARCHIVE} … … 1339 652 1340 653 #D-#================================================== 1341 #D-function IGCM_sys_GetBuffer1342 #D-* Purpose: Get a file from ${SCRATCHDIR}1343 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX1344 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/1345 function IGCM_sys_GetBuffer {1346 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@1347 1348 typeset DEST buf_liste target file_work1349 typeset NB_ESSAI DELAI status i1350 1351 if ( $DEBUG_sys ) ; then1352 echo "IGCM_sys_GetBuffer :" $@1353 fi1354 1355 # number of tentative1356 NB_ESSAI=31357 # time delay between tentative1358 DELAI=21359 1360 if [ $DRYRUN -le 2 ]; then1361 if [ X${1} = X'/l' ] ; then1362 eval set +A buf_liste \${${2}}1363 else1364 eval set +A buf_liste ${1}1365 fi1366 eval DEST=\${${#}}1367 1368 #USUAL WAY1369 if [ X${1} = X'/l' ] ; then1370 for target in ${buf_liste[*]} ; do1371 local_file=$( basename ${target} )1372 i=01373 while [ $i -lt $NB_ESSAI ] ; do1374 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11375 status=$?1376 if [ ${status} -gt 0 ]; then1377 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1378 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1379 sleep $DELAI1380 else1381 break1382 fi1383 (( i = i + 1 ))1384 done1385 if [ ${status} -gt 0 ] ; then1386 echo "IGCM_sys_Get : error"1387 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1388 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1389 IGCM_debug_Exit "IGCM_sys_GetBuffer"1390 else1391 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1392 fi1393 done1394 else1395 i=01396 while [ $i -lt $NB_ESSAI ] ; do1397 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11398 status=$?1399 if [ ${status} -gt 0 ]; then1400 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1401 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1402 sleep $DELAI1403 else1404 break1405 fi1406 (( i = i + 1 ))1407 done1408 if [ ${status} -gt 0 ] ; then1409 echo "IGCM_sys_Get : error"1410 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1411 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1412 IGCM_debug_Exit "IGCM_sys_GetBuffer"1413 else1414 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1415 fi1416 fi1417 fi1418 IGCM_debug_PopStack "IGCM_sys_GetBuffer"1419 }1420 1421 #D-#==================================================1422 #D-function IGCM_sys_GetDate_FichWork1423 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK1424 #D-* Examples:1425 #D-1426 function IGCM_sys_GetDate_FichWork {1427 IGCM_debug_PushStack "IGCM_sys_FichWork" $@1428 if ( $DEBUG_sys ) ; then1429 echo "IGCM_sys_GetDate_FichWork :" $@1430 fi1431 1432 if [ $# -ge 3 ] ; then1433 mode=$31434 TimeStyle=$41435 else1436 mode="default"1437 TimeStyle="%Y%m%d%H%M%S"1438 fi1439 1440 typeset dateF1441 set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )1442 1443 case $mode in1444 "default")1445 eval ${2}=${dateF[5]}1446 ;;1447 "SplitFields")1448 eval ${2}="${dateF[5]}\ ${dateF[6]}"1449 ;;1450 esac1451 1452 1453 # donne la date filesys d'un fichier sur la machine work1454 IGCM_debug_PopStack "IGCM_sys_FichWork"1455 }1456 1457 #D-#==================================================1458 #D-function IGCM_sys_GetDate_FichArchive1459 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE1460 #D-* Examples:1461 #D-1462 function IGCM_sys_GetDate_FichArchive {1463 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@1464 if ( $DEBUG_sys ) ; then1465 echo "IGCM_sys_GetDate_FichArchive :" $@1466 fi1467 typeset dateF1468 set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )1469 eval ${2}=${dateF[5]}1470 1471 IGCM_debug_PopStack "IGCM_sys_FichArchive"1472 }1473 1474 #D-#==================================================1475 654 #D-function IGCM_sys_GetDate_Monitoring 1476 655 #D-* Purpose: get the last year for which the monitoring has been computed … … 1540 719 fi 1541 720 IGCM_debug_PopStack "IGCM_sys_sync" 1542 }1543 1544 #D-#==================================================1545 #D-function IGCM_sys_rebuild1546 #D-* Purpose: rebuild parallel files1547 #D-* Examples:1548 #D-1549 function IGCM_sys_rebuild {1550 IGCM_debug_PushStack "IGCM_sys_rebuild" $@1551 if ( $DEBUG_sys ) ; then1552 echo "IGCM_sys_rebuild :" $@1553 fi1554 1555 typeset NB_ESSAI DELAI status i firstArg1556 # number of tentative1557 NB_ESSAI=31558 # time delay between tentative1559 DELAI=21560 1561 i=01562 while [ $i -lt $NB_ESSAI ] ; do1563 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11564 status=$?1565 if [ ${status} -gt 0 ] ; then1566 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"1567 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1568 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1569 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1570 firstArg=${1}1571 \rm ${firstArg}1572 sleep $DELAI1573 else1574 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1575 break1576 fi1577 (( i = i + 1 ))1578 done1579 1580 if [ ${status} -gt 0 ] ; then1581 echo "IGCM_sys_rebuild : rebuild error code is ${status}"1582 IGCM_debug_Exit "rebuild"1583 fi1584 1585 IGCM_debug_PopStack "IGCM_sys_rebuild"1586 }1587 1588 #D-#==================================================1589 #D-function IGCM_sys_rebuild_station1590 #D-* Purpose: rebuild parallel files describing station1591 #D-* Examples:1592 #D-1593 function IGCM_sys_rebuild_station {1594 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@1595 typeset i list_opt file_in file_out prefix_invert list_invert1596 if ( $DEBUG_sys ) ; then1597 echo "IGCM_sys_rebuild_station :" $@1598 fi1599 list_opt=$@1600 1601 # Invert Axis : t,x -> x,t1602 # t,pres,x -> x,t,pres1603 # So that we can concatenate along x1604 i=01605 for file_in in ${list_opt} ; do1606 (( i = i + 1))1607 [ ${i} = 1 ] && file_out=${file_in} && continue1608 # detect time counter and do the job only if present1609 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')1610 if [ X${var_unlim} = Xtime_counter ] ; then1611 prefix_invert=$( basename ${file_in} .nc )1612 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc1613 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc1614 fi1615 done1616 1617 # Concatenate1618 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc1619 1620 # Re-ivert file1621 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}1622 1623 # Station re-ordering is too expansive to be run within libIGCM1624 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.1625 # This re-ordering must be done "in memory" by the cmorization process1626 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)1627 # BEGIN reordering1628 1629 # Only LMDZ text output contains the exact ordering of the station.1630 # We isolate this in the code below:1631 # 0 38 -157.5000000000000 70.985915492957741632 # 0 54 27.49999999999999 67.183098591549281633 # 0 56 -62.50000000000001 82.394366197183091634 # 0 79 12.49999999999999 78.591549295774661635 # 0 116 -165.0000000000000 76.056338028169011636 # 0 117 130.0000000000000 70.985915492957741637 # 0 118 110.0000000000000 87.464788732394371638 # 1 40 4.999999999999995 51.971830985915501639 1640 # typeset iStation iProc list_opt file_in file_out prefix_invert1641 # typeset -Z4 j41642 # typeset -Z3 j31643 1644 # unset list_opt1645 # set +A list_opt $@1646 1647 # Filename after rebuild1648 # file_out=${list_opt[0]}1649 # Prefix of output files1650 # prefix_invert=$( basename ${file_out} .nc )1651 # Number of procs1652 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )1653 1654 # iProc=01655 # while [ ${iProc} -lt ${num_proc} ] ; do1656 # Array containing Station as a number1657 # unset proc_stn1658 # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )1659 # Number of stations produced by processor proc1660 # stationLast=${#proc_stn[*]}1661 # Proc number on 4 digits1662 # j4=${iProc}1663 # Init1664 # iStation=01665 # while [ ${iStation} -lt ${stationLast} ] ; do1666 # Station number on 3 digits1667 # j3=${proc_stn[${iStation}]}1668 # Extract station1669 # Invert Axis : t,x -> x,t1670 # t,pres,x -> x,t,pres1671 # So that we can concatenate along x1672 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc1673 # (( iStation = iStation + 1 ))1674 # done1675 # (( iProc = iProc + 1 ))1676 # done1677 1678 # Concatenate all station along x1679 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc1680 1681 # Re-invert file1682 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}1683 1684 # END reordering1685 1686 IGCM_debug_PopStack "IGCM_sys_rebuild_station"1687 721 } 1688 722 … … 2085 1119 IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 2086 1120 } 2087 2088 ##############################################################2089 # NCO OPERATOR2090 2091 #D-#==================================================2092 #D-function IGCM_sys_ncap22093 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry2094 #D-* Examples:2095 #D-2096 function IGCM_sys_ncap2 {2097 IGCM_debug_PushStack "IGCM_sys_ncap2" $@2098 if ( $DEBUG_sys ) ; then2099 echo "IGCM_sys_ncap2 :" $@2100 fi2101 2102 typeset NB_ESSAI DELAI status i2103 # number of tentative2104 NB_ESSAI=32105 # time delay between tentative2106 DELAI=22107 2108 i=02109 while [ $i -lt $NB_ESSAI ] ; do2110 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12111 status=$?2112 if [ ${status} -gt 0 ] ; then2113 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"2114 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2115 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2116 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2117 sleep $DELAI2118 else2119 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2120 break2121 fi2122 (( i = i + 1 ))2123 done2124 2125 if [ ${status} -gt 0 ] ; then2126 echo "IGCM_sys_ncap2 : ncap2 error"2127 IGCM_debug_Exit "ncap2"2128 fi2129 2130 IGCM_debug_PopStack "IGCM_sys_ncap2"2131 }2132 2133 #D-#==================================================2134 #D-function IGCM_sys_ncatted2135 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry2136 #D-* Examples:2137 #D-2138 function IGCM_sys_ncatted {2139 IGCM_debug_PushStack "IGCM_sys_ncatted" $@2140 if ( $DEBUG_sys ) ; then2141 echo "IGCM_sys_ncatted :" $@2142 fi2143 2144 typeset NB_ESSAI DELAI status i2145 # number of tentative2146 NB_ESSAI=32147 # time delay between tentative2148 DELAI=22149 2150 i=02151 while [ $i -lt $NB_ESSAI ] ; do2152 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12153 status=$?2154 if [ ${status} -gt 0 ] ; then2155 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"2156 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2157 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2158 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2159 sleep $DELAI2160 else2161 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2162 break2163 fi2164 (( i = i + 1 ))2165 done2166 2167 if [ ${status} -gt 0 ] ; then2168 echo "IGCM_sys_ncatted : ncatted error"2169 IGCM_debug_Exit "ncatted"2170 fi2171 2172 IGCM_debug_PopStack "IGCM_sys_ncatted"2173 }2174 2175 #D-#==================================================2176 #D-function IGCM_sys_ncbo2177 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry2178 #D-* Examples:2179 #D-2180 function IGCM_sys_ncbo {2181 IGCM_debug_PushStack "IGCM_sys_ncbo" $@2182 if ( $DEBUG_sys ) ; then2183 echo "IGCM_sys_ncbo :" $@2184 fi2185 2186 typeset NB_ESSAI DELAI status i2187 # number of tentative2188 NB_ESSAI=32189 # time delay between tentative2190 DELAI=22191 2192 i=02193 while [ $i -lt $NB_ESSAI ] ; do2194 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12195 status=$?2196 if [ ${status} -gt 0 ] ; then2197 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"2198 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2199 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2200 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2201 sleep $DELAI2202 else2203 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2204 break2205 fi2206 (( i = i + 1 ))2207 done2208 2209 if [ ${status} -gt 0 ] ; then2210 echo "IGCM_sys_ncbo : ncbo error"2211 IGCM_debug_Exit "ncbo"2212 fi2213 2214 IGCM_debug_PopStack "IGCM_sys_ncbo"2215 }2216 2217 #D-#==================================================2218 #D-function IGCM_sys_ncdif2219 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry2220 #D-* Examples:2221 #D-2222 function IGCM_sys_ncdiff {2223 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@2224 if ( $DEBUG_sys ) ; then2225 echo "IGCM_sys_ncdiff :" $@2226 fi2227 2228 typeset NB_ESSAI DELAI status i2229 # number of tentative2230 NB_ESSAI=32231 # time delay between tentative2232 DELAI=22233 2234 i=02235 while [ $i -lt $NB_ESSAI ] ; do2236 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12237 status=$?2238 if [ ${status} -gt 0 ] ; then2239 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"2240 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2241 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2242 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2243 sleep $DELAI2244 else2245 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2246 break2247 fi2248 (( i = i + 1 ))2249 done2250 2251 if [ ${status} -gt 0 ] ; then2252 echo "IGCM_sys_ncdiff : ncdiff error"2253 IGCM_debug_Exit "ncdiff"2254 fi2255 2256 IGCM_debug_PopStack "IGCM_sys_ncdiff"2257 }2258 2259 #D-#==================================================2260 #D-function IGCM_sys_ncea2261 #D-* Purpose: encapsulate ncea call so as to manage error code and retry2262 #D-* Examples:2263 #D-2264 function IGCM_sys_ncea {2265 IGCM_debug_PushStack "IGCM_sys_ncea" $@2266 if ( $DEBUG_sys ) ; then2267 echo "IGCM_sys_ncea :" $@2268 fi2269 2270 typeset NB_ESSAI DELAI status i2271 # number of tentative2272 NB_ESSAI=32273 # time delay between tentative2274 DELAI=22275 2276 i=02277 while [ $i -lt $NB_ESSAI ] ; do2278 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12279 status=$?2280 if [ ${status} -gt 0 ] ; then2281 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"2282 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2283 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2284 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2285 sleep $DELAI2286 else2287 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2288 break2289 fi2290 (( i = i + 1 ))2291 done2292 2293 if [ ${status} -gt 0 ] ; then2294 echo "IGCM_sys_ncea : ncea error"2295 IGCM_debug_Exit "ncea"2296 fi2297 2298 IGCM_debug_PopStack "IGCM_sys_ncea"2299 }2300 2301 #D-#==================================================2302 #D-function IGCM_sys_ncecat2303 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry2304 #D-* Examples:2305 #D-2306 function IGCM_sys_ncecat {2307 IGCM_debug_PushStack "IGCM_sys_ncecat" $@2308 if ( $DEBUG_sys ) ; then2309 echo "IGCM_sys_ncecat :" $@2310 fi2311 2312 typeset NB_ESSAI DELAI status i2313 # number of tentative2314 NB_ESSAI=32315 # time delay between tentative2316 DELAI=22317 2318 i=02319 while [ $i -lt $NB_ESSAI ] ; do2320 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12321 status=$?2322 if [ ${status} -gt 0 ] ; then2323 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"2324 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2325 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2326 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2327 sleep $DELAI2328 else2329 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2330 break2331 fi2332 (( i = i + 1 ))2333 done2334 2335 if [ ${status} -gt 0 ] ; then2336 echo "IGCM_sys_ncecat : ncecat error"2337 IGCM_debug_Exit "ncecat"2338 fi2339 2340 IGCM_debug_PopStack "IGCM_sys_ncecat"2341 }2342 2343 #D-#==================================================2344 #D-function IGCM_sys_ncflint2345 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry2346 #D-* Examples:2347 #D-2348 function IGCM_sys_ncflint {2349 IGCM_debug_PushStack "IGCM_sys_ncflint" $@2350 if ( $DEBUG_sys ) ; then2351 echo "IGCM_sys_ncflint :" $@2352 fi2353 2354 typeset NB_ESSAI DELAI status i2355 # number of tentative2356 NB_ESSAI=32357 # time delay between tentative2358 DELAI=22359 2360 i=02361 while [ $i -lt $NB_ESSAI ] ; do2362 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12363 status=$?2364 if [ ${status} -gt 0 ] ; then2365 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"2366 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2367 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2368 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2369 sleep $DELAI2370 else2371 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2372 break2373 fi2374 (( i = i + 1 ))2375 done2376 2377 if [ ${status} -gt 0 ] ; then2378 echo "IGCM_sys_ncflint : ncflint error"2379 IGCM_debug_Exit "ncflint"2380 fi2381 2382 IGCM_debug_PopStack "IGCM_sys_ncflint"2383 }2384 2385 #D-#==================================================2386 #D-function IGCM_sys_ncks2387 #D-* Purpose: encapsulate ncks call so as to manage error code and retry2388 #D-* Examples:2389 #D-2390 function IGCM_sys_ncks {2391 IGCM_debug_PushStack "IGCM_sys_ncks" $@2392 if ( $DEBUG_sys ) ; then2393 echo "IGCM_sys_ncks :" $@2394 fi2395 2396 typeset NB_ESSAI DELAI status i2397 # number of tentative2398 NB_ESSAI=32399 # time delay between tentative2400 DELAI=22401 2402 i=02403 while [ $i -lt $NB_ESSAI ] ; do2404 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12405 status=$?2406 if [ ${status} -gt 0 ] ; then2407 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"2408 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2409 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2410 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2411 sleep $DELAI2412 else2413 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2414 break2415 fi2416 (( i = i + 1 ))2417 done2418 2419 if [ ${status} -gt 0 ] ; then2420 echo "IGCM_sys_ncks : ncks error"2421 IGCM_debug_Exit "ncks"2422 fi2423 2424 IGCM_debug_PopStack "IGCM_sys_ncks"2425 }2426 2427 #D-#==================================================2428 #D-function IGCM_sys_ncpdq2429 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry2430 #D-* Examples:2431 #D-2432 function IGCM_sys_ncpdq {2433 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@2434 if ( $DEBUG_sys ) ; then2435 echo "IGCM_sys_ncpdq :" $@2436 fi2437 2438 typeset NB_ESSAI DELAI status i2439 # number of tentative2440 NB_ESSAI=32441 # time delay between tentative2442 DELAI=22443 2444 i=02445 while [ $i -lt $NB_ESSAI ] ; do2446 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12447 status=$?2448 if [ ${status} -gt 0 ] ; then2449 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"2450 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2451 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2452 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2453 sleep $DELAI2454 else2455 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2456 break2457 fi2458 (( i = i + 1 ))2459 done2460 2461 if [ ${status} -gt 0 ] ; then2462 echo "IGCM_sys_ncpdq : ncpdq error"2463 IGCM_debug_Exit "ncpdq"2464 fi2465 2466 IGCM_debug_PopStack "IGCM_sys_ncpdq"2467 }2468 2469 #D-#==================================================2470 #D-function IGCM_sys_ncra2471 #D-* Purpose: encapsulate ncra call so as to manage error code and retry2472 #D-* Examples:2473 #D-2474 function IGCM_sys_ncra {2475 IGCM_debug_PushStack "IGCM_sys_ncra" $@2476 if ( $DEBUG_sys ) ; then2477 echo "IGCM_sys_ncra :" $@2478 fi2479 2480 typeset NB_ESSAI DELAI status i2481 # number of tentative2482 NB_ESSAI=32483 # time delay between tentative2484 DELAI=22485 2486 i=02487 while [ $i -lt $NB_ESSAI ] ; do2488 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12489 status=$?2490 if [ ${status} -gt 0 ] ; then2491 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"2492 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2493 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2494 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2495 sleep $DELAI2496 else2497 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2498 break2499 fi2500 (( i = i + 1 ))2501 done2502 2503 if [ ${status} -gt 0 ] ; then2504 echo "IGCM_sys_ncra : ncra error"2505 IGCM_debug_Exit "ncra"2506 fi2507 2508 IGCM_debug_PopStack "IGCM_sys_ncra"2509 }2510 2511 #D-#==================================================2512 #D-function IGCM_sys_ncrcat2513 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry2514 #D-* Examples:2515 #D-2516 function IGCM_sys_ncrcat {2517 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@2518 if ( $DEBUG_sys ) ; then2519 echo "IGCM_sys_ncrcat :" $@2520 fi2521 2522 typeset NB_ESSAI DELAI status i lastArg2523 # number of tentative2524 NB_ESSAI=32525 # time delay between tentative2526 DELAI=22527 2528 i=02529 while [ $i -lt $NB_ESSAI ] ; do2530 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12531 status=$?2532 if [ ${status} -gt 0 ] ; then2533 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"2534 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2535 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2536 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2537 sleep $DELAI2538 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then2539 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"2540 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2541 # remove files having corrupted time axis2542 eval lastArg=\${$#}2543 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"2544 \rm ${lastArg}2545 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2546 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2547 sleep $DELAI2548 else2549 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2550 break2551 fi2552 (( i = i + 1 ))2553 done2554 2555 if [ ${status} -gt 0 ] ; then2556 echo "IGCM_sys_ncrcat : ncrcat error"2557 #IGCM_debug_Exit "ncrcat"2558 fi2559 2560 IGCM_debug_PopStack "IGCM_sys_ncrcat"2561 }2562 2563 #D-#==================================================2564 #D-function IGCM_sys_ncrename2565 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry2566 #D-* Examples:2567 #D-2568 function IGCM_sys_ncrename {2569 IGCM_debug_PushStack "IGCM_sys_ncrename" $@2570 if ( $DEBUG_sys ) ; then2571 echo "IGCM_sys_ncrename :" $@2572 fi2573 2574 typeset NB_ESSAI DELAI status i2575 # number of tentative2576 NB_ESSAI=32577 # time delay between tentative2578 DELAI=22579 2580 i=02581 while [ $i -lt $NB_ESSAI ] ; do2582 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12583 status=$?2584 if [ ${status} -gt 0 ] ; then2585 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"2586 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2587 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2588 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2589 sleep $DELAI2590 else2591 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2592 break2593 fi2594 (( i = i + 1 ))2595 done2596 2597 if [ ${status} -gt 0 ] ; then2598 echo "IGCM_sys_ncrename : ncrename error"2599 IGCM_debug_Exit "ncrename"2600 fi2601 2602 IGCM_debug_PopStack "IGCM_sys_ncrename"2603 }2604 2605 #D-#==================================================2606 #D-function IGCM_sys_ncwa2607 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry2608 #D-* Examples:2609 #D-2610 function IGCM_sys_ncwa {2611 IGCM_debug_PushStack "IGCM_sys_ncwa" $@2612 if ( $DEBUG_sys ) ; then2613 echo "IGCM_sys_ncwa :" $@2614 fi2615 2616 typeset NB_ESSAI DELAI status i2617 # number of tentative2618 NB_ESSAI=32619 # time delay between tentative2620 DELAI=22621 2622 i=02623 while [ $i -lt $NB_ESSAI ] ; do2624 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12625 status=$?2626 if [ ${status} -gt 0 ] ; then2627 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"2628 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2629 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2630 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2631 sleep $DELAI2632 else2633 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2634 break2635 fi2636 (( i = i + 1 ))2637 done2638 2639 if [ ${status} -gt 0 ] ; then2640 echo "IGCM_sys_ncwa : ncwa error"2641 IGCM_debug_Exit "ncwa"2642 fi2643 2644 IGCM_debug_PopStack "IGCM_sys_ncwa"2645 }2646 2647 ##############################################################2648 # CDO OPERATOR2649 2650 #D-#==================================================2651 #D-function IGCM_sys_cdo2652 #D-* Purpose: encapsulate cdo call so as to manage error code and retry2653 #D-* Examples:2654 #D-2655 function IGCM_sys_cdo {2656 IGCM_debug_PushStack "IGCM_sys_cdo" $@2657 if ( $DEBUG_sys ) ; then2658 echo "IGCM_sys_cdo :" $@2659 fi2660 2661 typeset status2662 2663 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12664 status=$?2665 if [ ${status} -gt 0 ] ; then2666 echo "IGCM_sys_cdo : error code ${status}"2667 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2668 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2669 IGCM_debug_PopStack "IGCM_sys_cdo"2670 return 12671 else2672 IGCM_debug_PopStack "IGCM_sys_cdo"2673 return 02674 fi2675 2676 IGCM_debug_PopStack "IGCM_sys_cdo"2677 }
Note: See TracChangeset
for help on using the changeset viewer.