[373] | 1 | #!/bin/ksh |
---|
| 2 | #************************************************************** |
---|
| 3 | # Author: Martial Mancip |
---|
[403] | 4 | # Contact: Martial.Mancip__at__ipsl.jussieu.fr |
---|
[373] | 5 | # $Revision:: $ Revision of last commit |
---|
| 6 | # $Author:: $ Author of last commit |
---|
| 7 | # $Date:: $ Date of last commit |
---|
[225] | 8 | # IPSL (2006) |
---|
| 9 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
[373] | 10 | # |
---|
| 11 | #************************************************************** |
---|
[1330] | 12 | # ID of your genci project. Curie only : post-processing jobs need it to run properly |
---|
| 13 | #-Q- curie export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
[1437] | 14 | #-Q- irene export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
[1525] | 15 | #-Q- irene-amd export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
[225] | 16 | |
---|
| 17 | #set -eu |
---|
| 18 | #set -vx |
---|
| 19 | |
---|
| 20 | libIGCM=::modipsl::/libIGCM |
---|
| 21 | |
---|
[1356] | 22 | #D- Task type DO NOT CHANGE (computing, post-processing or checking) |
---|
[712] | 23 | TaskType=post-processing |
---|
| 24 | |
---|
[225] | 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 | |
---|
[1342] | 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 !" |
---|
[225] | 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 | #------- |
---|
[428] | 51 | SUBMIT_DIR=$( pwd ) |
---|
[225] | 52 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
| 53 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[832] | 54 | #------- |
---|
| 55 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
| 56 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
| 57 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
[225] | 58 | |
---|
[1567] | 59 | clean_CESMEP() |
---|
| 60 | { |
---|
| 61 | IGCM_card_DefineVariableFromOption ${prefix}config.card Post Cesmep |
---|
| 62 | if [ ${config_Post_Cesmep} != FALSE ]; then |
---|
| 63 | echo -e "\033[1;32mDo you want to erase the CESMEP atlas and dedicated CliMAF cache) ?" |
---|
| 64 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 65 | read reponse |
---|
| 66 | case ${reponse} in |
---|
| 67 | oui|OUI|o|y|yes|YES) |
---|
| 68 | $SUBMIT_DIR/cesmep_lite/libIGCM_clean.sh |
---|
| 69 | ;; |
---|
| 70 | esac |
---|
| 71 | fi |
---|
| 72 | } |
---|
| 73 | |
---|
[225] | 74 | #================================== |
---|
[727] | 75 | # First of all |
---|
| 76 | # |
---|
| 77 | # Read libIGCM compatibility version in config.card |
---|
| 78 | # Read UserChoices section |
---|
| 79 | # Read Ensemble section |
---|
| 80 | # Read Post section |
---|
| 81 | # Define all netcdf output directories |
---|
| 82 | #================================== |
---|
| 83 | IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card |
---|
[225] | 84 | |
---|
[634] | 85 | #================================== |
---|
| 86 | # Define default value to keep compatibility with previous card: means before changes due to TGCC |
---|
| 87 | if [ X${PackDefault} = Xtrue ] ; then |
---|
| 88 | [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} |
---|
| 89 | else |
---|
| 90 | config_Post_PackFrequency=NONE |
---|
| 91 | fi |
---|
| 92 | |
---|
| 93 | #================================== |
---|
[906] | 94 | # Is the pack active |
---|
[634] | 95 | if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then |
---|
| 96 | Pack=true |
---|
| 97 | fi |
---|
| 98 | |
---|
[225] | 99 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 100 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 101 | |
---|
[906] | 102 | if [ ! -f ${SUBMIT_DIR}/run.card ]; then |
---|
[785] | 103 | echo "You seem NOT to have a run.card in this directory !!" |
---|
| 104 | echo "This script will fail because it doesn't know what to do without run.card available." |
---|
| 105 | exit 1 |
---|
[225] | 106 | else |
---|
[785] | 107 | #===================================# |
---|
| 108 | # Read updated run.card # |
---|
| 109 | #===================================# |
---|
| 110 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 111 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
| 112 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
| 113 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
[225] | 114 | |
---|
[1185] | 115 | # |
---|
| 116 | if [ X${run_Configuration_CumulPeriod} = X ] ; then |
---|
| 117 | echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?" |
---|
| 118 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 119 | read reponse |
---|
| 120 | case ${reponse} in |
---|
| 121 | |
---|
| 122 | oui|OUI|o|y|yes|YES) |
---|
| 123 | echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 124 | IGCM_sys_Rm ${SUBMIT_DIR}/run.card |
---|
| 125 | ;; |
---|
| 126 | non|NON|n|no|NO) |
---|
| 127 | echo "Nothing to do !" |
---|
| 128 | ;; |
---|
| 129 | esac |
---|
[1567] | 130 | clean_CESMEP |
---|
[1185] | 131 | exit 0 |
---|
| 132 | fi |
---|
| 133 | |
---|
[785] | 134 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
| 135 | echo "Search files with ${PeriodDateEnd} in ${R_SAVE}" |
---|
| 136 | set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) |
---|
| 137 | CountListFiles=${#ListFiles[@]} |
---|
[225] | 138 | |
---|
[785] | 139 | if [ X${Pack} = Xtrue ] ; then |
---|
| 140 | echo "Search files with ${PeriodDateEnd} in ${R_BUFR}" |
---|
| 141 | set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " ) |
---|
| 142 | CountListFilesBuf=${#ListFilesBuf[@]} |
---|
| 143 | else |
---|
| 144 | CountListFilesBuf=0 |
---|
| 145 | fi |
---|
| 146 | |
---|
| 147 | # If exist, erase REBUILD DIR |
---|
| 148 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
| 149 | CountRebuildDir=0 |
---|
| 150 | if [ X${config_Post_RebuildFrequency} != X ] ; then |
---|
[1031] | 151 | set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" ) |
---|
[785] | 152 | CountRebuildDir=${#RebuildDir[@]} |
---|
| 153 | fi |
---|
[545] | 154 | |
---|
[785] | 155 | IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." |
---|
[906] | 156 | if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then |
---|
[785] | 157 | for file in ${ListFiles[@]} ; do |
---|
| 158 | IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" |
---|
| 159 | done |
---|
| 160 | if [ X${Pack} = Xtrue ] ; then |
---|
| 161 | for file in ${ListFilesBuf[@]} ; do |
---|
| 162 | IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" |
---|
| 163 | done |
---|
[403] | 164 | fi |
---|
[785] | 165 | echo -e "\033[1;32mDo you REALLY want to erase all those files ?" |
---|
| 166 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 167 | read reponse |
---|
| 168 | case ${reponse} in |
---|
[403] | 169 | |
---|
[785] | 170 | oui|OUI|o|y|yes|YES) |
---|
| 171 | echo "OK. It will be erased." |
---|
| 172 | IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" |
---|
[634] | 173 | if [ X${Pack} = Xtrue ] ; then |
---|
[785] | 174 | IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" |
---|
[634] | 175 | fi |
---|
[785] | 176 | echo "done." |
---|
| 177 | ;; |
---|
| 178 | non|NON|n|no|NO) |
---|
| 179 | echo "Nothing to do !" |
---|
| 180 | ;; |
---|
| 181 | esac |
---|
| 182 | fi |
---|
[403] | 183 | |
---|
[906] | 184 | if [ ${CountRebuildDir} -gt 0 ] ; then |
---|
[785] | 185 | IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}." |
---|
| 186 | for Dir in ${RebuildDir[@]} ; do |
---|
| 187 | IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m" |
---|
| 188 | done |
---|
[403] | 189 | |
---|
[785] | 190 | echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" |
---|
| 191 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 192 | read reponse |
---|
| 193 | case ${reponse} in |
---|
[707] | 194 | |
---|
[785] | 195 | oui|OUI|o|y|yes|YES) |
---|
| 196 | echo "OK. It will be erased." |
---|
[1031] | 197 | find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \; |
---|
[785] | 198 | echo "done." |
---|
| 199 | ;; |
---|
| 200 | non|NON|n|no|NO) |
---|
| 201 | echo "Nothing to do !" |
---|
| 202 | ;; |
---|
| 203 | esac |
---|
| 204 | fi |
---|
[707] | 205 | |
---|
[785] | 206 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 207 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 208 | |
---|
| 209 | echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" |
---|
| 210 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 211 | read reponse |
---|
| 212 | case ${reponse} in |
---|
| 213 | |
---|
| 214 | oui|OUI|o|y|yes|YES) |
---|
| 215 | echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 216 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
| 217 | ;; |
---|
| 218 | non|NON|n|no|NO) |
---|
| 219 | echo "Nothing to do !" |
---|
| 220 | ;; |
---|
| 221 | esac |
---|
| 222 | else |
---|
| 223 | echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 224 | fi |
---|
| 225 | |
---|
[1185] | 226 | if [ X${run_Configuration_CumulPeriod} = X1 ] ; then |
---|
[896] | 227 | echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?" |
---|
| 228 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 229 | read reponse |
---|
| 230 | case ${reponse} in |
---|
| 231 | |
---|
| 232 | oui|OUI|o|y|yes|YES) |
---|
| 233 | echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 234 | IGCM_sys_Rm ${SUBMIT_DIR}/run.card |
---|
| 235 | ;; |
---|
| 236 | non|NON|n|no|NO) |
---|
| 237 | echo "Nothing to do !" |
---|
| 238 | ;; |
---|
| 239 | esac |
---|
[1383] | 240 | else |
---|
| 241 | # if not first period |
---|
| 242 | Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} |
---|
| 243 | Script_Output_Job=${Script_Output_Prefix}_${config_UserChoices_JobName} |
---|
| 244 | Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${run_Configuration_CumulPeriod} ) |
---|
| 245 | |
---|
| 246 | echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?" |
---|
| 247 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 248 | read reponse |
---|
| 249 | case ${reponse} in |
---|
| 250 | |
---|
| 251 | oui|OUI|o|y|yes|YES) |
---|
| 252 | cp ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$ |
---|
| 253 | 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} |
---|
| 254 | echo "Job : Job_${config_UserChoices_JobName} modified." |
---|
| 255 | echo "Old job saved here : Job_${config_UserChoices_JobName}_SAVED_$$" |
---|
| 256 | ;; |
---|
| 257 | non|NON|n|no|NO) |
---|
| 258 | echo "Nothing done in Job_${config_UserChoices_JobName} !" |
---|
| 259 | ;; |
---|
| 260 | esac |
---|
| 261 | |
---|
[785] | 262 | fi |
---|
[1567] | 263 | |
---|
| 264 | clean_CESMEP |
---|
| 265 | |
---|
[225] | 266 | fi |
---|
| 267 | exit 0 |
---|