[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 | |
---|
| 59 | #================================== |
---|
[727] | 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 |
---|
[225] | 69 | |
---|
[634] | 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 | #================================== |
---|
[906] | 79 | # Is the pack active |
---|
[634] | 80 | if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then |
---|
| 81 | Pack=true |
---|
| 82 | fi |
---|
| 83 | |
---|
[225] | 84 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 85 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 86 | |
---|
[906] | 87 | if [ ! -f ${SUBMIT_DIR}/run.card ]; then |
---|
[785] | 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 |
---|
[225] | 91 | else |
---|
[785] | 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 |
---|
[225] | 99 | |
---|
[1185] | 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 | |
---|
[785] | 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[@]} |
---|
[225] | 122 | |
---|
[785] | 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 |
---|
[1031] | 135 | set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" ) |
---|
[785] | 136 | CountRebuildDir=${#RebuildDir[@]} |
---|
| 137 | fi |
---|
[545] | 138 | |
---|
[785] | 139 | IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." |
---|
[906] | 140 | if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then |
---|
[785] | 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 |
---|
[403] | 148 | fi |
---|
[785] | 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 |
---|
[403] | 153 | |
---|
[785] | 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 '{}' \;" |
---|
[634] | 157 | if [ X${Pack} = Xtrue ] ; then |
---|
[785] | 158 | IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" |
---|
[634] | 159 | fi |
---|
[785] | 160 | echo "done." |
---|
| 161 | ;; |
---|
| 162 | non|NON|n|no|NO) |
---|
| 163 | echo "Nothing to do !" |
---|
| 164 | ;; |
---|
| 165 | esac |
---|
| 166 | fi |
---|
[403] | 167 | |
---|
[906] | 168 | if [ ${CountRebuildDir} -gt 0 ] ; then |
---|
[785] | 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 |
---|
[403] | 173 | |
---|
[785] | 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 |
---|
[707] | 178 | |
---|
[785] | 179 | oui|OUI|o|y|yes|YES) |
---|
| 180 | echo "OK. It will be erased." |
---|
[1031] | 181 | find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \; |
---|
[785] | 182 | echo "done." |
---|
| 183 | ;; |
---|
| 184 | non|NON|n|no|NO) |
---|
| 185 | echo "Nothing to do !" |
---|
| 186 | ;; |
---|
| 187 | esac |
---|
| 188 | fi |
---|
[707] | 189 | |
---|
[785] | 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 | |
---|
[1185] | 210 | if [ X${run_Configuration_CumulPeriod} = X1 ] ; then |
---|
[896] | 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 |
---|
[1383] | 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 | |
---|
[785] | 246 | fi |
---|
[225] | 247 | fi |
---|
| 248 | exit 0 |
---|