Changeset 1181 for trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh
- Timestamp:
- 04/01/15 14:54:34 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.