1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil |
---|
5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr |
---|
6 | # $Revision:: $ Revision of last commit |
---|
7 | # $Author:: $ Author of last commit |
---|
8 | # $Date:: $ Date of last commit |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # |
---|
12 | #************************************************************** |
---|
13 | # ID of your genci project. Curie only : post-processing jobs need it to run properly |
---|
14 | #-Q- curie export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
15 | #-Q- irene export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
16 | #-Q- irene-amd export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
17 | |
---|
18 | #D- Task type DO NOT CHANGE (computing, post-processing or checking) |
---|
19 | TaskType=checking |
---|
20 | |
---|
21 | #D- Low level debug : to perform lib test checks, stack construction and IO functions instrumentation |
---|
22 | DEBUG_debug=false |
---|
23 | |
---|
24 | #D- Messaging : all activities and call stacks will be sent to ipsl servers |
---|
25 | BigBrother=false |
---|
26 | |
---|
27 | # Check that everything went well during seasonal average production |
---|
28 | # Display a short report |
---|
29 | # Launch what's missing when a simulation has been completed PeriodState=Completed |
---|
30 | |
---|
31 | #D- Path to libIGCM |
---|
32 | #D- Default : value from AA_job if any |
---|
33 | # WARNING For StandAlone use : To run this script on some machine (ulam and cesium) |
---|
34 | # WARNING you must check MirrorlibIGCM variable in sys library. |
---|
35 | # WARNING If this variable is true, you must use libIGCM_POST path instead |
---|
36 | # WARNING of your running libIGCM directory. |
---|
37 | libIGCM=${libIGCM:=::modipsl::/libIGCM} |
---|
38 | |
---|
39 | # Current directory |
---|
40 | CURRENT_DIR=$( pwd ) |
---|
41 | |
---|
42 | # Directory with comp.cards |
---|
43 | CARD_DIR=${CARD_DIR:=${CURRENT_DIR}} |
---|
44 | |
---|
45 | # Directory for script output |
---|
46 | POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript} |
---|
47 | |
---|
48 | if [ ! -d ${CARD_DIR} ]; then |
---|
49 | echo "No ${CARD_DIR}, we stop here" |
---|
50 | exit |
---|
51 | fi |
---|
52 | |
---|
53 | ######################################################################## |
---|
54 | |
---|
55 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
56 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
57 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
58 | #------- |
---|
59 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
60 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
61 | #------- |
---|
62 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
63 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
64 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
65 | |
---|
66 | ######################################################################## |
---|
67 | |
---|
68 | #set -vx |
---|
69 | |
---|
70 | echo "Hi I'm here to help you check and complete the seasonal average production" |
---|
71 | echo -e "\033[1;31mDo you want me to run in dryrun mode just telling what I would submit? Answer no in this case\033[m" |
---|
72 | echo -e "\033[1;31mOr do you want me to submit job for real? Answer yes in this case.\033[m" |
---|
73 | echo -n " Run for real (y/n) :" |
---|
74 | read ActionAnswer |
---|
75 | |
---|
76 | case ${ActionAnswer} in |
---|
77 | oui|OUI|o|y|yes|YES) |
---|
78 | echo "OK. I will submit jobs" |
---|
79 | action=true |
---|
80 | ;; |
---|
81 | non|NON|n|no|NO) |
---|
82 | echo "OK. I won't submit any jobs" |
---|
83 | action=false |
---|
84 | ;; |
---|
85 | *) |
---|
86 | echo "I did not recognize your answer. I will stop here." |
---|
87 | echo "Please answer: oui|OUI|o|y|yes|YES" |
---|
88 | echo "Or answer: non|NON|n|no|NO" |
---|
89 | exit |
---|
90 | ;; |
---|
91 | esac |
---|
92 | |
---|
93 | #================================== |
---|
94 | # First of all |
---|
95 | # |
---|
96 | # Read libIGCM compatibility version in config.card |
---|
97 | # Read UserChoices section |
---|
98 | # Read Ensemble section |
---|
99 | # Read Post section |
---|
100 | # Define all netcdf output directories |
---|
101 | #================================== |
---|
102 | IGCM_config_CommonConfiguration ${CARD_DIR}/config.card |
---|
103 | |
---|
104 | #================================== |
---|
105 | # Read ListOfComponents section: |
---|
106 | IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents |
---|
107 | |
---|
108 | #================================== |
---|
109 | # Read SeasonalFrequency: |
---|
110 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency |
---|
111 | |
---|
112 | #=================================== |
---|
113 | # Read DateBegin from config.card |
---|
114 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
115 | |
---|
116 | #=================================== |
---|
117 | # Read end date from run.card or config.card |
---|
118 | if [ -f ${CARD_DIR}/run.card ] ; then |
---|
119 | # Read updated run.card : |
---|
120 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration PeriodDateBegin |
---|
121 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration PeriodState |
---|
122 | |
---|
123 | if [ X${run_Configuration_PeriodState} != X"Completed" ] ; then |
---|
124 | # Calculate DateEnd by read PeriodDateBegin from run.card and remove one day |
---|
125 | DateEnd=$( IGCM_date_AddDaysToGregorianDate $( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) -1 ) |
---|
126 | else |
---|
127 | # Simulation is finished, read DateEnd from config.card |
---|
128 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
129 | fi |
---|
130 | else |
---|
131 | # No run.card available, read DateEnd from config.card |
---|
132 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
133 | fi |
---|
134 | |
---|
135 | #=================================== |
---|
136 | # Calculate offset |
---|
137 | if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then |
---|
138 | PeriodOffset=0 |
---|
139 | else |
---|
140 | PeriodOffset=${config_Post_SeasonalFrequencyOffset} |
---|
141 | fi |
---|
142 | |
---|
143 | IGCM_debug_Print 1 "DateBegin for SE_Checker : "${DateBegin} |
---|
144 | IGCM_debug_Print 1 "DateEnd for SE_Checker : "${DateEnd} |
---|
145 | IGCM_debug_Print 1 "Offset for SE_Checker : "${PeriodOffset} |
---|
146 | echo |
---|
147 | # |
---|
148 | [ X${config_Post_SeasonalFrequency} = X"NONE" ] && exit |
---|
149 | |
---|
150 | freq=$( echo ${config_Post_SeasonalFrequency} | sed -e "s/[yY]//" ) |
---|
151 | |
---|
152 | an_deb=$( IGCM_date_YearDigit $(( DateBegin / 10000 + PeriodOffset )) ) |
---|
153 | an_fin=$( IGCM_date_YearDigit $(( an_deb + freq - 1 )) ) |
---|
154 | an_fin_all=$( IGCM_date_YearDigit $(( DateEnd / 10000 )) ) |
---|
155 | |
---|
156 | # |
---|
157 | while [ ${an_fin} -le ${an_fin_all} ] ; do |
---|
158 | |
---|
159 | countTotal=0 |
---|
160 | countGood=0 |
---|
161 | countBad=0 |
---|
162 | |
---|
163 | IGCM_debug_Print 1 " DateBegin/End for SE : ${an_deb}_${an_fin} " |
---|
164 | |
---|
165 | for comp in ${config_ListOfComponents[*]} ; do |
---|
166 | localcountBad=0 |
---|
167 | # Debug Print |
---|
168 | IGCM_debug_Print 1 ${comp} |
---|
169 | # Define component |
---|
170 | IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp} |
---|
171 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
172 | |
---|
173 | # Read libIGCM compatibility version in ${compname}.card |
---|
174 | card=${CARD_DIR}/COMP/${compname}.card |
---|
175 | |
---|
176 | # Read and Build Output File stuff |
---|
177 | #IGCM_debug_Print 1 "DefineArrayFromOption : ${compname}_OutputFiles ${card}" |
---|
178 | IGCM_card_DefineArrayFromOption ${card} OutputFiles List |
---|
179 | ListFilesName=${compname}_OutputFiles_List |
---|
180 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
181 | # |
---|
182 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
183 | # |
---|
184 | # INITIALISATION |
---|
185 | # |
---|
186 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
187 | typeset i=2 |
---|
188 | # |
---|
189 | until [ $i -gt $NbFiles ]; do |
---|
190 | # |
---|
191 | eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
192 | # |
---|
193 | if [ X${flag_post} != XNONE ] ; then |
---|
194 | # |
---|
195 | # Check if seasonal is required for this file |
---|
196 | # |
---|
197 | IGCM_card_DefineArrayFromSection ${card} ${flag_post} |
---|
198 | # |
---|
199 | # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default |
---|
200 | # |
---|
201 | # variable option allready typeset above |
---|
202 | for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do |
---|
203 | if [ ${option} = Seasonal ] ; then |
---|
204 | FoundSeasonal=true |
---|
205 | IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal |
---|
206 | fi |
---|
207 | done |
---|
208 | # |
---|
209 | if [ ! X${FoundSeasonal} = Xtrue ] ; then |
---|
210 | eval ${compname}_${flag_post}_Seasonal=ON |
---|
211 | fi |
---|
212 | # |
---|
213 | if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then |
---|
214 | (( i=i+3 )) |
---|
215 | continue |
---|
216 | fi |
---|
217 | # |
---|
218 | # CREATE LIST |
---|
219 | # |
---|
220 | FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' ) |
---|
221 | # |
---|
222 | DIRECTORY=${R_SAVE}/${comp}/Analyse/SE |
---|
223 | # |
---|
224 | TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc |
---|
225 | # |
---|
226 | (( countTotal = countTotal + 1 )) |
---|
227 | IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile} >/dev/null 2>&1 |
---|
228 | if [ ! $? = 0 ] ; then |
---|
229 | eval set +A LISTE_FILE_${comp}_${an_deb} \$\{LISTE_FILE_${comp}_${an_deb}[*]} ${TestedFile} |
---|
230 | (( countBad = countBad + 1 )) |
---|
231 | (( localcountBad = localcountBad + 1 )) |
---|
232 | else |
---|
233 | (( countGood = countGood + 1 )) |
---|
234 | fi |
---|
235 | fi |
---|
236 | (( i=i+3 )) # to explore file list |
---|
237 | done # until [ $i -eq $NbFiles ] |
---|
238 | fi # [ X${FileName0} != X${NULL_STR} ] |
---|
239 | |
---|
240 | [ $localcountBad = 0 ] || IGCM_debug_Print 1 "$localcountBad file(s) missing for ${comp} : " $( eval echo \${LISTE_FILE_${comp}_${an_deb}[*]} ) |
---|
241 | done |
---|
242 | |
---|
243 | # create_se submit if files don't exist |
---|
244 | if [ $countGood != $countTotal ] ; then |
---|
245 | if [ ${action} = true ] ; then |
---|
246 | |
---|
247 | IGCM_debug_Print 2 -e "\033[1;31mSubmit create_se \033[m for period ${an_deb}-${an_fin}" |
---|
248 | |
---|
249 | listVarEnv="DEBUG_debug,BigBrother,libIGCM,SUBMIT_DIR,POST_DIR,Script_Post_Output,DateBegin,PeriodDateEnd,RebuildFrequency,RESOL_ATM,RESOL_SRF,RESOL_SBG,RESOL_OCE,RESOL_ICE,RESOL_MBG" |
---|
250 | export DEBUG_debug=${DEBUG_debug} |
---|
251 | export BigBrother=${BigBrother} |
---|
252 | export libIGCM=${libIGCM} |
---|
253 | export SUBMIT_DIR=${CARD_DIR} |
---|
254 | export POST_DIR=${POST_DIR} |
---|
255 | export DateBegin=${an_deb} |
---|
256 | export PeriodDateEnd=${an_fin}1231 |
---|
257 | export RebuildFrequency=${RebuildFrequency} |
---|
258 | export RESOL_ATM=${RESOL_ATM} |
---|
259 | export RESOL_SRF=${RESOL_SRF} |
---|
260 | export RESOL_SBG=${RESOL_SBG} |
---|
261 | export RESOL_OCE=${RESOL_OCE} |
---|
262 | export RESOL_ICE=${RESOL_ICE} |
---|
263 | export RESOL_MBG=${RESOL_MBG} |
---|
264 | export listVarEnv=${listVarEnv} |
---|
265 | export Script_Post_Output=create_se.${PeriodDateEnd} |
---|
266 | |
---|
267 | IGCM_sys_MkdirWork ${POST_DIR} |
---|
268 | IGCM_debug_Verif_Exit |
---|
269 | IGCM_sys_QsubPost create_se |
---|
270 | echo |
---|
271 | else |
---|
272 | # only dry run |
---|
273 | IGCM_debug_Print 2 -e "\033[1;31mI should NOW Submit create_se \033[m for period ${an_deb}-${an_fin}" |
---|
274 | echo |
---|
275 | fi |
---|
276 | else |
---|
277 | IGCM_debug_Print 2 -e "\033[1;32mFiles are OK for period ${an_deb}-${an_fin}.\033[m Nothing needs to be done for this period." |
---|
278 | echo |
---|
279 | fi |
---|
280 | |
---|
281 | (( an_deb = an_deb + freq )) |
---|
282 | (( an_fin = an_fin + freq )) |
---|
283 | |
---|
284 | done # while |
---|