1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Martial Mancip |
---|
5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__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 | |
---|
14 | #=================================== |
---|
15 | function IGCM_config_Initialize |
---|
16 | { |
---|
17 | IGCM_debug_PushStack "IGCM_config_Initialize" |
---|
18 | |
---|
19 | # Debug Print : |
---|
20 | echo |
---|
21 | IGCM_debug_Print 1 "IGCM_config_Initialize" |
---|
22 | |
---|
23 | if [ ! -r ${SUBMIT_DIR}/run.card ]; then |
---|
24 | #================================================# |
---|
25 | # The file run.card doesn't exist # |
---|
26 | #================================================# |
---|
27 | FirstInitialize=true |
---|
28 | #copy initial run.card |
---|
29 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card |
---|
30 | IGCM_debug_Print 2 "run.card copied from run.card.init" |
---|
31 | else |
---|
32 | FirstInitialize=false |
---|
33 | IGCM_debug_Print 2 "run.card exists" |
---|
34 | fi |
---|
35 | |
---|
36 | # Test modipsl tree existence. |
---|
37 | IGCM_sys_TestDir ${MODIPSL} |
---|
38 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
39 | IGCM_sys_TestDir ${libIGCM} |
---|
40 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
41 | IGCM_sys_TestDir ${R_EXE} |
---|
42 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
43 | IGCM_sys_TestDir ${SUBMIT_DIR} |
---|
44 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
45 | |
---|
46 | if ( $DEBUG_debug ) ; then |
---|
47 | echo "Keep trace of inital SUBMIT_DIR : " |
---|
48 | ls -lta ${SUBMIT_DIR} |
---|
49 | fi |
---|
50 | |
---|
51 | #================================== |
---|
52 | |
---|
53 | typeset option auxprint CompatibilityTag |
---|
54 | # Read libIGCM compatibility version in config.card |
---|
55 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Compatibility libIGCM |
---|
56 | eval CompatibilityTag=${config_Compatibility_libIGCM} > /dev/null 2>&1 |
---|
57 | |
---|
58 | if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then |
---|
59 | IGCM_debug_Exit "config.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." |
---|
60 | fi |
---|
61 | |
---|
62 | #================================== |
---|
63 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices |
---|
64 | |
---|
65 | for option in ${config_UserChoices[*]} ; do |
---|
66 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} |
---|
67 | done |
---|
68 | echo |
---|
69 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
70 | # Name Space of this experience |
---|
71 | if [ X${config_UserChoices_SpaceName} != X ] ; then |
---|
72 | IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName |
---|
73 | fi |
---|
74 | # Expericence class of the run |
---|
75 | if [ X${config_UserChoices_ExperimentName} != X ] ; then |
---|
76 | IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName |
---|
77 | fi |
---|
78 | IGCM_debug_PrintVariables 3 config_UserChoices_JobName |
---|
79 | if [ 3 -le ${Verbosity} ] ; then |
---|
80 | echo "--------------Debug3-->" "config_UserChoices_LongName=" |
---|
81 | echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" |
---|
82 | fi |
---|
83 | IGCM_debug_PrintVariables 3 config_UserChoices_TagName |
---|
84 | IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType |
---|
85 | IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin |
---|
86 | IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd |
---|
87 | IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength |
---|
88 | |
---|
89 | #================================== |
---|
90 | |
---|
91 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents |
---|
92 | |
---|
93 | echo |
---|
94 | IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
95 | IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
96 | |
---|
97 | NbComponents=${#config_ListOfComponents[*]} |
---|
98 | |
---|
99 | #================================== |
---|
100 | # Define principal executable |
---|
101 | |
---|
102 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Executable |
---|
103 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name |
---|
104 | |
---|
105 | #================================== |
---|
106 | # Define Outputs Name |
---|
107 | IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" |
---|
108 | eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} |
---|
109 | IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" |
---|
110 | #MM : obsolete ! |
---|
111 | # eval Exe_Output=out_${config_Executable_Name} |
---|
112 | eval Exe_Output=out_execution |
---|
113 | # IGCM_debug_Print 3 "Exe_Output = ${Exe_Output}" |
---|
114 | |
---|
115 | #================================== |
---|
116 | |
---|
117 | #===================================================================# |
---|
118 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
119 | # But available to any son functions # |
---|
120 | #===================================================================# |
---|
121 | |
---|
122 | # Convert yyyy-mm-dd date to gregorian yyyymmdd |
---|
123 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
124 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
125 | |
---|
126 | # Period Length In Days between DateBegin and DateEnd |
---|
127 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
128 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
129 | IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
130 | IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." |
---|
131 | IGCM_debug_Verif_Exit |
---|
132 | fi |
---|
133 | |
---|
134 | # Day and Year of Initial State (Given in julian format) |
---|
135 | InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) |
---|
136 | InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) |
---|
137 | |
---|
138 | #================================== |
---|
139 | # Restarts : Gerneral rule or local for each component ? |
---|
140 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts |
---|
141 | |
---|
142 | echo |
---|
143 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" |
---|
144 | |
---|
145 | for option in ${config_Restarts[*]} ; do |
---|
146 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} |
---|
147 | eval auxprint=\${config_Restarts_${option}} |
---|
148 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
149 | done |
---|
150 | |
---|
151 | #================================================================# |
---|
152 | # Test and Prepare directories # |
---|
153 | #================================================================# |
---|
154 | |
---|
155 | # ==> 4 kinds of input files : |
---|
156 | # 1) R_INIT : Initial State Files (Etat0, carteveg) |
---|
157 | # 2) R_BC : Boundary Conditions (Forcages, lai) |
---|
158 | # 3) Parameters files (allready define through ${SUBMIT_DIR}) |
---|
159 | # 4) Restarts files (allready define in IGCM_config_Initialize) |
---|
160 | |
---|
161 | # Here we offer the possibility to redefine R_INIT, R_BC |
---|
162 | # and PeriodNb through config.card |
---|
163 | R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} |
---|
164 | IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb" |
---|
165 | IGCM_debug_Print 3 "R_INIT=${R_INIT}" |
---|
166 | R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} |
---|
167 | IGCM_debug_Print 3 "R_BC=${R_BC}" |
---|
168 | PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}} |
---|
169 | IGCM_debug_Print 3 "Loop in main Job with ${PeriodNb} period(s)" |
---|
170 | |
---|
171 | # Test Archive input/output. |
---|
172 | IGCM_sys_TestDirArchive ${ARCHIVE} |
---|
173 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
174 | IGCM_sys_TestDirArchive ${R_IN} |
---|
175 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
176 | |
---|
177 | #==================================================== |
---|
178 | #R_SAVE : Job output directory |
---|
179 | if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then |
---|
180 | FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) |
---|
181 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
182 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
183 | else |
---|
184 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
185 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
186 | fi |
---|
187 | |
---|
188 | if ( ${FirstInitialize} ) ; then |
---|
189 | IGCM_sys_MkdirArchive ${R_SAVE} |
---|
190 | else |
---|
191 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
192 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
193 | #Test state of run in run.card |
---|
194 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
195 | |
---|
196 | if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
197 | echo |
---|
198 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
199 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
200 | IGCM_debug_Exit |
---|
201 | IGCM_debug_Verif_Exit |
---|
202 | fi |
---|
203 | fi |
---|
204 | |
---|
205 | #================================== |
---|
206 | # Post : |
---|
207 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post |
---|
208 | |
---|
209 | echo |
---|
210 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" |
---|
211 | |
---|
212 | for option in ${config_Post[*]} ; do |
---|
213 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} |
---|
214 | eval auxprint=\${config_Post_${option}} |
---|
215 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
216 | done |
---|
217 | |
---|
218 | #==================================================== |
---|
219 | # Define REBUILD_DIR : where we store files needing rebuild process |
---|
220 | if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then |
---|
221 | REBUILD_DIR=${R_SAVE}/TMP |
---|
222 | IGCM_sys_MkdirArchive ${REBUILD_DIR} |
---|
223 | else |
---|
224 | REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
225 | IGCM_sys_MkdirWork ${REBUILD_DIR} |
---|
226 | fi |
---|
227 | |
---|
228 | #==================================================== |
---|
229 | # Experience type : DEB(ug), DEV(elopment), RUN |
---|
230 | if [ X${JobType} != XRUN ] ; then |
---|
231 | echo |
---|
232 | echo "====================================================" |
---|
233 | echo "libIGCM JOB is NOT in RUN type mode." |
---|
234 | echo "!! OUTPUT files will NOT be PROTECTED !!" |
---|
235 | echo "Be carefull : you can ERASE the result of this job !" |
---|
236 | |
---|
237 | case ${JobType} in |
---|
238 | DEB) |
---|
239 | echo "DEBUG mode : activation of 'set -vx' mode." |
---|
240 | echo "DEBUG mode : no protection for output files." |
---|
241 | echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
242 | ;; |
---|
243 | DEV) |
---|
244 | echo "DEVelopment mode : no protection for output files." |
---|
245 | echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
246 | ;; |
---|
247 | esac |
---|
248 | |
---|
249 | if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then |
---|
250 | if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then |
---|
251 | echo "------------" |
---|
252 | echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" |
---|
253 | echo " to PeriodLength : ${config_UserChoices_PeriodLength}" |
---|
254 | echo "------------" |
---|
255 | config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} |
---|
256 | fi |
---|
257 | fi |
---|
258 | echo "====================================================" |
---|
259 | echo |
---|
260 | fi |
---|
261 | |
---|
262 | #==================================================== |
---|
263 | #R_OUT_KSH : Storage place for job output |
---|
264 | #R_OUT_EXE : Storage place for binary used during simulation |
---|
265 | R_OUT_KSH=${R_SAVE}/Out |
---|
266 | R_OUT_EXE=${R_SAVE}/Exe |
---|
267 | |
---|
268 | IGCM_debug_PopStack "IGCM_config_Initialize" |
---|
269 | } |
---|
270 | |
---|
271 | #=================================== |
---|
272 | function IGCM_config_Analyse_PeriodLength |
---|
273 | { |
---|
274 | IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" |
---|
275 | |
---|
276 | typeset i |
---|
277 | |
---|
278 | # Determine number of day(s) in PeriodLength : |
---|
279 | case ${config_UserChoices_PeriodLength} in |
---|
280 | *Y|*y) |
---|
281 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' ) |
---|
282 | IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" |
---|
283 | PeriodLengthInDays=0 |
---|
284 | i=0 |
---|
285 | until [ $i -ge $PeriodLengthInYears ] ; do |
---|
286 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) |
---|
287 | (( i=i+1 )) |
---|
288 | done |
---|
289 | ;; |
---|
290 | *M|*m) |
---|
291 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' ) |
---|
292 | IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" |
---|
293 | PeriodLengthInDays=0 |
---|
294 | i=0 |
---|
295 | until [ $i -ge $PeriodLengthInMonths ] ; do |
---|
296 | if [ $(( month + i )) -lt 13 ] ; then |
---|
297 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) |
---|
298 | else |
---|
299 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) |
---|
300 | fi |
---|
301 | (( i=i+1 )) |
---|
302 | done |
---|
303 | ;; |
---|
304 | *D|*d) |
---|
305 | PeriodLengthInMonths=0 |
---|
306 | PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; |
---|
307 | *) |
---|
308 | IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." |
---|
309 | IGCM_debug_Verif_Exit ;; |
---|
310 | esac |
---|
311 | |
---|
312 | IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" |
---|
313 | } |
---|
314 | |
---|
315 | #=================================== |
---|
316 | function IGCM_config_Check |
---|
317 | { |
---|
318 | IGCM_debug_PushStack "IGCM_config_Check" |
---|
319 | |
---|
320 | # If one of the following modulo is not zero : |
---|
321 | # we will issue an error then explain and exit in |
---|
322 | # AA_job IGCM_debug_Verif_Exit call before binary submission |
---|
323 | |
---|
324 | echo |
---|
325 | IGCM_debug_Print 1 "IGCM_config_Check" |
---|
326 | echo |
---|
327 | |
---|
328 | typeset i |
---|
329 | |
---|
330 | if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then |
---|
331 | AsynchronousRebuild=true |
---|
332 | IGCM_debug_Print 1 "Asynchronous rebuild has been activated." |
---|
333 | echo |
---|
334 | # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
335 | IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" |
---|
336 | IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength |
---|
337 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" |
---|
338 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency |
---|
339 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" |
---|
340 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency |
---|
341 | else |
---|
342 | AsynchronousRebuild=false |
---|
343 | IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" |
---|
344 | IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" |
---|
345 | echo |
---|
346 | #modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero |
---|
347 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" |
---|
348 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength |
---|
349 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" |
---|
350 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength |
---|
351 | fi |
---|
352 | |
---|
353 | #modulo (TimeSeriesFrequency and all Chunck2D) must be zero |
---|
354 | NbJob=${#CHUNCK2D_SIZE[@]} |
---|
355 | i=0 |
---|
356 | until [ $i -ge $NbJob ]; do |
---|
357 | value=${CHUNCK2D_SIZE[${i}]} |
---|
358 | IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" |
---|
359 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
360 | case ${value} in |
---|
361 | *Y|*y) ;; |
---|
362 | *) IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" |
---|
363 | IGCM_debug_Exit "This will stop the job" ;; |
---|
364 | esac |
---|
365 | (( i=i+1 )) |
---|
366 | done |
---|
367 | |
---|
368 | #modulo (TimeSeriesFrequency and all Chunck3D) must be zero |
---|
369 | NbJob=${#CHUNCK3D_SIZE[@]} |
---|
370 | i=0 |
---|
371 | until [ $i -ge $NbJob ]; do |
---|
372 | value=${CHUNCK3D_SIZE[${i}]} |
---|
373 | IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" |
---|
374 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
375 | case ${value} in |
---|
376 | *Y|*y) ;; |
---|
377 | *) IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" |
---|
378 | IGCM_debug_Exit "This will stop the job" ;; |
---|
379 | esac |
---|
380 | (( i=i+1 )) |
---|
381 | done |
---|
382 | |
---|
383 | IGCM_debug_PopStack "IGCM_config_Check" |
---|
384 | } |
---|
385 | |
---|
386 | #=================================== |
---|
387 | function IGCM_config_PeriodStart |
---|
388 | { |
---|
389 | IGCM_debug_PushStack "IGCM_config_PeriodStart" |
---|
390 | |
---|
391 | echo |
---|
392 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" |
---|
393 | echo |
---|
394 | |
---|
395 | if ( ${FirstInitialize} ) ; then |
---|
396 | #================================================# |
---|
397 | # Initialize date/period information # |
---|
398 | #================================================# |
---|
399 | |
---|
400 | IGCM_date_GetYearMonth $DateBegin year month |
---|
401 | year_m1=$(( year - 1 )) |
---|
402 | year_p1=$(( year + 1 )) |
---|
403 | IGCM_config_Analyse_PeriodLength |
---|
404 | |
---|
405 | eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 |
---|
406 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
407 | eval CumulPeriod=1 > /dev/null 2>&1 |
---|
408 | |
---|
409 | #=================================================# |
---|
410 | # Write updated run.card # |
---|
411 | #=================================================# |
---|
412 | |
---|
413 | #Correct run.card Configuration for this period |
---|
414 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
415 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
416 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
417 | if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then |
---|
418 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} |
---|
419 | fi |
---|
420 | |
---|
421 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
422 | |
---|
423 | else |
---|
424 | #================================================# |
---|
425 | # The file run.card allready exist # |
---|
426 | #================================================# |
---|
427 | |
---|
428 | #Test state of run in run.card |
---|
429 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
430 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
431 | echo |
---|
432 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
433 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
434 | echo |
---|
435 | IGCM_debug_Exit |
---|
436 | IGCM_debug_Verif_Exit |
---|
437 | fi |
---|
438 | |
---|
439 | #===================================# |
---|
440 | # Read updated run.card # |
---|
441 | #===================================# |
---|
442 | |
---|
443 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix |
---|
444 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
445 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
446 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
447 | |
---|
448 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
449 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
450 | eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 |
---|
451 | |
---|
452 | LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) |
---|
453 | |
---|
454 | typeset LastDate |
---|
455 | set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) |
---|
456 | LastYearDateEnd=${LastDate[0]} |
---|
457 | LastMonthDateEnd=${LastDate[1]} |
---|
458 | LastDayDateEnd=${LastDate[2]} |
---|
459 | |
---|
460 | if [ ${Period} = 1 ]; then |
---|
461 | # save last Job output |
---|
462 | typeset LastPeriod iLastPeriod Last_Script_Output_Name |
---|
463 | (( LastPeriod=CumulPeriod-PeriodNb )) |
---|
464 | iLastPeriod=$( printf "%06d" ${LastPeriod} ) |
---|
465 | Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" |
---|
466 | Last_run_card="run.card.${iLastPeriod}" |
---|
467 | #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} |
---|
468 | #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 |
---|
469 | IGCM_debug_Print 2 "Try to save previous ksh job output" |
---|
470 | IGCM_sys_Cd ${SUBMIT_DIR}/ |
---|
471 | IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name}.$$ rw |
---|
472 | |
---|
473 | IGCM_card_CheckConflict run.card |
---|
474 | IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/${Last_run_card}.$$ rw |
---|
475 | |
---|
476 | IGCM_sys_Cd ${RUN_DIR} |
---|
477 | else |
---|
478 | unset FileToBeDeleted |
---|
479 | fi |
---|
480 | |
---|
481 | IGCM_date_GetYearMonth $PeriodDateBegin year month |
---|
482 | year_m1=$(( year - 1 )) |
---|
483 | year_p1=$(( year + 1 )) |
---|
484 | IGCM_config_Analyse_PeriodLength |
---|
485 | |
---|
486 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
487 | |
---|
488 | fi |
---|
489 | OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} |
---|
490 | |
---|
491 | #===================================================================# |
---|
492 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
493 | # But available to any son functions # |
---|
494 | #===================================================================# |
---|
495 | |
---|
496 | # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) |
---|
497 | (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) |
---|
498 | |
---|
499 | # Debug Print : |
---|
500 | IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" |
---|
501 | IGCM_debug_Print 1 "Year of simulation : ${year}" |
---|
502 | IGCM_debug_Print 1 "Month of simulation : ${month}" |
---|
503 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
504 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
505 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
506 | IGCM_debug_Print 1 "SimulationLengthInDays : ${SimulationLengthInDays}" |
---|
507 | IGCM_debug_Print 1 "ExperienceLengthInDays : ${ExperienceLengthInDays}" |
---|
508 | |
---|
509 | #================================================================# |
---|
510 | # Prepare variables available for comp_finalyze # |
---|
511 | #================================================================# |
---|
512 | |
---|
513 | # Period for save files |
---|
514 | eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 |
---|
515 | |
---|
516 | # Prefix for save files of this period |
---|
517 | eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod} > /dev/null 2>&1 |
---|
518 | |
---|
519 | # List of files that will be deleted in RUN_DIR after run |
---|
520 | [ -f stack ] && FileToBeDeleted[0]="stack" |
---|
521 | |
---|
522 | # Test if the same run as already been saved : |
---|
523 | if [ X${JobType} = XRUN ] ; then |
---|
524 | if [ ${DRYRUN} -le 0 ] ; then |
---|
525 | if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
526 | IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." |
---|
527 | IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" |
---|
528 | IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " |
---|
529 | IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." |
---|
530 | IGCM_debug_Print 1 " This exit has been initiated because at least ${R_OUT_KSH}/${PREFIX}_${Exe_Output} exists." |
---|
531 | IGCM_debug_Verif_Exit |
---|
532 | fi |
---|
533 | fi |
---|
534 | else |
---|
535 | if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
536 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." |
---|
537 | fi |
---|
538 | fi |
---|
539 | |
---|
540 | typeset ExeNameIn |
---|
541 | typeset comp i |
---|
542 | typeset tempvar tempvarMPI tempvarNOD NbElts j |
---|
543 | |
---|
544 | (( PROCESSUS_NUMBER = 0 )) |
---|
545 | (( i=0 )) |
---|
546 | |
---|
547 | OK_PARA_MPI=false |
---|
548 | OK_PARA_OMP=false |
---|
549 | OK_PARA_NOD=false |
---|
550 | for comp in ${config_ListOfComponents[*]} ; do |
---|
551 | |
---|
552 | IGCM_debug_Print 1 ${comp} |
---|
553 | |
---|
554 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
555 | |
---|
556 | # NO order in config.card for parallelized values ! |
---|
557 | # just use suffix : MPI , OMP and NOD (for number of NODes.) |
---|
558 | |
---|
559 | # NOD is the number of NODes allocated |
---|
560 | eval ${comp}_PROC_NOD=0 |
---|
561 | |
---|
562 | # MPI is the number of MPI processus per nodes |
---|
563 | eval ${comp}_PROC_MPI=0 |
---|
564 | |
---|
565 | # OMP is the number of OpenMP threads per MPI processus |
---|
566 | eval ${comp}_PROC_OMP=0 |
---|
567 | |
---|
568 | # Only if we really have an executable for the component : |
---|
569 | if [ X${ExeNameIn} != X\"\" ] ; then |
---|
570 | eval NbElts=\${#config_Executable_${comp}[@]} |
---|
571 | if [ ${NbElts} -ge 2 ] ; then |
---|
572 | (( j = 2 )) |
---|
573 | eval ${comp}_PROC_MPI=1 |
---|
574 | eval ${comp}_PROC_OMP=1 |
---|
575 | eval ${comp}_PROC_NOD=1 |
---|
576 | |
---|
577 | while [ $j -lt ${NbElts} ] ; do |
---|
578 | eval tempvar=\${config_Executable_${comp}[${j}]} |
---|
579 | |
---|
580 | echo |
---|
581 | #MM BUG impossible ?! |
---|
582 | if [ X${tempvar} == X ] ; then |
---|
583 | echo "Error reading MPI/OMP parameters !!!" |
---|
584 | echo "Check your config.card." |
---|
585 | # MM : A enlever : |
---|
586 | exit 1 |
---|
587 | #break |
---|
588 | fi |
---|
589 | |
---|
590 | eval IGCM_debug_Print 2 ${tempvar} |
---|
591 | |
---|
592 | case ${tempvar} in |
---|
593 | *MPI) |
---|
594 | # Read MPI parameter for composante |
---|
595 | eval ${comp}_PROC_MPI=$( echo ${tempvar} | sed -e "s/MPI//" ) |
---|
596 | OK_PARA_MPI=true;; |
---|
597 | *OMP) |
---|
598 | # Read OMP parameter for composante |
---|
599 | eval ${comp}_PROC_OMP=$( echo ${tempvar} | sed -e "s/OMP//" ) |
---|
600 | OK_PARA_OMP=true;; |
---|
601 | *NOD) |
---|
602 | # Read NOD (NumBer of Nodes) parameter for composante |
---|
603 | eval ${comp}_PROC_NOD=$( echo ${tempvar} | sed -e "s/NOD//" ) |
---|
604 | OK_PARA_NOD=true |
---|
605 | OK_PARA_MPI=true;; |
---|
606 | esac |
---|
607 | |
---|
608 | (( j = j + 1 )) |
---|
609 | done |
---|
610 | |
---|
611 | eval tempvarMPI=\${${comp}_PROC_MPI} |
---|
612 | eval tempvarNOD=\${${comp}_PROC_NOD} |
---|
613 | eval tempvarOMP=\${${comp}_PROC_OMP} |
---|
614 | (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP )) |
---|
615 | fi |
---|
616 | fi |
---|
617 | |
---|
618 | (( i=i+1 )) |
---|
619 | done |
---|
620 | |
---|
621 | # sequential case ! |
---|
622 | if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then |
---|
623 | (( PROCESSUS_NUMBER = 1 )) |
---|
624 | echo "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)." |
---|
625 | echo "We set it to 1." |
---|
626 | fi |
---|
627 | |
---|
628 | IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}" |
---|
629 | |
---|
630 | # Verification with PBS parameter |
---|
631 | if [ X${BATCH_NUM_PROC_TOT} != X ] ; then |
---|
632 | if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then |
---|
633 | echo "Warning with parallelization parameters !" |
---|
634 | echo "PBS variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " |
---|
635 | echo " is the total number of _processors_ reserved." |
---|
636 | echo "It is not equal to the sum of _processus_ in config.card = ${PROCESSUS_NUMBER}." |
---|
637 | fi |
---|
638 | if ( ! ${OK_PARA_MPI} ) ; then |
---|
639 | if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then |
---|
640 | echo "You have given a reservation of ${BATCH_NUM_PROC_TOT} processors," |
---|
641 | echo "but you havn't filled the parallel parameter in config->Executable->list." |
---|
642 | echo "This is the old method and it is no more supported." |
---|
643 | echo "Please read documentation or config specific comments." |
---|
644 | echo "We stop now." |
---|
645 | exit 1 |
---|
646 | else |
---|
647 | PROCESSUS_NUMBER=1 |
---|
648 | fi |
---|
649 | fi |
---|
650 | else |
---|
651 | if ( ${OK_PARA_MPI} ) ; then |
---|
652 | echo "You have not given a value of ${BATCH_NUM_PROC_TOT} processors," |
---|
653 | echo "but you have filled the parallel parameter in config->Executable->list." |
---|
654 | echo "This is the old method and it is no more supported." |
---|
655 | echo "Please read documentation or config specific comments." |
---|
656 | echo "We stop now." |
---|
657 | exit 1 |
---|
658 | fi |
---|
659 | fi |
---|
660 | |
---|
661 | # if ( ${OK_PARA_MPI} || ${OK_PARA_OMP} || ${OK_PARA_NOD} ) ; then |
---|
662 | IGCM_sys_build_execution_scripts |
---|
663 | # fi |
---|
664 | |
---|
665 | ExecutionFail=false |
---|
666 | |
---|
667 | IGCM_debug_PopStack "IGCM_config_PeriodStart" |
---|
668 | } |
---|
669 | |
---|
670 | #=================================== |
---|
671 | function IGCM_config_PeriodEnd |
---|
672 | { |
---|
673 | IGCM_debug_PushStack "IGCM_config_PeriodEnd" |
---|
674 | |
---|
675 | echo |
---|
676 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd" |
---|
677 | echo |
---|
678 | |
---|
679 | #==================================# |
---|
680 | # Save Job output # |
---|
681 | #==================================# |
---|
682 | IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output} |
---|
683 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" |
---|
684 | |
---|
685 | IGCM_card_CheckConflict run.card |
---|
686 | IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card rw |
---|
687 | |
---|
688 | IGCM_debug_Print 1 "Check components binary : size and creation date" |
---|
689 | |
---|
690 | typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize |
---|
691 | typeset comp i |
---|
692 | typeset ExeNameIn ExeNameOut |
---|
693 | |
---|
694 | #==================================# |
---|
695 | # Get last Exe Size # |
---|
696 | #==================================# |
---|
697 | |
---|
698 | (( i=0 )) |
---|
699 | if ( ${FirstInitialize} ) ; then |
---|
700 | run_Log_LastExeSize="" |
---|
701 | for comp in ${config_ListOfComponents[*]} ; do |
---|
702 | run_Log_LastExeSize[$i]=0 |
---|
703 | (( i=i+1 )) |
---|
704 | done |
---|
705 | else |
---|
706 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize |
---|
707 | fi |
---|
708 | #==================================# |
---|
709 | # And Build ExeDate # |
---|
710 | #==================================# |
---|
711 | |
---|
712 | # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33 |
---|
713 | # Would be nice to have next line but no way to format ls output (need to ls -l --time-style "+%Y-%m-%dT%H:%M") |
---|
714 | # ExeDate = ATM_2009-06-12T09:34+SRF_2009-06-12T09:34+OCE_2009-06-12T09:34+ICE_2009-06-12T09:34+CPL_2009-06-12T09:34 |
---|
715 | ExeDate="" |
---|
716 | NextExeSize="( " |
---|
717 | (( i=0 )) |
---|
718 | |
---|
719 | for comp in ${config_ListOfComponents[*]} ; do |
---|
720 | |
---|
721 | IGCM_debug_Print 3 ${comp} |
---|
722 | |
---|
723 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
724 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
725 | # Only if we really have an executable for the component : |
---|
726 | if [ X${ExeNameIn} = X\"\" ] ; then |
---|
727 | # If there is no exe file for this component |
---|
728 | (( ExeSize=0 )) |
---|
729 | else |
---|
730 | eval LS_bin=${R_EXE}/${ExeNameIn} |
---|
731 | IGCM_sys_FileSize ${LS_bin} ExeSize |
---|
732 | |
---|
733 | set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) |
---|
734 | if [ X${ExeDate} = X ] ; then |
---|
735 | # First component exe date |
---|
736 | ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
737 | else |
---|
738 | ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
739 | fi |
---|
740 | ExeDate=${ExeDate}_${LS_comp[7]} |
---|
741 | fi |
---|
742 | |
---|
743 | if [ ${i} -eq 0 ] ; then |
---|
744 | # First component |
---|
745 | NextExeSize="( "${ExeSize} |
---|
746 | else |
---|
747 | NextExeSize=${NextExeSize}", "${ExeSize} |
---|
748 | fi |
---|
749 | eval LastCompExeSize=${run_Log_LastExeSize[$i]} |
---|
750 | (( i=i+1 )) |
---|
751 | |
---|
752 | if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then |
---|
753 | if ( ${FirstInitialize} ) ; then |
---|
754 | IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
755 | else |
---|
756 | IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" |
---|
757 | IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
758 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} |
---|
759 | fi |
---|
760 | eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw |
---|
761 | fi |
---|
762 | done |
---|
763 | |
---|
764 | NextExeSize=${NextExeSize}" )" |
---|
765 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" |
---|
766 | |
---|
767 | if [ ${DRYRUN} -le 1 ] ; then |
---|
768 | tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt |
---|
769 | ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt ) |
---|
770 | RET=$? |
---|
771 | if [ $RET -eq 0 ] ; then |
---|
772 | # ExeCpuLog variable contents 5 fields |
---|
773 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" | \ |
---|
774 | gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ |
---|
775 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card |
---|
776 | fi |
---|
777 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt" |
---|
778 | fi |
---|
779 | |
---|
780 | # All was right ? no ? then we stop. |
---|
781 | IGCM_debug_Verif_Exit |
---|
782 | |
---|
783 | # If all was OK, we can delete all files not necessary for next Job |
---|
784 | echo |
---|
785 | IGCM_debug_Print 1 "Files that will be deleted before next period-run : " |
---|
786 | |
---|
787 | if [ ${DRYRUN} -le 2 ] ; then |
---|
788 | for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done |
---|
789 | else |
---|
790 | echo ${FileToBeDeleted[@]} |
---|
791 | fi |
---|
792 | |
---|
793 | #=================================================# |
---|
794 | # Modification of libIGCM behaviour # |
---|
795 | #=================================================# |
---|
796 | |
---|
797 | # To use this function, one must copy libIGCM.card from ${libIGCM} directory |
---|
798 | # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, |
---|
799 | # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop. |
---|
800 | if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then |
---|
801 | echo |
---|
802 | echo "########################################################################" |
---|
803 | echo "!!! Modification of libIGCM behaviour !!!" |
---|
804 | echo |
---|
805 | |
---|
806 | IGCM_debug_Print 1 "DefineArrayFromOption : libIGCM_UserChanges in libIGCM.card" |
---|
807 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges |
---|
808 | IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} |
---|
809 | |
---|
810 | # Special treatments for libIGCM internals |
---|
811 | for option in ${libIGCM_UserChanges[*]} ; do |
---|
812 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} |
---|
813 | |
---|
814 | echo "We will change : ${option}." |
---|
815 | eval echo "Previous value : " \${${option}} |
---|
816 | eval echo "Change to : " \${libIGCM_UserChanges_${option}} |
---|
817 | |
---|
818 | eval ${option}=\${libIGCM_UserChanges_${option}} |
---|
819 | |
---|
820 | case ${option} in |
---|
821 | config_UserChoices_DateEnd) |
---|
822 | IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd |
---|
823 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
824 | |
---|
825 | # Period Length In Days between DateBegin and DateEnd |
---|
826 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
827 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
828 | IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
829 | IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." |
---|
830 | IGCM_debug_Verif_Exit |
---|
831 | fi |
---|
832 | ;; |
---|
833 | config_UserChoices_PeriodLength) |
---|
834 | IGCM_debug_Print 1 "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" |
---|
835 | ;; |
---|
836 | PeriodNb) |
---|
837 | IGCM_debug_Print 1 "Loop in main Job with ${PeriodNb} period(s)" |
---|
838 | ;; |
---|
839 | config_Post_RebuildFrequency) |
---|
840 | IGCM_debug_Print 1 "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" |
---|
841 | IGCM_post_Configure |
---|
842 | ;; |
---|
843 | config_Post_TimeSeriesFrequency) |
---|
844 | IGCM_debug_Print 1 "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" |
---|
845 | IGCM_post_Configure |
---|
846 | ;; |
---|
847 | config_Post_SeasonalFrequency) |
---|
848 | IGCM_debug_Print 1 "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" |
---|
849 | IGCM_post_Configure |
---|
850 | ;; |
---|
851 | esac |
---|
852 | done |
---|
853 | |
---|
854 | echo |
---|
855 | echo "########################################################################" |
---|
856 | echo |
---|
857 | fi |
---|
858 | |
---|
859 | #=================================================# |
---|
860 | # Determine next computed period # |
---|
861 | #=================================================# |
---|
862 | |
---|
863 | PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) |
---|
864 | IGCM_date_GetYearMonth $PeriodDateBegin year month |
---|
865 | year_m1=$(( year - 1 )) |
---|
866 | year_p1=$(( year + 1 )) |
---|
867 | IGCM_config_Analyse_PeriodLength |
---|
868 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
869 | |
---|
870 | # Debug Print : |
---|
871 | echo |
---|
872 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" |
---|
873 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
874 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
875 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
876 | |
---|
877 | PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) |
---|
878 | PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) |
---|
879 | |
---|
880 | (( CumulPeriod = CumulPeriod + 1 )) |
---|
881 | |
---|
882 | # Debug Print : |
---|
883 | echo |
---|
884 | IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" |
---|
885 | IGCM_debug_Print 3 "PeriodDateEnd Human : ${PeriodDateEnd}" |
---|
886 | IGCM_debug_Print 3 "CumulPeriod : ${CumulPeriod}" |
---|
887 | |
---|
888 | #=================================================# |
---|
889 | # Write updated run.card # |
---|
890 | #=================================================# |
---|
891 | |
---|
892 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} |
---|
893 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
894 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
895 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
896 | |
---|
897 | if ( ${FirstInitialize} ) ; then |
---|
898 | # It's no more the first time |
---|
899 | FirstInitialize=false |
---|
900 | fi |
---|
901 | |
---|
902 | IGCM_debug_PopStack "IGCM_config_PeriodEnd" |
---|
903 | } |
---|
904 | |
---|
905 | #=================================== |
---|
906 | function IGCM_config_Finalize |
---|
907 | { |
---|
908 | IGCM_debug_PushStack "IGCM_config_Finalize" |
---|
909 | |
---|
910 | echo |
---|
911 | IGCM_debug_Print 1 "IGCM_config_Finalize" |
---|
912 | echo |
---|
913 | |
---|
914 | if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then |
---|
915 | #==========================# |
---|
916 | # End of entire simulation # |
---|
917 | #==========================# |
---|
918 | |
---|
919 | # Mail notification |
---|
920 | IGCM_sys_SendMail |
---|
921 | |
---|
922 | # |
---|
923 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" |
---|
924 | IGCM_debug_Print 1 "Normal End of computation." |
---|
925 | if ( $DEBUG_debug ) ; then |
---|
926 | echo |
---|
927 | IGCM_debug_Print 1 "Your files on ${R_OUT} :" |
---|
928 | IGCM_sys_Tree ${R_SAVE} |
---|
929 | fi |
---|
930 | else |
---|
931 | #=================# |
---|
932 | # Submit next job # |
---|
933 | #=================# |
---|
934 | |
---|
935 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
936 | |
---|
937 | # Name of next Ksh Script output : |
---|
938 | eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" |
---|
939 | |
---|
940 | IGCM_debug_Print 1 "Submit next job" |
---|
941 | # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR |
---|
942 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
943 | # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} |
---|
944 | ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) |
---|
945 | [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) |
---|
946 | # Submit next job and come back |
---|
947 | IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} |
---|
948 | IGCM_sys_Cd - |
---|
949 | fi |
---|
950 | |
---|
951 | # Supress Non Deleted Boundary files |
---|
952 | if [ ${DRYRUN} -le 2 ] ; then |
---|
953 | IGCM_comp_DelFixeBoundaryFiles |
---|
954 | ls -la |
---|
955 | fi |
---|
956 | |
---|
957 | # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
958 | # Only for production run (No clean up in DEV or DEB mode) |
---|
959 | # and command sent from .. directory. |
---|
960 | IGCM_sys_Cd .. |
---|
961 | [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} |
---|
962 | |
---|
963 | IGCM_debug_PopStack "IGCM_config_Finalize" |
---|
964 | } |
---|
965 | |
---|
966 | #=================================== |
---|