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_CommonConfiguration |
---|
16 | { |
---|
17 | IGCM_debug_PushStack "IGCM_config_CommonConfiguration" $@ |
---|
18 | |
---|
19 | # Debug Print : |
---|
20 | [ ${Verbosity} -gt 0 ] && echo |
---|
21 | IGCM_debug_Print 1 "IGCM_config_CommonConfiguration" $@ |
---|
22 | |
---|
23 | # config.card path |
---|
24 | configCardPath=$1 |
---|
25 | |
---|
26 | #================================== |
---|
27 | typeset option auxprint |
---|
28 | |
---|
29 | #================================== |
---|
30 | # Read UserChoices section: |
---|
31 | [ ${Verbosity} -gt 0 ] && echo |
---|
32 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
33 | |
---|
34 | IGCM_card_DefineArrayFromSection ${configCardPath} UserChoices |
---|
35 | for option in ${config_UserChoices[*]} ; do |
---|
36 | IGCM_card_DefineVariableFromOption ${configCardPath} UserChoices ${option} |
---|
37 | eval auxprint=\${config_UserChoices_${option}} |
---|
38 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
39 | done |
---|
40 | |
---|
41 | # Set variables with shorter names on some variables which |
---|
42 | # are used in the executable name in config.card |
---|
43 | ResolAtm=${config_UserChoices_ResolAtm} |
---|
44 | ResolOce=${config_UserChoices_ResolOce} |
---|
45 | ConfChem=${config_UserChoices_ConfChem} |
---|
46 | OptMode=${config_UserChoices_OptMode} |
---|
47 | ConfigType=${config_UserChoices_ConfigType} |
---|
48 | |
---|
49 | #================================== |
---|
50 | # Read Ensemble section: |
---|
51 | [ ${Verbosity} -gt 0 ] && echo |
---|
52 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Ensemble" |
---|
53 | |
---|
54 | IGCM_card_DefineArrayFromSection ${configCardPath} Ensemble |
---|
55 | for option in ${config_Ensemble[*]} ; do |
---|
56 | IGCM_card_DefineVariableFromOption ${configCardPath} Ensemble ${option} |
---|
57 | eval auxprint=\${config_Ensemble_${option}} |
---|
58 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
59 | done |
---|
60 | |
---|
61 | #================================== |
---|
62 | # Read Post section: |
---|
63 | [ ${Verbosity} -gt 0 ] && echo |
---|
64 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" |
---|
65 | |
---|
66 | IGCM_card_DefineArrayFromSection ${configCardPath} Post |
---|
67 | for option in ${config_Post[*]} ; do |
---|
68 | IGCM_card_DefineVariableFromOption ${configCardPath} Post ${option} |
---|
69 | eval auxprint=\${config_Post_${option}} |
---|
70 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
71 | done |
---|
72 | [ ${Verbosity} -gt 0 ] && echo |
---|
73 | |
---|
74 | #================================== |
---|
75 | # Define default value to keep compatibility with previous card: means before changes due to TGCC |
---|
76 | # Apply some overrules to ensure proper usage of computing centres resources |
---|
77 | # |
---|
78 | |
---|
79 | # if RebuildFrequency is not define in config.card - we initilize it to NONE |
---|
80 | if [ X${config_Post_RebuildFrequency} = X ] ; then |
---|
81 | config_Post_RebuildFrequency=NONE |
---|
82 | fi |
---|
83 | |
---|
84 | if [ X${PackDefault} = Xtrue ] ; then |
---|
85 | if [ X${config_UserChoices_SpaceName} = XTEST ]; then |
---|
86 | # TEST simulations will not be packed and will stay on SCRATCHDIR filesystem |
---|
87 | IGCM_debug_Print 1 "SpaceName=TEST. OVERRULE PackFrequency to NONE" |
---|
88 | config_Post_PackFrequency=NONE |
---|
89 | else |
---|
90 | # Default to RebuildFrequency if nothing has been set up related to PackFrequency |
---|
91 | [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} |
---|
92 | fi |
---|
93 | else |
---|
94 | # If we DO NOT apply pack in this computing center |
---|
95 | config_Post_PackFrequency=NONE |
---|
96 | fi |
---|
97 | |
---|
98 | #==================================================== |
---|
99 | # Define ARCHIVE : Dedicated to large files |
---|
100 | # Define STORAGE : Dedicated to small/medium files |
---|
101 | # Define R_OUT : Output tree located on ARCHIVE |
---|
102 | # Define R_BUF : Output tree located on STORAGE (files waiting treatment, or file lcoation when SpaceName=!PROD) |
---|
103 | # Define R_FIG : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files) |
---|
104 | # Define R_TMP : A temporary space used by IGCM_debug_send_AMQP_msg__MAILTUNNEL. Must be persistent in between jobs |
---|
105 | IGCM_sys_defineArchives |
---|
106 | |
---|
107 | #==================================================== |
---|
108 | # R_SAVE : Job output directory |
---|
109 | # R_BUFR : Job output buffered directory |
---|
110 | # R_CMIP : Job output directory for CMIP6 standard files |
---|
111 | |
---|
112 | if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then |
---|
113 | FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) |
---|
114 | |
---|
115 | if ( [ X${config_Post_StorageCMIP} = XSCRATCH ] || [ X${config_Post_StorageCMIP} = Xscratch ] ) ; then |
---|
116 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: SCRATCH R_BUF=${R_BUF}" |
---|
117 | StoreCMIP=${R_BUF} |
---|
118 | elif ( [ X${config_Post_StorageCMIP} = XSTORE ] || [ X${config_Post_StorageCMIP} = Xstore ] ) ; then |
---|
119 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: SCRATCH R_OUT=${R_OUT}" |
---|
120 | StoreCMIP=${R_OUT} |
---|
121 | else |
---|
122 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: ELSE CMIP_BUF=${CMIP6_BUF}" |
---|
123 | StoreCMIP=${CMIP6_BUF} |
---|
124 | fi |
---|
125 | # Ensemble cases (default all members outputs in same directory) |
---|
126 | if ( [ ! X${config_Ensemble_EnsembleName} = X ] ) ; then |
---|
127 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName} |
---|
128 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName} |
---|
129 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName} |
---|
130 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName} |
---|
131 | R_CMIP=${StoreCMIP}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName} |
---|
132 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: ENSEMBLE R_CMIP=${R_CMIP}" |
---|
133 | |
---|
134 | # PERTURB Ensemble Outputs |
---|
135 | if ( [ X${config_Ensemble_EnsembleType} = XEns_PERTURB ] ) ; then |
---|
136 | if ( [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then |
---|
137 | R_SAVE=${R_SAVE}/${config_Ensemble_EnsembleDate}/${FreeName} |
---|
138 | R_FIGR=${R_FIGR}/${config_Ensemble_EnsembleDate}/${FreeName} |
---|
139 | R_BUFR=${R_BUFR}/${config_Ensemble_EnsembleDate}/${FreeName} |
---|
140 | R_DODS=${R_DODS}/${config_Ensemble_EnsembleDate}/${FreeName} |
---|
141 | R_CMIP=${R_CMIP}/${config_Ensemble_EnsembleDate}/${FreeName} |
---|
142 | else |
---|
143 | R_SAVE=${R_SAVE}/${FreeName} |
---|
144 | R_FIGR=${R_FIGR}/${FreeName} |
---|
145 | R_BUFR=${R_BUFR}/${FreeName} |
---|
146 | R_DODS=${R_DODS}/${FreeName} |
---|
147 | R_CMIP=${R_CMIP}/${FreeName} |
---|
148 | fi |
---|
149 | # DATE Ensemble Outputs |
---|
150 | elif ( [ X${config_Ensemble_EnsembleType} = XEns_DATE ] ) ; then |
---|
151 | R_FIGR=${R_FIGR}/${FreeName} |
---|
152 | R_BUFR=${R_BUFR}/${FreeName} |
---|
153 | R_DODS=${R_DODS}/${FreeName} |
---|
154 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: ENSEMBLE DATE R_CMIP=${R_CMIP}" |
---|
155 | if ( [ X${config_Ensemble_EnsembleMergeSave} = X ] || [ X${config_Ensemble_EnsembleMergeSave} = Xn ] || |
---|
156 | [ X${config_Ensemble_EnsembleMergeSave} = Xno ] ) ; then |
---|
157 | # One SAVE directory per member, else common output dir for all members |
---|
158 | R_SAVE=${R_SAVE}/${FreeName} |
---|
159 | R_CMIP=${R_CMIP}/${FreeName} |
---|
160 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: ENSEMBLE DATE MERGE R_CMIP=${R_CMIP}" |
---|
161 | fi |
---|
162 | fi |
---|
163 | else |
---|
164 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
165 | if [ ! X${TMPARCHIVE} = X ] ; then |
---|
166 | R_TMPSAVE=${R_TMPOUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
167 | fi |
---|
168 | if [ ! X${OLDARCHIVE} = X ] ; then |
---|
169 | R_OLDSAVE=${R_OLDOUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
170 | fi |
---|
171 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
172 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
173 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
174 | R_CMIP=${StoreCMIP}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
175 | fi |
---|
176 | else |
---|
177 | if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then |
---|
178 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName} |
---|
179 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName} |
---|
180 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName} |
---|
181 | R_DODS=${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName} |
---|
182 | else |
---|
183 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
184 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
185 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
186 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
187 | fi |
---|
188 | fi |
---|
189 | |
---|
190 | IGCM_debug_Print 1 "LIBIGCM CONFIG:: R_CMIP = ${R_CMIP}" |
---|
191 | |
---|
192 | #==================================================== |
---|
193 | # Define R_OUT_KSH : Storage place for job output |
---|
194 | # Define R_OUT_EXE : Storage place for binary used during simulation |
---|
195 | if [ ! X${TMPARCHIVE} = X ] ; then |
---|
196 | R_OUT_KSH=${R_TMPSAVE}/Out |
---|
197 | R_OUT_EXE=${R_TMPSAVE}/Exe |
---|
198 | else |
---|
199 | R_OUT_KSH=${R_SAVE}/Out |
---|
200 | R_OUT_EXE=${R_SAVE}/Exe |
---|
201 | fi |
---|
202 | |
---|
203 | #==================================================== |
---|
204 | # Define R_BUF_KSH : Buffer place for job output |
---|
205 | # Define R_BUF_EXE : Buffer place for binary used during simulation |
---|
206 | R_BUF_KSH=${R_BUFR}/Out |
---|
207 | R_BUF_EXE=${R_BUFR}/Exe |
---|
208 | |
---|
209 | #==================================================== |
---|
210 | # Define REBUILD_DIR : where we store files needing rebuild process |
---|
211 | REBUILD_DIR=${R_BUFR}/REBUILD |
---|
212 | if [ ! X${TaskType} = Xchecking ] ; then |
---|
213 | IGCM_sys_MkdirWork ${REBUILD_DIR} |
---|
214 | fi |
---|
215 | |
---|
216 | #==================================================== |
---|
217 | # DodsCopy : apply default value if not defined |
---|
218 | if ( [ X${config_Post_DodsCopy} = X${NULL_STR} ] || [ X${config_Post_DodsCopy} = X ] ) ; then |
---|
219 | config_Post_DodsCopy=TRUE |
---|
220 | fi |
---|
221 | |
---|
222 | #==================================================== |
---|
223 | # AtlasIPSL : apply default value if not defined |
---|
224 | if ( [ X${config_Post_AtlasIPSL} = X${NULL_STR} ] || [ X${config_Post_AtlasIPSL} = X ] ) ; then |
---|
225 | config_Post_AtlasIPSL=FALSE |
---|
226 | fi |
---|
227 | |
---|
228 | #==================================================== |
---|
229 | # ParserXIOS : apply default value if not defined |
---|
230 | if ( [ X${config_Post_ParserXIOS} = X${NULL_STR} ] || [ X${config_Post_ParserXIOS} = X ] ) ; then |
---|
231 | config_Post_ParserXIOS=FALSE |
---|
232 | fi |
---|
233 | |
---|
234 | #==================================================== |
---|
235 | # MetricsPCMDI : apply default value if not defined |
---|
236 | if ( [ X${config_Post_MetricsPCMDI} = X${NULL_STR} ] || [ X${config_Post_MetricsPCMDI} = X ] ) ; then |
---|
237 | config_Post_MetricsPCMDI=FALSE |
---|
238 | fi |
---|
239 | #==================================================== |
---|
240 | # Cesmep : apply default value FALSE if not defined, and if TRUE |
---|
241 | # or *Y set it based on an adhoc algorithm |
---|
242 | if ( [ X${config_Post_Cesmep} = X${NULL_STR} ] || [ X${config_Post_Cesmep} = XNONE ] || \ |
---|
243 | [ X${config_Post_Cesmep} = X ] || [ X${config_Post_Cesmep} = XFALSE ] ) ; then |
---|
244 | config_Post_Cesmep=FALSE |
---|
245 | elif [ X${config_Post_Cesmep} = XTRUE ] ; then |
---|
246 | if ([ ! X${config_Post_SeasonalFrequency} = XNONE ] && [ ! X${config_Post_SeasonalFrequency} = X ] ) ; then |
---|
247 | config_Post_Cesmep="SE" |
---|
248 | elif ([ ! X${config_Post_TimeSeriesFrequency} = XNONE ] && [ ! X${config_Post_TimeSeriesFrequency} = X ] ) ; then |
---|
249 | config_Post_Cesmep="TS" |
---|
250 | elif ([ ! X${config_Post_PackFrequency} = XNONE ] && [ ! X${config_Post_PackFrequency} = X ] ) ; then |
---|
251 | config_Post_Cesmep="Pack" |
---|
252 | else |
---|
253 | # This covers case SpaceName=TEST with no SE nor TS (nor Pack) |
---|
254 | config_Post_Cesmep=AtEnd |
---|
255 | fi |
---|
256 | fi |
---|
257 | # |
---|
258 | if [ X${config_Post_Cesmep} != XFALSE ] ; then |
---|
259 | if ( [ X${config_Post_CesmepPeriod} != X${NULL_STR} ] && [ X${config_Post_CesmepPeriod} != X ] ) ; then |
---|
260 | CesmepPeriod=${config_Post_CesmepPeriod%Y} |
---|
261 | if [ $config_Post_CesmepPeriod = 12M ] ; then |
---|
262 | CesmepPeriod=1 |
---|
263 | fi |
---|
264 | fi |
---|
265 | if [ X${config_Post_Cesmep} = XSE ] ; then |
---|
266 | if ([ X${config_Post_SeasonalFrequency} = XNONE ] || [ X${config_Post_SeasonalFrequency} = X ] ) ; then |
---|
267 | IGCM_debug_Exit "Cannot use SE for Cesmep : SE post-processing is not active" |
---|
268 | else |
---|
269 | [ -z $CesmepPeriod ] && CesmepPeriod=${config_Post_SeasonalFrequency%Y} |
---|
270 | fi |
---|
271 | elif [ X${config_Post_Cesmep} = XTS ] ; then |
---|
272 | if ([ X${config_Post_TimeSeriesFrequency} = XNONE ] || [ X${config_Post_TimeSeriesFrequency} = X ] ) ; then |
---|
273 | IGCM_debug_Exit "Cannot use TS for Cesmep : TS post-processing is not active" |
---|
274 | else |
---|
275 | [ -z $CesmepPeriod ] && CesmepPeriod=${config_Post_TimeSeriesFrequency%Y} |
---|
276 | fi |
---|
277 | elif [ X${config_Post_Cesmep} = XPack ] ; then |
---|
278 | if ([ X${config_Post_PackFrequency} = XNONE ] || [ X${config_Post_PackFrequency} = X ] ) ; then |
---|
279 | IGCM_debug_Exit "Cannot use Packed output for Cesmep : Pack post-processing is not active" |
---|
280 | else |
---|
281 | [ -z $CesmepPeriod ] && CesmepPeriod=${config_Post_PackFrequency%Y} |
---|
282 | fi |
---|
283 | elif [ X${config_Post_Cesmep} != XAtEnd ] ; then |
---|
284 | IGCM_debug_Exit "config.card's Post section's value for Cesmep (${config_Post_Cesmep}) is invalid; use SE, TS, Pack, AtEnd or TRUE" |
---|
285 | else |
---|
286 | [ -z $CesmepPeriod ] && CesmepPeriod=0 |
---|
287 | fi |
---|
288 | |
---|
289 | if ( [ X${config_Post_CesmepComparison} = XNONE ] || [ X${config_Post_CesmepComparison} = X ] ) ; then |
---|
290 | config_Post_CesmepComparison=run_comparison |
---|
291 | fi |
---|
292 | |
---|
293 | if ( [ X${config_Post_CesmepCode} = XNONE ] || [ X${config_Post_CesmepCode} = X ] ) ; then |
---|
294 | if ( [ X"${SYSTEM}" == "Xirene" ] || [ X"${SYSTEM}" == "Xirene-amd" ] ); then |
---|
295 | config_Post_CesmepCode=/ccc/cont003/home/igcmg/igcmg/Tools/cesmep |
---|
296 | elif ( [ X"${SYSTEM}" == "Xjeanzay" ] ); then |
---|
297 | config_Post_CesmepCode=/gpfswork/rech/psl/commun/Tools/cesmep |
---|
298 | elif ( [ X"${SYSTEM}" == "Xmesoipsl" ] ); then |
---|
299 | config_Post_CesmepCode=/net/nfs/tools/Users/SU/jservon/cesmep_installs/cesmep_for_libIGCM |
---|
300 | else |
---|
301 | IGCM_debug_Exit "Cannot locate a default C-ESM-EP code on $SYSTEM, please set CesmepCode in section Post" |
---|
302 | fi |
---|
303 | fi |
---|
304 | |
---|
305 | if ( [ X${config_Post_CesmepSlices} = XNONE ] || [ X${config_Post_CesmepSlices} = X ] ) ; then |
---|
306 | config_Post_CesmepSlices=8 |
---|
307 | fi |
---|
308 | if ( [ X${config_Post_CesmepSlicesDuration} != X${NULL_STR} ] && [ X${config_Post_CesmepSlicesDuration} != X ] &&\ |
---|
309 | [ X${config_Post_CesmepSlicesDuration} != XNONE ] ) ; then |
---|
310 | CesmepSlicesDuration=${config_Post_CesmepSlicesDuration%Y} |
---|
311 | else |
---|
312 | CesmepSlicesDuration=$CesmepPeriod |
---|
313 | fi |
---|
314 | if [ $CesmepSlicesDuration -gt $CesmepPeriod ]; then |
---|
315 | IGCM_debug_Exit "C-ESM-EP : you cannot set a CesmepSlicesDuration ($CesmepSlicesDuration) longer than CesmepPeriod ($CesmepPeriod)" |
---|
316 | fi |
---|
317 | if [ X${config_Post_CesmepReferences} = X${NULL_STR} ] || [ X${config_Post_CesmepReferences} = XNONE ] || \ |
---|
318 | [ X${config_Post_CesmepReferences} = X ] ; then |
---|
319 | config_Post_CesmepReferences=NONE |
---|
320 | fi |
---|
321 | if [ X${config_Post_CesmepInputFrequency} = X${NULL_STR} ] || [ X${config_Post_CesmepInputFrequency} = XNONE ] || \ |
---|
322 | [ X${config_Post_CesmepInputFrequency} = X ] ; then |
---|
323 | config_Post_CesmepInputFrequency=monthly |
---|
324 | fi |
---|
325 | fi |
---|
326 | #==================================================== |
---|
327 | # IgnoreNonMonotonic : apply default value if not defined |
---|
328 | if ( [ X${config_Post_IgnoreNonMonotonic} = X${NULL_STR} ] || [ X${config_Post_IgnoreNonMonotonic} = X ] ) ; then |
---|
329 | config_Post_IgnoreNonMonotonic=FALSE |
---|
330 | fi |
---|
331 | |
---|
332 | #==================================================== |
---|
333 | # LightRestartPack : apply default value if not defined |
---|
334 | if ( [ X${config_Post_LightRestartPack} = X${NULL_STR} ] || [ X${config_Post_LightRestartPack} = X ] ) ; then |
---|
335 | config_Post_LightRestartPack=FALSE |
---|
336 | fi |
---|
337 | |
---|
338 | #==================================================== |
---|
339 | # dr2xmlIPSL : apply default value if not defined |
---|
340 | if ( [ X${config_Post_dr2xmlIPSL} = X${NULL_STR} ] || [ X${config_Post_dr2xmlIPSL} = X ] ) ; then |
---|
341 | config_Post_dr2xmlIPSL=FALSE |
---|
342 | fi |
---|
343 | |
---|
344 | |
---|
345 | #==================================================== |
---|
346 | # Define StackFileLocation : directory where we store stack files |
---|
347 | # Define StackFileName : stack file containing call tree and instrumentation |
---|
348 | # Stack file containing call tree will be stored there. |
---|
349 | if ( $DEBUG_debug ) ; then |
---|
350 | StackFileLocation=${StackFileLocation:=${R_BUF_KSH}} |
---|
351 | [ ! -d ${StackFileLocation} ] && mkdir -p ${StackFileLocation} |
---|
352 | if [ X${TaskType} = Xcomputing ]; then |
---|
353 | StackFileName=computing.stack.$$ |
---|
354 | elif [ X${TaskType} = Xpost-processing ]; then |
---|
355 | StackFileName=${Script_Post_Output}.stack.$$ |
---|
356 | elif [ X${TaskType} = Xchecking ]; then |
---|
357 | StackFileName=checking.stack.$$ |
---|
358 | else |
---|
359 | IGCM_debug_Exit "IGCM_config_CommonConfiguration unknown TaskType : ${TaskType}" |
---|
360 | IGCM_debug_Verif_Exit |
---|
361 | fi |
---|
362 | |
---|
363 | # This boolean will trigger the filling of the stack |
---|
364 | # Only now we know where things should be ... |
---|
365 | # We don't fill the stack when we perform checking task |
---|
366 | if [ ! X${TaskType} = Xchecking ] ; then |
---|
367 | ActivateStackFilling=true |
---|
368 | fi |
---|
369 | fi |
---|
370 | |
---|
371 | IGCM_debug_PopStack "IGCM_config_CommonConfiguration" |
---|
372 | } |
---|
373 | |
---|
374 | #=================================== |
---|
375 | function IGCM_config_Initialize |
---|
376 | { |
---|
377 | IGCM_debug_PushStack "IGCM_config_Initialize" |
---|
378 | |
---|
379 | # Debug Print : |
---|
380 | echo |
---|
381 | IGCM_debug_Print 1 "IGCM_config_Initialize" |
---|
382 | |
---|
383 | # Test modipsl tree existence. |
---|
384 | IGCM_sys_TestDir ${MODIPSL} |
---|
385 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
386 | IGCM_sys_TestDir ${libIGCM} |
---|
387 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
388 | IGCM_sys_TestDir ${R_EXE} |
---|
389 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
390 | IGCM_sys_TestDir ${SUBMIT_DIR} |
---|
391 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
392 | |
---|
393 | if ( $DEBUG_debug ) ; then |
---|
394 | echo "Keep trace of inital SUBMIT_DIR : " |
---|
395 | ls -lta ${SUBMIT_DIR} |
---|
396 | fi |
---|
397 | |
---|
398 | #================================== |
---|
399 | # Read ListOfComponents section: |
---|
400 | echo |
---|
401 | IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
402 | |
---|
403 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents |
---|
404 | for comp in ${config_ListOfComponents[*]} ; do |
---|
405 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} |
---|
406 | done |
---|
407 | IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
408 | |
---|
409 | #================================== |
---|
410 | # Read Executable section: |
---|
411 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Executable |
---|
412 | |
---|
413 | #================================== |
---|
414 | # Read Restarts section: |
---|
415 | # Restarts : Gerneral rule or local for each component. |
---|
416 | echo |
---|
417 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" |
---|
418 | |
---|
419 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts |
---|
420 | for option in ${config_Restarts[*]} ; do |
---|
421 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} |
---|
422 | eval auxprint=\${config_Restarts_${option}} |
---|
423 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
424 | done |
---|
425 | |
---|
426 | #================================== |
---|
427 | # Define Job Outputs Name |
---|
428 | echo |
---|
429 | IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" |
---|
430 | Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} |
---|
431 | IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" |
---|
432 | Exe_Output=out_execution |
---|
433 | IGCM_debug_Print 3 "Exe_Output = ${Exe_Output}" |
---|
434 | |
---|
435 | #===================================================================# |
---|
436 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
437 | # But available to any son functions # |
---|
438 | #===================================================================# |
---|
439 | |
---|
440 | # Convert yyyy-mm-dd date to gregorian yyyymmdd |
---|
441 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
442 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
443 | EndYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateEnd ) / 1000 )) |
---|
444 | EndYear_p1=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateEnd ) / 1000 + 1 )) |
---|
445 | |
---|
446 | # Check month and day good format |
---|
447 | IGCM_date_GetYearMonthDay $DateBegin date_begin_year date_begin_month date_begin_day |
---|
448 | IGCM_date_GetYearMonthDay $DateEnd date_end_year date_end_month date_end_day |
---|
449 | if [ ${date_begin_month} -gt 12 ] || [ ${date_begin_day} -gt 31 ] || [ ${date_end_month} -gt 12 ] || [ ${date_end_day} -gt 31 ] ; then |
---|
450 | IGCM_debug_Print 1 "Problem with dates in config.card: DateBegin (${DateBegin}) or DateEnd (${DateEnd}) hasve wrong format |
---|
451 | (must be yyymmdd). You must check that." |
---|
452 | IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." |
---|
453 | IGCM_debug_Verif_Exit |
---|
454 | fi |
---|
455 | |
---|
456 | # Period Length In Days between DateBegin and DateEnd |
---|
457 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
458 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
459 | IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
460 | IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." |
---|
461 | IGCM_debug_Verif_Exit |
---|
462 | fi |
---|
463 | |
---|
464 | # Day and Year of Initial State (Given in julian format) |
---|
465 | InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) |
---|
466 | InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) |
---|
467 | InitYear_m1=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 - 1 )) |
---|
468 | |
---|
469 | #================================================================# |
---|
470 | # Test and Prepare directories # |
---|
471 | #================================================================# |
---|
472 | |
---|
473 | # ==> 4 kinds of input files : |
---|
474 | # 1) R_INIT : Initial State Files (Etat0, carteveg) |
---|
475 | # 2) R_BC : Boundary Conditions (Forcages, lai) |
---|
476 | # 3) Parameters files (allready define through ${SUBMIT_DIR}) |
---|
477 | # 4) Restarts files (allready define in IGCM_config_Initialize) |
---|
478 | |
---|
479 | # Here we offer the possibility to redefine R_INIT, R_BC |
---|
480 | # and NbPeriodsPerJob through config.card |
---|
481 | R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} |
---|
482 | echo |
---|
483 | IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and NbPeriodsPerJob" |
---|
484 | IGCM_debug_Print 3 "R_IN=${R_IN}" |
---|
485 | IGCM_debug_Print 3 "R_INIT=${R_INIT}" |
---|
486 | R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} |
---|
487 | IGCM_debug_Print 3 "R_BC=${R_BC}" |
---|
488 | NbPeriodsPerJob=${config_UserChoices_NbPeriodsPerJob:=${NbPeriodsPerJob}} |
---|
489 | IGCM_debug_Print 3 "Loop in main Job with ${NbPeriodsPerJob} period(s)" |
---|
490 | |
---|
491 | # SD ADA SPECIFIC # |
---|
492 | # TO FIX # |
---|
493 | #IGCM_sys_TestDirArchive ${R_IN} |
---|
494 | #[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
495 | |
---|
496 | if ( ${FirstInitialize} ) ; then |
---|
497 | if [ ! X${TMPARCHIVE} = X ] ; then |
---|
498 | IGCM_sys_MkdirArchive ${R_TMPSAVE} |
---|
499 | else |
---|
500 | IGCM_sys_MkdirArchive ${R_SAVE} |
---|
501 | fi |
---|
502 | [ ! ${config_Post_PackFrequency} = NONE ] && IGCM_sys_Mkdir ${R_BUFR} |
---|
503 | else |
---|
504 | if [ ! X${TMPARCHIVE} = X ] ; then |
---|
505 | IGCM_sys_TestDirArchive ${R_TMPSAVE} |
---|
506 | else |
---|
507 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
508 | fi |
---|
509 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}" |
---|
510 | |
---|
511 | if [ ! ${config_Post_PackFrequency} = NONE ] ; then |
---|
512 | IGCM_sys_TestDir ${R_BUFR} |
---|
513 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}" |
---|
514 | fi |
---|
515 | |
---|
516 | # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal" |
---|
517 | IGCM_config_StateCheck |
---|
518 | |
---|
519 | # And EXIT if not OK |
---|
520 | IGCM_debug_Verif_Exit |
---|
521 | fi |
---|
522 | |
---|
523 | #==================================================== |
---|
524 | # Experience type : DEB(ug), DEV(elopment), RUN |
---|
525 | if [ X${JobType} != XRUN ] ; then |
---|
526 | echo |
---|
527 | echo "====================================================" |
---|
528 | echo "libIGCM JOB is NOT in RUN type mode." |
---|
529 | echo "!! OUTPUT files will NOT be PROTECTED !!" |
---|
530 | echo "Be carefull : you can ERASE the result of this job !" |
---|
531 | |
---|
532 | case ${JobType} in |
---|
533 | DEB) |
---|
534 | echo "DEBUG mode : activation of 'set -vx' mode." |
---|
535 | echo "DEBUG mode : no protection for output files." |
---|
536 | echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
537 | ;; |
---|
538 | DEV) |
---|
539 | echo "DEVelopment mode : no protection for output files." |
---|
540 | echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
541 | ;; |
---|
542 | esac |
---|
543 | |
---|
544 | if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then |
---|
545 | if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then |
---|
546 | echo "------------" |
---|
547 | echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" |
---|
548 | echo " to PeriodLength : ${config_UserChoices_PeriodLength}" |
---|
549 | echo "------------" |
---|
550 | config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} |
---|
551 | fi |
---|
552 | fi |
---|
553 | echo "====================================================" |
---|
554 | echo |
---|
555 | fi |
---|
556 | |
---|
557 | IGCM_debug_PopStack "IGCM_config_Initialize" |
---|
558 | } |
---|
559 | |
---|
560 | #=================================== |
---|
561 | function IGCM_config_DaysInPeriodLength |
---|
562 | { |
---|
563 | IGCM_debug_PushStack "IGCM_config_DaysInPeriodLength" |
---|
564 | |
---|
565 | typeset i |
---|
566 | |
---|
567 | # Determine number of day(s) in PeriodLength : |
---|
568 | case ${config_UserChoices_PeriodLength} in |
---|
569 | *Y|*y) |
---|
570 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' ) |
---|
571 | echo |
---|
572 | IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" |
---|
573 | PeriodLengthInDays=0 |
---|
574 | i=0 |
---|
575 | until [ $i -ge $PeriodLengthInYears ] ; do |
---|
576 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) |
---|
577 | (( i=i+1 )) |
---|
578 | done |
---|
579 | ;; |
---|
580 | *M|*m) |
---|
581 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' ) |
---|
582 | echo |
---|
583 | IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" |
---|
584 | PeriodLengthInDays=0 |
---|
585 | i=0 |
---|
586 | until [ $i -ge $PeriodLengthInMonths ] ; do |
---|
587 | if [ $(( 10#${month} + ${i} )) -lt 13 ] ; then |
---|
588 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( 10#${month} + ${i} )) ) )) |
---|
589 | else |
---|
590 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( 10#${month} + ${i} - 12 )) ) )) |
---|
591 | fi |
---|
592 | (( i=i+1 )) |
---|
593 | done |
---|
594 | ;; |
---|
595 | *D|*d) |
---|
596 | PeriodLengthInMonths=0 |
---|
597 | PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' ) |
---|
598 | echo |
---|
599 | IGCM_debug_Print 2 "Number of days for PeriodLength : ${PeriodLengthInDays}";; |
---|
600 | *) |
---|
601 | IGCM_debug_Exit "IGCM_config_DaysInPeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." |
---|
602 | IGCM_debug_Verif_Exit ;; |
---|
603 | esac |
---|
604 | |
---|
605 | IGCM_debug_PopStack "IGCM_config_DaysInPeriodLength" |
---|
606 | } |
---|
607 | |
---|
608 | #=================================== |
---|
609 | function IGCM_config_DateCoherency |
---|
610 | { |
---|
611 | IGCM_debug_PushStack "IGCM_config_DateCoherency" |
---|
612 | |
---|
613 | echo |
---|
614 | IGCM_debug_Print 1 "IGCM_config_DateCoherency" |
---|
615 | echo |
---|
616 | |
---|
617 | typeset Length VerifiedPeriodDateBegin VerifiedPeriodDateEnd |
---|
618 | |
---|
619 | # check coherency between (PeriodDateBegin, PeriodDateEnd) and (DateBegin, CumulPeriod, PeriodLength) |
---|
620 | # DateBegin + CumulPeriod*PeriodLength = PeriodDateBegin |
---|
621 | echo |
---|
622 | |
---|
623 | case ${config_UserChoices_PeriodLength} in |
---|
624 | *Y|*y) |
---|
625 | Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInYears} ))Y ) |
---|
626 | ;; |
---|
627 | *M|*m) |
---|
628 | Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInMonths} ))M ) |
---|
629 | ;; |
---|
630 | *D|*d) |
---|
631 | Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInDays} ))D ) |
---|
632 | ;; |
---|
633 | esac |
---|
634 | VerifiedPeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Length}-1 ) |
---|
635 | |
---|
636 | if [ ${VerifiedPeriodDateEnd} != ${PeriodDateEnd} ] ; then |
---|
637 | IGCM_debug_Print 1 "From run.card PeriodDateEnd is not consistent with DateBegin and CumulPeriod." |
---|
638 | IGCM_debug_Print 1 "We have DateBegin = ${DateBegin}" |
---|
639 | IGCM_debug_Print 1 "We have CumulPeriod = ${CumulPeriod}" |
---|
640 | IGCM_debug_Print 1 "We have PeriodDateEnd = ${PeriodDateEnd}" |
---|
641 | IGCM_debug_Print 1 "We have VerifiedPeriodDateEnd = ${VerifiedPeriodDateEnd}" |
---|
642 | IGCM_debug_Print 1 "You must have change run.card in an inconsistent way." |
---|
643 | |
---|
644 | IGCM_debug_Exit "STOP here to avoid further issues." |
---|
645 | fi |
---|
646 | |
---|
647 | # PeriodDateBegin + PeriodLength = PeriodDateEnd |
---|
648 | VerifiedPeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${VerifiedPeriodDateEnd} $(( ${PeriodLengthInDays} * -1 )) ) |
---|
649 | |
---|
650 | IGCM_debug_PopStack "IGCM_config_DateCoherency" |
---|
651 | } |
---|
652 | |
---|
653 | #=================================== |
---|
654 | function IGCM_config_StateCheck |
---|
655 | { |
---|
656 | IGCM_debug_PushStack "IGCM_config_StateCheck" |
---|
657 | |
---|
658 | #Test state of run in run.card |
---|
659 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
660 | |
---|
661 | if [ ${run_Configuration_PeriodState} = "Fatal" ] ; then |
---|
662 | echo |
---|
663 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
664 | IGCM_debug_Print 1 "Check the overall status of your simulation by visiting this page:" |
---|
665 | IGCM_debug_Print 1 "https://hermes.ipsl.upmc.fr/static/simulation.detail.html?uid=${simuid}" |
---|
666 | IGCM_debug_Print 1 "Then try running ${libIGCM}/clean_PeriodLenght.job to clean latest failed period" |
---|
667 | IGCM_debug_Print 1 "Or try running ${libIGCM}/clean_latestPackperiod.job to clean lastest pack period." |
---|
668 | IGCM_debug_Print 1 "Or use ${libIGCM}/purge_simulation.job to delete the full simulation." |
---|
669 | IGCM_debug_Exit |
---|
670 | elif [ $( echo ${run_Configuration_PeriodState} | grep Fatal | wc -l ) -eq 1 ] ; then |
---|
671 | echo |
---|
672 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
673 | IGCM_debug_Print 1 "Compute jobs has been stop because at least the above mentionned post-processing jobs fails." |
---|
674 | IGCM_debug_Print 1 "Check post-processing jobs carefully by visiting this page:" |
---|
675 | IGCM_debug_Print 1 "https://hermes.ipsl.upmc.fr/static/simulation.detail.html?uid=${simuid}" |
---|
676 | IGCM_debug_Print 1 "Please visit that page to see how to fix issues:" |
---|
677 | IGCM_debug_Print 1 "https://forge.ipsl.jussieu.fr/igcmg_doc/wiki/DocGmonitor" |
---|
678 | IGCM_debug_Print 1 "Then try running ${libIGCM}/clean_PeriodLenght.job to clean latest failed period" |
---|
679 | IGCM_debug_Print 1 "Or try running ${libIGCM}/clean_latestPackperiod.job to clean latest pack period." |
---|
680 | IGCM_debug_Print 1 "Or use ${libIGCM}/purge_simulation.job to delete the full simulation." |
---|
681 | IGCM_debug_Exit |
---|
682 | fi |
---|
683 | |
---|
684 | IGCM_debug_PopStack "IGCM_config_StateCheck" |
---|
685 | } |
---|
686 | |
---|
687 | #=================================== |
---|
688 | function IGCM_config_Check |
---|
689 | { |
---|
690 | IGCM_debug_PushStack "IGCM_config_Check" |
---|
691 | |
---|
692 | # If one of the following modulo is not zero : |
---|
693 | # we will issue an error then explain and exit in |
---|
694 | # AA_job IGCM_debug_Verif_Exit call before binary submission |
---|
695 | |
---|
696 | echo |
---|
697 | IGCM_debug_Print 1 "IGCM_config_Check" |
---|
698 | echo |
---|
699 | |
---|
700 | typeset i |
---|
701 | |
---|
702 | # Check RebuildFrequency against key frequencies : PeriodLength ; PackFrequency ; TimeSeriesFrequency ; SeasonalFrequency |
---|
703 | if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then |
---|
704 | AsynchronousRebuild=true |
---|
705 | IGCM_debug_Print 1 "Asynchronous rebuild has been activated." |
---|
706 | echo |
---|
707 | # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
708 | IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" |
---|
709 | IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength |
---|
710 | IGCM_debug_Print 1 "Check coherence between PackFrequency and RebuildFrequency" |
---|
711 | IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_Post_RebuildFrequency |
---|
712 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" |
---|
713 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency |
---|
714 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" |
---|
715 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency |
---|
716 | else |
---|
717 | AsynchronousRebuild=false |
---|
718 | IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" |
---|
719 | IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" |
---|
720 | echo |
---|
721 | #modulo (PeriodLength and TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
722 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" |
---|
723 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength |
---|
724 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" |
---|
725 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength |
---|
726 | fi |
---|
727 | |
---|
728 | # Check PackFrequency against other key frequencies |
---|
729 | # Modulo (PackFrequency and TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero |
---|
730 | if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then |
---|
731 | Pack=true |
---|
732 | # |
---|
733 | IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength" |
---|
734 | IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_UserChoices_PeriodLength |
---|
735 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PackFrequency" |
---|
736 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_PackFrequency |
---|
737 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PackFrequency" |
---|
738 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_PackFrequency |
---|
739 | else |
---|
740 | Pack=false |
---|
741 | if ( [ X${MASTER} = Xjeanzay ] && [ X${TaskType} = Xcomputing ] ) ; then |
---|
742 | if [ ! X${config_UserChoices_SpaceName} = XTEST ]; then |
---|
743 | IGCM_debug_Exit "ERROR On JeanZay it is not possible to run without Pack" |
---|
744 | IGCM_debug_Verif_Exit |
---|
745 | fi |
---|
746 | fi |
---|
747 | |
---|
748 | fi |
---|
749 | # Loop over components |
---|
750 | for comp in ${config_ListOfComponents[*]} ; do |
---|
751 | |
---|
752 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} |
---|
753 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
754 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
755 | IGCM_card_DefineArrayFromOption ${card} OutputFiles List |
---|
756 | ListFilesName=${compname}_OutputFiles_List |
---|
757 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
758 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
759 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
760 | |
---|
761 | (( i=0 )) |
---|
762 | until [ $i -ge $NbFiles ]; do |
---|
763 | (( i_ = i+3 )) |
---|
764 | eval Testvar_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
765 | eval Testvar=${Testvar_} |
---|
766 | if [[ ${Testvar} =~ [0-9][DMY]$ ]] ; then |
---|
767 | IGCM_debug_Print 1 "Check coherence between PackFrequency and specific pack frequencies" |
---|
768 | DaysTemp1=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${Testvar} ) |
---|
769 | DaysTemp2=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${config_Post_PackFrequency} ) |
---|
770 | if [ ${DaysTemp2} -lt ${DaysTemp1} ] ; then |
---|
771 | IGCM_debug_Print 1 "PackFrequency in config.card is smaller than the specific pack frequency" |
---|
772 | IGCM_debug_Print 1 "we found in ${compname}.card" |
---|
773 | IGCM_debug_Exit "ERROR You have to modify the PackFrequency in config.card to be always greater or equal to specific pack frequencies defined in comp.card" |
---|
774 | IGCM_debug_Verif_Exit |
---|
775 | fi |
---|
776 | ((i = i+4)) |
---|
777 | else |
---|
778 | ((i = i+3)) |
---|
779 | fi |
---|
780 | done |
---|
781 | fi |
---|
782 | done |
---|
783 | |
---|
784 | # modulo (TimeSeriesFrequency and all Chunck2D) must be zero |
---|
785 | NbJob=${#CHUNCK2D_SIZE[@]} |
---|
786 | i=0 |
---|
787 | until [ $i -ge $NbJob ]; do |
---|
788 | value=${CHUNCK2D_SIZE[${i}]} |
---|
789 | IGCM_debug_Print 1 "Check coherence between ${CHUNCK2D_NAME[${i}]} Chunck2D frequency and TimeSeriesFrequency" |
---|
790 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
791 | case ${value} in |
---|
792 | *Y|*y) ;; |
---|
793 | *) |
---|
794 | IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" |
---|
795 | IGCM_debug_Exit "This will stop the job" ;; |
---|
796 | esac |
---|
797 | (( i=i+1 )) |
---|
798 | done |
---|
799 | |
---|
800 | # modulo (TimeSeriesFrequency and all Chunck3D) must be zero |
---|
801 | NbJob=${#CHUNCK3D_SIZE[@]} |
---|
802 | i=0 |
---|
803 | until [ $i -ge $NbJob ]; do |
---|
804 | value=${CHUNCK3D_SIZE[${i}]} |
---|
805 | IGCM_debug_Print 1 "Check coherence between ${CHUNCK3D_NAME[${i}]} Chunck3D frequency and TimeSeriesFrequency" |
---|
806 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
807 | case ${value} in |
---|
808 | *Y|*y) ;; |
---|
809 | *) |
---|
810 | IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" |
---|
811 | IGCM_debug_Exit "This will stop the job" ;; |
---|
812 | esac |
---|
813 | (( i=i+1 )) |
---|
814 | done |
---|
815 | |
---|
816 | # check to be sure there is enough space on temporary filesystems to run |
---|
817 | echo |
---|
818 | IGCM_debug_Print 1 "Check if there is enough space on temporary filesystem" |
---|
819 | IGCM_sys_check_quota |
---|
820 | |
---|
821 | # check to be sure that RUN_DIR_PATH, that will be removed is not pointing to an important directory |
---|
822 | echo |
---|
823 | IGCM_debug_Print 1 "Check where RUN_DIR_PATH variable is pointing to" |
---|
824 | IGCM_sys_check_path |
---|
825 | |
---|
826 | |
---|
827 | IGCM_debug_PopStack "IGCM_config_Check" |
---|
828 | } |
---|
829 | |
---|
830 | #=================================== |
---|
831 | function IGCM_config_ConfigureExecution |
---|
832 | { |
---|
833 | IGCM_debug_PushStack " IGCM_config_ConfigureExecution" |
---|
834 | |
---|
835 | #echo |
---|
836 | IGCM_debug_Print 1 " IGCM_config_ConfigureExecution" |
---|
837 | #echo |
---|
838 | |
---|
839 | typeset ExeNameIn ExeNameFirst CompNameFirst configCardPath comp i |
---|
840 | typeset tempvar tempvarMPI tempvarNOD NbElts NbExec |
---|
841 | |
---|
842 | # config.card path |
---|
843 | configCardPath=$1 |
---|
844 | |
---|
845 | coreNumber=0 |
---|
846 | mpiTasks=0 |
---|
847 | openMPthreads=0 |
---|
848 | NbExec=0 |
---|
849 | |
---|
850 | OK_PARA_MPI=false |
---|
851 | OK_PARA_OMP=false |
---|
852 | OK_PARA_NOD=false |
---|
853 | OK_PARA_MPMD=false |
---|
854 | |
---|
855 | for comp in ${config_ListOfComponents[*]} ; do |
---|
856 | |
---|
857 | # Manage component executable |
---|
858 | IGCM_card_DefineArrayFromOption ${configCardPath} Executable ${comp} |
---|
859 | |
---|
860 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
861 | |
---|
862 | # NO order in config.card for parallelized values ! |
---|
863 | # just use suffix : MPI , OMP and NOD (for number of NODes.) |
---|
864 | |
---|
865 | # NOD is the number of NODes allocated |
---|
866 | eval ${comp}_PROC_NOD=0 |
---|
867 | |
---|
868 | # MPI is the number of MPI processus per nodes |
---|
869 | eval ${comp}_PROC_MPI=0 |
---|
870 | |
---|
871 | # OMP is the number of OpenMP threads per MPI processus |
---|
872 | eval ${comp}_PROC_OMP=0 |
---|
873 | |
---|
874 | # DEP is the factor to increase the number of cores per process |
---|
875 | eval ${comp}_PROC_DEP=0 |
---|
876 | |
---|
877 | # DEDICATED is the flag to activate the use of dedicated node for XIOS server only |
---|
878 | eval ${comp}_OK_DEDICATED=0 |
---|
879 | |
---|
880 | # Only if we really have an executable for the component : |
---|
881 | if ( [ "X${ExeNameIn}" != X\"\" ] && [ "X${ExeNameIn}" != "Xinca.dat" ] ) ; then |
---|
882 | |
---|
883 | IGCM_debug_Print 1 ${comp} |
---|
884 | |
---|
885 | # Keep the first executable found and the first CompName |
---|
886 | eval ExeNameFirst=${ExeNameIn} |
---|
887 | CompNameFirst=${comp} |
---|
888 | |
---|
889 | # Are we a second executable? |
---|
890 | (( NbExec = NbExec + 1 )) |
---|
891 | |
---|
892 | # set 1 MPI task, 1 OpenMP thread and 1 node as default |
---|
893 | eval ${comp}_PROC_MPI=1 |
---|
894 | eval ${comp}_PROC_OMP=1 |
---|
895 | eval ${comp}_PROC_NOD=1 |
---|
896 | eval ${comp}_PROC_DEP=1 |
---|
897 | |
---|
898 | eval NbElts=\${#config_Executable_${comp}[@]} |
---|
899 | if [ ${NbElts} -gt 2 ] ; then |
---|
900 | # |
---|
901 | # CURRENT METHOD TO SPECIFY MPI AND OMP RESSOURCES |
---|
902 | # |
---|
903 | i=2 |
---|
904 | while [ ${i} -lt ${NbElts} ] ; do |
---|
905 | eval tempvar=\${config_Executable_${comp}[${i}]} |
---|
906 | IGCM_debug_Print 2 ${tempvar} |
---|
907 | |
---|
908 | if [ X${tempvar} = X ] ; then |
---|
909 | IGCM_debug_Print 2 "Error reading MPI/OMP parameters !!!" |
---|
910 | IGCM_debug_Exit "Check your config.card. Exit now" |
---|
911 | IGCM_debug_Verif_Exit |
---|
912 | fi |
---|
913 | |
---|
914 | case ${tempvar} in |
---|
915 | *[mM][pP][iI]*) |
---|
916 | # Read MPI parameter for composante |
---|
917 | eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" ) |
---|
918 | OK_PARA_MPI=true;; |
---|
919 | *[oO][mM][pP]*) |
---|
920 | # Read OMP parameter for composante |
---|
921 | eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" ) |
---|
922 | ;; |
---|
923 | *[nN][oO][dD]*) |
---|
924 | # Read NOD (NumBer of Nodes) parameter for composante |
---|
925 | eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" ) |
---|
926 | OK_PARA_NOD=true |
---|
927 | OK_PARA_MPI=true |
---|
928 | ;; |
---|
929 | *[dD][eE][pP]*) |
---|
930 | # Read DEP parameter for composante |
---|
931 | eval ${comp}_PROC_DEP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/DEP//" ) |
---|
932 | ;; |
---|
933 | *[dD][eE][dD][iI][cC][aA][tT][eE][dD]*) |
---|
934 | # Read DEDICATED parameter for composante |
---|
935 | eval ${comp}_OK_DEDICATED=1 |
---|
936 | esac |
---|
937 | (( i = i + 1 )) |
---|
938 | done |
---|
939 | else |
---|
940 | # |
---|
941 | # BACKWARD COMPATIBILITY NOT SUPPORTED ANYMORE |
---|
942 | # |
---|
943 | IGCM_debug_Exit "You are using a deprecated ressources specification mechanism in your config.card" |
---|
944 | IGCM_debug_Exit "Please check : https://forge.ipsl.jussieu.fr/igcmg_doc/wiki/DocEsetup#ThesectionExecutable" |
---|
945 | IGCM_debug_Exit "Please modify ${configCardPath}" |
---|
946 | exit |
---|
947 | fi |
---|
948 | if [ ${comp}_PROC_NOD -gt 1 ] ; then |
---|
949 | if ( [ ${comp}_PROC_MPI -gt 1 ] && [ ${comp}_PROC_OMP -gt 1 ] ) ; then |
---|
950 | IGCM_debug_Print 2 "Error using MPI/OMP/NOD parameters !!!" |
---|
951 | IGCM_debug_Exit "It is not allowed to use MPI and OMP and NOD parameters for the same component" |
---|
952 | IGCM_debug_Exit "Check your config.card. Exit now" |
---|
953 | IGCM_debug_Verif_Exit |
---|
954 | fi |
---|
955 | if [ "${comp}" != "IOS" ] ; then |
---|
956 | IGCM_debug_Print 2 "Error using NOD parameter !!!" |
---|
957 | IGCM_debug_Exit "NOD parameter is only available for IOS component " |
---|
958 | IGCM_debug_Exit "Check your config.card. Exit now" |
---|
959 | IGCM_debug_Verif_Exit |
---|
960 | fi |
---|
961 | fi |
---|
962 | if ( [ ${comp}_OK_DEDICATED -eq 1 ] && [ "${comp}" != "IOS" ] ) ; then |
---|
963 | IGCM_debug_Print 2 "Error using DEDICATED parameter !!!" |
---|
964 | IGCM_debug_Exit "DEDICATED parameter is only available for IOS component " |
---|
965 | IGCM_debug_Exit "Check your config.card. Exit now" |
---|
966 | IGCM_debug_Verif_Exit |
---|
967 | fi |
---|
968 | |
---|
969 | eval tempvarMPI=\${${comp}_PROC_MPI} |
---|
970 | eval tempvarNOD=\${${comp}_PROC_NOD} |
---|
971 | eval tempvarOMP=\${${comp}_PROC_OMP} |
---|
972 | eval tempvarDEP=\${${comp}_PROC_DEP} |
---|
973 | |
---|
974 | # set OMP mode if more than 1 OMP thread. |
---|
975 | [ ${tempvarOMP} -ge 2 ] && OK_PARA_OMP=true |
---|
976 | |
---|
977 | # Number of OMP threads |
---|
978 | [ ${openMPthreads} -lt ${tempvarOMP} ] && openMPthreads=${tempvarOMP} |
---|
979 | |
---|
980 | # SUM UP NUMBER OF CORES |
---|
981 | if [ ${comp}_PROC_NOD -gt 1 ] ; then |
---|
982 | (( coreNumber = coreNumber + tempvarNOD * NB_CORE_PER_NODE )) |
---|
983 | else |
---|
984 | (( coreNumber = coreNumber + tempvarMPI * tempvarNOD * tempvarOMP * tempvarDEP )) |
---|
985 | fi |
---|
986 | # SUM UP NUMBER OF MPI TASKS |
---|
987 | (( mpiTasks = mpiTasks + tempvarMPI * tempvarNOD )) |
---|
988 | fi |
---|
989 | done |
---|
990 | |
---|
991 | # MANDATORY FOR THE OPA9.DRIVER. USED TO EDIT OPA NAMELIST |
---|
992 | # WE SHOULD PLANIFY NUM_PROC_??? DEPRECATION |
---|
993 | NUM_PROC_CPL=${CPL_PROC_MPI} |
---|
994 | NUM_PROC_OCE=${OCE_PROC_MPI} |
---|
995 | NUM_PROC_ATM=${ATM_PROC_MPI} |
---|
996 | |
---|
997 | # set MPMD mode if more than 2 executable names. |
---|
998 | [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true |
---|
999 | |
---|
1000 | # Define the execution type we are running in |
---|
1001 | if ( ${OK_PARA_MPMD} ) ; then |
---|
1002 | if ( ${OK_PARA_MPI} ) ; then |
---|
1003 | # MPMD always implies MPI |
---|
1004 | executionType=1 |
---|
1005 | fi |
---|
1006 | if ( ${OK_PARA_OMP} ) ; then |
---|
1007 | # MPMD + MPI/OMP |
---|
1008 | executionType=2 |
---|
1009 | fi |
---|
1010 | else |
---|
1011 | if ( ( ${OK_PARA_MPI} ) && ( ${OK_PARA_OMP} ) ) ; then |
---|
1012 | # SPMD + MPI/OMP |
---|
1013 | executionType=3 |
---|
1014 | elif ( ( ${OK_PARA_MPI} ) && ( ! ${OK_PARA_OMP} ) ) ; then |
---|
1015 | # SPMD + MPI only |
---|
1016 | executionType=4 |
---|
1017 | elif ( ( ! ${OK_PARA_MPI} ) && ( ${OK_PARA_OMP} ) ) ; then |
---|
1018 | # SPMD + OMP only |
---|
1019 | executionType=5 |
---|
1020 | elif ( ( ! ${OK_PARA_MPI} ) && ( ! ${OK_PARA_OMP} ) ) ; then |
---|
1021 | # SEQUENTIAL THEN |
---|
1022 | executionType=6 |
---|
1023 | coreNumber=1 |
---|
1024 | fi |
---|
1025 | fi |
---|
1026 | |
---|
1027 | IGCM_debug_Print 1 "MPI/OMP treatment coreNumber = ${coreNumber}" |
---|
1028 | IGCM_debug_Print 1 "MPI/OMP treatment mpiTasks = ${mpiTasks}" |
---|
1029 | IGCM_debug_Print 1 "MPI/OMP treatment openMPthreads = ${openMPthreads}" |
---|
1030 | IGCM_debug_Print 1 "MPI/OMP treatment executionType = ${executionType}" |
---|
1031 | |
---|
1032 | IGCM_debug_PopStack "IGCM_config_ConfigureExecution" |
---|
1033 | } |
---|
1034 | |
---|
1035 | #=================================== |
---|
1036 | function IGCM_config_PeriodStart |
---|
1037 | { |
---|
1038 | IGCM_debug_PushStack "IGCM_config_PeriodStart" |
---|
1039 | |
---|
1040 | echo |
---|
1041 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" |
---|
1042 | echo |
---|
1043 | |
---|
1044 | if ( ${FirstInitialize} ) ; then |
---|
1045 | #================================================# |
---|
1046 | # Initialize date/period information # |
---|
1047 | #================================================# |
---|
1048 | |
---|
1049 | IGCM_date_GetYearMonthDay ${DateBegin} year month day |
---|
1050 | IGCM_config_DaysInPeriodLength |
---|
1051 | |
---|
1052 | PeriodDateBegin=${DateBegin} |
---|
1053 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
1054 | CumulPeriod=1 |
---|
1055 | |
---|
1056 | #=================================================# |
---|
1057 | # Write updated run.card # |
---|
1058 | #=================================================# |
---|
1059 | |
---|
1060 | #Correct run.card Configuration for this period |
---|
1061 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
1062 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
1063 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
1064 | if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then |
---|
1065 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} |
---|
1066 | fi |
---|
1067 | |
---|
1068 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
1069 | |
---|
1070 | else |
---|
1071 | #================================================# |
---|
1072 | # The file run.card allready exist # |
---|
1073 | #================================================# |
---|
1074 | |
---|
1075 | # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal" |
---|
1076 | IGCM_config_StateCheck |
---|
1077 | # And EXIT if not OK |
---|
1078 | IGCM_debug_Verif_Exit |
---|
1079 | |
---|
1080 | #===================================# |
---|
1081 | # Read updated run.card # |
---|
1082 | #===================================# |
---|
1083 | |
---|
1084 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
1085 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
1086 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
1087 | |
---|
1088 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
1089 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
1090 | CumulPeriod=${run_Configuration_CumulPeriod} |
---|
1091 | |
---|
1092 | LastPeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate $( IGCM_date_ConvertFormatToGregorian ${PeriodDateBegin} ) -1 ) |
---|
1093 | |
---|
1094 | if [ ${Period} = 1 ]; then |
---|
1095 | # save last Job output and current run.card |
---|
1096 | typeset Potential |
---|
1097 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
1098 | # |
---|
1099 | IGCM_debug_Print 2 "Save previous ksh job output" |
---|
1100 | for Potential in $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.[0-9][0-9][0-9][0-9][0-9][0-9] ) ; do |
---|
1101 | if [ X${Pack} = Xtrue ] ; then |
---|
1102 | ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${Potential} ) || IGCM_sys_Cp ${Potential} ${R_BUF_KSH}/${Potential}.$$ |
---|
1103 | else |
---|
1104 | ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${Potential} ) || IGCM_sys_Put_Out ${Potential} ${R_OUT_KSH}/${Potential}.$$ NOMOVE |
---|
1105 | IGCM_debug_Print 1 "Save of previous ksh job output is not done for Pack=false" |
---|
1106 | fi |
---|
1107 | done |
---|
1108 | |
---|
1109 | # |
---|
1110 | IGCM_debug_Print 2 "Save current run.card" |
---|
1111 | IGCM_card_CheckConflict run.card |
---|
1112 | |
---|
1113 | if [ X${Pack} = Xtrue ] ; then |
---|
1114 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card |
---|
1115 | else |
---|
1116 | IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card NOMOVE |
---|
1117 | IGCM_debug_Print 1 "Save of run.card is not done for Pack=false" |
---|
1118 | fi |
---|
1119 | # |
---|
1120 | IGCM_sys_Cd ${RUN_DIR} |
---|
1121 | else |
---|
1122 | unset FileToBeDeleted |
---|
1123 | fi |
---|
1124 | |
---|
1125 | # Determine number of day(s) in PeriodLength |
---|
1126 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
1127 | IGCM_config_DaysInPeriodLength |
---|
1128 | |
---|
1129 | # Check coherency between (PeriodDateBegin, PeriodDateEnd) and (DateBegin, CumulPeriod, PeriodLength) |
---|
1130 | IGCM_config_DateCoherency |
---|
1131 | # And EXIT if not OK |
---|
1132 | IGCM_debug_Verif_Exit |
---|
1133 | |
---|
1134 | # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal" |
---|
1135 | IGCM_config_StateCheck |
---|
1136 | # And EXIT if not OK |
---|
1137 | IGCM_debug_Verif_Exit |
---|
1138 | |
---|
1139 | # We can say we are "Running" now. |
---|
1140 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
1141 | fi |
---|
1142 | |
---|
1143 | # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
1144 | # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) |
---|
1145 | year_m1=$(( year - 1 )) |
---|
1146 | year_p1=$(( year + 1 )) |
---|
1147 | # Compute month_m1 (month minus 1M) |
---|
1148 | # Compute yyyymm_m1 (yyyymm minus 1M) |
---|
1149 | month_m1=$(( 10#${month} - 1 )) |
---|
1150 | if [ ${month_m1} = 0 ]; then |
---|
1151 | month_m1=12 |
---|
1152 | yyyymm_m1=${year_m1}12 |
---|
1153 | elif [ ${month_m1} -le 9 ]; then |
---|
1154 | month_m1=0${month_m1} |
---|
1155 | yyyymm_m1=${year}${month_m1} |
---|
1156 | else |
---|
1157 | yyyymm_m1=${year}${month_m1} |
---|
1158 | fi |
---|
1159 | # Compute month_p1 (month plus 1M) |
---|
1160 | # Compute yyyymm_p1 (yyyymm plus 1M) |
---|
1161 | month_p1=$(( 10#${month} + 1 )) |
---|
1162 | if [ ${month_p1} = 13 ]; then |
---|
1163 | month_p1=01 |
---|
1164 | yyyymm_p1=${year_p1}01 |
---|
1165 | elif [ ${month_p1} -le 9 ]; then |
---|
1166 | month_p1=0${month_p1} |
---|
1167 | yyyymm_p1=${year}${month_p1} |
---|
1168 | else |
---|
1169 | yyyymm_p1=${year}${month_p1} |
---|
1170 | fi |
---|
1171 | |
---|
1172 | |
---|
1173 | #===================================================================# |
---|
1174 | # Calculate CyclicYear to be used for looping over a given forcing # |
---|
1175 | # period. Add CyclicBegin and CyclicEnd in config.card UserChoices. # |
---|
1176 | #===================================================================# |
---|
1177 | |
---|
1178 | # To use the variable CyclicYear, one must add in config.card CyclicBegin and CyclicEnd. |
---|
1179 | # CyclicBegin is the first year in the cycle. CyclicEnd is the last year included in the cycle. |
---|
1180 | if ( [ ! X${config_UserChoices_CyclicBegin} = X ] && [ ! X${config_UserChoices_CyclicEnd} = X ] ) ; then |
---|
1181 | CycleNb=$(( ${config_UserChoices_CyclicEnd} - ${config_UserChoices_CyclicBegin} + 1 )) |
---|
1182 | #CyclicYear_p1= #NOTDEFINED |
---|
1183 | |
---|
1184 | # For current year |
---|
1185 | yeartmp=$year |
---|
1186 | diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} )) |
---|
1187 | while [ $diffy -lt 0 ] ; do |
---|
1188 | yeartmp=$(( ${yeartmp} + ${CycleNb} )) |
---|
1189 | diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} )) |
---|
1190 | done |
---|
1191 | CyclicYear=$(( ( ${diffy} % ${CycleNb} ) + ${config_UserChoices_CyclicBegin} )) |
---|
1192 | |
---|
1193 | # For next coming year |
---|
1194 | CyclicYear_p1=$(( CyclicYear + 1 )) |
---|
1195 | |
---|
1196 | # For previous year |
---|
1197 | CyclicYear_m1=$(( CyclicYear - 1 )) |
---|
1198 | |
---|
1199 | IGCM_debug_Print 1 "CyclicYear = ${CyclicYear}, current year=$year" |
---|
1200 | IGCM_debug_Print 1 "CyclicYear_p1 = ${CyclicYear_p1}, CyclicYear_m1 = ${CyclicYear_m1} " |
---|
1201 | else |
---|
1202 | CyclicYear="ERROR_CyclicYear_Variable_Not_Defined" |
---|
1203 | CyclicYear_p1="ERROR_CyclicYear_p1_Variable_Not_Defined" |
---|
1204 | IGCM_debug_Print 1 "CyclicYear wont be use without adding CyclicBegin and CyclicEnd in config.card" |
---|
1205 | fi |
---|
1206 | |
---|
1207 | # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
1208 | |
---|
1209 | #===================================================================# |
---|
1210 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
1211 | # But available to any son functions # |
---|
1212 | #===================================================================# |
---|
1213 | |
---|
1214 | # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) |
---|
1215 | (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) |
---|
1216 | |
---|
1217 | # Debug Print : |
---|
1218 | echo |
---|
1219 | IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" |
---|
1220 | IGCM_debug_Print 1 "Year of simulation : ${year}" |
---|
1221 | IGCM_debug_Print 1 "Month of simulation : ${month}" |
---|
1222 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
1223 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
1224 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
1225 | IGCM_debug_Print 1 "SimulationLengthInDays : ${SimulationLengthInDays}" |
---|
1226 | IGCM_debug_Print 1 "ExperienceLengthInDays : ${ExperienceLengthInDays}" |
---|
1227 | |
---|
1228 | #================================================================# |
---|
1229 | # Prepare variables available for comp_finalyze # |
---|
1230 | #================================================================# |
---|
1231 | |
---|
1232 | # Period for save files |
---|
1233 | DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} |
---|
1234 | |
---|
1235 | # Prefix for save files of this period |
---|
1236 | PREFIX=${config_UserChoices_JobName}_${DatesPeriod} |
---|
1237 | |
---|
1238 | # List of files that will be deleted in RUN_DIR after run |
---|
1239 | [ -f stack ] && FileToBeDeleted[0]="stack" |
---|
1240 | |
---|
1241 | # Test if the same run as already been saved : |
---|
1242 | if [ X${JobType} = XRUN ] ; then |
---|
1243 | if [ ${DRYRUN} -le 0 ] ; then |
---|
1244 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
1245 | IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently re-running an old job." |
---|
1246 | IGCM_debug_Print 1 "Because of readonly permissions, you can't re-run a job when saved files" |
---|
1247 | IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " |
---|
1248 | IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See different clean_*.job in ${libIGCM} directory." |
---|
1249 | IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists." |
---|
1250 | IGCM_debug_Verif_Exit |
---|
1251 | fi |
---|
1252 | fi |
---|
1253 | else |
---|
1254 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
1255 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." |
---|
1256 | fi |
---|
1257 | fi |
---|
1258 | |
---|
1259 | #================================================================# |
---|
1260 | # Prepare variables available for binary execution # |
---|
1261 | # Call function for creation of run script # |
---|
1262 | # Only done once per job # |
---|
1263 | #================================================================# |
---|
1264 | |
---|
1265 | if [ ${Period} -eq 1 ]; then |
---|
1266 | # Define the execution context (MPMD, SPMD, MPI/OMP ...) |
---|
1267 | IGCM_config_ConfigureExecution ${SUBMIT_DIR}/config.card |
---|
1268 | # Create the execution script for the current context |
---|
1269 | IGCM_sys_build_execution_scripts |
---|
1270 | fi |
---|
1271 | |
---|
1272 | ExecutionFail=false |
---|
1273 | |
---|
1274 | # Update the rabbitMQ queue |
---|
1275 | IGCM_debug_BigBro_Update |
---|
1276 | |
---|
1277 | IGCM_debug_PopStack "IGCM_config_PeriodStart" |
---|
1278 | } |
---|
1279 | |
---|
1280 | #=================================== |
---|
1281 | function IGCM_config_SaveSourceModifications |
---|
1282 | { |
---|
1283 | IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" |
---|
1284 | |
---|
1285 | typeset ExeOutDateMax listVarEnv |
---|
1286 | ExeOutDateMax=$1 |
---|
1287 | |
---|
1288 | listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" |
---|
1289 | IGCM_sys_RshMaster "\ |
---|
1290 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \ |
---|
1291 | export ExeOutDateMax=${ExeOutDateMax};\ |
---|
1292 | export R_OUT_EXE=${R_OUT_EXE};\ |
---|
1293 | export PREFIX=${PREFIX};\ |
---|
1294 | export SUBMIT_DIR=${SUBMIT_DIR};\ |
---|
1295 | export listVarEnv=${listVarEnv};\ |
---|
1296 | Script_Output=out_SaveSourceModifications;\ |
---|
1297 | IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}" |
---|
1298 | |
---|
1299 | IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" |
---|
1300 | } |
---|
1301 | |
---|
1302 | #=================================== |
---|
1303 | function IGCM_config_PeriodEnd |
---|
1304 | { |
---|
1305 | IGCM_debug_PushStack "IGCM_config_PeriodEnd" |
---|
1306 | |
---|
1307 | echo |
---|
1308 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd" |
---|
1309 | echo |
---|
1310 | |
---|
1311 | if [ ${DRYRUN} -le 1 ] ; then |
---|
1312 | |
---|
1313 | IGCM_debug_Print 1 "Check components binary : size and creation date" |
---|
1314 | |
---|
1315 | typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize |
---|
1316 | typeset comp i |
---|
1317 | typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax |
---|
1318 | |
---|
1319 | #==================================# |
---|
1320 | # Get last Exe Size # |
---|
1321 | #==================================# |
---|
1322 | |
---|
1323 | (( i=0 )) |
---|
1324 | if ( ${FirstInitialize} ) ; then |
---|
1325 | run_Log_LastExeSize="" |
---|
1326 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1327 | run_Log_LastExeSize[$i]=0 |
---|
1328 | (( i=i+1 )) |
---|
1329 | done |
---|
1330 | else |
---|
1331 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize |
---|
1332 | fi |
---|
1333 | #==================================# |
---|
1334 | # And Build ExeDate # |
---|
1335 | #==================================# |
---|
1336 | |
---|
1337 | # 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 |
---|
1338 | # 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") |
---|
1339 | # 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 |
---|
1340 | ExeDate="" |
---|
1341 | NextExeSize="( " |
---|
1342 | (( i=0 )) |
---|
1343 | UpdateExe=false |
---|
1344 | (( ExeSecDateMax = 0 )) |
---|
1345 | for comp in ${config_ListOfComponents[*]} ; do |
---|
1346 | |
---|
1347 | IGCM_debug_Print 3 ${comp} |
---|
1348 | |
---|
1349 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
1350 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
1351 | # Only if we really have an executable for the component : |
---|
1352 | if [ X${ExeNameIn} = X\"\" ] ; then |
---|
1353 | # If there is no exe file for this component |
---|
1354 | (( ExeSize=0 )) |
---|
1355 | else |
---|
1356 | eval ExeNameIn=${ExeNameIn} |
---|
1357 | LS_bin=${R_EXE}/${ExeNameIn} |
---|
1358 | IGCM_sys_FileSize ${LS_bin} ExeSize |
---|
1359 | |
---|
1360 | set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) |
---|
1361 | if [ X${ExeDate} = X ] ; then |
---|
1362 | # First component exe date |
---|
1363 | ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
1364 | else |
---|
1365 | ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
1366 | fi |
---|
1367 | ExeDate=${ExeDate}_${LS_comp[7]} |
---|
1368 | fi |
---|
1369 | |
---|
1370 | if [ ${i} -eq 0 ] ; then |
---|
1371 | # First component |
---|
1372 | NextExeSize="( "${ExeSize} |
---|
1373 | else |
---|
1374 | NextExeSize=${NextExeSize}", "${ExeSize} |
---|
1375 | fi |
---|
1376 | LastCompExeSize=${run_Log_LastExeSize[$i]} |
---|
1377 | (( i=i+1 )) |
---|
1378 | |
---|
1379 | if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then |
---|
1380 | if ( ${FirstInitialize} ) ; then |
---|
1381 | IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
1382 | else |
---|
1383 | IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" |
---|
1384 | IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
1385 | FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} |
---|
1386 | fi |
---|
1387 | IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw |
---|
1388 | UpdateExe=true |
---|
1389 | |
---|
1390 | # SD : switch off for now |
---|
1391 | #IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate |
---|
1392 | #if [ $ExeSecDateMax -lt $ExeSecDate ] ; then |
---|
1393 | # ExeSecDateMax=$ExeSecDate |
---|
1394 | #fi |
---|
1395 | fi |
---|
1396 | done |
---|
1397 | |
---|
1398 | # SD : switch off for now |
---|
1399 | #if ( ${UpdateExe} ) ; then |
---|
1400 | # echo "Launch SaveSourceModifications." |
---|
1401 | # IGCM_config_SaveSourceModifications ${ExeSecDateMax} |
---|
1402 | #fi |
---|
1403 | |
---|
1404 | NextExeSize=${NextExeSize}" )" |
---|
1405 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" |
---|
1406 | |
---|
1407 | if [ ${DRYRUN} -le 1 ] ; then |
---|
1408 | tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt |
---|
1409 | ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt ) |
---|
1410 | RET=$? |
---|
1411 | if [ $RET -eq 0 ] ; then |
---|
1412 | # ExeCpuLog variable contents 5 fields |
---|
1413 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" | \ |
---|
1414 | gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ |
---|
1415 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card |
---|
1416 | fi |
---|
1417 | FileToBeDeleted[${#FileToBeDeleted[@]}]=${Exe_Output}_tail.txt |
---|
1418 | fi |
---|
1419 | |
---|
1420 | fi |
---|
1421 | |
---|
1422 | #==================================# |
---|
1423 | # Save Job output # |
---|
1424 | #==================================# |
---|
1425 | if [ X${Pack} = Xtrue ] ; then |
---|
1426 | IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output} |
---|
1427 | else |
---|
1428 | IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output} |
---|
1429 | fi |
---|
1430 | FileToBeDeleted[${#FileToBeDeleted[@]}]=${Exe_Output} |
---|
1431 | |
---|
1432 | # All was right ? no ? then we stop. |
---|
1433 | IGCM_debug_Verif_Exit |
---|
1434 | |
---|
1435 | # If all was OK, we can delete all files not necessary for next Job |
---|
1436 | echo |
---|
1437 | IGCM_debug_Print 1 "Files that will be deleted before next period-run : " |
---|
1438 | |
---|
1439 | if [ ${DRYRUN} -le 2 ] ; then |
---|
1440 | for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done |
---|
1441 | else |
---|
1442 | echo ${FileToBeDeleted[@]} |
---|
1443 | fi |
---|
1444 | |
---|
1445 | # Send some accounting element to the user if CumulPeriod=3 |
---|
1446 | if [ ${CumulPeriod} -eq 3 ] ; then |
---|
1447 | echo |
---|
1448 | RealCpuTime=$( echo ${ExeCpuLog} | gawk '{print $3}' ) |
---|
1449 | |
---|
1450 | consumeHoursPerPeriod=$( echo "scale=6;${RealCpuTime}*${coreNumber}/3600" | bc ) |
---|
1451 | |
---|
1452 | consumeHoursPerWholeSimulation=$( echo "scale=6;${consumeHoursPerPeriod}/${PeriodLengthInDays}*${ExperienceLengthInDays}" | bc ) |
---|
1453 | |
---|
1454 | # Only continue if jobWarnaingDelay has been set in libIGCM_sys |
---|
1455 | if [ ! X${jobWarningDelay} = X ] ; then |
---|
1456 | recommendedNbPeriodsPerJob=$( echo "scale=6;${jobWarningDelay}/3600/${consumeHoursPerPeriod}*${coreNumber}" | bc ) |
---|
1457 | IGCM_debug_Print 1 "Send email containing some accounting information : " |
---|
1458 | IGCM_sys_SendMail Accounting |
---|
1459 | fi |
---|
1460 | fi |
---|
1461 | |
---|
1462 | #=================================================# |
---|
1463 | # Modification of libIGCM behaviour # |
---|
1464 | #=================================================# |
---|
1465 | |
---|
1466 | # To use this function, one must copy libIGCM.card from ${libIGCM} directory |
---|
1467 | # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, |
---|
1468 | # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop. |
---|
1469 | if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then |
---|
1470 | echo |
---|
1471 | echo "########################################################################" |
---|
1472 | echo "!!! Modification of libIGCM behaviour !!!" |
---|
1473 | echo |
---|
1474 | |
---|
1475 | IGCM_debug_Print 1 "DefineArrayFromOption : libIGCM_UserChanges in libIGCM.card" |
---|
1476 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges |
---|
1477 | IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} |
---|
1478 | |
---|
1479 | # Special treatments for libIGCM internals |
---|
1480 | for option in ${libIGCM_UserChanges[*]} ; do |
---|
1481 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} |
---|
1482 | |
---|
1483 | echo "We will change : ${option}." |
---|
1484 | eval echo "Previous value : " \${${option}} |
---|
1485 | eval echo "Change to : " \${libIGCM_UserChanges_${option}} |
---|
1486 | |
---|
1487 | eval ${option}=\${libIGCM_UserChanges_${option}} |
---|
1488 | |
---|
1489 | case ${option} in |
---|
1490 | config_UserChoices_DateEnd) |
---|
1491 | IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd |
---|
1492 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
1493 | |
---|
1494 | # Period Length In Days between DateBegin and DateEnd |
---|
1495 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
1496 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
1497 | IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
1498 | IGCM_debug_Exit "IGCM_PeriodEnd have wrong dates." |
---|
1499 | IGCM_debug_Verif_Exit |
---|
1500 | fi |
---|
1501 | ;; |
---|
1502 | config_UserChoices_PeriodLength) |
---|
1503 | IGCM_debug_Print 1 "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" |
---|
1504 | ;; |
---|
1505 | NbPeriodsPerJob) |
---|
1506 | IGCM_debug_Print 1 "Loop in main Job with ${NbPeriodsPerJob} period(s)" |
---|
1507 | ;; |
---|
1508 | config_Post_RebuildFrequency) |
---|
1509 | IGCM_debug_Print 1 "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" |
---|
1510 | IGCM_post_Configure |
---|
1511 | ;; |
---|
1512 | config_Post_TimeSeriesFrequency) |
---|
1513 | IGCM_debug_Print 1 "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Configure" |
---|
1514 | IGCM_post_Configure |
---|
1515 | ;; |
---|
1516 | config_Post_SeasonalFrequency) |
---|
1517 | IGCM_debug_Print 1 "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Configure" |
---|
1518 | IGCM_post_Configure |
---|
1519 | ;; |
---|
1520 | esac |
---|
1521 | done |
---|
1522 | |
---|
1523 | echo |
---|
1524 | echo "########################################################################" |
---|
1525 | echo |
---|
1526 | fi |
---|
1527 | |
---|
1528 | #=================================================# |
---|
1529 | # Determine next computed period # |
---|
1530 | #=================================================# |
---|
1531 | |
---|
1532 | PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) |
---|
1533 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
1534 | year_m1=$(( year - 1 )) |
---|
1535 | year_p1=$(( year + 1 )) |
---|
1536 | IGCM_config_DaysInPeriodLength |
---|
1537 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
1538 | |
---|
1539 | # Debug Print : |
---|
1540 | echo |
---|
1541 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" |
---|
1542 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
1543 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
1544 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
1545 | |
---|
1546 | PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) |
---|
1547 | PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) |
---|
1548 | |
---|
1549 | (( CumulPeriod = CumulPeriod + 1 )) |
---|
1550 | |
---|
1551 | # Debug Print : |
---|
1552 | echo |
---|
1553 | IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" |
---|
1554 | IGCM_debug_Print 3 "PeriodDateEnd Human : ${PeriodDateEnd}" |
---|
1555 | IGCM_debug_Print 3 "CumulPeriod : ${CumulPeriod}" |
---|
1556 | |
---|
1557 | #=================================================# |
---|
1558 | # Write updated run.card # |
---|
1559 | #=================================================# |
---|
1560 | |
---|
1561 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
1562 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
1563 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
1564 | |
---|
1565 | if ( ${FirstInitialize} ) ; then |
---|
1566 | # It's no more the first time |
---|
1567 | FirstInitialize=false |
---|
1568 | fi |
---|
1569 | |
---|
1570 | IGCM_debug_PopStack "IGCM_config_PeriodEnd" |
---|
1571 | } |
---|
1572 | |
---|
1573 | #=================================== |
---|
1574 | function IGCM_config_Finalize |
---|
1575 | { |
---|
1576 | IGCM_debug_PushStack "IGCM_config_Finalize" |
---|
1577 | |
---|
1578 | echo |
---|
1579 | IGCM_debug_Print 1 "IGCM_config_Finalize" |
---|
1580 | echo |
---|
1581 | |
---|
1582 | # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal" |
---|
1583 | IGCM_config_StateCheck |
---|
1584 | |
---|
1585 | # And EXIT if not OK |
---|
1586 | IGCM_debug_Verif_Exit |
---|
1587 | |
---|
1588 | if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then |
---|
1589 | #==========================# |
---|
1590 | # End of entire simulation # |
---|
1591 | #==========================# |
---|
1592 | simulationIsOver=true |
---|
1593 | |
---|
1594 | # Mail notification |
---|
1595 | IGCM_sys_SendMail |
---|
1596 | # |
---|
1597 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" |
---|
1598 | # |
---|
1599 | IGCM_debug_Print 1 "Normal End of computation." |
---|
1600 | |
---|
1601 | else |
---|
1602 | #=================# |
---|
1603 | # Submit next job # |
---|
1604 | #=================# |
---|
1605 | simulationIsOver=false |
---|
1606 | |
---|
1607 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
1608 | |
---|
1609 | # Name of next Ksh Script output : |
---|
1610 | Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} ) |
---|
1611 | |
---|
1612 | IGCM_debug_Print 1 "Submit next job" |
---|
1613 | # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR |
---|
1614 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
1615 | # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} |
---|
1616 | ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) |
---|
1617 | [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) |
---|
1618 | # Submit next job and come back |
---|
1619 | IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} |
---|
1620 | IGCM_sys_Cd - |
---|
1621 | fi |
---|
1622 | |
---|
1623 | # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_JobName}.${$} |
---|
1624 | # Only for production run (No clean up in DEV or DEB mode) |
---|
1625 | # and command sent from .. directory. |
---|
1626 | IGCM_sys_Cd .. |
---|
1627 | [ X${JobType} = XRUN ] && IGCM_sys_RmRunDir -rf ${RUN_DIR_PATH} |
---|
1628 | |
---|
1629 | # Inform the rabbitMQ queue |
---|
1630 | IGCM_debug_BigBro_Finalize |
---|
1631 | |
---|
1632 | IGCM_debug_PopStack "IGCM_config_Finalize" |
---|
1633 | } |
---|
1634 | |
---|
1635 | #=================================== |
---|