[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 | #************************************************************** |
---|
[225] | 12 | |
---|
| 13 | #set -eu |
---|
| 14 | #set -vx |
---|
| 15 | |
---|
| 16 | libIGCM=::modipsl::/libIGCM |
---|
| 17 | |
---|
[712] | 18 | #D- Task type (computing or post-processing) |
---|
| 19 | TaskType=post-processing |
---|
| 20 | |
---|
[225] | 21 | #D--------------------------------------------------------------------== |
---|
| 22 | #D- -1. User modification place |
---|
| 23 | #D--------------------------------------------------------------------== |
---|
| 24 | |
---|
| 25 | #D- Increased verbosity (1, 2, 3) |
---|
| 26 | Verbosity=3 |
---|
| 27 | |
---|
| 28 | #D- Low level debug : to bypass lib test checks and stack construction |
---|
| 29 | #D- Default=true |
---|
| 30 | DEBUG_debug=false |
---|
| 31 | |
---|
| 32 | #D--------------------------------------------------------------------== |
---|
| 33 | |
---|
| 34 | echo "clean month script :" |
---|
| 35 | echo "Script used to clean a month on SAVE directory !" |
---|
| 36 | echo "This script will erase some files !!! Be careful and read all informations !" |
---|
| 37 | echo "----" |
---|
| 38 | echo "It must be called in Experience directory (so-called SUBMIT_DIR)." |
---|
| 39 | echo "----" |
---|
| 40 | |
---|
| 41 | #D--------------------------------------------------------------------== |
---|
| 42 | |
---|
| 43 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 44 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 45 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 46 | #------- |
---|
[428] | 47 | SUBMIT_DIR=$( pwd ) |
---|
[225] | 48 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
| 49 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[832] | 50 | #------- |
---|
| 51 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
| 52 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
| 53 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
[225] | 54 | |
---|
| 55 | #================================== |
---|
[727] | 56 | # First of all |
---|
| 57 | # |
---|
| 58 | # Read libIGCM compatibility version in config.card |
---|
| 59 | # Read UserChoices section |
---|
| 60 | # Read Ensemble section |
---|
| 61 | # Read Post section |
---|
| 62 | # Define all netcdf output directories |
---|
| 63 | #================================== |
---|
| 64 | IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card |
---|
[225] | 65 | |
---|
[634] | 66 | #================================== |
---|
| 67 | # Define default value to keep compatibility with previous card: means before changes due to TGCC |
---|
| 68 | if [ X${PackDefault} = Xtrue ] ; then |
---|
| 69 | [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} |
---|
| 70 | else |
---|
| 71 | config_Post_PackFrequency=NONE |
---|
| 72 | fi |
---|
| 73 | |
---|
| 74 | #================================== |
---|
[906] | 75 | # Is the pack active |
---|
[634] | 76 | if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then |
---|
| 77 | Pack=true |
---|
| 78 | fi |
---|
| 79 | |
---|
[225] | 80 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 81 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 82 | |
---|
[906] | 83 | if [ ! -f ${SUBMIT_DIR}/run.card ]; then |
---|
[785] | 84 | echo "You seem NOT to have a run.card in this directory !!" |
---|
| 85 | echo "This script will fail because it doesn't know what to do without run.card available." |
---|
| 86 | exit 1 |
---|
[225] | 87 | else |
---|
[785] | 88 | #===================================# |
---|
| 89 | # Read updated run.card # |
---|
| 90 | #===================================# |
---|
| 91 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 92 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
| 93 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
| 94 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
[225] | 95 | |
---|
[785] | 96 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
| 97 | echo "Search files with ${PeriodDateEnd} in ${R_SAVE}" |
---|
| 98 | set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) |
---|
| 99 | CountListFiles=${#ListFiles[@]} |
---|
[225] | 100 | |
---|
[785] | 101 | if [ X${Pack} = Xtrue ] ; then |
---|
| 102 | echo "Search files with ${PeriodDateEnd} in ${R_BUFR}" |
---|
| 103 | set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " ) |
---|
| 104 | CountListFilesBuf=${#ListFilesBuf[@]} |
---|
| 105 | else |
---|
| 106 | CountListFilesBuf=0 |
---|
| 107 | fi |
---|
| 108 | |
---|
| 109 | # If exist, erase REBUILD DIR |
---|
| 110 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
| 111 | CountRebuildDir=0 |
---|
| 112 | if [ X${config_Post_RebuildFrequency} != X ] ; then |
---|
[1031] | 113 | set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" ) |
---|
[785] | 114 | CountRebuildDir=${#RebuildDir[@]} |
---|
| 115 | fi |
---|
[545] | 116 | |
---|
[785] | 117 | IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." |
---|
[906] | 118 | if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then |
---|
[785] | 119 | for file in ${ListFiles[@]} ; do |
---|
| 120 | IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" |
---|
| 121 | done |
---|
| 122 | if [ X${Pack} = Xtrue ] ; then |
---|
| 123 | for file in ${ListFilesBuf[@]} ; do |
---|
| 124 | IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" |
---|
| 125 | done |
---|
[403] | 126 | fi |
---|
[785] | 127 | echo -e "\033[1;32mDo you REALLY want to erase all those files ?" |
---|
| 128 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 129 | read reponse |
---|
| 130 | case ${reponse} in |
---|
[403] | 131 | |
---|
[785] | 132 | oui|OUI|o|y|yes|YES) |
---|
| 133 | echo "OK. It will be erased." |
---|
| 134 | IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" |
---|
[634] | 135 | if [ X${Pack} = Xtrue ] ; then |
---|
[785] | 136 | IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" |
---|
[634] | 137 | fi |
---|
[785] | 138 | echo "done." |
---|
| 139 | ;; |
---|
| 140 | non|NON|n|no|NO) |
---|
| 141 | echo "Nothing to do !" |
---|
| 142 | ;; |
---|
| 143 | esac |
---|
| 144 | fi |
---|
[403] | 145 | |
---|
[906] | 146 | if [ ${CountRebuildDir} -gt 0 ] ; then |
---|
[785] | 147 | IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}." |
---|
| 148 | for Dir in ${RebuildDir[@]} ; do |
---|
| 149 | IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m" |
---|
| 150 | done |
---|
[403] | 151 | |
---|
[785] | 152 | echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" |
---|
| 153 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 154 | read reponse |
---|
| 155 | case ${reponse} in |
---|
[707] | 156 | |
---|
[785] | 157 | oui|OUI|o|y|yes|YES) |
---|
| 158 | echo "OK. It will be erased." |
---|
[1031] | 159 | find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \; |
---|
[785] | 160 | echo "done." |
---|
| 161 | ;; |
---|
| 162 | non|NON|n|no|NO) |
---|
| 163 | echo "Nothing to do !" |
---|
| 164 | ;; |
---|
| 165 | esac |
---|
| 166 | fi |
---|
[707] | 167 | |
---|
[785] | 168 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 169 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 170 | |
---|
| 171 | echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" |
---|
| 172 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 173 | read reponse |
---|
| 174 | case ${reponse} in |
---|
| 175 | |
---|
| 176 | oui|OUI|o|y|yes|YES) |
---|
| 177 | echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 178 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
| 179 | ;; |
---|
| 180 | non|NON|n|no|NO) |
---|
| 181 | echo "Nothing to do !" |
---|
| 182 | ;; |
---|
| 183 | esac |
---|
| 184 | else |
---|
| 185 | echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 186 | fi |
---|
| 187 | |
---|
| 188 | if ( [ X${run_Configuration_CumulPeriod} = X ] || [ X${run_Configuration_CumulPeriod} = X1 ] ); then |
---|
[896] | 189 | |
---|
| 190 | echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?" |
---|
| 191 | echo -n -e " Your answer (y/n) : \033[m" |
---|
| 192 | read reponse |
---|
| 193 | case ${reponse} in |
---|
| 194 | |
---|
| 195 | oui|OUI|o|y|yes|YES) |
---|
| 196 | echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 197 | IGCM_sys_Rm ${SUBMIT_DIR}/run.card |
---|
| 198 | ;; |
---|
| 199 | non|NON|n|no|NO) |
---|
| 200 | echo "Nothing to do !" |
---|
| 201 | ;; |
---|
| 202 | esac |
---|
| 203 | |
---|
[785] | 204 | fi |
---|
[225] | 205 | fi |
---|
| 206 | exit 0 |
---|