Changeset 1181 for trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
- Timestamp:
- 04/01/15 14:54:34 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
r1180 r1181 205 205 206 206 #D-#================================================== 207 #D-function IGCM_sys_RshMaster208 #D-* Purpose: Connection to frontend machine.209 #D-* Examples:210 #D-211 function IGCM_sys_RshMaster {212 IGCM_debug_PushStack "IGCM_sys_RshMaster" $@213 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF214 export libIGCM=${libIGCM}215 export DEBUG_debug=${DEBUG_debug}216 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh217 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh218 ${@}219 EOF220 if [ $? -gt 0 ] ; then221 echo "IGCM_sys_RshMaster : erreur."222 IGCM_debug_Exit "IGCM_sys_RshMaster"223 fi224 IGCM_debug_PopStack "IGCM_sys_RshMaster"225 }226 227 #D-#==================================================228 207 #D-function IGCM_sys_RshArchive 229 208 #D-* Purpose: Archive rsh command … … 258 237 259 238 #D-#================================================== 260 #D-function IGCM_sys_RshPost261 #D-* Purpose: Post-process rsh command262 #D-* Examples:263 #D-264 function IGCM_sys_RshPost {265 IGCM_debug_PushStack "IGCM_sys_RshPost" $@266 if ( $DEBUG_sys ) ; then267 echo "IGCM_sys_RshPost :" $@268 fi269 # keep standard input (stdin) for the loop onto temporary file270 cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}271 272 OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}273 if [ $? -gt 0 ] ; then274 echo "IGCM_sys_RshPost : erreur."275 IGCM_debug_Exit "IGCM_sys_RshPost"276 fi277 # delete temporary file278 \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}279 280 IGCM_debug_PopStack "IGCM_sys_RshPost"281 }282 283 #D-#==================================================284 #D-function IGCM_sys_SendMail285 #D-* Purpose: Send mail when simulation is over286 #D-* Examples:287 #D-288 function IGCM_sys_SendMail {289 IGCM_debug_PushStack "IGCM_sys_SendMail" $@290 if ( $DEBUG_sys ) ; then291 echo "IGCM_sys_SendMail :" $@292 fi293 294 if [ X${1} = XAccounting ] ; then295 status=Accounting296 mailText=jobAccounting.mail297 elif ( ${ExitFlag} ) ; then298 status=failed299 mailText=jobEnd.mail300 else301 status=completed302 mailText=jobEnd.mail303 fi304 305 # Update selected mail template306 while read -r line; do307 eval echo $line >> mail.txt ;308 done < ${libIGCM}/libIGCM_sys/${mailText}309 310 if [ ! -z ${config_UserChoices_MailName} ] ; then311 mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt312 elif [ -f ~/.forward ] ; then313 mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt314 else315 mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt316 fi317 318 sleep 10319 rm -f mail.txt320 321 IGCM_debug_PopStack "IGCM_sys_SendMail"322 }323 324 #D-#==================================================325 #D-function IGCM_sys_Mkdir326 #D-* Purpose: Master locale mkdir command327 #D-* Examples:328 #D-329 function IGCM_sys_Mkdir {330 IGCM_debug_PushStack "IGCM_sys_Mkdir" $@331 if ( $DEBUG_sys ) ; then332 echo "IGCM_sys_Mkdir :" $@333 fi334 if [ ! -d ${1} ]; then335 \mkdir -p $1336 if [ $? -gt 0 ] ; then337 echo "IGCM_sys_Mkdir : erreur."338 IGCM_debug_Exit "IGCM_sys_Mkdir"339 fi340 fi341 # vérification :342 if [ ! -d ${1} ] ; then343 echo "IGCM_sys_Mkdir : erreur."344 IGCM_debug_Exit "IGCM_sys_Mkdir"345 fi346 IGCM_debug_PopStack "IGCM_sys_Mkdir"347 }348 349 #D-#==================================================350 239 #D-function IGCM_sys_MkdirArchive 351 240 #D-* Purpose: Mkdir on Archive … … 368 257 fi 369 258 IGCM_debug_PopStack "IGCM_sys_MkdirArchive" 370 }371 372 #D-#==================================================373 #D-function IGCM_sys_MkdirWork374 #D-* Purpose: Mkdir on Work375 #D-* Examples:376 #D-377 function IGCM_sys_MkdirWork {378 IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@379 if ( $DEBUG_sys ) ; then380 echo "IGCM_sys_MkdirWork :" $@381 fi382 #- creation de repertoire sur le serveur fichier383 if [ ! -d ${1} ]; then384 \mkdir -p $1385 if [ $? -gt 0 ] ; then386 echo "IGCM_sys_MkdirWork : erreur."387 IGCM_debug_Exit "IGCM_sys_MkdirWork"388 fi389 fi390 IGCM_debug_PopStack "IGCM_sys_MkdirWork"391 }392 393 #D-#==================================================394 #D-function IGCM_sys_Cd395 #D-* Purpose: master cd command396 #D-* Examples:397 #D-398 function IGCM_sys_Cd {399 IGCM_debug_PushStack "IGCM_sys_Cd" $@400 if ( $DEBUG_sys ) ; then401 echo "IGCM_sys_Cd :" $@402 fi403 \cd $1404 if [ $? -gt 0 ] ; then405 echo "IGCM_sys_Cd : erreur."406 IGCM_debug_Exit "IGCM_sys_Cd"407 fi408 IGCM_debug_PopStack "IGCM_sys_Cd"409 }410 411 #D-#==================================================412 #D-function IGCM_sys_Chmod413 #D-* Purpose: Chmod414 #D-* Examples:415 #D-416 function IGCM_sys_Chmod {417 IGCM_debug_PushStack "IGCM_sys_Chmod" $@418 if ( $DEBUG_sys ) ; then419 echo "IGCM_sys_Chmod :" $@420 fi421 \chmod $@422 if [ $? -gt 0 ] ; then423 echo "IGCM_sys_Chmod : erreur."424 IGCM_debug_Exit "IGCM_sys_Chmod"425 fi426 IGCM_debug_PopStack "IGCM_sys_Chmod"427 }428 429 #D-#==================================================430 #D-function IGCM_sys_FileSize431 #D-* Purpose: Filesize432 #D-* Examples:433 #D-434 function IGCM_sys_FileSize {435 IGCM_debug_PushStack "IGCM_sys_FileSize" $@436 437 typeset sizeF438 set +A sizeF -- $( ls -la ${1} )439 if [ $? -gt 0 ] ; then440 IGCM_debug_Exit "IGCM_sys_FileSize"441 fi442 eval ${2}=${sizeF[4]}443 444 IGCM_debug_PopStack "IGCM_sys_FileSize"445 }446 447 #D-#==================================================448 #D-function IGCM_sys_TestDir449 #D-* Purpose: Test Directory that must exists450 #D-* Examples:451 #D-452 function IGCM_sys_TestDir {453 IGCM_debug_PushStack "IGCM_sys_TestDir" $@454 if ( $DEBUG_sys ) ; then455 echo "IGCM_sys_TestDir :" $@456 fi457 typeset ExistFlag458 ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )459 IGCM_debug_PopStack "IGCM_sys_TestDir"460 461 return ${ExistFlag}462 259 } 463 260 … … 505 302 ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" ) 506 303 IGCM_debug_PopStack "IGCM_sys_TestFileArchive" 507 508 return ${ExistFlag}509 }510 511 #D-#==================================================512 #D-function IGCM_sys_TestFileBuffer513 #D-* Purpose: Test file that must NOT EXISTS on Buffer514 #D-* Examples:515 #D-516 function IGCM_sys_TestFileBuffer {517 IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@518 typeset ExistFlag519 ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )520 IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"521 304 522 305 return ${ExistFlag} … … 546 329 547 330 #D-#================================================== 548 #D-function IGCM_sys_CountFileBuffer549 #D-* Purpose: Count files on Scratch filesystem550 #D-* Examples:551 #D-552 function IGCM_sys_CountFileBuffer {553 IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@554 ls ${@} 2>/dev/null | wc -l555 if [ $? -gt 0 ] ; then556 echo "IGCM_sys_CountFileBuffer : erreur."557 fi558 IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"559 }560 561 #D-#==================================================562 #D-function IGCM_sys_Tree563 #D-* Purpose: Tree directories with files on ${ARCHIVE}564 #D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}565 #D-566 function IGCM_sys_Tree {567 IGCM_debug_PushStack "IGCM_sys_Tree" $@568 if ( $DEBUG_sys ) ; then569 echo "IGCM_sys_Tree :" $@570 fi571 572 \tree -f $@573 574 IGCM_debug_PopStack "IGCM_sys_Tree"575 }576 577 #D-#==================================================578 #D-function IGCM_sys_Tar579 #D-* Purpose: master tar command580 #D-* Examples:581 #D-582 function IGCM_sys_Tar {583 IGCM_debug_PushStack "IGCM_sys_Tar" $@584 if ( $DEBUG_sys ) ; then585 echo "IGCM_sys_Tar :" $@586 fi587 \tar cf $@588 if [ $? -gt 0 ] ; then589 echo "IGCM_sys_Tar : erreur."590 IGCM_debug_Exit "IGCM_sys_Tar"591 fi592 IGCM_debug_PopStack "IGCM_sys_Tar"593 }594 595 #D-#==================================================596 #D-function IGCM_sys_UnTar597 #D-* Purpose: master un-tar command598 #D-* Examples:599 #D-600 function IGCM_sys_UnTar {601 IGCM_debug_PushStack "IGCM_sys_UnTar" $@602 if ( $DEBUG_sys ) ; then603 echo "IGCM_sys_UnTar :" $@604 fi605 \tar xvf $1606 if [ $? -gt 0 ] ; then607 echo "IGCM_sys_UnTar : erreur."608 IGCM_debug_Exit "IGCM_sys_UnTar"609 fi610 IGCM_debug_PopStack "IGCM_sys_UnTar"611 }612 613 #D-#==================================================614 331 #D-function IGCM_sys_Qsub 615 332 #D-* Purpose: Qsub new job … … 683 400 684 401 #D-#================================================== 685 #D-function IGCM_sys_Rsync_out686 #D-* Purpose: treat return val of rsync687 #D-* Examples: IGCM_sys_Rsync_out out_RET_rsync688 #D- Error values and explanations can depend on your system version.689 function IGCM_sys_Rsync_out {690 status=$1691 if [ ! $status ] ; then692 echo "rsync error !"693 fi694 695 if [ $MYLANG = "fr" ]; then696 case $status in697 0) return ;;698 1) echo "Erreur de rsync ; RERR_SYNTAX : "699 echo "Erreur de syntaxe ou d'utilisation."700 return;;701 2) echo "Erreur de rsync ; RERR_PROTOCOL : "702 echo "Incompatibilité de protocole."703 return;;704 3) echo "Erreur de rsync ; RERR_FILESELECT 3"705 echo "Erreurs lors de la sélection des fichiers d'entrée sortie et"706 echo "répertoires"707 return;;708 4) echo "Erreur de rsync ; RERR_UNSUPPORTED"709 echo "Action demandée non supportée : une tentative de manipulation de"710 echo "fichiers 64-bits sur une plate-forme qui ne les supporte pas a"711 echo "été faite ; ou une option qui est supportée par le client mais"712 echo "pas par le serveur a été spécifiée."713 return;;714 10) echo "Erreur de rsync ; RERR_SOCKETIO"715 echo "Erreur dans le socket d'entrée sortie"716 return;;717 11) echo "Erreur de rsync ; RERR_FILEIO"718 echo "Erreur d'entrée sortie fichier"719 return;;720 12) echo "Erreur de rsync ; RERR_STREAMIO"721 echo "Erreur dans flux de donnée du protocole rsync"722 return;;723 13) echo "Erreur de rsync ; RERR_MESSAGEIO"724 echo "Erreur avec les diagnostics du programme"725 return;;726 14) echo "Erreur de rsync ; RERR_IPC"727 echo "Erreur dans le code IPC"728 return;;729 20) echo "Erreur de rsync ; RERR_SIGNAL"730 echo "SIGUSR1 ou SIGINT reçu"731 return;;732 21) echo "Erreur de rsync ; RERR_WAITCHILD"733 echo "Une erreur retournée par waitpid()"734 return;;735 22) echo "Erreur de rsync ; RERR_MALLOC"736 echo "Erreur lors de l'allocation des tampons de mémoire de coeur"737 return;;738 23) echo ""739 echo "Erreur fichier inexistant"740 return;;741 30) echo "Erreur de rsync ; RERR_TIMEOUT"742 echo "Temps d'attente écoulé dans l'envoi/réception de données"743 return;;744 *) echo "Erreur de rsync : code de retour de rsync inconnu :" $status745 return;;746 esac747 elif [ $MYLANG = "en" ] ; then748 case $status in749 0) return;;750 1) echo "rsync error : Syntax or usage error "751 return;;752 2) echo "rsync error : Protocol incompatibility "753 return;;754 3) echo "rsync error : Errors selecting input/output files, dirs"755 return;;756 4) echo "rsync error : Requested action not supported: an attempt"757 echo "was made to manipulate 64-bit files on a platform that cannot support"758 echo "them; or an option was specified that is supported by the client and"759 echo "not by the server."760 return;;761 5) echo "rsync error : Error starting client-server protocol"762 return;;763 10) echo "rsync error : Error in socket I/O "764 return;;765 11) echo "rsync error : Error in file I/O "766 return;;767 12) echo "rsync error : Error in rsync protocol data stream "768 return;;769 13) echo "rsync error : Errors with program diagnostics "770 return;;771 14) echo "rsync error : Error in IPC code "772 return;;773 20) echo "rsync error : Received SIGUSR1 or SIGINT "774 return;;775 21) echo "rsync error : Some error returned by waitpid() "776 return;;777 22) echo "rsync error : Error allocating core memory buffers "778 return;;779 23) echo "rsync error : Partial transfer due to error"780 return;;781 24) echo "rsync error : Partial transfer due to vanished source files"782 return;;783 30) echo "rsync error : Timeout in data send/receive "784 return;;785 *) echo "rsync error : return code of rsync unknown :" $status786 return;;787 esac788 else789 echo "unknown language $MYLANG."790 return791 fi792 }793 794 #D-#==================================================795 #D-function IGCM_sys_Miror_libIGCM796 #D-* Purpose: Mirror libIGCM PATH and lib to frontend797 #D-* Examples:798 #D-799 function IGCM_sys_Mirror_libIGCM {800 IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"801 if ( $DEBUG_sys ) ; then802 echo "IGCM_sys_Mirror_libIGCM"803 fi804 805 typeset status806 807 mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}808 809 echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1810 ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1811 status=$?812 813 if [ ${status} -gt 0 ] ; then814 echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."815 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$816 fi817 IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"818 }819 820 #D-#==================================================821 #D-function IGCM_sys_Cp822 #D-* Purpose: generic cp823 #D-* Examples:824 #D-825 function IGCM_sys_Cp {826 IGCM_debug_PushStack "IGCM_sys_Cp" $@827 if ( $DEBUG_sys ) ; then828 echo "IGCM_sys_Cp :" $@829 fi830 831 typeset status832 833 echo cp $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1834 \cp $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1835 status=$?836 837 if [ ${status} -gt 0 ] ; then838 echo "IGCM_sys_Cp : error code ${status}"839 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$840 IGCM_debug_Exit "IGCM_sys_Cp"841 else842 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$843 fi844 IGCM_debug_PopStack "IGCM_sys_Cp"845 }846 847 #D-#==================================================848 #D-function IGCM_sys_Rm849 #D-* Purpose: generic rm850 #D-* Examples:851 #D-852 function IGCM_sys_Rm {853 IGCM_debug_PushStack "IGCM_sys_Rm" $@854 if ( $DEBUG_sys ) ; then855 echo "IGCM_sys_Rm :" $@856 fi857 858 typeset status859 860 echo rm $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1861 \rm $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1862 status=$?863 864 if [ ${status} -gt 0 ] ; then865 echo "IGCM_sys_Rm : error code ${status}"866 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$867 IGCM_debug_Exit "IGCM_sys_Rm"868 else869 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$870 fi871 IGCM_debug_PopStack "IGCM_sys_Rm"872 }873 874 #D-#==================================================875 402 #D-function IGCM_sys_RmRunDir 876 403 #D-* Purpose: rm tmpdir (dummy function most of the time batch … … 901 428 902 429 #D-#================================================== 903 #D-function IGCM_sys_Mv904 #D-* Purpose: generic move905 #D-* Examples:906 #D-907 function IGCM_sys_Mv {908 IGCM_debug_PushStack "IGCM_sys_Mv" $@909 if ( $DEBUG_sys ) ; then910 echo "IGCM_sys_Mv :" $@911 fi912 913 if [ $DRYRUN = 0 ]; then914 915 typeset status916 917 echo mv $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1918 \mv $@ >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1919 status=$?920 921 if [ ${status} -gt 0 ] ; then922 echo "IGCM_sys_Mv : error code ${status}"923 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$924 IGCM_debug_Exit "IGCM_sys_Mv"925 else926 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$927 fi928 fi929 IGCM_debug_PopStack "IGCM_sys_Mv"930 }931 932 #D-#==================================================933 430 #D-function IGCM_sys_Put_Dir 934 431 #D-* Purpose: Copy a complete directory on $(ARCHIVE) … … 1000 497 IGCM_debug_PopStack "IGCM_sys_Get_Dir" 1001 498 } 1002 1003 #D-#==================================================1004 #D-function IGCM_sys_Get_Master1005 #D-* Purpose: Copy a complete directory from MASTER filesystem1006 #D-* Examples:1007 #D-1008 function IGCM_sys_Get_Master {1009 IGCM_debug_PushStack "IGCM_sys_Get_Master" $@1010 if ( $DEBUG_sys ) ; then1011 echo "IGCM_sys_Get_Master :" $@1012 fi1013 if [ $DRYRUN = 0 ]; then1014 if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then1015 echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."1016 IGCM_debug_PopStack "IGCM_sys_Get_Master"1017 return1018 fi1019 1020 typeset NB_ESSAI DELAI status i1021 # number of tentative1022 NB_ESSAI=31023 # time delay between tentative1024 DELAI=21025 1026 i=01027 while [ $i -lt $NB_ESSAI ] ; do1028 \cp -urL $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11029 status=$?1030 if [ ${status} -gt 0 ]; then1031 IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"1032 IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."1033 sleep $DELAI1034 else1035 break1036 fi1037 (( i = i + 1 ))1038 done1039 1040 if [ ${status} -gt 0 ] ; then1041 echo "IGCM_sys_Get_Master : error."1042 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1043 IGCM_debug_Exit "IGCM_sys_Get_Master"1044 else1045 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1046 fi1047 fi1048 IGCM_debug_PopStack "IGCM_sys_Get_Master"1049 }1050 1051 #====================================================1052 #- Call IGCM_sys_Mirror_libIGCM now !1053 if ( $MirrorlibIGCM ) ; then1054 IGCM_sys_Mirror_libIGCM1055 fi1056 499 1057 500 #D-#================================================== … … 1097 540 1098 541 #D-#================================================== 1099 #D-function IGCM_sys_PutBuffer_Rest1100 #D-* Purpose: Put computied restarts on ${SCRATCHDIR}.1101 #D- File and target directory must exist.1102 #D-* Examples:1103 #D-1104 function IGCM_sys_PutBuffer_Rest {1105 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@1106 if ( $DEBUG_sys ) ; then1107 echo "IGCM_sys_PutBuffer_Rest :" $@1108 fi1109 if [ $DRYRUN = 0 ]; then1110 if [ ! -f ${1} ] ; then1111 echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."1112 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1113 fi1114 1115 typeset status1116 #1117 if [ X${JobType} = XRUN ] ; then1118 IGCM_sys_Chmod 444 ${1}1119 fi1120 1121 #1122 # USUAL WAY1123 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11124 status=$?1125 1126 if [ ${status} -gt 0 ] ; then1127 echo "IGCM_sys_PutBuffer_Rest : error code ${status}"1128 [ -f ${2} ] && ls -l ${2}1129 [ -f ${2}/${1} ] && ls -l ${2}/${1}1130 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1131 IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"1132 else1133 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1134 fi1135 fi1136 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"1137 }1138 1139 #D-#==================================================1140 #D-function IGCM_sys_PrepareTaredRestart1141 #D-* Purpose: Prepare tared restart to be access by computing job. Identity here.1142 #D-* Examples:1143 #D-1144 function IGCM_sys_PrepareTaredRestart {1145 IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@1146 1147 IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"1148 }1149 1150 #D-#==================================================1151 542 #D-function IGCM_sys_Put_Out 1152 543 #D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly … … 1189 580 fi 1190 581 IGCM_debug_PopStack "IGCM_sys_Put_Out" 1191 return 01192 }1193 1194 #D-#==================================================1195 #D-function IGCM_sys_PutBuffer_Out1196 #D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly1197 #D-* Examples:1198 #D-1199 function IGCM_sys_PutBuffer_Out {1200 IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@1201 if ( $DEBUG_sys ) ; then1202 echo "IGCM_sys_PutBuffer_Out :" $@1203 fi1204 1205 typeset NB_ESSAI DELAI status i exist skip1206 1207 # number of tentative1208 NB_ESSAI=31209 # time delay between tentative1210 DELAI=21211 1212 if [ $DRYRUN = 0 ]; then1213 if [ ! -f ${1} ] ; then1214 echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."1215 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1216 return 11217 fi1218 #1219 IGCM_sys_Mkdir $( dirname $2 )1220 #1221 1222 exist=false1223 skip=false1224 if [ -f $2 ] ; then1225 IGCM_debug_Print 1 "$2 already exist"1226 exist=true1227 if [ "X$( diff $1 $2 )" = X ] ; then1228 IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"1229 status=01230 skip=true1231 else1232 IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"1233 skip=false1234 fi1235 fi1236 #1237 if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then1238 IGCM_sys_Chmod u+w $21239 fi1240 1241 if [ X${skip} = Xfalse ] ; then1242 i=01243 while [ $i -lt $NB_ESSAI ] ; do1244 if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then1245 # USUAL WAY1246 \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11247 status=$?1248 else1249 # NOT SO USUAL WAY1250 \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11251 status=$?1252 fi1253 if [ ${status} -gt 0 ]; then1254 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"1255 IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."1256 [ -f ${2} ] && ls -l ${2}1257 [ -f ${2}/${1} ] && ls -l ${2}/${1}1258 sleep $DELAI1259 else1260 break1261 fi1262 (( i = i + 1 ))1263 done1264 fi1265 1266 if [ ${status} -gt 0 ] ; then1267 echo "IGCM_sys_PutBuffer_Out : error."1268 [ -f ${2} ] && ls -l ${2}1269 [ -f ${2}/${1} ] && ls -l ${2}/${1}1270 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1271 IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"1272 else1273 1274 if [ X${JobType} = XRUN ] ; then1275 if [ X${3} = X ] ; then1276 [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}1277 [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}1278 fi1279 fi1280 1281 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1282 fi1283 fi1284 IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"1285 582 return 0 1286 583 } … … 1339 636 1340 637 #D-#================================================== 1341 #D-function IGCM_sys_GetBuffer1342 #D-* Purpose: Get a file from ${SCRATCHDIR}1343 #D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX1344 #D- IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/1345 function IGCM_sys_GetBuffer {1346 IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@1347 1348 typeset DEST buf_liste target file_work1349 typeset NB_ESSAI DELAI status i1350 1351 if ( $DEBUG_sys ) ; then1352 echo "IGCM_sys_GetBuffer :" $@1353 fi1354 1355 # number of tentative1356 NB_ESSAI=31357 # time delay between tentative1358 DELAI=21359 1360 if [ $DRYRUN -le 2 ]; then1361 if [ X${1} = X'/l' ] ; then1362 eval set +A buf_liste \${${2}}1363 else1364 eval set +A buf_liste ${1}1365 fi1366 eval DEST=\${${#}}1367 1368 #USUAL WAY1369 if [ X${1} = X'/l' ] ; then1370 for target in ${buf_liste[*]} ; do1371 local_file=$( basename ${target} )1372 i=01373 while [ $i -lt $NB_ESSAI ] ; do1374 \cp ${target} ${DEST}/${local_file} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11375 status=$?1376 if [ ${status} -gt 0 ]; then1377 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1378 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1379 sleep $DELAI1380 else1381 break1382 fi1383 (( i = i + 1 ))1384 done1385 if [ ${status} -gt 0 ] ; then1386 echo "IGCM_sys_Get : error"1387 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1388 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1389 IGCM_debug_Exit "IGCM_sys_GetBuffer"1390 else1391 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1392 fi1393 done1394 else1395 i=01396 while [ $i -lt $NB_ESSAI ] ; do1397 \cp ${buf_liste} ${DEST} >> ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11398 status=$?1399 if [ ${status} -gt 0 ]; then1400 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"1401 IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."1402 sleep $DELAI1403 else1404 break1405 fi1406 (( i = i + 1 ))1407 done1408 if [ ${status} -gt 0 ] ; then1409 echo "IGCM_sys_Get : error"1410 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1411 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1412 IGCM_debug_Exit "IGCM_sys_GetBuffer"1413 else1414 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1415 fi1416 fi1417 fi1418 IGCM_debug_PopStack "IGCM_sys_GetBuffer"1419 }1420 1421 #D-#==================================================1422 #D-function IGCM_sys_GetDate_FichWork1423 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK1424 #D-* Examples:1425 #D-1426 function IGCM_sys_GetDate_FichWork {1427 IGCM_debug_PushStack "IGCM_sys_FichWork" $@1428 if ( $DEBUG_sys ) ; then1429 echo "IGCM_sys_GetDate_FichWork :" $@1430 fi1431 # donne la date filesys d'un fichier sur la machine work1432 IGCM_debug_PopStack "IGCM_sys_FichWork"1433 }1434 1435 #D-#==================================================1436 #D-function IGCM_sys_GetDate_FichArchive1437 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE1438 #D-* Examples:1439 #D-1440 function IGCM_sys_GetDate_FichArchive {1441 IGCM_debug_PushStack "IGCM_sys_FichArchive" $@1442 if ( $DEBUG_sys ) ; then1443 echo "IGCM_sys_GetDate_FichArchive :" $@1444 fi1445 IGCM_debug_PopStack "IGCM_sys_FichArchive"1446 }1447 1448 #D-#==================================================1449 638 #D-function IGCM_sys_Dods_Rm 1450 639 #D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. … … 1498 687 fi 1499 688 IGCM_debug_PopStack "IGCM_sys_sync" 1500 }1501 1502 #D-#==================================================1503 #D-function IGCM_sys_rebuild1504 #D-* Purpose: rebuild parallel files1505 #D-* Examples:1506 #D-1507 function IGCM_sys_rebuild {1508 IGCM_debug_PushStack "IGCM_sys_rebuild" $@1509 if ( $DEBUG_sys ) ; then1510 echo "IGCM_sys_rebuild :" $@1511 fi1512 1513 typeset NB_ESSAI DELAI status i firstArg1514 # number of tentative1515 NB_ESSAI=31516 # time delay between tentative1517 DELAI=21518 1519 i=01520 while [ $i -lt $NB_ESSAI ] ; do1521 rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11522 status=$?1523 if [ ${status} -gt 0 ] ; then1524 IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"1525 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1526 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1527 IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1528 firstArg=${1}1529 \rm ${firstArg}1530 sleep $DELAI1531 else1532 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1533 break1534 fi1535 (( i = i + 1 ))1536 done1537 1538 if [ ${status} -gt 0 ] ; then1539 echo "IGCM_sys_rebuild : rebuild error code is ${status}"1540 IGCM_debug_Exit "rebuild"1541 fi1542 1543 IGCM_debug_PopStack "IGCM_sys_rebuild"1544 }1545 1546 #D-#==================================================1547 #D-function IGCM_sys_rebuild_station1548 #D-* Purpose: rebuild parallel files describing station1549 #D-* Examples:1550 #D-1551 function IGCM_sys_rebuild_station {1552 IGCM_debug_PushStack "IGCM_sys_rebuild_station" $@1553 typeset i list_opt file_in file_out prefix_invert list_invert1554 if ( $DEBUG_sys ) ; then1555 echo "IGCM_sys_rebuild_station :" $@1556 fi1557 list_opt=$@1558 1559 # Invert Axis : t,x -> x,t1560 # t,pres,x -> x,t,pres1561 # So that we can concatenate along x1562 i=01563 for file_in in ${list_opt} ; do1564 (( i = i + 1))1565 [ ${i} = 1 ] && file_out=${file_in} && continue1566 # detect time counter and do the job only if present1567 var_unlim=$(ncdump -h ${file_in} | grep UNLIMITED | cut -d ' ' -f 1 | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')1568 if [ X${var_unlim} = Xtime_counter ] ; then1569 prefix_invert=$( basename ${file_in} .nc )1570 IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc1571 list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc1572 fi1573 done1574 1575 # Concatenate1576 IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc1577 1578 # Re-ivert file1579 IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}1580 1581 # Station re-ordering is too expansive to be run within libIGCM1582 # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.1583 # This re-ordering must be done "in memory" by the cmorization process1584 # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)1585 # BEGIN reordering1586 1587 # Only LMDZ text output contains the exact ordering of the station.1588 # We isolate this in the code below:1589 # 0 38 -157.5000000000000 70.985915492957741590 # 0 54 27.49999999999999 67.183098591549281591 # 0 56 -62.50000000000001 82.394366197183091592 # 0 79 12.49999999999999 78.591549295774661593 # 0 116 -165.0000000000000 76.056338028169011594 # 0 117 130.0000000000000 70.985915492957741595 # 0 118 110.0000000000000 87.464788732394371596 # 1 40 4.999999999999995 51.971830985915501597 1598 # typeset iStation iProc list_opt file_in file_out prefix_invert1599 # typeset -Z4 j41600 # typeset -Z3 j31601 1602 # unset list_opt1603 # set +A list_opt $@1604 1605 # Filename after rebuild1606 # file_out=${list_opt[0]}1607 # Prefix of output files1608 # prefix_invert=$( basename ${file_out} .nc )1609 # Number of procs1610 # num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )1611 1612 # iProc=01613 # while [ ${iProc} -lt ${num_proc} ] ; do1614 # Array containing Station as a number1615 # unset proc_stn1616 # set +A proc_stn $( grep "iophy_mpi rank ip lon lat $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )1617 # Number of stations produced by processor proc1618 # stationLast=${#proc_stn[*]}1619 # Proc number on 4 digits1620 # j4=${iProc}1621 # Init1622 # iStation=01623 # while [ ${iStation} -lt ${stationLast} ] ; do1624 # Station number on 3 digits1625 # j3=${proc_stn[${iStation}]}1626 # Extract station1627 # Invert Axis : t,x -> x,t1628 # t,pres,x -> x,t,pres1629 # So that we can concatenate along x1630 # IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc1631 # (( iStation = iStation + 1 ))1632 # done1633 # (( iProc = iProc + 1 ))1634 # done1635 1636 # Concatenate all station along x1637 # IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc1638 1639 # Re-invert file1640 # IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}1641 1642 # END reordering1643 1644 IGCM_debug_PopStack "IGCM_sys_rebuild_station"1645 689 } 1646 690 … … 1925 969 IGCM_debug_PopStack "IGCM_sys_CountJobInQueue" 1926 970 } 1927 1928 ##############################################################1929 # NCO OPERATOR1930 1931 #D-#==================================================1932 #D-function IGCM_sys_ncap21933 #D-* Purpose: encapsulate ncap2 call so as to manage error code and retry1934 #D-* Examples:1935 #D-1936 function IGCM_sys_ncap2 {1937 IGCM_debug_PushStack "IGCM_sys_ncap2" $@1938 if ( $DEBUG_sys ) ; then1939 echo "IGCM_sys_ncap2 :" $@1940 fi1941 1942 typeset NB_ESSAI DELAI status i1943 # number of tentative1944 NB_ESSAI=31945 # time delay between tentative1946 DELAI=21947 1948 i=01949 while [ $i -lt $NB_ESSAI ] ; do1950 ncap2 -C "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11951 status=$?1952 if [ ${status} -gt 0 ] ; then1953 IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"1954 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1955 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1956 IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1957 sleep $DELAI1958 else1959 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1960 break1961 fi1962 (( i = i + 1 ))1963 done1964 1965 if [ ${status} -gt 0 ] ; then1966 echo "IGCM_sys_ncap2 : ncap2 error"1967 IGCM_debug_Exit "ncap2"1968 fi1969 1970 IGCM_debug_PopStack "IGCM_sys_ncap2"1971 }1972 1973 #D-#==================================================1974 #D-function IGCM_sys_ncatted1975 #D-* Purpose: encapsulate ncatted call so as to manage error code and retry1976 #D-* Examples:1977 #D-1978 function IGCM_sys_ncatted {1979 IGCM_debug_PushStack "IGCM_sys_ncatted" $@1980 if ( $DEBUG_sys ) ; then1981 echo "IGCM_sys_ncatted :" $@1982 fi1983 1984 typeset NB_ESSAI DELAI status i1985 # number of tentative1986 NB_ESSAI=31987 # time delay between tentative1988 DELAI=21989 1990 i=01991 while [ $i -lt $NB_ESSAI ] ; do1992 ncatted "$@" > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&11993 status=$?1994 if [ ${status} -gt 0 ] ; then1995 IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"1996 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1997 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$1998 IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."1999 sleep $DELAI2000 else2001 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2002 break2003 fi2004 (( i = i + 1 ))2005 done2006 2007 if [ ${status} -gt 0 ] ; then2008 echo "IGCM_sys_ncatted : ncatted error"2009 IGCM_debug_Exit "ncatted"2010 fi2011 2012 IGCM_debug_PopStack "IGCM_sys_ncatted"2013 }2014 2015 #D-#==================================================2016 #D-function IGCM_sys_ncbo2017 #D-* Purpose: encapsulate ncbo call so as to manage error code and retry2018 #D-* Examples:2019 #D-2020 function IGCM_sys_ncbo {2021 IGCM_debug_PushStack "IGCM_sys_ncbo" $@2022 if ( $DEBUG_sys ) ; then2023 echo "IGCM_sys_ncbo :" $@2024 fi2025 2026 typeset NB_ESSAI DELAI status i2027 # number of tentative2028 NB_ESSAI=32029 # time delay between tentative2030 DELAI=22031 2032 i=02033 while [ $i -lt $NB_ESSAI ] ; do2034 ncbo -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12035 status=$?2036 if [ ${status} -gt 0 ] ; then2037 IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"2038 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2039 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2040 IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2041 sleep $DELAI2042 else2043 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2044 break2045 fi2046 (( i = i + 1 ))2047 done2048 2049 if [ ${status} -gt 0 ] ; then2050 echo "IGCM_sys_ncbo : ncbo error"2051 IGCM_debug_Exit "ncbo"2052 fi2053 2054 IGCM_debug_PopStack "IGCM_sys_ncbo"2055 }2056 2057 #D-#==================================================2058 #D-function IGCM_sys_ncdif2059 #D-* Purpose: encapsulate ncdiff call so as to manage error code and retry2060 #D-* Examples:2061 #D-2062 function IGCM_sys_ncdiff {2063 IGCM_debug_PushStack "IGCM_sys_ncdiff" $@2064 if ( $DEBUG_sys ) ; then2065 echo "IGCM_sys_ncdiff :" $@2066 fi2067 2068 typeset NB_ESSAI DELAI status i2069 # number of tentative2070 NB_ESSAI=32071 # time delay between tentative2072 DELAI=22073 2074 i=02075 while [ $i -lt $NB_ESSAI ] ; do2076 ncdiff -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12077 status=$?2078 if [ ${status} -gt 0 ] ; then2079 IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"2080 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2081 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2082 IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2083 sleep $DELAI2084 else2085 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2086 break2087 fi2088 (( i = i + 1 ))2089 done2090 2091 if [ ${status} -gt 0 ] ; then2092 echo "IGCM_sys_ncdiff : ncdiff error"2093 IGCM_debug_Exit "ncdiff"2094 fi2095 2096 IGCM_debug_PopStack "IGCM_sys_ncdiff"2097 }2098 2099 #D-#==================================================2100 #D-function IGCM_sys_ncea2101 #D-* Purpose: encapsulate ncea call so as to manage error code and retry2102 #D-* Examples:2103 #D-2104 function IGCM_sys_ncea {2105 IGCM_debug_PushStack "IGCM_sys_ncea" $@2106 if ( $DEBUG_sys ) ; then2107 echo "IGCM_sys_ncea :" $@2108 fi2109 2110 typeset NB_ESSAI DELAI status i2111 # number of tentative2112 NB_ESSAI=32113 # time delay between tentative2114 DELAI=22115 2116 i=02117 while [ $i -lt $NB_ESSAI ] ; do2118 ncea -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12119 status=$?2120 if [ ${status} -gt 0 ] ; then2121 IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"2122 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2123 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2124 IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2125 sleep $DELAI2126 else2127 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2128 break2129 fi2130 (( i = i + 1 ))2131 done2132 2133 if [ ${status} -gt 0 ] ; then2134 echo "IGCM_sys_ncea : ncea error"2135 IGCM_debug_Exit "ncea"2136 fi2137 2138 IGCM_debug_PopStack "IGCM_sys_ncea"2139 }2140 2141 #D-#==================================================2142 #D-function IGCM_sys_ncecat2143 #D-* Purpose: encapsulate ncecat call so as to manage error code and retry2144 #D-* Examples:2145 #D-2146 function IGCM_sys_ncecat {2147 IGCM_debug_PushStack "IGCM_sys_ncecat" $@2148 if ( $DEBUG_sys ) ; then2149 echo "IGCM_sys_ncecat :" $@2150 fi2151 2152 typeset NB_ESSAI DELAI status i2153 # number of tentative2154 NB_ESSAI=32155 # time delay between tentative2156 DELAI=22157 2158 i=02159 while [ $i -lt $NB_ESSAI ] ; do2160 ncecat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12161 status=$?2162 if [ ${status} -gt 0 ] ; then2163 IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"2164 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2165 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2166 IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2167 sleep $DELAI2168 else2169 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2170 break2171 fi2172 (( i = i + 1 ))2173 done2174 2175 if [ ${status} -gt 0 ] ; then2176 echo "IGCM_sys_ncecat : ncecat error"2177 IGCM_debug_Exit "ncecat"2178 fi2179 2180 IGCM_debug_PopStack "IGCM_sys_ncecat"2181 }2182 2183 #D-#==================================================2184 #D-function IGCM_sys_ncflint2185 #D-* Purpose: encapsulate ncflint call so as to manage error code and retry2186 #D-* Examples:2187 #D-2188 function IGCM_sys_ncflint {2189 IGCM_debug_PushStack "IGCM_sys_ncflint" $@2190 if ( $DEBUG_sys ) ; then2191 echo "IGCM_sys_ncflint :" $@2192 fi2193 2194 typeset NB_ESSAI DELAI status i2195 # number of tentative2196 NB_ESSAI=32197 # time delay between tentative2198 DELAI=22199 2200 i=02201 while [ $i -lt $NB_ESSAI ] ; do2202 ncflint -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12203 status=$?2204 if [ ${status} -gt 0 ] ; then2205 IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"2206 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2207 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2208 IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2209 sleep $DELAI2210 else2211 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2212 break2213 fi2214 (( i = i + 1 ))2215 done2216 2217 if [ ${status} -gt 0 ] ; then2218 echo "IGCM_sys_ncflint : ncflint error"2219 IGCM_debug_Exit "ncflint"2220 fi2221 2222 IGCM_debug_PopStack "IGCM_sys_ncflint"2223 }2224 2225 #D-#==================================================2226 #D-function IGCM_sys_ncks2227 #D-* Purpose: encapsulate ncks call so as to manage error code and retry2228 #D-* Examples:2229 #D-2230 function IGCM_sys_ncks {2231 IGCM_debug_PushStack "IGCM_sys_ncks" $@2232 if ( $DEBUG_sys ) ; then2233 echo "IGCM_sys_ncks :" $@2234 fi2235 2236 typeset NB_ESSAI DELAI status i2237 # number of tentative2238 NB_ESSAI=32239 # time delay between tentative2240 DELAI=22241 2242 i=02243 while [ $i -lt $NB_ESSAI ] ; do2244 ncks -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12245 status=$?2246 if [ ${status} -gt 0 ] ; then2247 IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"2248 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2249 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2250 IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2251 sleep $DELAI2252 else2253 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2254 break2255 fi2256 (( i = i + 1 ))2257 done2258 2259 if [ ${status} -gt 0 ] ; then2260 echo "IGCM_sys_ncks : ncks error"2261 IGCM_debug_Exit "ncks"2262 fi2263 2264 IGCM_debug_PopStack "IGCM_sys_ncks"2265 }2266 2267 #D-#==================================================2268 #D-function IGCM_sys_ncpdq2269 #D-* Purpose: encapsulate ncpdq call so as to manage error code and retry2270 #D-* Examples:2271 #D-2272 function IGCM_sys_ncpdq {2273 IGCM_debug_PushStack "IGCM_sys_ncpdq" $@2274 if ( $DEBUG_sys ) ; then2275 echo "IGCM_sys_ncpdq :" $@2276 fi2277 2278 typeset NB_ESSAI DELAI status i2279 # number of tentative2280 NB_ESSAI=32281 # time delay between tentative2282 DELAI=22283 2284 i=02285 while [ $i -lt $NB_ESSAI ] ; do2286 ncpdq -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12287 status=$?2288 if [ ${status} -gt 0 ] ; then2289 IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"2290 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2291 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2292 IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2293 sleep $DELAI2294 else2295 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2296 break2297 fi2298 (( i = i + 1 ))2299 done2300 2301 if [ ${status} -gt 0 ] ; then2302 echo "IGCM_sys_ncpdq : ncpdq error"2303 IGCM_debug_Exit "ncpdq"2304 fi2305 2306 IGCM_debug_PopStack "IGCM_sys_ncpdq"2307 }2308 2309 #D-#==================================================2310 #D-function IGCM_sys_ncra2311 #D-* Purpose: encapsulate ncra call so as to manage error code and retry2312 #D-* Examples:2313 #D-2314 function IGCM_sys_ncra {2315 IGCM_debug_PushStack "IGCM_sys_ncra" $@2316 if ( $DEBUG_sys ) ; then2317 echo "IGCM_sys_ncra :" $@2318 fi2319 2320 typeset NB_ESSAI DELAI status i2321 # number of tentative2322 NB_ESSAI=32323 # time delay between tentative2324 DELAI=22325 2326 i=02327 while [ $i -lt $NB_ESSAI ] ; do2328 ncra -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12329 status=$?2330 if [ ${status} -gt 0 ] ; then2331 IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"2332 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2333 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2334 IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2335 sleep $DELAI2336 else2337 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2338 break2339 fi2340 (( i = i + 1 ))2341 done2342 2343 if [ ${status} -gt 0 ] ; then2344 echo "IGCM_sys_ncra : ncra error"2345 IGCM_debug_Exit "ncra"2346 fi2347 2348 IGCM_debug_PopStack "IGCM_sys_ncra"2349 }2350 2351 #D-#==================================================2352 #D-function IGCM_sys_ncrcat2353 #D-* Purpose: encapsulate ncrcat call so as to manage error code and retry2354 #D-* Examples:2355 #D-2356 function IGCM_sys_ncrcat {2357 IGCM_debug_PushStack "IGCM_sys_ncrcat" $@2358 if ( $DEBUG_sys ) ; then2359 echo "IGCM_sys_ncrcat :" $@2360 fi2361 2362 typeset NB_ESSAI DELAI status i lastArg2363 # number of tentative2364 NB_ESSAI=32365 # time delay between tentative2366 DELAI=22367 2368 i=02369 while [ $i -lt $NB_ESSAI ] ; do2370 ncrcat -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12371 status=$?2372 if [ ${status} -gt 0 ] ; then2373 IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"2374 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2375 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2376 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2377 sleep $DELAI2378 elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ )" = "X" ] ; then2379 IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"2380 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2381 # remove files having corrupted time axis2382 eval lastArg=\${$#}2383 IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"2384 \rm ${lastArg}2385 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2386 IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2387 sleep $DELAI2388 else2389 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2390 break2391 fi2392 (( i = i + 1 ))2393 done2394 2395 if [ ${status} -gt 0 ] ; then2396 echo "IGCM_sys_ncrcat : ncrcat error"2397 #IGCM_debug_Exit "ncrcat"2398 fi2399 2400 IGCM_debug_PopStack "IGCM_sys_ncrcat"2401 }2402 2403 #D-#==================================================2404 #D-function IGCM_sys_ncrename2405 #D-* Purpose: encapsulate ncrename call so as to manage error code and retry2406 #D-* Examples:2407 #D-2408 function IGCM_sys_ncrename {2409 IGCM_debug_PushStack "IGCM_sys_ncrename" $@2410 if ( $DEBUG_sys ) ; then2411 echo "IGCM_sys_ncrename :" $@2412 fi2413 2414 typeset NB_ESSAI DELAI status i2415 # number of tentative2416 NB_ESSAI=32417 # time delay between tentative2418 DELAI=22419 2420 i=02421 while [ $i -lt $NB_ESSAI ] ; do2422 ncrename $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12423 status=$?2424 if [ ${status} -gt 0 ] ; then2425 IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"2426 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2427 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2428 IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2429 sleep $DELAI2430 else2431 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2432 break2433 fi2434 (( i = i + 1 ))2435 done2436 2437 if [ ${status} -gt 0 ] ; then2438 echo "IGCM_sys_ncrename : ncrename error"2439 IGCM_debug_Exit "ncrename"2440 fi2441 2442 IGCM_debug_PopStack "IGCM_sys_ncrename"2443 }2444 2445 #D-#==================================================2446 #D-function IGCM_sys_ncwa2447 #D-* Purpose: encapsulate ncwa call so as to manage error code and retry2448 #D-* Examples:2449 #D-2450 function IGCM_sys_ncwa {2451 IGCM_debug_PushStack "IGCM_sys_ncwa" $@2452 if ( $DEBUG_sys ) ; then2453 echo "IGCM_sys_ncwa :" $@2454 fi2455 2456 typeset NB_ESSAI DELAI status i2457 # number of tentative2458 NB_ESSAI=32459 # time delay between tentative2460 DELAI=22461 2462 i=02463 while [ $i -lt $NB_ESSAI ] ; do2464 ncwa -C $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12465 status=$?2466 if [ ${status} -gt 0 ] ; then2467 IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"2468 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2469 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2470 IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."2471 sleep $DELAI2472 else2473 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2474 break2475 fi2476 (( i = i + 1 ))2477 done2478 2479 if [ ${status} -gt 0 ] ; then2480 echo "IGCM_sys_ncwa : ncwa error"2481 IGCM_debug_Exit "ncwa"2482 fi2483 2484 IGCM_debug_PopStack "IGCM_sys_ncwa"2485 }2486 2487 ##############################################################2488 # CDO OPERATOR2489 2490 #D-#==================================================2491 #D-function IGCM_sys_cdo2492 #D-* Purpose: encapsulate cdo call so as to manage error code and retry2493 #D-* Examples:2494 #D-2495 function IGCM_sys_cdo {2496 IGCM_debug_PushStack "IGCM_sys_cdo" $@2497 if ( $DEBUG_sys ) ; then2498 echo "IGCM_sys_cdo :" $@2499 fi2500 2501 typeset status2502 2503 \cdo $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&12504 status=$?2505 if [ ${status} -gt 0 ] ; then2506 echo "IGCM_sys_cdo : error code ${status}"2507 cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2508 \rm ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$2509 IGCM_debug_PopStack "IGCM_sys_cdo"2510 return 12511 else2512 IGCM_debug_PopStack "IGCM_sys_cdo"2513 return 02514 fi2515 2516 IGCM_debug_PopStack "IGCM_sys_cdo"2517 }
Note: See TracChangeset
for help on using the changeset viewer.