[225] | 1 | #!/usr/bin/ksh |
---|
| 2 | |
---|
| 3 | # $Date: $ |
---|
| 4 | # $Author: $ |
---|
| 5 | # $Revision: $ |
---|
| 6 | # IPSL (2006) |
---|
| 7 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 8 | |
---|
| 9 | #set -eu |
---|
| 10 | #set -vx |
---|
| 11 | |
---|
| 12 | libIGCM=::modipsl::/libIGCM |
---|
| 13 | |
---|
| 14 | #D--------------------------------------------------------------------== |
---|
| 15 | #D- -1. User modification place |
---|
| 16 | #D--------------------------------------------------------------------== |
---|
| 17 | |
---|
| 18 | #D- Increased verbosity (1, 2, 3) |
---|
| 19 | Verbosity=3 |
---|
| 20 | |
---|
| 21 | #D- Low level debug : to bypass lib test checks and stack construction |
---|
| 22 | #D- Default=true |
---|
| 23 | DEBUG_debug=false |
---|
| 24 | |
---|
| 25 | #D--------------------------------------------------------------------== |
---|
| 26 | |
---|
| 27 | echo "clean month script :" |
---|
| 28 | echo "Script used to clean a month on SAVE directory !" |
---|
| 29 | echo "This script will erase some files !!! Be careful and read all informations !" |
---|
| 30 | echo "----" |
---|
| 31 | echo "It must be called in Experience directory (so-called SUBMIT_DIR)." |
---|
| 32 | echo "----" |
---|
| 33 | |
---|
| 34 | #D--------------------------------------------------------------------== |
---|
| 35 | |
---|
| 36 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 37 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
| 38 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 39 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
| 40 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 41 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
| 42 | #------- |
---|
| 43 | SUBMIT_DIR=${pwd} |
---|
| 44 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
| 45 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | #================================== |
---|
| 49 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices |
---|
| 50 | |
---|
| 51 | for option in ${config_UserChoices[*]} ; do |
---|
| 52 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} |
---|
| 53 | done |
---|
| 54 | |
---|
| 55 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
| 56 | IGCM_debug_PrintVariables 3 config_UserChoices_JobName |
---|
| 57 | if [ 3 -le ${Verbosity} ] ; then |
---|
| 58 | echo "--------------Debug3-->" "config_UserChoices_LongName=" |
---|
| 59 | echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" |
---|
| 60 | fi |
---|
| 61 | IGCM_debug_PrintVariables 3 config_UserChoices_TagName |
---|
| 62 | IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType |
---|
| 63 | IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin |
---|
| 64 | IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd |
---|
| 65 | IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength |
---|
| 66 | |
---|
| 67 | #==================================================== |
---|
| 68 | #R_SAVE : Job output directory |
---|
[273] | 69 | if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then |
---|
| 70 | FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) |
---|
| 71 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 72 | else |
---|
| 73 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 74 | fi |
---|
[225] | 75 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 76 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 77 | |
---|
| 78 | if [ ! -f ${SUBMIT_DIR}/run.card ]; then |
---|
| 79 | echo "You seem NOT to have a run.card in this directory !!" |
---|
| 80 | echo "This script will fail because it doesn't know what to do without run.card avaible." |
---|
| 81 | exit 1 |
---|
| 82 | else |
---|
| 83 | #===================================# |
---|
| 84 | # Read updated run.card # |
---|
| 85 | #===================================# |
---|
| 86 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 87 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix |
---|
| 88 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
| 89 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
| 90 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
| 91 | |
---|
| 92 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
[286] | 93 | echo "Search files with ${PeriodDateEnd} in ${R_SAVE}" |
---|
| 94 | set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) |
---|
| 95 | CountListFiles=${#ListFiles[@]} |
---|
[225] | 96 | |
---|
[286] | 97 | IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." |
---|
[225] | 98 | if [ ${CountListFiles} -gt 0 ] ; then |
---|
[286] | 99 | for file in ${ListFiles[@]} ; do |
---|
| 100 | IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" |
---|
| 101 | done |
---|
| 102 | |
---|
| 103 | echo "\033[1;32mDo you REALLY want to erase all those files ?" |
---|
| 104 | echo -n " Your answer (y/n) : \033[m" |
---|
[225] | 105 | read reponse |
---|
| 106 | case ${reponse} in |
---|
| 107 | |
---|
| 108 | oui|OUI|o|y|yes|YES) |
---|
| 109 | echo "OK. It will be erased." |
---|
| 110 | IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" |
---|
| 111 | echo "done." |
---|
| 112 | ;; |
---|
| 113 | non|NON|n|no|NO) |
---|
| 114 | echo "Nothing to do !" |
---|
| 115 | ;; |
---|
| 116 | esac |
---|
| 117 | fi |
---|
| 118 | |
---|
| 119 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 120 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
[288] | 121 | echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" |
---|
[286] | 122 | echo -n -e " Your answer (y/n) : \033[m" |
---|
[225] | 123 | read reponse |
---|
| 124 | case ${reponse} in |
---|
| 125 | |
---|
| 126 | oui|OUI|o|y|yes|YES) |
---|
[288] | 127 | echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
| 128 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
[225] | 129 | ;; |
---|
| 130 | non|NON|n|no|NO) |
---|
| 131 | echo "Nothing to do !" |
---|
| 132 | ;; |
---|
| 133 | esac |
---|
| 134 | else |
---|
[304] | 135 | echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." |
---|
[225] | 136 | fi |
---|
| 137 | fi |
---|
| 138 | exit 0 |
---|