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