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