Changeset 1575
- Timestamp:
- 02/16/23 11:56:52 (7 months ago)
- Location:
- trunk/libIGCM
- Files:
-
- 1 deleted
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/AA_clean_PeriodLength
r1525 r1575 10 10 # 11 11 #************************************************************** 12 # ID of your genci project. Curie only : post-processing jobs need it to run properly13 #-Q- curie export BRIDGE_MSUB_PROJECT=::default_project::14 #-Q- irene export BRIDGE_MSUB_PROJECT=::default_project::15 #-Q- irene-amd export BRIDGE_MSUB_PROJECT=::default_project::16 12 17 #set -eu 18 #set -vx 19 20 libIGCM=::modipsl::/libIGCM 21 22 #D- Task type DO NOT CHANGE (computing, post-processing or checking) 23 TaskType=post-processing 24 25 #D--------------------------------------------------------------------== 26 #D- -1. User modification place 27 #D--------------------------------------------------------------------== 28 29 #D- Increased verbosity (1, 2, 3) 30 Verbosity=3 31 32 #D- Low level debug : to bypass lib test checks and stack construction 33 #D- Default=true 34 DEBUG_debug=false 35 36 #D--------------------------------------------------------------------== 37 38 echo "clean PeriodLenght script :" 39 echo "Script used to clean a PeriodLength from the IGCM_OUT directory !" 40 echo "This script will erase files !!! Be careful and read all informations !" 41 echo "----" 42 echo "It must be called in Experience directory (so-called SUBMIT_DIR)." 43 echo "----" 44 45 #D--------------------------------------------------------------------== 46 47 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 48 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 49 . ${libIGCM}/libIGCM_date/libIGCM_date.ksh 50 #------- 51 SUBMIT_DIR=$( pwd ) 52 . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh 53 . ${libIGCM}/libIGCM_config/libIGCM_config.ksh 54 #------- 55 ( ${DEBUG_debug} ) && IGCM_debug_Check 56 ( ${DEBUG_debug} ) && IGCM_card_Check 57 ( ${DEBUG_debug} ) && IGCM_date_Check 58 59 #================================== 60 # First of all 61 # 62 # Read libIGCM compatibility version in config.card 63 # Read UserChoices section 64 # Read Ensemble section 65 # Read Post section 66 # Define all netcdf output directories 67 #================================== 68 IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card 69 70 #================================== 71 # Define default value to keep compatibility with previous card: means before changes due to TGCC 72 if [ X${PackDefault} = Xtrue ] ; then 73 [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} 74 else 75 config_Post_PackFrequency=NONE 76 fi 77 78 #================================== 79 # Is the pack active 80 if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then 81 Pack=true 82 fi 83 84 IGCM_sys_TestDirArchive ${R_SAVE} 85 [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 86 87 if [ ! -f ${SUBMIT_DIR}/run.card ]; then 88 echo "You seem NOT to have a run.card in this directory !!" 89 echo "This script will fail because it doesn't know what to do without run.card available." 90 exit 1 91 else 92 #===================================# 93 # Read updated run.card # 94 #===================================# 95 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 96 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin 97 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd 98 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod 99 100 # 101 if [ X${run_Configuration_CumulPeriod} = X ] ; then 102 echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?" 103 echo -n -e " Your answer (y/n) : \033[m" 104 read reponse 105 case ${reponse} in 106 107 oui|OUI|o|y|yes|YES) 108 echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 109 IGCM_sys_Rm ${SUBMIT_DIR}/run.card 110 ;; 111 non|NON|n|no|NO) 112 echo "Nothing to do !" 113 ;; 114 esac 115 exit 0 116 fi 117 118 PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) 119 echo "Search files with ${PeriodDateEnd} in ${R_SAVE}" 120 set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) 121 CountListFiles=${#ListFiles[@]} 122 123 if [ X${Pack} = Xtrue ] ; then 124 echo "Search files with ${PeriodDateEnd} in ${R_BUFR}" 125 set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " ) 126 CountListFilesBuf=${#ListFilesBuf[@]} 127 else 128 CountListFilesBuf=0 129 fi 130 131 # If exist, erase REBUILD DIR 132 PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) 133 CountRebuildDir=0 134 if [ X${config_Post_RebuildFrequency} != X ] ; then 135 set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" ) 136 CountRebuildDir=${#RebuildDir[@]} 137 fi 138 139 IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." 140 if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then 141 for file in ${ListFiles[@]} ; do 142 IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" 143 done 144 if [ X${Pack} = Xtrue ] ; then 145 for file in ${ListFilesBuf[@]} ; do 146 IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" 147 done 148 fi 149 echo -e "\033[1;32mDo you REALLY want to erase all those files ?" 150 echo -n -e " Your answer (y/n) : \033[m" 151 read reponse 152 case ${reponse} in 153 154 oui|OUI|o|y|yes|YES) 155 echo "OK. It will be erased." 156 IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 157 if [ X${Pack} = Xtrue ] ; then 158 IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 159 fi 160 echo "done." 161 ;; 162 non|NON|n|no|NO) 163 echo "Nothing to do !" 164 ;; 165 esac 166 fi 167 168 if [ ${CountRebuildDir} -gt 0 ] ; then 169 IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}." 170 for Dir in ${RebuildDir[@]} ; do 171 IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m" 172 done 173 174 echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" 175 echo -n -e " Your answer (y/n) : \033[m" 176 read reponse 177 case ${reponse} in 178 179 oui|OUI|o|y|yes|YES) 180 echo "OK. It will be erased." 181 find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \; 182 echo "done." 183 ;; 184 non|NON|n|no|NO) 185 echo "Nothing to do !" 186 ;; 187 esac 188 fi 189 190 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 191 if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 192 193 echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" 194 echo -n -e " Your answer (y/n) : \033[m" 195 read reponse 196 case ${reponse} in 197 198 oui|OUI|o|y|yes|YES) 199 echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 200 IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 201 ;; 202 non|NON|n|no|NO) 203 echo "Nothing to do !" 204 ;; 205 esac 206 else 207 echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 208 fi 209 210 if [ X${run_Configuration_CumulPeriod} = X1 ] ; then 211 echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?" 212 echo -n -e " Your answer (y/n) : \033[m" 213 read reponse 214 case ${reponse} in 215 216 oui|OUI|o|y|yes|YES) 217 echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 218 IGCM_sys_Rm ${SUBMIT_DIR}/run.card 219 ;; 220 non|NON|n|no|NO) 221 echo "Nothing to do !" 222 ;; 223 esac 224 else 225 # if not first period 226 Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} 227 Script_Output_Job=${Script_Output_Prefix}_${config_UserChoices_JobName} 228 Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${run_Configuration_CumulPeriod} ) 229 230 echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?" 231 echo -n -e " Your answer (y/n) : \033[m" 232 read reponse 233 case ${reponse} in 234 235 oui|OUI|o|y|yes|YES) 236 cp ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$ 237 sed -e"s/${Script_Output_Job}.[0-9][0-9][0-9][0-9][0-9][0-9]/${Script_Output}/" ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$ >${SUBMIT_DIR}/Job_${config_UserChoices_JobName} 238 echo "Job : Job_${config_UserChoices_JobName} modified." 239 echo "Old job saved here : Job_${config_UserChoices_JobName}_SAVED_$$" 240 ;; 241 non|NON|n|no|NO) 242 echo "Nothing done in Job_${config_UserChoices_JobName} !" 243 ;; 244 esac 245 246 fi 247 fi 248 exit 0 13 echo "" 14 echo "clean_PeriodLength.job has been replaced by clean_or_continue.job." 15 echo "The new script keeps the same funtionnalities as the old one. " 16 echo "Launch using " 17 echo "../../../libIGCM/clean_or_continue.job -h : for help" 18 echo "../../../libIGCM/clean_or_continut.job : for normal execution" 19 echo "Exit now" 20 echo "" 21 exit -
trunk/libIGCM/AA_clean_or_continue
r1574 r1575 35 35 36 36 #D--------------------------------------------------------------------== 37 38 echo "clean PeriodLenght script :" 39 echo "Script used to clean a PeriodLength from the IGCM_OUT directory !" 40 echo "This script will erase files !!! Be careful and read all informations !" 41 echo "----" 42 echo "It must be called in Experience directory (so-called SUBMIT_DIR)." 43 echo "----" 37 echo "" 38 echo "clean_or_continue.job " 39 if [ $# -gt 0 ] ; then 40 # Print help and exit 41 echo "" 42 echo "The script is called from in the your experiment directory, the so-called SUBMIT_DIR, in the following way" 43 echo "../../../libIGCM/clean_or_continue.job -h : to print following information" 44 echo "../../../libIGCM/clean_or_continue.job : normal execution" 45 echo "" 46 echo "This script can be used for 3 cases:" 47 echo "1- The simulation crashed and you have PeriodState=Fatal in run.card." 48 echo "For this case, all output from the current PeriodLength set in run.card will be deleted. " 49 echo "You need to answer yes to the questions." 50 echo "" 51 echo "2- The simulation stopped due to an exceeded time limit, PeriodState=Running in run.card". 52 echo "As for case 1, all output from the current PeriodLength will be deleted and you should answer yes to questions". 53 echo "" 54 echo "3- The simulation is completed but you want to continue it, PeriodState=Completed in run.card." 55 echo "For this case, you just need to change DateEnd in config.card and launch this script." 56 echo "" 57 echo "For all cases, the run.card is changed as needed and the number for the current period is set in the main Job_ for the Script_Output_ file" 58 echo "" 59 echo "This script needs to delete files to work correctly. Therefore you should answer yes to the questions." 60 echo "" 61 62 exit 63 fi 64 echo "" 65 echo "This script needs to delete files to work correctly. Therefore you should answer yes to the questions." 66 echo "Use ../../../libIGCM/clean_or_contine.job -h for more information" 67 echo "" 44 68 45 69 #D--------------------------------------------------------------------==
Note: See TracChangeset
for help on using the changeset viewer.