Changeset 810
- Timestamp:
- 03/05/13 12:43:08 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
r809 r810 68 68 typeset LOGIN=${LOGIN:=$( whoami )} 69 69 # $hostname of the MASTER job 70 typeset -r MASTER=iitm0170 ntypeset -r MASTER=iitm01 71 71 72 72 #D- … … 75 75 #D-#================================================== 76 76 77 # Submit command 78 typeset SUBMIT=${SUBMIT:=/usr/lpp/LoadL/full/bin/llsubmit} 77 79 # rsync with path 78 80 typeset -r RSYNC=/usr/bin/rsync 79 81 # RSYNC_opt args to rsync 80 82 typeset -r RSYNC_opt="-va" 83 # ie storage filesystem 84 typeset -r STOREHOST=iitm01 85 typeset -r REMOTE_RSYNC=/usr/bin/rsync 86 87 #==================================================== 88 # Source default environment 89 #==================================================== 90 ##. /etc/profile 91 92 #==================================================== 93 # Set environment tools (ferret, nco, cdo) 94 #==================================================== 95 # Not applicable here 81 96 82 97 #==================================================== 83 98 # Host specific DIRECTORIES 84 99 #==================================================== 100 101 #==================================================== 102 #- Mirror libIGCM from iitm to a post-processing machine 103 typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 104 105 #==================================================== 106 #- libIGCM_POST for frontend 107 typeset -r libIGCM_POST=${libIGCM} 85 108 86 109 #==================================================== … … 99 122 #==================================================== 100 123 #- ARCHIVE 101 typeset -r ARCHIVE=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" ) 102 103 #==================================================== 104 #- Mirror libIGCM from iitm to a post-processing machine 105 typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false} 106 107 #==================================================== 108 #- libIGCM_POST 109 typeset -r HOME_POST=${HOME} 110 typeset -r libIGCM_POST=${libIGCM} 111 112 #==================================================== 113 #- OUT 114 typeset -r R_OUT=${ARCHIVE}/IGCM_OUT 124 typeset ARCHIVE=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" ) 125 126 #==================================================== 127 #- STORAGE (dedicated to small/medium files) 128 typeset STORAGE=${ARCHIVE} 129 130 #==================================================== 131 #- R_OUT 132 typeset R_OUT=${ARCHIVE}/IGCM_OUT 133 134 #==================================================== 135 #- R_FIG (hosting figures : monitoring and atlas, and/or small files) 136 typeset R_FIG=${WORKDIR}/IGCM_OUT 137 138 #==================================================== 139 #- R_BUF (ONLY FOR double copy an scratch) 140 typeset -r R_BUF=${WORKDIR}/IGCM_OUT 115 141 116 142 #==================================================== … … 120 146 #==================================================== 121 147 #- HOST_MPIRUN_COMMAND 122 typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:=" time poe"}148 typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"} 123 149 124 150 #==================================================== … … 126 152 UNIX_MAX_LIMIT=360 127 153 154 #==================================================== 155 #- set PackDefault true on curie 156 PackDefault=false 157 158 #==================================================== 159 #- Number of core per node (max number of OpenMP task) 160 NUM_COREPERNODE=2 161 162 #==================================================== 163 #- Default number of MPI task for IPSL coupled model 164 #- required for backward compatibility 165 #- 166 DEFAULT_NUM_PROC_OCE=5 167 DEFAULT_NUM_PROC_CPL=1 168 (( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL )) 169 DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT} 170 128 171 #D-#================================================== 129 172 #D-function IGCM_sys_ChangeArchive … … 132 175 #D- 133 176 function IGCM_sys_ChangeArchive { 134 135 177 IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive " 136 137 178 } 138 179 … … 147 188 #D- 148 189 function IGCM_sys_RshMaster { 149 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 190 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@ 191 /bin/ksh <<-EOF 192 export libIGCM=${libIGCM} 193 export DEBUG_debug=${DEBUG_debug} 194 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 195 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 196 ${@} 197 EOF 198 if [ $? -gt 0 ] ; then 199 echo "IGCM_sys_RshMaster : erreur." 200 IGCM_debug_Exit "IGCM_sys_RshMaster" 201 fi 202 IGCM_debug_PopStack "IGCM_sys_RshMaster" 203 } 204 205 #D-#================================================== 206 #D-function IGCM_sys_RshArchive 207 #D-* Purpose: Archive rsh command 208 #D-* Examples: 209 #D- 210 function IGCM_sys_RshArchive { 211 IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 212 DEBUG_sys=false IGCM_sys_IsFileArchived "$@" 213 if [ $? = 0 ] ; then 150 214 /bin/ksh <<-EOF 151 215 ${@} 152 216 EOF 153 if [ $? -gt 0 ] ; then 154 echo "IGCM_sys_RshArchive : erreur." 155 IGCM_debug_Exit "IGCM_sys_RshArchive" 156 fi 157 IGCM_debug_PopStack "IGCM_sys_RshMaster" 158 } 159 160 #D-#================================================== 161 #D-function IGCM_sys_RshArchive 162 #D-* Purpose: Archive rsh command 163 #D-* Examples: 164 #D- 165 function IGCM_sys_RshArchive { 166 IGCM_debug_PushStack "IGCM_sys_RshArchive" $@ 217 status=$? 218 else 167 219 /bin/ksh <<-EOF 168 220 ${@} 169 221 EOF 170 if [ $? -gt 0 ] ; then 171 echo "IGCM_sys_RshArchive : erreur." 172 IGCM_debug_Exit "IGCM_sys_RshArchive" 173 fi 174 IGCM_debug_PopStack "IGCM_sys_RshArchive" 222 status=$? 223 fi 224 if [ ${status} -gt 0 ] ; then 225 IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}" 226 IGCM_debug_Exit "IGCM_sys_RshArchive" 227 fi 228 IGCM_debug_PopStack "IGCM_sys_RshArchive" 175 229 } 176 230 … … 181 235 #D- 182 236 function IGCM_sys_RshPost { 183 IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 184 if ( $DEBUG_sys ) ; then 185 echo "IGCM_sys_RshPost :" $@ 186 fi 187 /bin/ksh ${@} 188 #rsh ulam exec /bin/ksh ${@} 189 if [ $? -gt 0 ] ; then 190 echo "IGCM_sys_RshPost : erreur." 191 IGCM_debug_Exit "IGCM_sys_RshPost" 192 fi 193 IGCM_debug_PopStack "IGCM_sys_RshPost" 237 IGCM_debug_PushStack "IGCM_sys_RshPost" $@ 238 if ( $DEBUG_sys ) ; then 239 echo "IGCM_sys_RshPost :" $@ 240 fi 241 242 # keep standard input to keep it for postpone if ulam don't answer 243 cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 244 245 /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 246 if [ $? -gt 0 ] ; then 247 echo "IGCM_sys_RshPost : erreur." 248 IGCM_debug_Exit "IGCM_sys_RshPost" 249 fi 250 # delete temporary file 251 \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME} 252 253 IGCM_debug_PopStack "IGCM_sys_RshPost" 194 254 } 195 255 … … 200 260 #D- 201 261 function IGCM_sys_SendMail { 202 IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 203 if ( $DEBUG_sys ) ; then 204 echo "IGCM_sys_SendMail :" $@ 205 fi 206 207 if ( ${ExitFlag} ) ; then 208 status=failed 209 else 210 status=completed 211 fi 212 cat << END_MAIL > job_end.mail 262 IGCM_debug_PushStack "IGCM_sys_SendMail" $@ 263 if ( $DEBUG_sys ) ; then 264 echo "IGCM_sys_SendMail :" $@ 265 fi 266 267 if ( ${ExitFlag} ) ; then 268 status=failed 269 else 270 status=completed 271 fi 272 273 cat << END_MAIL > job_end.mail 213 274 Dear ${LOGIN}, 214 275 … … 216 277 Job started : ${DateBegin} 217 278 Job ended : ${DateEnd} 218 Ouput files are available in ${R_SAVE} 279 Output files are available in ${R_SAVE} 280 Files to be rebuild are temporarily available in ${REBUILD_DIR} 281 Pre-packed files are temporarily available in ${R_BUFR} 219 282 Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR} 220 283 END_MAIL 221 284 222 if [ ! -z ${config_UserChoices_MailName} ] ; then 223 mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail 224 elif [ -f ~/.forward ] ; then 225 mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 226 else 227 mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < job_end.mail 228 fi 229 230 if [ $? -gt 0 ] ; then 231 echo "IGCM_sys_SendMail : erreur." 232 IGCM_debug_Exit "IGCM_sys_SendMail" 233 fi 234 IGCM_debug_PopStack "IGCM_sys_SendMail" 285 if [ ! -z ${config_UserChoices_MailName} ] ; then 286 mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail 287 elif [ -f ~/.forward ] ; then 288 mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail 289 else 290 mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < job_end.mail 291 fi 292 293 sleep 10 294 rm -f job_end.mail 295 296 if [ $? -gt 0 ] ; then 297 echo "IGCM_sys_SendMail : erreur." 298 IGCM_debug_Exit "IGCM_sys_SendMail" 299 fi 300 IGCM_debug_PopStack "IGCM_sys_SendMail" 235 301 } 236 302 … … 241 307 #D- 242 308 function IGCM_sys_Mkdir { 243 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 244 if ( $DEBUG_sys ) ; then 245 echo "IGCM_sys_Mkdir :" $@ 246 fi 247 if [ ! -d ${1} ]; then 248 \mkdir -p $1 249 if [ $? -gt 0 ] ; then 250 echo "IGCM_sys_Mkdir : erreur." 251 IGCM_debug_Exit "IGCM_sys_Mkdir" 252 fi 253 fi 254 # vérification : 255 if [ ! -d ${1} ] ; then 309 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@ 310 if ( $DEBUG_sys ) ; then 311 echo "IGCM_sys_Mkdir :" $@ 312 fi 313 if [ ! -d ${1} ]; then 314 \mkdir -p $1 315 if [ $? -gt 0 ] ; then 256 316 echo "IGCM_sys_Mkdir : erreur." 257 317 IGCM_debug_Exit "IGCM_sys_Mkdir" 258 318 fi 259 IGCM_debug_PopStack "IGCM_sys_Mkdir" 319 fi 320 # vérification : 321 if [ ! -d ${1} ] ; then 322 echo "IGCM_sys_Mkdir : erreur." 323 IGCM_debug_Exit "IGCM_sys_Mkdir" 324 fi 325 IGCM_debug_PopStack "IGCM_sys_Mkdir" 260 326 } 261 327 … … 266 332 #D- 267 333 function IGCM_sys_MkdirArchive { 268 IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 269 if ( $DEBUG_sys ) ; then 270 echo "IGCM_sys_MkdirArchive :" $@ 271 fi 272 #- creation de repertoire sur le serveur fichier 273 mkdir -p $1 274 275 if [ $? -gt 0 ] ; then 276 echo "IGCM_sys_MkdirArchive : erreur." 277 IGCM_debug_Exit "IGCM_sys_MkdirArchive" 278 fi 279 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 334 IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@ 335 if ( $DEBUG_sys ) ; then 336 echo "IGCM_sys_MkdirArchive :" $@ 337 fi 338 #- creation de repertoire sur le serveur fichier 339 mkdir -p $1 340 status=$? 341 342 if [ ${status} -gt 0 ] ; then 343 IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}" 344 IGCM_debug_Exit "IGCM_sys_MkdirArchive" 345 fi 346 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 280 347 } 281 348 … … 286 353 #D- 287 354 function IGCM_sys_MkdirWork { 288 289 290 291 292 293 294 295 296 297 298 299 300 355 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@ 356 if ( $DEBUG_sys ) ; then 357 echo "IGCM_sys_MkdirWork :" $@ 358 fi 359 #- creation de repertoire sur le serveur fichier 360 if [ ! -d ${1} ]; then 361 \mkdir -p $1 362 if [ $? -gt 0 ] ; then 363 echo "IGCM_sys_MkdirWork : erreur." 364 IGCM_debug_Exit "IGCM_sys_MkdirWork" 365 fi 366 fi 367 IGCM_debug_PopStack "IGCM_sys_MkdirWork" 301 368 } 302 369 … … 307 374 #D- 308 375 function IGCM_sys_Cd { 309 310 311 312 313 314 315 316 317 318 376 IGCM_debug_PushStack "IGCM_sys_Cd" $@ 377 if ( $DEBUG_sys ) ; then 378 echo "IGCM_sys_Cd :" $@ 379 fi 380 \cd $1 381 if [ $? -gt 0 ] ; then 382 echo "IGCM_sys_Cd : erreur." 383 IGCM_debug_Exit "IGCM_sys_Cd" 384 fi 385 IGCM_debug_PopStack "IGCM_sys_Cd" 319 386 } 320 387 … … 325 392 #D- 326 393 function IGCM_sys_Chmod { 327 328 329 330 331 332 333 334 335 336 394 IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@ 395 if ( $DEBUG_sys ) ; then 396 echo "IGCM_sys_Chmod :" $@ 397 fi 398 \chmod $@ 399 if [ $? -gt 0 ] ; then 400 echo "IGCM_sys_Chmod : erreur." 401 IGCM_debug_Exit "IGCM_sys_Chmod" 402 fi 403 IGCM_debug_PopStack "IGCM_sys_Chmod" 337 404 } 338 405 … … 343 410 #D- 344 411 function IGCM_sys_FileSize { 345 346 347 348 349 350 351 352 353 354 412 IGCM_debug_PushStack "IGCM_sys_FileSize" $@ 413 414 typeset sizeF 415 set +A sizeF -- $( ls -la ${1} ) 416 if [ $? -gt 0 ] ; then 417 IGCM_debug_Exit "IGCM_sys_FileSize" 418 fi 419 eval ${2}=${sizeF[4]} 420 421 IGCM_debug_PopStack "IGCM_sys_FileSize" 355 422 } 356 423 … … 361 428 #D- 362 429 function IGCM_sys_TestDir { 363 364 365 366 367 368 369 370 371 430 IGCM_debug_PushStack "IGCM_sys_TestDir" $@ 431 if ( $DEBUG_sys ) ; then 432 echo "IGCM_sys_TestDir :" $@ 433 fi 434 typeset ExistFlag 435 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 ) 436 IGCM_debug_PopStack "IGCM_sys_TestDir" 437 438 return ${ExistFlag} 372 439 } 373 440 … … 378 445 #D- 379 446 function IGCM_sys_TestDirArchive { 380 IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 381 if ( $DEBUG_sys ) ; then 382 echo "IGCM_sys_TestDirArchive :" $@ 383 fi 384 typeset ExistFlag 385 ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" ) 386 IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 387 388 return ${ExistFlag} 447 IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@ 448 if ( $DEBUG_sys ) ; then 449 echo "IGCM_sys_TestDirArchive :" $@ 450 fi 451 typeset ExistFlag 452 ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" ) 453 IGCM_debug_PopStack "IGCM_sys_TestDirArchive" 454 return ${ExistFlag} 455 } 456 457 #D-#================================================== 458 #D-function IGCM_sys_IsFileArchived 459 #D-* Purpose: Test file that must NOT EXISTS on Archive 460 #D-* Examples: 461 #D- 462 function IGCM_sys_IsFileArchived { 463 IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@ 464 if ( $DEBUG_sys ) ; then 465 echo "IGCM_sys_IsFileArchived :" $@ 466 fi 467 typeset IsArchivedFlag 468 IsArchivedFlag=$( [ "X$( echo $1 | grep \/gpfs3 )" != "X" ] && echo 0 || echo 1 ) 469 IGCM_debug_PopStack "IGCM_sys_IsFileArchived" 470 471 return ${IsArchivedFlag} 389 472 } 390 473 … … 395 478 #D- 396 479 function IGCM_sys_TestFileArchive { 397 IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 398 typeset ExistFlag 399 ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 400 IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 401 402 return ${ExistFlag} 480 IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@ 481 typeset ExistFlag 482 ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 483 IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 484 485 return ${ExistFlag} 486 } 487 488 #D-#================================================== 489 #D-function IGCM_sys_TestFileBuffer 490 #D-* Purpose: Test file that must NOT EXISTS on Buffer 491 #D-* Examples: 492 #D- 493 function IGCM_sys_TestFileBuffer { 494 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@ 495 typeset ExistFlag 496 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 ) 497 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer" 498 499 return ${ExistFlag} 403 500 } 404 501 … … 409 506 #D- 410 507 function IGCM_sys_CountFileArchive { 411 IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 508 IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@ 509 #Command depends on targeted file system 510 DEBUG_sys=false IGCM_sys_IsFileArchived $1 511 if [ $? = 0 ] ; then 412 512 IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l" 413 if [ $? -gt 0 ] ; then 414 echo "IGCM_sys_CountFileArchive : erreur." 415 fi 416 IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 513 status=$? 514 else 515 ls ${@} 2>/dev/null | wc -l 516 status=$? 517 fi 518 if [ ${status} -gt 0 ] ; then 519 echo "IGCM_sys_CountFileArchive : erreur." 520 fi 521 IGCM_debug_PopStack "IGCM_sys_CountFileArchive" 522 } 523 524 #D-#================================================== 525 #D-function IGCM_sys_CountFileBuffer 526 #D-* Purpose: Count files on Scratch filesystem 527 #D-* Examples: 528 #D- 529 function IGCM_sys_CountFileBuffer { 530 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@ 531 ls ${@} 2>/dev/null | wc -l 532 if [ $? -gt 0 ] ; then 533 echo "IGCM_sys_CountFileBuffer : erreur." 534 fi 535 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer" 417 536 } 418 537 … … 423 542 #D- 424 543 function IGCM_sys_Tree { 425 426 427 428 429 430 431 432 544 IGCM_debug_PushStack "IGCM_sys_Tree" $@ 545 if ( $DEBUG_sys ) ; then 546 echo "IGCM_sys_Tree :" $@ 547 fi 548 549 \ls -r $@ 550 551 IGCM_debug_PopStack "IGCM_sys_Tree" 433 552 } 434 553 435 554 #D-#================================================== 436 555 #D-function IGCM_sys_Tar 437 #D-* Purpose: master un-tar command556 #D-* Purpose: master tar command 438 557 #D-* Examples: 439 558 #D- 440 559 function IGCM_sys_Tar { 441 IGCM_debug_PushStack "IGCM_sys_Tar" $@ 442 if ( $DEBUG_sys ) ; then 443 echo "IGCM_sys_Tar :" $@ 444 fi 445 \tar cvf $@ 446 if [ $? -gt 0 ] ; then 447 echo "IGCM_sys_Tar : erreur." 448 IGCM_debug_Exit "IGCM_sys_Tar" 449 fi 450 \tar tvf $1 451 452 IGCM_debug_PopStack "IGCM_sys_Tar" 560 IGCM_debug_PushStack "IGCM_sys_Tar" $@ 561 if ( $DEBUG_sys ) ; then 562 echo "IGCM_sys_Tar :" $@ 563 fi 564 \tar cf $@ 565 if [ $? -gt 0 ] ; then 566 echo "IGCM_sys_Tar : erreur." 567 IGCM_debug_Exit "IGCM_sys_Tar" 568 fi 569 IGCM_debug_PopStack "IGCM_sys_Tar" 453 570 } 454 571 … … 459 576 #D- 460 577 function IGCM_sys_UnTar { 461 462 463 464 465 466 467 468 469 470 578 IGCM_debug_PushStack "IGCM_sys_UnTar" $@ 579 if ( $DEBUG_sys ) ; then 580 echo "IGCM_sys_UnTar :" $@ 581 fi 582 \tar xvf $1 583 if [ $? -gt 0 ] ; then 584 echo "IGCM_sys_UnTar : erreur." 585 IGCM_debug_Exit "IGCM_sys_UnTar" 586 fi 587 IGCM_debug_PopStack "IGCM_sys_UnTar" 471 588 } 472 589 … … 477 594 #D- 478 595 function IGCM_sys_Qsub { 479 IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 480 if ( $DEBUG_sys ) ; then 481 echo "IGCM_sys_Qsub :" $@ 482 fi 483 { 484 [ ${#@} = 1 ] && { cd $LOADL_STEP_INITDIR ; /usr/lpp/LoadL/full/bin/llsubmit $1 ; ERROR=$? ; cd - ; } 485 [ ${#@} = 2 ] && { cd $2 ; /usr/lpp/LoadL/full/bin/llsubmit $1 ; ERROR=$? ; cd - ; } 486 } 487 if [ ${ERROR} -gt 0 ] ; then 488 echo "IGCM_sys_Qsub : erreur $@." 489 IGCM_debug_Exit "IGCM_sys_Qsub" 490 fi 491 IGCM_debug_PopStack "IGCM_sys_Qsub" 596 IGCM_debug_PushStack "IGCM_sys_Qsub" $@ 597 598 typeset ERROR 599 ERROR=0 600 601 if ( $DEBUG_sys ) ; then 602 echo "IGCM_sys_Qsub :" $@ 603 fi 604 # We have to change output/error file 605 [ ${#@} = 1 ] && REP_FOR_JOB=${SUBMIT_DIR} 606 [ ${#@} = 2 ] && REP_FOR_JOB=${2} 607 sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \ 608 -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:" \ 609 $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM 610 cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM ; ERROR=$? ; cd - ; 611 612 if [ ${ERROR} -gt 0 ] ; then 613 echo "IGCM_sys_Qsub : erreur $@" 614 IGCM_debug_Exit "IGCM_sys_Qsub" 615 else 616 IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM 617 fi 618 IGCM_debug_PopStack "IGCM_sys_Qsub" 492 619 } 493 620 … … 498 625 #D- 499 626 function IGCM_sys_QsubPost { 500 IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 501 if ( $DEBUG_sys ) ; then 502 echo "IGCM_sys_QsubPost :" $@ 503 fi 504 cd ${POST_DIR} 505 /usr/lpp/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job 506 cd - 507 if [ $? -gt 0 ] ; then 508 echo "IGCM_sys_QsubPost : erreur " $@ 509 IGCM_debug_Exit "IGCM_sys_QsubPost" 510 fi 511 IGCM_debug_PopStack "IGCM_sys_QsubPost" 627 IGCM_debug_PushStack "IGCM_sys_QsubPost" $@ 628 629 typeset ERROR 630 ERROR=0 631 632 if ( $DEBUG_sys ) ; then 633 echo "IGCM_sys_QsubPost :" $@ 634 fi 635 # We have to change output/error file 636 [ ${#@} = 1 ] && REP_FOR_JOB=${POST_DIR} 637 [ ${#@} = 2 ] && REP_FOR_JOB=${2} 638 639 sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \ 640 -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:" \ 641 ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM 642 643 cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM ; ERROR=$? ; cd - ; 644 if [ ${ERROR} -gt 0 ] ; then 645 echo "IGCM_sys_QsubPost : erreur $@." 646 IGCM_debug_Exit "IGCM_sys_QsubPost" 647 else 648 IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM 649 fi 650 651 IGCM_debug_PopStack "IGCM_sys_QsubPost" 512 652 } 513 653 … … 523 663 #D- Error values and explanations can depend on your system version. 524 664 function IGCM_sys_Rsync_out { 525 RET=$1 526 if [ ! $RET ] ; then 527 echo "rsync error !" 528 fi 529 530 if [ $MYLANG = "fr" ]; then 531 case $RET in 532 0) return ;; 533 1) echo "Erreur de rsync ; RERR_SYNTAX : " 534 echo "Erreur de syntaxe ou d'utilisation." 535 return;; 536 2) echo "Erreur de rsync ; RERR_PROTOCOL : " 537 echo "Incompatibilité de protocole." 538 return;; 539 3) echo "Erreur de rsync ; RERR_FILESELECT 3" 540 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" 541 echo "répertoires" 542 return;; 543 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" 544 echo "Action demandée non supportée : une tentative de manipulation de" 545 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" 546 echo "été faite ; ou une option qui est supportée par le client mais" 547 echo "pas par le serveur a été spécifiée." 548 return;; 549 10) echo "Erreur de rsync ; RERR_SOCKETIO" 550 echo "Erreur dans le socket d'entrée sortie" 551 return;; 552 11) echo "Erreur de rsync ; RERR_FILEIO" 553 echo "Erreur d'entrée sortie fichier" 554 return;; 555 12) echo "Erreur de rsync ; RERR_STREAMIO" 556 echo "Erreur dans flux de donnée du protocole rsync" 557 return;; 558 13) echo "Erreur de rsync ; RERR_MESSAGEIO" 559 echo "Erreur avec les diagnostics du programme" 560 return;; 561 14) echo "Erreur de rsync ; RERR_IPC" 562 echo "Erreur dans le code IPC" 563 return;; 564 20) echo "Erreur de rsync ; RERR_SIGNAL" 565 echo "SIGUSR1 ou SIGINT reçu" 566 return;; 567 21) echo "Erreur de rsync ; RERR_WAITCHILD" 568 echo "Une erreur retournée par waitpid()" 569 return;; 570 22) echo "Erreur de rsync ; RERR_MALLOC" 571 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 572 return;; 573 23) echo "" 574 echo "Erreur fichier inexistant" 575 return;; 576 30) echo "Erreur de rsync ; RERR_TIMEOUT" 577 echo "Temps d'attente écoulé dans l'envoi/réception de données" 578 return;; 579 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $RET 580 return;; 581 esac 582 elif [ $MYLANG = "en" ] ; then 583 case $RET in 584 0) return;; 585 1) echo "rsync error : Syntax or usage error " 586 return;; 587 2) echo "rsync error : Protocol incompatibility " 588 return;; 589 3) echo "rsync error : Errors selecting input/output files, dirs" 590 return;; 591 4) echo "rsync error : Requested action not supported: an attempt" 592 echo "was made to manipulate 64-bit files on a platform that cannot support" 593 echo "them; or an option was specified that is supported by the client and" 594 echo "not by the server." 595 return;; 596 5) echo "rsync error : Error starting client-server protocol" 597 return;; 598 10) echo "rsync error : Error in socket I/O " 599 return;; 600 11) echo "rsync error : Error in file I/O " 601 return;; 602 12) echo "rsync error : Error in rsync protocol data stream " 603 return;; 604 13) echo "rsync error : Errors with program diagnostics " 605 return;; 606 14) echo "rsync error : Error in IPC code " 607 return;; 608 20) echo "rsync error : Received SIGUSR1 or SIGINT " 609 return;; 610 21) echo "rsync error : Some error returned by waitpid() " 611 return;; 612 22) echo "rsync error : Error allocating core memory buffers " 613 return;; 614 23) echo "rsync error : Partial transfer due to error" 615 return;; 616 24) echo "rsync error : Partial transfer due to vanished source files" 617 return;; 618 30) echo "rsync error : Timeout in data send/receive " 619 return;; 620 *) echo "rsync error : return code of rsync unknown :" $RET 621 return;; 622 esac 623 else 624 echo "unknown language $MYLANG." 625 return 626 fi 665 status=$1 666 if [ ! $status ] ; then 667 echo "rsync error !" 668 fi 669 670 if [ $MYLANG = "fr" ]; then 671 case $status in 672 0) return ;; 673 1) echo "Erreur de rsync ; RERR_SYNTAX : " 674 echo "Erreur de syntaxe ou d'utilisation." 675 return;; 676 2) echo "Erreur de rsync ; RERR_PROTOCOL : " 677 echo "Incompatibilité de protocole." 678 return;; 679 3) echo "Erreur de rsync ; RERR_FILESELECT 3" 680 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et" 681 echo "répertoires" 682 return;; 683 4) echo "Erreur de rsync ; RERR_UNSUPPORTED" 684 echo "Action demandée non supportée : une tentative de manipulation de" 685 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a" 686 echo "été faite ; ou une option qui est supportée par le client mais" 687 echo "pas par le serveur a été spécifiée." 688 return;; 689 10) echo "Erreur de rsync ; RERR_SOCKETIO" 690 echo "Erreur dans le socket d'entrée sortie" 691 return;; 692 11) echo "Erreur de rsync ; RERR_FILEIO" 693 echo "Erreur d'entrée sortie fichier" 694 return;; 695 12) echo "Erreur de rsync ; RERR_STREAMIO" 696 echo "Erreur dans flux de donnée du protocole rsync" 697 return;; 698 13) echo "Erreur de rsync ; RERR_MESSAGEIO" 699 echo "Erreur avec les diagnostics du programme" 700 return;; 701 14) echo "Erreur de rsync ; RERR_IPC" 702 echo "Erreur dans le code IPC" 703 return;; 704 20) echo "Erreur de rsync ; RERR_SIGNAL" 705 echo "SIGUSR1 ou SIGINT reçu" 706 return;; 707 21) echo "Erreur de rsync ; RERR_WAITCHILD" 708 echo "Une erreur retournée par waitpid()" 709 return;; 710 22) echo "Erreur de rsync ; RERR_MALLOC" 711 echo "Erreur lors de l'allocation des tampons de mémoire de coeur" 712 return;; 713 23) echo "" 714 echo "Erreur fichier inexistant" 715 return;; 716 30) echo "Erreur de rsync ; RERR_TIMEOUT" 717 echo "Temps d'attente écoulé dans l'envoi/réception de données" 718 return;; 719 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status 720 return;; 721 esac 722 elif [ $MYLANG = "en" ] ; then 723 case $status in 724 0) return;; 725 1) echo "rsync error : Syntax or usage error " 726 return;; 727 2) echo "rsync error : Protocol incompatibility " 728 return;; 729 3) echo "rsync error : Errors selecting input/output files, dirs" 730 return;; 731 4) echo "rsync error : Requested action not supported: an attempt" 732 echo "was made to manipulate 64-bit files on a platform that cannot support" 733 echo "them; or an option was specified that is supported by the client and" 734 echo "not by the server." 735 return;; 736 5) echo "rsync error : Error starting client-server protocol" 737 return;; 738 10) echo "rsync error : Error in socket I/O " 739 return;; 740 11) echo "rsync error : Error in file I/O " 741 return;; 742 12) echo "rsync error : Error in rsync protocol data stream " 743 return;; 744 13) echo "rsync error : Errors with program diagnostics " 745 return;; 746 14) echo "rsync error : Error in IPC code " 747 return;; 748 20) echo "rsync error : Received SIGUSR1 or SIGINT " 749 return;; 750 21) echo "rsync error : Some error returned by waitpid() " 751 return;; 752 22) echo "rsync error : Error allocating core memory buffers " 753 return;; 754 23) echo "rsync error : Partial transfer due to error" 755 return;; 756 24) echo "rsync error : Partial transfer due to vanished source files" 757 return;; 758 30) echo "rsync error : Timeout in data send/receive " 759 return;; 760 *) echo "rsync error : return code of rsync unknown :" $status 761 return;; 762 esac 763 else 764 echo "unknown language $MYLANG." 765 return 766 fi 767 } 768 769 #D-#================================================== 770 #D-function IGCM_sys_Miror_libIGCM 771 #D-* Purpose: Mirror libIGCM PATH and lib to frontend 772 #D-* Examples: 773 #D- 774 function IGCM_sys_Mirror_libIGCM { 775 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM" 776 if ( $DEBUG_sys ) ; then 777 echo "IGCM_sys_Mirror_libIGCM" 778 fi 779 780 typeset status 781 782 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM} 783 784 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1 785 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1 786 status=$? 787 788 if [ ${status} -gt 0 ] ; then 789 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend." 790 cat out_rsync 791 fi 792 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM" 627 793 } 628 794 … … 633 799 #D- 634 800 function IGCM_sys_Cp { 635 IGCM_debug_PushStack "IGCM_sys_Cp" $@ 636 if ( $DEBUG_sys ) ; then 637 echo "IGCM_sys_Cp :" $@ 638 fi 639 640 typeset RET 641 642 echo cp $@ > out_rsync 2>&1 643 \cp $@ >> out_rsync 2>&1 644 RET=$? 645 646 if [ ${RET} -gt 0 ] ; then 647 echo "IGCM_sys_Cp : error." 648 cat out_rsync 649 IGCM_debug_Exit "IGCM_sys_Cp" 650 fi 651 IGCM_debug_PopStack "IGCM_sys_Cp" 801 IGCM_debug_PushStack "IGCM_sys_Cp" $@ 802 if ( $DEBUG_sys ) ; then 803 echo "IGCM_sys_Cp :" $@ 804 fi 805 806 typeset status 807 808 echo cp $@ > out_rsync 2>&1 809 \cp $@ >> out_rsync 2>&1 810 status=$? 811 812 if [ ${status} -gt 0 ] ; then 813 echo "IGCM_sys_Cp : error code ${status}" 814 cat out_rsync 815 IGCM_debug_Exit "IGCM_sys_Cp" 816 else 817 \rm out_rsync 818 fi 819 IGCM_debug_PopStack "IGCM_sys_Cp" 652 820 } 653 821 … … 658 826 #D- 659 827 function IGCM_sys_Rm { 660 IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 661 if ( $DEBUG_sys ) ; then 662 echo "IGCM_sys_Rm :" $@ 663 fi 664 665 typeset RET 666 667 echo rm $@ > out_rsync 2>&1 668 \rm $@ >> out_rsync 2>&1 669 RET=$? 670 671 if [ ${RET} -gt 0 ] ; then 672 echo "IGCM_sys_Rm : error." 673 cat out_rsync 674 IGCM_debug_Exit "IGCM_sys_Rm" 675 fi 676 IGCM_debug_PopStack "IGCM_sys_Rm" 828 IGCM_debug_PushStack "IGCM_sys_Rm" -- $@ 829 if ( $DEBUG_sys ) ; then 830 echo "IGCM_sys_Rm :" $@ 831 fi 832 833 typeset status 834 835 echo rm $@ > out_rsync 2>&1 836 \rm $@ >> out_rsync 2>&1 837 status=$? 838 839 if [ ${status} -gt 0 ] ; then 840 echo "IGCM_sys_Rm : error code ${status}" 841 cat out_rsync 842 IGCM_debug_Exit "IGCM_sys_Rm" 843 else 844 \rm out_rsync 845 fi 846 IGCM_debug_PopStack "IGCM_sys_Rm" 677 847 } 678 848 … … 684 854 #D- 685 855 function IGCM_sys_RmRunDir { 686 687 688 689 690 691 typeset RET692 693 694 695 RET=$?696 697 if [ ${RET} -gt 0 ] ; then698 echo "IGCM_sys_RmRunDir : error."699 700 701 702 703 704 705 856 IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@ 857 if ( $DEBUG_sys ) ; then 858 echo "IGCM_sys_RmRunDir :" $@ 859 fi 860 861 typeset status 862 863 echo rm $@ > out_rsync 2>&1 864 \rm $@ >> out_rsync 2>&1 865 status=$? 866 867 if [ ${status} -gt 0 ] ; then 868 echo "IGCM_sys_RmRunDir : rm error code is ${status}." 869 cat out_rsync 870 IGCM_debug_Exit "IGCM_sys_RmRunDir" 871 else 872 \rm out_rsync 873 fi 874 875 IGCM_debug_PopStack "IGCM_sys_RmRunDir" 706 876 } 707 877 … … 712 882 #D- 713 883 function IGCM_sys_Mv { 714 IGCM_debug_PushStack "IGCM_sys_Mv" $@ 715 if ( $DEBUG_sys ) ; then 716 echo "IGCM_sys_Mv :" $@ 717 fi 718 719 if [ $DRYRUN = 0 ]; then 720 721 typeset RET 722 723 echo mv $@ > out_rsync 2>&1 724 \mv $@ >> out_rsync 2>&1 725 RET=$? 726 727 if [ ${RET} -gt 0 ] ; then 728 echo "IGCM_sys_Mv : error in mv." 729 cat out_rsync 730 IGCM_debug_Exit "IGCM_sys_Mv" 731 fi 732 else 733 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 734 fi 735 736 IGCM_debug_PopStack "IGCM_sys_Mv" 884 IGCM_debug_PushStack "IGCM_sys_Mv" $@ 885 if ( $DEBUG_sys ) ; then 886 echo "IGCM_sys_Mv :" $@ 887 fi 888 889 if [ $DRYRUN = 0 ]; then 890 891 typeset status 892 893 echo mv $@ > out_rsync 2>&1 894 \mv $@ >> out_rsync 2>&1 895 status=$? 896 897 if [ ${status} -gt 0 ] ; then 898 echo "IGCM_sys_Mv : error code ${status}" 899 cat out_rsync 900 IGCM_debug_Exit "IGCM_sys_Mv" 901 else 902 \rm out_rsync 903 fi 904 else 905 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 906 fi 907 908 IGCM_debug_PopStack "IGCM_sys_Mv" 737 909 } 738 910 … … 743 915 #D- 744 916 function IGCM_sys_Put_Dir { 745 IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 746 if ( $DEBUG_sys ) ; then 747 echo "IGCM_sys_Put_Dir :" $@ 748 fi 749 if [ $DRYRUN = 0 ]; then 750 if [ ! -d ${1} ] ; then 751 echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 752 IGCM_debug_PopStack "IGCM_sys_Put_Dir" 753 return 754 fi 755 756 typeset RET 757 758 # Only if we use rsync 759 #IGCM_sys_TestDirArchive $( dirname $2 ) 760 # 917 IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@ 918 if ( $DEBUG_sys ) ; then 919 echo "IGCM_sys_Put_Dir :" $@ 920 fi 921 if [ $DRYRUN = 0 ]; then 922 if [ ! -d ${1} ] ; then 923 echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ." 924 IGCM_debug_PopStack "IGCM_sys_Put_Dir" 925 return 926 fi 927 928 typeset status 929 930 # Only if we use rsync 931 #IGCM_sys_TestDirArchive $( dirname $2 ) 932 # 933 #USUAL WAY 934 \cp -r $1 $2 > out_rsync 2>&1 935 status=$? 936 937 if [ ${status} -gt 0 ] ; then 938 IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}" 939 cat out_rsync 940 IGCM_debug_Exit "IGCM_sys_Put_Dir" 941 else 942 \rm out_rsync 943 fi 944 else 945 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 946 fi 947 IGCM_debug_PopStack "IGCM_sys_Put_Dir" 948 } 949 950 #D-#================================================== 951 #D-function IGCM_sys_Get_Dir 952 #D-* Purpose: Copy a complete directory from ${ARCHIVE} 953 #D-* Examples: 954 #D- 955 function IGCM_sys_Get_Dir { 956 IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 957 if ( $DEBUG_sys ) ; then 958 echo "IGCM_sys_Get_Dir :" $@ 959 fi 960 if [ $DRYRUN = 0 ]; then 961 if [ ! -d ${1} ] ; then 962 echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 963 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 964 return 965 fi 966 967 typeset status 968 761 969 #USUAL WAY 762 \cp -r $1 $2 > out_rsync 2>&1 763 RET=$? 764 765 if [ ${RET} -gt 0 ] ; then 766 echo "IGCM_sys_Put_Dir : error." 767 cat out_rsync 768 IGCM_debug_Exit "IGCM_sys_Put_Dir" 769 fi 770 else 771 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 772 fi 773 IGCM_debug_PopStack "IGCM_sys_Put_Dir" 774 } 775 776 #D-#================================================== 777 #D-function IGCM_sys_Get_Dir 778 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 779 #D-* Examples: 780 #D- 781 function IGCM_sys_Get_Dir { 782 IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@ 783 if ( $DEBUG_sys ) ; then 784 echo "IGCM_sys_Get_Dir :" $@ 785 fi 786 if [ $DRYRUN = 0 ]; then 787 if [ ! -d ${1} ] ; then 788 echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 789 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 790 return 791 fi 792 793 typeset RET 794 795 #USUAL WAY 796 \cp -rp $1 $2 > out_rsync 2>&1 797 RET=$? 798 799 if [ ${RET} -gt 0 ] ; then 800 echo "IGCM_sys_Get_Dir : error." 801 cat out_rsync 802 IGCM_debug_Exit "IGCM_sys_Get_Dir" 803 fi 804 else 805 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 806 fi 807 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 970 \cp -rp $1 $2 > out_rsync 2>&1 971 status=$? 972 973 if [ ${status} -gt 0 ] ; then 974 IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}" 975 cat out_rsync 976 IGCM_debug_Exit "IGCM_sys_Get_Dir" 977 else 978 \rm out_rsync 979 fi 980 else 981 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 982 fi 983 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 808 984 } 809 985 … … 814 990 #D- 815 991 function IGCM_sys_Get_Master { 816 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 817 if ( $DEBUG_sys ) ; then 818 echo "IGCM_sys_Get_Master :" $@ 819 fi 820 if [ $DRYRUN = 0 ]; then 821 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 822 echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 823 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 824 return 825 fi 826 827 typeset RET 828 829 #USUAL WAY 830 \cp -rp $1 $2 > out_rsync 2>&1 831 RET=$? 832 833 if [ ${RET} -gt 0 ] ; then 834 echo "IGCM_sys_Get_Dir : error." 835 cat out_rsync 836 IGCM_debug_Exit "IGCM_sys_Get_Dir" 837 fi 838 else 839 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 840 fi 841 IGCM_debug_PopStack "IGCM_sys_Get_Master" 842 } 992 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@ 993 if ( $DEBUG_sys ) ; then 994 echo "IGCM_sys_Get_Master :" $@ 995 fi 996 if [ $DRYRUN = 0 ]; then 997 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then 998 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ." 999 IGCM_debug_PopStack "IGCM_sys_Get_Master" 1000 return 1001 fi 1002 1003 typeset NB_ESSAI DELAI status i 1004 # number of tentative 1005 NB_ESSAI=3 1006 # time delay between tentative 1007 DELAI=2 1008 1009 i=0 1010 while [ $i -lt $NB_ESSAI ] ; do 1011 \cp -urL $1 $2 > out_rsync 2>&1 1012 status=$? 1013 if [ ${status} -gt 0 ]; then 1014 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}" 1015 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again." 1016 sleep $DELAI 1017 else 1018 break 1019 fi 1020 (( i = i + 1 )) 1021 done 1022 1023 if [ ${status} -gt 0 ] ; then 1024 echo "IGCM_sys_Get_Master : error." 1025 cat out_rsync 1026 IGCM_debug_Exit "IGCM_sys_Get_Master" 1027 else 1028 \rm out_rsync 1029 fi 1030 else 1031 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1032 fi 1033 IGCM_debug_PopStack "IGCM_sys_Get_Master" 1034 } 1035 1036 #==================================================== 1037 #- Call IGCM_sys_Mirror_libIGCM now ! 1038 if ( $MirrorlibIGCM ) ; then 1039 IGCM_sys_Mirror_libIGCM 1040 fi 843 1041 844 1042 #D-#================================================== 845 1043 #D-function IGCM_sys_Put_Rest 846 #D-* Purpose: Put computied restarts on $ (ARCHIVE).1044 #D-* Purpose: Put computied restarts on ${ARCHIVE}. 847 1045 #D- File and target directory must exist. 848 1046 #D-* Examples: 849 1047 #D- 850 1048 function IGCM_sys_Put_Rest { 851 IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 852 if ( $DEBUG_sys ) ; then 853 echo "IGCM_sys_Put_Rest :" $@ 854 fi 855 if [ $DRYRUN = 0 ]; then 856 if [ ! -f ${1} ] ; then 857 echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 858 IGCM_debug_Exit "IGCM_sys_Put_Rest" 859 fi 860 861 typeset RET 862 # 863 if [ X${JobType} = XRUN ] ; then 864 IGCM_sys_Chmod 444 ${1} 865 fi 866 # 867 # Only if we use rsync 868 #IGCM_sys_MkdirArchive $( dirname $2 ) 869 # 870 #USUAL WAY 871 \cp $1 $2 > out_rsync 2>&1 872 RET=$? 873 874 if [ ${RET} -gt 0 ] ; then 875 echo "IGCM_sys_Put_Rest : error." 876 cat out_rsync 877 IGCM_debug_Exit "IGCM_sys_Put_Rest" 878 fi 879 else 880 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 881 fi 882 IGCM_debug_PopStack "IGCM_sys_Put_Rest" 1049 IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@ 1050 if ( $DEBUG_sys ) ; then 1051 echo "IGCM_sys_Put_Rest :" $@ 1052 fi 1053 if [ $DRYRUN = 0 ]; then 1054 if [ ! -f ${1} ] ; then 1055 echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ." 1056 IGCM_debug_Exit "IGCM_sys_Put_Rest" 1057 fi 1058 1059 typeset status 1060 # 1061 if [ X${JobType} = XRUN ] ; then 1062 IGCM_sys_Chmod 444 ${1} 1063 fi 1064 # 1065 # Only if we use rsync 1066 #IGCM_sys_MkdirArchive $( dirname $2 ) 1067 # 1068 #USUAL WAY 1069 \cp $1 $2 > out_rsync 2>&1 1070 status=$? 1071 1072 if [ ${status} -gt 0 ] ; then 1073 echo "IGCM_sys_Put_Rest : cp failed error code ${status}" 1074 cat out_rsync 1075 IGCM_debug_Exit "IGCM_sys_Put_Rest" 1076 else 1077 \rm out_rsync 1078 fi 1079 else 1080 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1081 fi 1082 IGCM_debug_PopStack "IGCM_sys_Put_Rest" 1083 } 1084 1085 #D-#================================================== 1086 #D-function IGCM_sys_PutBuffer_Rest 1087 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}. 1088 #D- File and target directory must exist. 1089 #D-* Examples: 1090 #D- 1091 function IGCM_sys_PutBuffer_Rest { 1092 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@ 1093 if ( $DEBUG_sys ) ; then 1094 echo "IGCM_sys_PutBuffer_Rest :" $@ 1095 fi 1096 if [ $DRYRUN = 0 ]; then 1097 if [ ! -f ${1} ] ; then 1098 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ." 1099 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 1100 fi 1101 1102 typeset status 1103 # 1104 if [ X${JobType} = XRUN ] ; then 1105 IGCM_sys_Chmod 444 ${1} 1106 fi 1107 1108 # 1109 # USUAL WAY 1110 \cp $1 $2 > out_rsync 2>&1 1111 status=$? 1112 1113 if [ ${status} -gt 0 ] ; then 1114 echo "IGCM_sys_PutBuffer_Rest : error code ${status}" 1115 [ -f ${2} ] && ls -l ${2} 1116 [ -f ${2}/${1} ] && ls -l ${2}/${1} 1117 cat out_rsync 1118 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest" 1119 else 1120 \rm out_rsync 1121 fi 1122 else 1123 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1124 fi 1125 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest" 883 1126 } 884 1127 … … 896 1139 #D-#================================================== 897 1140 #D-function IGCM_sys_Put_Out 898 #D-* Purpose: Copy a file on $ (ARCHIVE) after havechmod it in readonly1141 #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly 899 1142 #D-* Examples: 900 1143 #D- 901 1144 function IGCM_sys_Put_Out { 902 IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 903 if ( $DEBUG_sys ) ; then 904 echo "IGCM_sys_Put_Out :" $@ 905 fi 906 if [ $DRYRUN = 0 ]; then 907 if [ ! -f ${1} ] ; then 908 echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 909 IGCM_debug_PopStack "IGCM_sys_Put_Out" 910 return 1 1145 IGCM_debug_PushStack "IGCM_sys_Put_Out" $@ 1146 if ( $DEBUG_sys ) ; then 1147 echo "IGCM_sys_Put_Out :" $@ 1148 fi 1149 1150 typeset status 1151 1152 if [ $DRYRUN = 0 ]; then 1153 if [ ! -f ${1} ] ; then 1154 echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ." 1155 IGCM_debug_PopStack "IGCM_sys_Put_Out" 1156 return 1 1157 fi 1158 # 1159 IGCM_sys_MkdirArchive $( dirname $2 ) 1160 # 1161 typeset RET 1162 # 1163 if [ X${JobType} = XRUN ] ; then 1164 if [ X${3} = X ] ; then 1165 IGCM_sys_Chmod 444 ${1} 911 1166 fi 912 # 913 IGCM_sys_MkdirArchive $( dirname $2 ) 914 # 915 typeset RET 916 # 1167 fi 1168 # 1169 #USUAL WAY 1170 \cp $1 $2 > out_rsync 2>&1 1171 status=$? 1172 1173 if [ ${status} -gt 0 ] ; then 1174 IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}" 1175 cat out_rsync 1176 IGCM_debug_Exit "IGCM_sys_Put_Out" 1177 else 1178 \rm out_rsync 1179 fi 1180 else 1181 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1182 fi 1183 IGCM_debug_PopStack "IGCM_sys_Put_Out" 1184 return 0 1185 } 1186 1187 #D-#================================================== 1188 #D-function IGCM_sys_PutBuffer_Out 1189 #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly 1190 #D-* Examples: 1191 #D- 1192 function IGCM_sys_PutBuffer_Out { 1193 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@ 1194 if ( $DEBUG_sys ) ; then 1195 echo "IGCM_sys_PutBuffer_Out :" $@ 1196 fi 1197 1198 typeset NB_ESSAI DELAI status i exist skip 1199 1200 # number of tentative 1201 NB_ESSAI=3 1202 # time delay between tentative 1203 DELAI=2 1204 1205 if [ $DRYRUN = 0 ]; then 1206 if [ ! -f ${1} ] ; then 1207 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ." 1208 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 1209 return 1 1210 fi 1211 # 1212 IGCM_sys_Mkdir $( dirname $2 ) 1213 # 1214 1215 exist=false 1216 skip=false 1217 if [ -f $2 ] ; then 1218 IGCM_debug_Print 1 "$2 already exist" 1219 exist=true 1220 if [ "X$( diff $1 $2 )" = X ] ; then 1221 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 1222 status=0 1223 skip=true 1224 else 1225 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 1226 skip=false 1227 fi 1228 fi 1229 # 1230 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 1231 IGCM_sys_Chmod u+w $2 1232 fi 1233 1234 if [ X${skip} = Xfalse ] ; then 1235 i=0 1236 while [ $i -lt $NB_ESSAI ] ; do 1237 # USUAL WAY 1238 \cp $1 $2 > out_rsync 2>&1 1239 status=$? 1240 if [ ${status} -gt 0 ]; then 1241 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}" 1242 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 1243 [ -f ${2} ] && ls -l ${2} 1244 [ -f ${2}/${1} ] && ls -l ${2}/${1} 1245 sleep $DELAI 1246 else 1247 break 1248 fi 1249 (( i = i + 1 )) 1250 done 1251 fi 1252 1253 if [ ${status} -gt 0 ] ; then 1254 echo "IGCM_sys_PutBuffer_Out : error." 1255 [ -f ${2} ] && ls -l ${2} 1256 [ -f ${2}/${1} ] && ls -l ${2}/${1} 1257 cat out_rsync 1258 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out" 1259 else 1260 917 1261 if [ X${JobType} = XRUN ] ; then 918 if [ X${3} = X ] ; then 919 IGCM_sys_Chmod 444 ${1} 920 fi 1262 if [ X${3} = X ] ; then 1263 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2} 1264 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1} 1265 fi 921 1266 fi 922 # 923 #USUAL WAY 924 \cp $1 $2 > out_rsync 2>&1 925 RET=$? 926 927 if [ ${RET} -gt 0 ] ; then 928 echo "IGCM_sys_Put_Out : error." 929 cat out_rsync 930 IGCM_debug_Exit "IGCM_sys_Put_Out" 931 fi 932 else 933 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 934 fi 935 IGCM_debug_PopStack "IGCM_sys_Put_Out" 936 return 0 1267 1268 \rm out_rsync 1269 fi 1270 else 1271 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1272 fi 1273 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out" 1274 return 0 937 1275 } 938 1276 … … 943 1281 #D- IGCM_sys_Get /l Array_contain_myfiles /destpath/ 944 1282 function IGCM_sys_Get { 945 IGCM_debug_PushStack "IGCM_sys_Get" $@ 946 947 typeset DEST RET dm_liste ifile target 948 949 if ( $DEBUG_sys ) ; then 950 echo "IGCM_sys_Get :" $@ 951 fi 952 if [ $DRYRUN -le 2 ]; then 953 if [ X${1} = X'/l' ] ; then 954 # test if the first file is present in the old computation : 955 eval set +A dm_liste \${${2}} 1283 IGCM_debug_PushStack "IGCM_sys_Get" $@ 1284 1285 typeset DEST status dm_liste 1286 1287 if ( $DEBUG_sys ) ; then 1288 echo "IGCM_sys_Get :" $@ 1289 fi 1290 if [ $DRYRUN -le 2 ]; then 1291 if [ X${1} = X'/l' ] ; then 1292 # test if the first file is present in the old computation : 1293 eval set +A dm_liste \${${2}} 1294 else 1295 dm_liste=${1} 1296 fi 1297 eval DEST=\${${#}} 1298 1299 # test if the (first) file is present in the old computation : 1300 DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]} 1301 if [ $? = 0 ] ; then 1302 IGCM_sys_TestFileArchive ${dm_liste[0]} 1303 status=$? 1304 else 1305 IGCM_sys_TestFileBuffer ${dm_liste[0]} 1306 status=$? 1307 fi 1308 1309 if [ ${status} -gt 0 ] ; then 1310 echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 1311 IGCM_debug_Exit "IGCM_sys_Get" 1312 return 1313 fi 1314 1315 # SD : dm_liste is not suited for computing job 1316 # because we change filename during transfert 1317 # dm_liste is better suited for post-treatment 1318 #dm_liste=" " 1319 #(( ifile=1 )) 1320 #while [ $ifile -lt $# ] ; do 1321 # dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} ) 1322 # (( ifile = ifile + 1 )) 1323 #done 1324 #DEST=$( eval echo \${${#}} ) 1325 1326 #USUAL WAY 1327 \cp ${dm_liste[*]} ${DEST} > out_rsync 2>&1 1328 status=$? 1329 1330 if [ ${status} -gt 0 ] ; then 1331 IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}" 1332 cat out_rsync 1333 IGCM_debug_Exit "IGCM_sys_Get" 1334 else 1335 \rm out_rsync 1336 fi 1337 else 1338 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1339 fi 1340 IGCM_debug_PopStack "IGCM_sys_Get" 1341 } 1342 1343 #D-#================================================== 1344 #D-function IGCM_sys_GetBuffer 1345 #D-* Purpose: Get a file from ${SCRATCHDIR} 1346 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX 1347 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/ 1348 function IGCM_sys_GetBuffer { 1349 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 1350 1351 typeset DEST buf_liste target file_work 1352 typeset NB_ESSAI DELAI status i 1353 1354 if ( $DEBUG_sys ) ; then 1355 echo "IGCM_sys_GetBuffer :" $@ 1356 fi 1357 1358 # number of tentative 1359 NB_ESSAI=3 1360 # time delay between tentative 1361 DELAI=2 1362 1363 if [ $DRYRUN -le 2 ]; then 1364 if [ X${1} = X'/l' ] ; then 1365 # test if the first file is present in the old computation : 1366 eval set +A buf_liste \${${2}} 1367 else 1368 eval set +A buf_liste ${1} 1369 fi 1370 eval DEST=\${${#}} 1371 1372 #USUAL WAY 1373 if [ X${1} = X'/l' ] ; then 1374 for target in ${buf_liste[*]} ; do 1375 local_file=$( basename ${target} ) 1376 i=0 1377 while [ $i -lt $NB_ESSAI ] ; do 1378 \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 1379 status=$? 1380 if [ ${status} -gt 0 ]; then 1381 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 1382 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 1383 sleep $DELAI 1384 else 1385 break 1386 fi 1387 (( i = i + 1 )) 1388 done 1389 if [ ${status} -gt 0 ] ; then 1390 echo "IGCM_sys_Get : error" 1391 cat out_rsync 1392 \rm out_rsync 1393 IGCM_debug_Exit "IGCM_sys_GetBuffer" 1394 else 1395 \rm out_rsync 1396 fi 1397 done 1398 else 1399 i=0 1400 while [ $i -lt $NB_ESSAI ] ; do 1401 \cp ${buf_liste} ${DEST} >> out_rsync 2>&1 1402 status=$? 1403 if [ ${status} -gt 0 ]; then 1404 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}" 1405 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again." 1406 sleep $DELAI 1407 else 1408 break 1409 fi 1410 (( i = i + 1 )) 1411 done 1412 if [ ${status} -gt 0 ] ; then 1413 echo "IGCM_sys_Get : error" 1414 cat out_rsync 1415 \rm out_rsync 1416 IGCM_debug_Exit "IGCM_sys_GetBuffer" 956 1417 else 957 dm_liste=${1}1418 \rm out_rsync 958 1419 fi 959 eval DEST=\${${#}} 960 961 # test if the (first) file is present in the old computation : 962 IGCM_sys_TestFileArchive ${dm_liste[0]} 963 RET=$? 964 if [ ${RET} -gt 0 ] ; then 965 echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 966 IGCM_debug_Exit "IGCM_sys_Get" 967 return 968 fi 969 970 # SD : dm_liste is not suited for computing job 971 # because we change filename during transfert 972 # dm_liste is better suited for post-treatment 973 #dm_liste=" " 974 #(( ifile=1 )) 975 #while [ $ifile -lt $# ] ; do 976 # dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} ) 977 # (( ifile = ifile + 1 )) 978 #done 979 #DEST=$( eval echo \${${#}} ) 980 981 #USUAL WAY 982 \cp ${dm_liste[*]} ${DEST} > out_rsync 2>&1 983 RET=$? 984 985 if [ ${RET} -gt 0 ] ; then 986 echo "IGCM_sys_Get : copy error." 987 cat out_rsync 988 IGCM_debug_Exit "IGCM_sys_Get" 989 fi 990 else 991 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 992 fi 993 IGCM_debug_PopStack "IGCM_sys_Get" 994 } 995 996 ############################################################## A FINIR !! 1420 fi 1421 else 1422 ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 1423 fi 1424 IGCM_debug_PopStack "IGCM_sys_GetBuffer" 1425 } 997 1426 998 1427 #D-#================================================== … … 1002 1431 #D- 1003 1432 function IGCM_sys_GetDate_FichWork { 1004 1005 1006 1007 1008 1009 1433 IGCM_debug_PushStack "IGCM_sys_FichWork" $@ 1434 if ( $DEBUG_sys ) ; then 1435 echo "IGCM_sys_GetDate_FichWork :" $@ 1436 fi 1437 # donne la date filesys d'un fichier sur la machine work 1438 IGCM_debug_PopStack "IGCM_sys_FichWork" 1010 1439 } 1011 1440 … … 1016 1445 #D- 1017 1446 function IGCM_sys_GetDate_FichArchive { 1018 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 1019 if ( $DEBUG_sys ) ; then 1020 echo "IGCM_sys_GetDate_FichArchive :" $@ 1021 fi 1022 IGCM_debug_PopStack "IGCM_sys_FichArchive" 1447 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@ 1448 if ( $DEBUG_sys ) ; then 1449 echo "IGCM_sys_GetDate_FichArchive :" $@ 1450 fi 1451 IGCM_debug_PopStack "IGCM_sys_FichArchive" 1452 } 1453 1454 #D-#================================================== 1455 #D-function IGCM_sys_Put_Dods 1456 #D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here 1457 #D-* Examples: 1458 #D- 1459 function IGCM_sys_Put_Dods { 1460 IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@ 1461 if ( $DEBUG_sys ) ; then 1462 echo "IGCM_sys_Put_Dods :" $@ 1463 fi 1464 IGCM_debug_PopStack "IGCM_sys_Put_Dods" 1023 1465 } 1024 1466 … … 1026 1468 # REBUILD OPERATOR 1027 1469 1470 #D-#================================================== 1471 #D-function IGCM_sys_rebuild 1472 #D-* Purpose: rebuild parallel files 1473 #D-* Examples: 1474 #D- 1028 1475 function IGCM_sys_rebuild { 1029 IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 1030 if ( $DEBUG_sys ) ; then 1031 echo "IGCM_sys_rebuild :" $@ 1032 fi 1033 /gpfs1/home/sebastien/REBUILD/rebuild -f -o $@ 1034 if [ $? -gt 0 ] ; then 1035 echo "IGCM_sys_rebuild : erreur ${@}." 1036 IGCM_debug_Exit "rebuild" 1037 fi 1038 1039 IGCM_debug_PopStack "IGCM_sys_rebuild" 1476 IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@ 1477 if ( $DEBUG_sys ) ; then 1478 echo "IGCM_sys_rebuild :" $@ 1479 fi 1480 1481 typeset NB_ESSAI DELAI status i firstArg 1482 # number of tentative 1483 NB_ESSAI=3 1484 # time delay between tentative 1485 DELAI=2 1486 1487 i=0 1488 while [ $i -lt $NB_ESSAI ] ; do 1489 /gpfs1/home/sebastien/REBUILD/rebuild -f -o $@ > out_rsync 2>&1 1490 status=$? 1491 if [ ${status} -gt 0 ] ; then 1492 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}" 1493 cat out_rsync 1494 \rm out_rsync 1495 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1496 firstArg=${1} 1497 \rm ${firstArg} 1498 sleep $DELAI 1499 else 1500 \rm out_rsync 1501 break 1502 fi 1503 (( i = i + 1 )) 1504 done 1505 1506 if [ ${status} -gt 0 ] ; then 1507 echo "IGCM_sys_rebuild : rebuild error code is ${status}" 1508 IGCM_debug_Exit "rebuild" 1509 fi 1510 1511 IGCM_debug_PopStack "IGCM_sys_rebuild" 1512 } 1513 1514 #D-#================================================== 1515 #D-function IGCM_sys_rebuild_station 1516 #D-* Purpose: rebuild parallel files describing station 1517 #D-* Examples: 1518 #D- 1519 function IGCM_sys_rebuild_station { 1520 IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@ 1521 typeset i list_opt file_in file_out prefix_invert list_invert 1522 if ( $DEBUG_sys ) ; then 1523 echo "IGCM_sys_rebuild_station :" $@ 1524 fi 1525 list_opt=$@ 1526 1527 # Invert Axis : t,x -> x,t 1528 # t,pres,x -> x,t,pres 1529 # So that we can concatenate along x 1530 i=0 1531 for file_in in ${list_opt} ; do 1532 (( i = i + 1)) 1533 [ ${i} = 1 ] && file_out=${file_in} && continue 1534 prefix_invert=$( basename ${file_in} .nc ) 1535 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc 1536 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc 1537 done 1538 1539 # Concatenate 1540 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc 1541 1542 # Re-ivert file 1543 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out} 1544 1545 # Station re-ordering is too expansive to be run within libICGM 1546 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence. 1547 # This re-ordering must be done "in memory" by the cmorization process 1548 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq) 1549 # BEGIN reordering 1550 1551 # Only LMDZ text output contains the exact ordering of the station. 1552 # We isolate this in the code below: 1553 # 0 38 -157.5000000000000 70.98591549295774 1554 # 0 54 27.49999999999999 67.18309859154928 1555 # 0 56 -62.50000000000001 82.39436619718309 1556 # 0 79 12.49999999999999 78.59154929577466 1557 # 0 116 -165.0000000000000 76.05633802816901 1558 # 0 117 130.0000000000000 70.98591549295774 1559 # 0 118 110.0000000000000 87.46478873239437 1560 # 1 40 4.999999999999995 51.97183098591550 1561 # typeset iStation iProc list_opt file_in file_out prefix_invert 1562 # typeset -Z4 j4 1563 # typeset -Z3 j3 1564 1565 # unset list_opt 1566 # set +A list_opt $@ 1567 1568 # Filename after rebuild 1569 # file_out=${list_opt[0]} 1570 # Prefix of output files 1571 # prefix_invert=$( basename ${file_out} .nc ) 1572 # Number of procs 1573 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l ) 1574 1575 # iProc=0 1576 # while [ ${iProc} -lt ${num_proc} ] ; do 1577 # Array containing Station as a number 1578 # unset proc_stn 1579 # 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" | awk ' {print $2}' ) 1580 # Number of stations produced by processor proc 1581 # stationLast=${#proc_stn[*]} 1582 # Proc number on 4 digits 1583 # j4=${iProc} 1584 # Init 1585 # iStation=0 1586 # while [ ${iStation} -lt ${stationLast} ] ; do 1587 # Station number on 3 digits 1588 # j3=${proc_stn[${iStation}]} 1589 # Extract station 1590 # Invert Axis : t,x -> x,t 1591 # t,pres,x -> x,t,pres 1592 # So that we can concatenate along x 1593 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc 1594 # (( iStation = iStation + 1 )) 1595 # done 1596 # (( iProc = iProc + 1 )) 1597 # done 1598 1599 # Concatenate all station along x 1600 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc 1601 1602 # Re-invert file 1603 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out} 1604 1605 # END reordering 1606 1607 IGCM_debug_PopStack "IGCM_sys_rebuild_station" 1040 1608 } 1041 1609 … … 1043 1611 # Activate Running Environnment Variables 1044 1612 1613 #D-#================================================== 1614 #D-function IGCM_sys_desactiv_variables 1615 #D-* Purpose: set environement variables prior to execution 1616 #D-* Examples: 1617 #D- 1045 1618 function IGCM_sys_activ_variables { 1046 1047 1048 1049 1619 IGCM_debug_PushStack "IGCM_sys_activ_variables" 1620 if ( $DEBUG_sys ) ; then 1621 echo "IGCM_sys_activ_variables " 1622 fi 1050 1623 1051 1624 # -------------------------------------------------------------------- … … 1057 1630 # -------------------------------------------------------------------- 1058 1631 1059 IGCM_debug_PopStack "IGCM_sys_activ_variables" 1060 1632 IGCM_debug_PopStack "IGCM_sys_activ_variables" 1061 1633 } 1062 1634 … … 1064 1636 # Desactivate Running Environnment Variables 1065 1637 1638 #D-#================================================== 1639 #D-function IGCM_sys_desactiv_variables 1640 #D-* Purpose: unset environement variables after execution 1641 #D-* Examples: 1642 #D- 1066 1643 function IGCM_sys_desactiv_variables { 1067 1068 1069 1070 1644 IGCM_debug_PushStack "IGCM_sys_desactiv_variables" 1645 if ( $DEBUG_sys ) ; then 1646 echo "IGCM_sys_desactiv_variables " 1647 fi 1071 1648 # -------------------------------------------------------------------- 1072 1649 #D- MPI specifications … … 1077 1654 # -------------------------------------------------------------------- 1078 1655 1079 IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 1080 1656 IGCM_debug_PopStack "IGCM_sys_desactiv_variables" 1081 1657 } 1082 1658 1083 1659 ############################################################ 1084 # Build run file 1085 1660 # Build MPI/OMP scripts run file (dummy function) 1661 1662 #D-#================================================== 1663 #D-function IGCM_sys_build_run_file 1664 #D-* Purpose: build run file (deprecated) 1665 #D-* Examples: 1666 #D- 1086 1667 function IGCM_sys_build_run_file { 1087 IGCM_debug_PushStack "IGCM_sys_build_run_file" $@ 1088 set -x 1668 1669 IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file " 1670 1671 } 1672 1673 ############################################################ 1674 # Build MPI/OMP scripts 1675 1676 #D-#================================================== 1677 #D-function IGCM_sys_build_execution_scripts 1678 #D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND} 1679 #D-* Examples: 1680 #D- 1681 function IGCM_sys_build_execution_scripts 1682 { 1683 IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@ 1684 if ( $DEBUG_sys ) ; then 1685 echo "IGCM_sys_build_execution_scripts " $@ 1686 fi 1687 1688 typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count 1689 1690 if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then 1691 IGCM_debug_Exit "IGCM_sys_iitm build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} " 1692 fi 1693 1694 if ( ${OK_PARA_MPMD} ) ; then 1695 1696 if [ -f run_file ] ; then 1697 IGCM_sys_Rm -f run_file 1698 fi 1699 touch run_file 1700 1701 if ( ${OK_PARA_OMP} ) ; then 1702 # NEW : 2 Noeuds 1703 # @ task_geometry={(0)(1,2,3)} 1704 # Nombre de processus demandes 1705 echo "Job_${config_UserChoices_JobName} includes task_geometry = \c" 1706 cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" 1707 echo "Job_${config_UserChoices_JobName} includes task_geometry with NbNodes = \c" 1708 cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c 1709 NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 )) 1710 1711 if [ ${NbNodes_Job} -eq 0 ] ; then 1712 IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run." 1713 exit 1 1714 fi 1715 else 1716 1717 # OLD : 1718 # @ total_tasks = 3 1719 # @ environment = "BATCH_NUM_PROC_TOT=3" 1720 # Pas d OpenMP 1721 # @ resources = ConsumableCpus(1) 1722 1723 echo "Job_${config_UserChoices_JobName} includes total_tasks = \c" 1724 cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" 1725 NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" ) 1726 NbProc_Job=${NbProc_Job:=0} 1727 if [ ${NbProc_Job} -eq 0 ] ; then 1728 IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run." 1729 exit 1 1730 fi 1731 if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then 1732 IGCM_debug_Print 2 "ressources = ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}" 1733 else 1734 IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) " 1735 exit 1 1736 fi 1737 fi 1738 1739 # run_file construction 1740 1741 # Then first loop on the components for the coupler ie oasis 1742 1743 ### the coupler ie oasis must be the first one 1744 for comp in ${config_ListOfComponents[*]} ; do 1745 1746 eval ExeNameIn=\${config_Executable_${comp}[0]} 1747 eval ExeNameOut=\${config_Executable_${comp}[1]} 1748 1749 # for CPL component only 1750 if [ "X${comp}" = "XCPL" ] ; then 1751 1752 eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 1753 eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 1754 1755 if ( ${OK_PARA_MPI} ) ; then 1756 1757 (( mpi_count = 1 )) 1758 until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do 1759 if ( ${OK_PARA_OMP} ) ; then 1760 echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file 1761 else 1762 echo "./${ExeNameOut}" >> run_file 1763 fi 1764 (( mpi_count = mpi_count + 1 )) 1765 done 1766 else 1767 if ( ${OK_PARA_OMP} ) ; then 1768 echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file 1769 else 1770 echo "./${ExeNameOut} " >> run_file 1771 fi 1772 fi 1773 fi 1774 done 1775 1776 # Then second loop on the components 1777 1778 for comp in ${config_ListOfComponents[*]} ; do 1779 1780 eval ExeNameIn=\${config_Executable_${comp}[0]} 1781 eval ExeNameOut=\${config_Executable_${comp}[1]} 1782 1783 # Only if we really have an executable for the component and not the coupler ie oasis: 1784 if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then 1785 1786 eval comp_proc_mpi_loc=\${${comp}_PROC_MPI} 1787 eval comp_proc_omp_loc=\${${comp}_PROC_OMP} 1788 1789 if ( ${OK_PARA_MPI} ) ; then 1790 1791 (( mpi_count = 1 )) 1792 until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do 1793 if ( ${OK_PARA_OMP} ) ; then 1794 echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file 1795 else 1796 echo "./${ExeNameOut}" >> run_file 1797 fi 1798 (( mpi_count = mpi_count + 1 )) 1799 done 1800 else 1801 if ( ${OK_PARA_OMP} ) ; then 1802 echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file 1803 else 1804 # to be tested : no MPI only OpenMP into MPMD mode 1805 echo "./${ExeNameOut} " >> run_file 1806 fi 1807 fi 1808 fi 1809 done 1810 1811 EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file" 1812 1813 IGCM_sys_Chmod u+x run_file 1089 1814 if ( $DEBUG_sys ) ; then 1090 echo "IGCM_sys_build_run_file " $@ 1091 fi 1092 1093 NUM_PROC_OASIS=1 1094 1095 # Set the number of processors for OCE here 1096 NUM_PROC_OCE=5 1097 1098 (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - NUM_PROC_OASIS - NUM_PROC_OCE )) 1099 1100 if [ $1 = MPI2 ]; then 1101 echo "IGCM_sys_build_run_file : error - MPI2 not available on iitm. " 1102 IGCM_debug_Exit "IGCM_sys_build_run_file" 1103 elif [ $1 = MPI1 ]; then 1104 cat <<EOF > run_file 1105 ./oasis 1106 EOF 1107 1108 typeset i 1109 (( i = 0 )) 1110 while [ ${i} -lt ${NUM_PROC_ATM} ] ; do 1111 (( i = i + 1 )) 1112 cat <<EOF >> run_file 1113 ./lmdz.x 1114 EOF 1115 done 1116 1117 (( i = 0 )) 1118 while [ ${i} -lt ${NUM_PROC_OCE} ] ; do 1119 (( i = i + 1 )) 1120 cat <<EOF >> run_file 1121 ./opa.xx 1122 EOF 1123 done 1124 1125 wc -l run_file 1126 fi 1127 set +x 1128 IGCM_debug_PopStack "IGCM_sys_build_run_file" 1815 echo "run_file contains : " 1816 cat run_file 1817 fi 1818 1819 else # Only one executable. launch it. 1820 1821 for comp in ${config_ListOfComponents[*]} ; do 1822 1823 # Only if we really have an executable for the component : 1824 eval ExeNameOut=\${config_Executable_${comp}[1]} 1825 if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then 1826 EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}" 1827 fi 1828 1829 done 1830 1831 fi 1832 1833 IGCM_debug_Print 1 "sys iitm : execution command is " 1834 IGCM_debug_Print 1 "$EXECUTION" 1835 1836 IGCM_debug_PopStack "IGCM_sys_build_execution_scripts" 1129 1837 } 1130 1838 1131 1839 ############################################################ 1132 # Check of space available on temporary filesytems 1840 # Check of space available on temporary filesytems. Dummy function here 1841 1842 #D-#================================================== 1843 #D-function IGCM_sys_check_quota. Dummy call here 1844 #D-* Purpose: check user quota. Stop the simulation if quota above 90% 1845 #D-* Examples: 1846 #D- 1133 1847 function IGCM_sys_check_quota { 1134 IGCM_debug_PushStack "IGCM_sys_check_quota" 1135 if ( $DEBUG_sys ) ; then 1136 echo "IGCM_sys_check_quota" 1137 fi 1138 IGCM_debug_PopStack "IGCM_sys_check_quota" 1139 } 1848 IGCM_debug_PushStack "IGCM_sys_check_quota" 1849 if ( $DEBUG_sys ) ; then 1850 echo "IGCM_sys_check_quota" 1851 fi 1852 IGCM_debug_PopStack "IGCM_sys_check_quota" 1853 } 1854 1855 #D-#================================================== 1856 #D-function IGCM_sys_CountJobInQueue 1857 #D-* Purpose: Check if job_name is currently 1858 #D- running or in queue 1859 #D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun 1860 #D- 1861 function IGCM_sys_CountJobInQueue { 1862 IGCM_debug_PushStack "IGCM_sys_CountJobInQueue" 1863 if ( $DEBUG_sys ) ; then 1864 echo "IGCM_sys_CountJobInQueue" 1865 fi 1866 1867 # Print only the full (-W) JobName (%jn) 1868 NbRun=$( llq -W -f %jn | grep -c "$1" ) 1869 1870 eval ${2}=${NbRun} 1871 1872 IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 1873 } 1874 1875 ############################################################## 1876 # NCO OPERATOR 1877 1878 #D-#================================================== 1879 #D-function IGCM_sys_ncap2 1880 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry 1881 #D-* Examples: 1882 #D- 1883 function IGCM_sys_ncap2 { 1884 IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@ 1885 if ( $DEBUG_sys ) ; then 1886 echo "IGCM_sys_ncap2 :" $@ 1887 fi 1888 1889 typeset NB_ESSAI DELAI status i 1890 # number of tentative 1891 NB_ESSAI=3 1892 # time delay between tentative 1893 DELAI=2 1894 1895 i=0 1896 while [ $i -lt $NB_ESSAI ] ; do 1897 ncap2 "$@" > out_rsync 2>&1 1898 status=$? 1899 if [ ${status} -gt 0 ] ; then 1900 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}" 1901 cat out_rsync 1902 \rm out_rsync 1903 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1904 sleep $DELAI 1905 else 1906 \rm out_rsync 1907 break 1908 fi 1909 (( i = i + 1 )) 1910 done 1911 1912 if [ ${status} -gt 0 ] ; then 1913 echo "IGCM_sys_ncap2 : ncap2 error" 1914 IGCM_debug_Exit "ncap2" 1915 fi 1916 1917 IGCM_debug_PopStack "IGCM_sys_ncap2" 1918 } 1919 1920 #D-#================================================== 1921 #D-function IGCM_sys_ncatted 1922 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry 1923 #D-* Examples: 1924 #D- 1925 function IGCM_sys_ncatted { 1926 IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@ 1927 if ( $DEBUG_sys ) ; then 1928 echo "IGCM_sys_ncatted :" $@ 1929 fi 1930 1931 typeset NB_ESSAI DELAI status i 1932 # number of tentative 1933 NB_ESSAI=3 1934 # time delay between tentative 1935 DELAI=2 1936 1937 i=0 1938 while [ $i -lt $NB_ESSAI ] ; do 1939 ncatted "$@" > out_rsync 2>&1 1940 status=$? 1941 if [ ${status} -gt 0 ] ; then 1942 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}" 1943 cat out_rsync 1944 \rm out_rsync 1945 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1946 sleep $DELAI 1947 else 1948 \rm out_rsync 1949 break 1950 fi 1951 (( i = i + 1 )) 1952 done 1953 1954 if [ ${status} -gt 0 ] ; then 1955 echo "IGCM_sys_ncatted : ncatted error" 1956 IGCM_debug_Exit "ncatted" 1957 fi 1958 1959 IGCM_debug_PopStack "IGCM_sys_ncatted" 1960 } 1961 1962 #D-#================================================== 1963 #D-function IGCM_sys_ncbo 1964 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry 1965 #D-* Examples: 1966 #D- 1967 function IGCM_sys_ncbo { 1968 IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@ 1969 if ( $DEBUG_sys ) ; then 1970 echo "IGCM_sys_ncbo :" $@ 1971 fi 1972 1973 typeset NB_ESSAI DELAI status i 1974 # number of tentative 1975 NB_ESSAI=3 1976 # time delay between tentative 1977 DELAI=2 1978 1979 i=0 1980 while [ $i -lt $NB_ESSAI ] ; do 1981 ncbo $@ > out_rsync 2>&1 1982 status=$? 1983 if [ ${status} -gt 0 ] ; then 1984 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}" 1985 cat out_rsync 1986 \rm out_rsync 1987 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 1988 sleep $DELAI 1989 else 1990 \rm out_rsync 1991 break 1992 fi 1993 (( i = i + 1 )) 1994 done 1995 1996 if [ ${status} -gt 0 ] ; then 1997 echo "IGCM_sys_ncbo : ncbo error" 1998 IGCM_debug_Exit "ncbo" 1999 fi 2000 2001 IGCM_debug_PopStack "IGCM_sys_ncbo" 2002 } 2003 2004 #D-#================================================== 2005 #D-function IGCM_sys_ncdif 2006 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry 2007 #D-* Examples: 2008 #D- 2009 function IGCM_sys_ncdiff { 2010 IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@ 2011 if ( $DEBUG_sys ) ; then 2012 echo "IGCM_sys_ncdiff :" $@ 2013 fi 2014 2015 typeset NB_ESSAI DELAI status i 2016 # number of tentative 2017 NB_ESSAI=3 2018 # time delay between tentative 2019 DELAI=2 2020 2021 i=0 2022 while [ $i -lt $NB_ESSAI ] ; do 2023 ncdiff $@ > out_rsync 2>&1 2024 status=$? 2025 if [ ${status} -gt 0 ] ; then 2026 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}" 2027 cat out_rsync 2028 \rm out_rsync 2029 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2030 sleep $DELAI 2031 else 2032 \rm out_rsync 2033 break 2034 fi 2035 (( i = i + 1 )) 2036 done 2037 2038 if [ ${status} -gt 0 ] ; then 2039 echo "IGCM_sys_ncdiff : ncdiff error" 2040 IGCM_debug_Exit "ncdiff" 2041 fi 2042 2043 IGCM_debug_PopStack "IGCM_sys_ncdiff" 2044 } 2045 2046 #D-#================================================== 2047 #D-function IGCM_sys_ncea 2048 #D-* Purpose: encapsulate ncea call so as to manage error code and retry 2049 #D-* Examples: 2050 #D- 2051 function IGCM_sys_ncea { 2052 IGCM_debug_PushStack "IGCM_sys_ncea" -- $@ 2053 if ( $DEBUG_sys ) ; then 2054 echo "IGCM_sys_ncea :" $@ 2055 fi 2056 2057 typeset NB_ESSAI DELAI status i 2058 # number of tentative 2059 NB_ESSAI=3 2060 # time delay between tentative 2061 DELAI=2 2062 2063 i=0 2064 while [ $i -lt $NB_ESSAI ] ; do 2065 ncea $@ > out_rsync 2>&1 2066 status=$? 2067 if [ ${status} -gt 0 ] ; then 2068 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}" 2069 cat out_rsync 2070 \rm out_rsync 2071 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2072 sleep $DELAI 2073 else 2074 \rm out_rsync 2075 break 2076 fi 2077 (( i = i + 1 )) 2078 done 2079 2080 if [ ${status} -gt 0 ] ; then 2081 echo "IGCM_sys_ncea : ncea error" 2082 IGCM_debug_Exit "ncea" 2083 fi 2084 2085 IGCM_debug_PopStack "IGCM_sys_ncea" 2086 } 2087 2088 #D-#================================================== 2089 #D-function IGCM_sys_ncecat 2090 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry 2091 #D-* Examples: 2092 #D- 2093 function IGCM_sys_ncecat { 2094 IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@ 2095 if ( $DEBUG_sys ) ; then 2096 echo "IGCM_sys_ncecat :" $@ 2097 fi 2098 2099 typeset NB_ESSAI DELAI status i 2100 # number of tentative 2101 NB_ESSAI=3 2102 # time delay between tentative 2103 DELAI=2 2104 2105 i=0 2106 while [ $i -lt $NB_ESSAI ] ; do 2107 ncecat $@ > out_rsync 2>&1 2108 status=$? 2109 if [ ${status} -gt 0 ] ; then 2110 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}" 2111 cat out_rsync 2112 \rm out_rsync 2113 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2114 sleep $DELAI 2115 else 2116 \rm out_rsync 2117 break 2118 fi 2119 (( i = i + 1 )) 2120 done 2121 2122 if [ ${status} -gt 0 ] ; then 2123 echo "IGCM_sys_ncecat : ncecat error" 2124 IGCM_debug_Exit "ncecat" 2125 fi 2126 2127 IGCM_debug_PopStack "IGCM_sys_ncecat" 2128 } 2129 2130 #D-#================================================== 2131 #D-function IGCM_sys_ncflint 2132 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry 2133 #D-* Examples: 2134 #D- 2135 function IGCM_sys_ncflint { 2136 IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@ 2137 if ( $DEBUG_sys ) ; then 2138 echo "IGCM_sys_ncflint :" $@ 2139 fi 2140 2141 typeset NB_ESSAI DELAI status i 2142 # number of tentative 2143 NB_ESSAI=3 2144 # time delay between tentative 2145 DELAI=2 2146 2147 i=0 2148 while [ $i -lt $NB_ESSAI ] ; do 2149 ncflint $@ > out_rsync 2>&1 2150 status=$? 2151 if [ ${status} -gt 0 ] ; then 2152 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}" 2153 cat out_rsync 2154 \rm out_rsync 2155 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2156 sleep $DELAI 2157 else 2158 \rm out_rsync 2159 break 2160 fi 2161 (( i = i + 1 )) 2162 done 2163 2164 if [ ${status} -gt 0 ] ; then 2165 echo "IGCM_sys_ncflint : ncflint error" 2166 IGCM_debug_Exit "ncflint" 2167 fi 2168 2169 IGCM_debug_PopStack "IGCM_sys_ncflint" 2170 } 2171 2172 #D-#================================================== 2173 #D-function IGCM_sys_ncks 2174 #D-* Purpose: encapsulate ncks call so as to manage error code and retry 2175 #D-* Examples: 2176 #D- 2177 function IGCM_sys_ncks { 2178 IGCM_debug_PushStack "IGCM_sys_ncks" -- $@ 2179 if ( $DEBUG_sys ) ; then 2180 echo "IGCM_sys_ncks :" $@ 2181 fi 2182 2183 typeset NB_ESSAI DELAI status i 2184 # number of tentative 2185 NB_ESSAI=3 2186 # time delay between tentative 2187 DELAI=2 2188 2189 i=0 2190 while [ $i -lt $NB_ESSAI ] ; do 2191 ncks $@ > out_rsync 2>&1 2192 status=$? 2193 if [ ${status} -gt 0 ] ; then 2194 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}" 2195 cat out_rsync 2196 \rm out_rsync 2197 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2198 sleep $DELAI 2199 else 2200 \rm out_rsync 2201 break 2202 fi 2203 (( i = i + 1 )) 2204 done 2205 2206 if [ ${status} -gt 0 ] ; then 2207 echo "IGCM_sys_ncks : ncks error" 2208 IGCM_debug_Exit "ncks" 2209 fi 2210 2211 IGCM_debug_PopStack "IGCM_sys_ncks" 2212 } 2213 2214 #D-#================================================== 2215 #D-function IGCM_sys_ncpdq 2216 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry 2217 #D-* Examples: 2218 #D- 2219 function IGCM_sys_ncpdq { 2220 IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@ 2221 if ( $DEBUG_sys ) ; then 2222 echo "IGCM_sys_ncpdq :" $@ 2223 fi 2224 2225 typeset NB_ESSAI DELAI status i 2226 # number of tentative 2227 NB_ESSAI=3 2228 # time delay between tentative 2229 DELAI=2 2230 2231 i=0 2232 while [ $i -lt $NB_ESSAI ] ; do 2233 ncpdq $@ > out_rsync 2>&1 2234 status=$? 2235 if [ ${status} -gt 0 ] ; then 2236 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}" 2237 cat out_rsync 2238 \rm out_rsync 2239 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2240 sleep $DELAI 2241 else 2242 \rm out_rsync 2243 break 2244 fi 2245 (( i = i + 1 )) 2246 done 2247 2248 if [ ${status} -gt 0 ] ; then 2249 echo "IGCM_sys_ncpdq : ncpdq error" 2250 IGCM_debug_Exit "ncpdq" 2251 fi 2252 2253 IGCM_debug_PopStack "IGCM_sys_ncpdq" 2254 } 2255 2256 #D-#================================================== 2257 #D-function IGCM_sys_ncra 2258 #D-* Purpose: encapsulate ncra call so as to manage error code and retry 2259 #D-* Examples: 2260 #D- 2261 function IGCM_sys_ncra { 2262 IGCM_debug_PushStack "IGCM_sys_ncra" -- $@ 2263 if ( $DEBUG_sys ) ; then 2264 echo "IGCM_sys_ncra :" $@ 2265 fi 2266 2267 typeset NB_ESSAI DELAI status i 2268 # number of tentative 2269 NB_ESSAI=3 2270 # time delay between tentative 2271 DELAI=2 2272 2273 i=0 2274 while [ $i -lt $NB_ESSAI ] ; do 2275 ncra $@ > out_rsync 2>&1 2276 status=$? 2277 if [ ${status} -gt 0 ] ; then 2278 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}" 2279 cat out_rsync 2280 \rm out_rsync 2281 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2282 sleep $DELAI 2283 else 2284 \rm out_rsync 2285 break 2286 fi 2287 (( i = i + 1 )) 2288 done 2289 2290 if [ ${status} -gt 0 ] ; then 2291 echo "IGCM_sys_ncra : ncra error" 2292 IGCM_debug_Exit "ncra" 2293 fi 2294 2295 IGCM_debug_PopStack "IGCM_sys_ncra" 2296 } 2297 2298 #D-#================================================== 2299 #D-function IGCM_sys_ncrcat 2300 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry 2301 #D-* Examples: 2302 #D- 2303 function IGCM_sys_ncrcat { 2304 IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@ 2305 if ( $DEBUG_sys ) ; then 2306 echo "IGCM_sys_ncrcat :" $@ 2307 fi 2308 2309 typeset NB_ESSAI DELAI status i lastArg 2310 # number of tentative 2311 NB_ESSAI=3 2312 # time delay between tentative 2313 DELAI=2 2314 2315 i=0 2316 while [ $i -lt $NB_ESSAI ] ; do 2317 ncrcat $@ > out_rsync 2>&1 2318 status=$? 2319 if [ ${status} -gt 0 ] ; then 2320 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}" 2321 cat out_rsync 2322 \rm out_rsync 2323 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2324 sleep $DELAI 2325 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" out_rsync )" = "X" ] ; then 2326 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity" 2327 cat out_rsync 2328 # remove files having corrupted time axis 2329 eval lastArg=\${$#} 2330 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}" 2331 \rm ${lastArg} 2332 \rm out_rsync 2333 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2334 sleep $DELAI 2335 else 2336 \rm out_rsync 2337 break 2338 fi 2339 (( i = i + 1 )) 2340 done 2341 2342 if [ ${status} -gt 0 ] ; then 2343 echo "IGCM_sys_ncrcat : ncrcat error" 2344 #IGCM_debug_Exit "ncrcat" 2345 fi 2346 2347 IGCM_debug_PopStack "IGCM_sys_ncrcat" 2348 } 2349 2350 #D-#================================================== 2351 #D-function IGCM_sys_ncrename 2352 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry 2353 #D-* Examples: 2354 #D- 2355 function IGCM_sys_ncrename { 2356 IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@ 2357 if ( $DEBUG_sys ) ; then 2358 echo "IGCM_sys_ncrename :" $@ 2359 fi 2360 2361 typeset NB_ESSAI DELAI status i 2362 # number of tentative 2363 NB_ESSAI=3 2364 # time delay between tentative 2365 DELAI=2 2366 2367 i=0 2368 while [ $i -lt $NB_ESSAI ] ; do 2369 ncrename $@ > out_rsync 2>&1 2370 status=$? 2371 if [ ${status} -gt 0 ] ; then 2372 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}" 2373 cat out_rsync 2374 \rm out_rsync 2375 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2376 sleep $DELAI 2377 else 2378 \rm out_rsync 2379 break 2380 fi 2381 (( i = i + 1 )) 2382 done 2383 2384 if [ ${status} -gt 0 ] ; then 2385 echo "IGCM_sys_ncrename : ncrename error" 2386 IGCM_debug_Exit "ncrename" 2387 fi 2388 2389 IGCM_debug_PopStack "IGCM_sys_ncrename" 2390 } 2391 2392 #D-#================================================== 2393 #D-function IGCM_sys_ncwa 2394 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry 2395 #D-* Examples: 2396 #D- 2397 function IGCM_sys_ncwa { 2398 IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@ 2399 if ( $DEBUG_sys ) ; then 2400 echo "IGCM_sys_ncwa :" $@ 2401 fi 2402 2403 typeset NB_ESSAI DELAI status i 2404 # number of tentative 2405 NB_ESSAI=3 2406 # time delay between tentative 2407 DELAI=2 2408 2409 i=0 2410 while [ $i -lt $NB_ESSAI ] ; do 2411 ncwa $@ > out_rsync 2>&1 2412 status=$? 2413 if [ ${status} -gt 0 ] ; then 2414 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}" 2415 cat out_rsync 2416 \rm out_rsync 2417 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again." 2418 sleep $DELAI 2419 else 2420 \rm out_rsync 2421 break 2422 fi 2423 (( i = i + 1 )) 2424 done 2425 2426 if [ ${status} -gt 0 ] ; then 2427 echo "IGCM_sys_ncwa : ncwa error" 2428 IGCM_debug_Exit "ncwa" 2429 fi 2430 2431 IGCM_debug_PopStack "IGCM_sys_ncwa" 2432 } 2433 2434 ############################################################## 2435 # CDO OPERATOR 2436 2437 #D-#================================================== 2438 #D-function IGCM_sys_cdo 2439 #D-* Purpose: encapsulate cdo call so as to manage error code and retry 2440 #D-* Examples: 2441 #D- 2442 function IGCM_sys_cdo { 2443 IGCM_debug_PushStack "IGCM_sys_cdo" -- $@ 2444 if ( $DEBUG_sys ) ; then 2445 echo "IGCM_sys_cdo :" $@ 2446 fi 2447 2448 typeset status 2449 2450 \cdo $@ > out_rsync 2>&1 2451 status=$? 2452 if [ ${status} -gt 0 ] ; then 2453 echo "IGCM_sys_cdo : error code ${status}" 2454 cat out_rsync 2455 \rm out_rsync 2456 IGCM_debug_PopStack "IGCM_sys_cdo" 2457 return 1 2458 else 2459 IGCM_debug_PopStack "IGCM_sys_cdo" 2460 return 0 2461 fi 2462 2463 IGCM_debug_PopStack "IGCM_sys_cdo" 2464 }
Note: See TracChangeset
for help on using the changeset viewer.