1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Sebastien Denvil, Martial Mancip |
---|
5 | # Contact: Sebastien.Denvil@ipsl.jussieu.fr Martial.Mancip@ipsl.jussieu.fr |
---|
6 | # $Date$ |
---|
7 | # $Author$ |
---|
8 | # $Revision$ |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # History: |
---|
12 | # Modification: |
---|
13 | # |
---|
14 | #************************************************************** |
---|
15 | |
---|
16 | #======================================================================== |
---|
17 | function IGCM_comp_Initialize |
---|
18 | { |
---|
19 | IGCM_debug_PushStack "IGCM_comp_Initialize" |
---|
20 | |
---|
21 | # Debug Print : |
---|
22 | echo |
---|
23 | IGCM_debug_Print 1 "IGCM_comp_Initialize :" |
---|
24 | echo |
---|
25 | |
---|
26 | typeset comp compname comptagname CompatibilityTag auxprint card_UserChoices first_option |
---|
27 | for comp in ${config_ListOfComponents[*]} ; do |
---|
28 | # Debug Print |
---|
29 | IGCM_debug_Print 1 ${comp} |
---|
30 | # Define component |
---|
31 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} |
---|
32 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
33 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
34 | |
---|
35 | # Read libIGCM compatibility version in ${compname}.card |
---|
36 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
37 | IGCM_card_DefineVariableFromOption ${card} Compatibility libIGCM |
---|
38 | eval CompatibilityTag=\${${compname}_Compatibility_libIGCM} > /dev/null 2>&1 |
---|
39 | |
---|
40 | if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then |
---|
41 | IGCM_debug_Exit "${compname}.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." |
---|
42 | fi |
---|
43 | |
---|
44 | # Manage component executable |
---|
45 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card Executable ${comp} |
---|
46 | |
---|
47 | # Read component Write Frequency in config.card |
---|
48 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} WriteFrequency |
---|
49 | # Debug Print : |
---|
50 | eval auxprint=\${config_${comp}_WriteFrequency} |
---|
51 | IGCM_debug_Print 1 "Write frequency for ${compname} : ${auxprint} " |
---|
52 | #2> /dev/null |
---|
53 | |
---|
54 | # Debug Print : |
---|
55 | IGCM_debug_Print 1 "Initialize following component library :" |
---|
56 | IGCM_debug_Print 1 ${SUBMIT_DIR}/COMP/${compname}.driver |
---|
57 | IGCM_debug_Print 3 "With tag : ${comptagname}" |
---|
58 | # Source component library |
---|
59 | . ${SUBMIT_DIR}/COMP/${compname}.driver |
---|
60 | |
---|
61 | # Debug Print |
---|
62 | IGCM_debug_Print 3 "Initialize ${comp} output directory." |
---|
63 | # Define Dirs |
---|
64 | eval R_OUT_${comp}=${R_SAVE}/${comp} |
---|
65 | eval IGCM_sys_MkdirArchive \${R_OUT_${comp}} |
---|
66 | |
---|
67 | eval R_OUT_${comp}_O=\${R_OUT_${comp}}/Output |
---|
68 | eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_O} |
---|
69 | |
---|
70 | eval R_OUT_${comp}_R=\${R_OUT_${comp}}/Restart |
---|
71 | eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_R} |
---|
72 | |
---|
73 | eval R_OUT_${comp}_D=\${R_OUT_${comp}}/Debug |
---|
74 | eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_D} |
---|
75 | |
---|
76 | eval R_OUT_${comp}_O_I=\${R_OUT_${comp}_O}/INS |
---|
77 | eval R_OUT_${comp}_O_H=\${R_OUT_${comp}_O}/HF |
---|
78 | eval R_OUT_${comp}_O_D=\${R_OUT_${comp}_O}/DA |
---|
79 | eval R_OUT_${comp}_O_M=\${R_OUT_${comp}_O}/MO |
---|
80 | eval R_OUT_${comp}_O_Y=\${R_OUT_${comp}_O}/YE |
---|
81 | |
---|
82 | |
---|
83 | # Read UserChoices section of component card |
---|
84 | IGCM_debug_Print 1 "DefineArrayFromOption : ${compname}_UserChoices ${card}" |
---|
85 | IGCM_card_DefineArrayFromSection ${card} UserChoices |
---|
86 | eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1 |
---|
87 | if [ X${first_option} != X"Error:" ] ; then |
---|
88 | if [ X${card_UserChoices[0]} != X ] ; then |
---|
89 | unset card_UserChoices |
---|
90 | fi |
---|
91 | eval set +A card_UserChoices -- \${${compname}_UserChoices[*]} > /dev/null 2>&1 |
---|
92 | typeset option |
---|
93 | for option in ${card_UserChoices[*]} ; do |
---|
94 | IGCM_card_DefineVariableFromOption ${card} UserChoices ${option} |
---|
95 | eval IGCM_debug_Print 2 "${compname}_UserChoices_values: ${option} \${card_UserChoices_${option}}" |
---|
96 | done |
---|
97 | fi |
---|
98 | |
---|
99 | # Debug Print |
---|
100 | IGCM_debug_Print 3 "Initialize ${compname} with driver." |
---|
101 | # INIT component |
---|
102 | ${comp}_Initialize |
---|
103 | echo |
---|
104 | done |
---|
105 | echo "-----" |
---|
106 | |
---|
107 | echo |
---|
108 | IGCM_debug_Print 1 "DefineArrayFromOption : ListOfComponents" |
---|
109 | IGCM_debug_PrintVariables 3 config_ListOfComponents |
---|
110 | |
---|
111 | IGCM_debug_PopStack "IGCM_comp_Initialize" |
---|
112 | } |
---|
113 | |
---|
114 | #======================================================================= |
---|
115 | function IGCM_comp_PrepareDeletedFiles |
---|
116 | { |
---|
117 | IGCM_debug_PushStack "IGCM_comp_PrepareDeletedFiles" $@ |
---|
118 | |
---|
119 | if [ X${2} != X. ] ; then |
---|
120 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${2} ) > /dev/null 2>&1 |
---|
121 | else |
---|
122 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${1} ) > /dev/null 2>&1 |
---|
123 | fi |
---|
124 | |
---|
125 | IGCM_debug_PopStack "IGCM_comp_PrepareDeletedFiles" |
---|
126 | } |
---|
127 | |
---|
128 | #======================================================================= |
---|
129 | function IGCM_comp_GetInputInitialStateFiles |
---|
130 | { |
---|
131 | IGCM_debug_PushStack "IGCM_comp_GetInputInitialStateFiles" |
---|
132 | |
---|
133 | # Debug Print : |
---|
134 | echo |
---|
135 | IGCM_debug_Print 1 "IGCM_comp_GetInputInitialStateFiles :" |
---|
136 | echo |
---|
137 | |
---|
138 | # Only the first time step need InitialStateFiles |
---|
139 | # otherwise it's BoundaryConditions |
---|
140 | if ( ${FirstInitialize} ) ; then |
---|
141 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ |
---|
142 | typeset file_in_ file_in file_out_ file_out do_init |
---|
143 | for comp in ${config_ListOfComponents[*]} ; do |
---|
144 | # Initialize |
---|
145 | do_init="y" |
---|
146 | # Do we need to bring initial state file for this component |
---|
147 | if [ "${config_Restarts_OverRule}" = "y" ] ; then |
---|
148 | eval do_init="n" |
---|
149 | else |
---|
150 | # Read component Restarts parameters |
---|
151 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart |
---|
152 | eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 |
---|
153 | if [ "${do_start}" = "y" ] ; then |
---|
154 | do_init="n" |
---|
155 | else |
---|
156 | do_init="y" |
---|
157 | fi |
---|
158 | fi |
---|
159 | |
---|
160 | if [ "${do_init}" = "y" ] ; then |
---|
161 | # Define component |
---|
162 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
163 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
164 | |
---|
165 | # Debug Print : |
---|
166 | IGCM_debug_Print 3 "Initialisation files ${compname}" |
---|
167 | |
---|
168 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
169 | |
---|
170 | IGCM_card_DefineArrayFromOption ${card} InitialStateFiles List |
---|
171 | ListFilesName=${compname}_InitialStateFiles_List |
---|
172 | |
---|
173 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
174 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
175 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
176 | |
---|
177 | (( i=0 )) |
---|
178 | until [ $i -ge $NbFiles ]; do |
---|
179 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
180 | eval file_in=${file_in_} |
---|
181 | (( i_ = i+1 )) |
---|
182 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
183 | eval file_out=${file_out_} |
---|
184 | |
---|
185 | IGCM_sys_Get ${file_in} ${file_out} |
---|
186 | |
---|
187 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
188 | |
---|
189 | (( i=i+2 )) |
---|
190 | done |
---|
191 | fi |
---|
192 | fi |
---|
193 | done |
---|
194 | fi |
---|
195 | IGCM_debug_PopStack "IGCM_comp_GetInputInitialStateFiles" |
---|
196 | } |
---|
197 | |
---|
198 | #======================================================================= |
---|
199 | function IGCM_comp_GetInputBoundaryFiles |
---|
200 | { |
---|
201 | IGCM_debug_PushStack "IGCM_comp_GetInputBoundaryFiles" |
---|
202 | |
---|
203 | # Debug Print : |
---|
204 | echo |
---|
205 | IGCM_debug_Print 1 "IGCM_comp_GetInputBoundaryFiles :" |
---|
206 | echo |
---|
207 | |
---|
208 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ |
---|
209 | typeset file_in_ file_in file_out_ file_out |
---|
210 | |
---|
211 | if [ ${Period} = 1 ]; then |
---|
212 | ListFixBoundary=" " |
---|
213 | fi |
---|
214 | |
---|
215 | for comp in ${config_ListOfComponents[*]} ; do |
---|
216 | |
---|
217 | echo "-----" |
---|
218 | # Define component |
---|
219 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
220 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
221 | |
---|
222 | # Debug Print : |
---|
223 | IGCM_debug_Print 3 "Boundary files ${compname}" |
---|
224 | |
---|
225 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
226 | |
---|
227 | IGCM_card_DefineArrayFromOption ${card} BoundaryFiles List |
---|
228 | ListFilesName=${compname}_BoundaryFiles_List |
---|
229 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
230 | |
---|
231 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
232 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
233 | |
---|
234 | (( i=0 )) |
---|
235 | until [ $i -ge $NbFiles ]; do |
---|
236 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
237 | eval file_in=${file_in_} |
---|
238 | (( i_ = i+1 )) |
---|
239 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
240 | eval file_out=${file_out_} |
---|
241 | |
---|
242 | IGCM_sys_Get ${file_in} ${file_out} |
---|
243 | |
---|
244 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
245 | |
---|
246 | (( i=i+2 )) |
---|
247 | done |
---|
248 | fi |
---|
249 | |
---|
250 | # Get non deleted files |
---|
251 | if [ ${Period} = 1 ]; then |
---|
252 | |
---|
253 | IGCM_card_DefineArrayFromOption ${card} BoundaryFiles ListNonDel |
---|
254 | ListFilesName=${compname}_BoundaryFiles_ListNonDel |
---|
255 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
256 | |
---|
257 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
258 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
259 | |
---|
260 | (( i=0 )) |
---|
261 | until [ $i -ge $NbFiles ]; do |
---|
262 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
263 | eval file_in=${file_in_} |
---|
264 | (( i_ = i+1 )) |
---|
265 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
266 | eval file_out=${file_out_} |
---|
267 | |
---|
268 | IGCM_sys_Get ${file_in} ${file_out} |
---|
269 | |
---|
270 | if [ X${file_out} != X. ] ; then |
---|
271 | ListFixBoundary=${ListFixBoundary}" "${file_out} |
---|
272 | else |
---|
273 | ListFixBoundary=${ListFixBoundary}" "$( basename ${file_in} ) |
---|
274 | fi |
---|
275 | |
---|
276 | (( i=i+2 )) |
---|
277 | done |
---|
278 | fi |
---|
279 | fi |
---|
280 | done |
---|
281 | |
---|
282 | IGCM_debug_PopStack "IGCM_comp_GetInputBoundaryFiles" |
---|
283 | } |
---|
284 | |
---|
285 | #======================================================================= |
---|
286 | function IGCM_comp_DelFixeBoundaryFiles |
---|
287 | { |
---|
288 | IGCM_debug_PushStack "IGCM_comp_DelFixeBoundaryFiles" |
---|
289 | |
---|
290 | # Debug Print : |
---|
291 | echo |
---|
292 | IGCM_debug_Print 1 "IGCM_comp_DelFixeBoundaryFiles :" |
---|
293 | echo |
---|
294 | |
---|
295 | ls -l ${ListFixBoundary} |
---|
296 | rm -f ${ListFixBoundary} |
---|
297 | |
---|
298 | IGCM_debug_PopStack "IGCM_comp_DelFixeBoundaryFiles" |
---|
299 | } |
---|
300 | |
---|
301 | #======================================================================= |
---|
302 | function IGCM_comp_GetInputParametersFiles |
---|
303 | { |
---|
304 | IGCM_debug_PushStack "IGCM_comp_GetInputParametersFiles" |
---|
305 | |
---|
306 | # Debug Print : |
---|
307 | echo |
---|
308 | IGCM_debug_Print 1 "IGCM_comp_GetInputParametersFiles :" |
---|
309 | echo |
---|
310 | |
---|
311 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ file_in file_out |
---|
312 | for comp in ${config_ListOfComponents[*]} ; do |
---|
313 | # Define component |
---|
314 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
315 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
316 | |
---|
317 | # Debug Print : |
---|
318 | IGCM_debug_Print 3 "Parameters ${compname}" |
---|
319 | |
---|
320 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
321 | |
---|
322 | IGCM_card_DefineArrayFromOption ${card} ParametersFiles List |
---|
323 | ListFilesName=${compname}_ParametersFiles_List |
---|
324 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
325 | |
---|
326 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
327 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
328 | |
---|
329 | (( i=0 )) |
---|
330 | until [ $i -ge $NbFiles ]; do |
---|
331 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
332 | eval file_in=${file_in_} |
---|
333 | (( i_ = i+1 )) |
---|
334 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
335 | eval file_out=${file_out_} |
---|
336 | |
---|
337 | IGCM_sys_Cp ${file_in} ${file_out} |
---|
338 | |
---|
339 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
340 | |
---|
341 | (( i=i+2 )) |
---|
342 | done |
---|
343 | fi |
---|
344 | done |
---|
345 | |
---|
346 | IGCM_debug_PopStack "IGCM_comp_GetInputParametersFiles" |
---|
347 | } |
---|
348 | |
---|
349 | #======================================================================= |
---|
350 | function IGCM_comp_GetInputRestartFiles |
---|
351 | { |
---|
352 | IGCM_debug_PushStack "IGCM_comp_GetInputRestartFiles" |
---|
353 | |
---|
354 | # Debug Print : |
---|
355 | echo |
---|
356 | IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles :" |
---|
357 | echo |
---|
358 | |
---|
359 | typeset Date_tmp Date_r Path_r do_start CompOldName |
---|
360 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ |
---|
361 | typeset file_in file_out file_in_ file_out_ file_in_Name |
---|
362 | |
---|
363 | for comp in ${config_ListOfComponents[*]} ; do |
---|
364 | # Define component |
---|
365 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
366 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
367 | |
---|
368 | # Debug Print : |
---|
369 | IGCM_debug_Print 3 "restart ${compname}" |
---|
370 | |
---|
371 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
372 | |
---|
373 | if ( ${FirstInitialize} ) ; then |
---|
374 | |
---|
375 | if [ "${config_Restarts_OverRule}" = "y" ] ; then |
---|
376 | eval config_${comp}_Restart="y" |
---|
377 | eval config_${comp}_RestartDate=${config_Restarts_RestartDate} |
---|
378 | eval config_${comp}_RestartJobName=${config_Restarts_RestartJobName} |
---|
379 | eval config_${comp}_RestartPath=${config_Restarts_RestartPath} |
---|
380 | eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 |
---|
381 | eval CompOldName=${comp} |
---|
382 | else |
---|
383 | # Read component Restarts parameters |
---|
384 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart |
---|
385 | eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 |
---|
386 | |
---|
387 | if [ "${do_start}" = "y" ] ; then |
---|
388 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartDate |
---|
389 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartJobName |
---|
390 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartPath |
---|
391 | else |
---|
392 | eval config_${comp}_RestartDate=-1 |
---|
393 | eval config_${comp}_RestartJobName=${NULL_STR} |
---|
394 | eval config_${comp}_RestartPath=${NULL_STR} |
---|
395 | fi |
---|
396 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} OldName |
---|
397 | eval CompOldName=\${config_${comp}_OldName} |
---|
398 | if [ X${CompOldName} = X ] ; then |
---|
399 | eval CompOldName=${comp} |
---|
400 | fi |
---|
401 | fi |
---|
402 | |
---|
403 | if [ "${do_start}" = "y" ] ; then |
---|
404 | |
---|
405 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
406 | ListFilesName=${compname}_RestartFiles_List |
---|
407 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
408 | |
---|
409 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
410 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
411 | |
---|
412 | (( i=1 )) |
---|
413 | until [ $i -gt $NbFiles ]; do |
---|
414 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
415 | eval file_in=${file_in_} |
---|
416 | |
---|
417 | (( i_ = i+1 )) |
---|
418 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
419 | eval file_out=${file_out_} |
---|
420 | |
---|
421 | eval Date_tmp=\${config_${comp}_RestartDate} |
---|
422 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} ) |
---|
423 | eval Path_r=\${config_${comp}_RestartPath}/\${config_${comp}_RestartJobName}/${CompOldName}/Restart |
---|
424 | eval file_in_Name=\${config_${comp}_RestartJobName}_${Date_r}_${file_in} |
---|
425 | |
---|
426 | eval IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out} |
---|
427 | |
---|
428 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
429 | |
---|
430 | (( i=i+3 )) |
---|
431 | done |
---|
432 | else |
---|
433 | if [ X${FileName0} != XNONE ] ; then |
---|
434 | IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." |
---|
435 | else |
---|
436 | IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." |
---|
437 | fi |
---|
438 | fi |
---|
439 | fi |
---|
440 | else |
---|
441 | # if not FirstInitialize |
---|
442 | |
---|
443 | # Restore Restarts files |
---|
444 | #----------------------- |
---|
445 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
446 | ListFilesName=${compname}_RestartFiles_List |
---|
447 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
448 | |
---|
449 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
450 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
451 | |
---|
452 | (( i=1 )) |
---|
453 | until [ $i -gt $NbFiles ]; do |
---|
454 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
455 | eval file_in=${file_in_} |
---|
456 | (( i_ = i+1 )) |
---|
457 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
458 | eval file_out=${file_out_} |
---|
459 | |
---|
460 | file_in_Name=${run_Configuration_OldPrefix}_${file_in} |
---|
461 | eval IGCM_sys_Get \${R_OUT_${comp}_R}/${file_in_Name} ${file_out} |
---|
462 | |
---|
463 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
464 | |
---|
465 | (( i=i+3 )) |
---|
466 | done |
---|
467 | else |
---|
468 | if [ X${FileName0} != XNONE ] ; then |
---|
469 | IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." |
---|
470 | else |
---|
471 | IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." |
---|
472 | fi |
---|
473 | fi |
---|
474 | fi |
---|
475 | done |
---|
476 | IGCM_sys_Chmod -R u+rw . |
---|
477 | |
---|
478 | IGCM_debug_PopStack "IGCM_comp_GetInputRestartFiles" |
---|
479 | } |
---|
480 | |
---|
481 | #======================================================================= |
---|
482 | function IGCM_comp_Update |
---|
483 | { |
---|
484 | IGCM_debug_PushStack "IGCM_comp_Update" |
---|
485 | |
---|
486 | # Debug Print : |
---|
487 | echo |
---|
488 | IGCM_debug_Print 1 "IGCM_comp_Update :" |
---|
489 | echo |
---|
490 | |
---|
491 | typeset ExeNameIn ExeNameOut |
---|
492 | typeset comp compname comptagname |
---|
493 | for comp in ${config_ListOfComponents[*]} ; do |
---|
494 | # Define component |
---|
495 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
496 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
497 | |
---|
498 | # Copy executable for this component |
---|
499 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
500 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
501 | if [ -f ${R_EXE}/${ExeNameIn} ] ; then |
---|
502 | eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} |
---|
503 | if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then |
---|
504 | eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} |
---|
505 | fi |
---|
506 | fi |
---|
507 | |
---|
508 | # Debug Print |
---|
509 | IGCM_debug_Print 3 "Update ${compname} Parameter Files." |
---|
510 | # UPDATE component |
---|
511 | ${comp}_Update |
---|
512 | |
---|
513 | done |
---|
514 | |
---|
515 | IGCM_debug_PopStack "IGCM_comp_Update" |
---|
516 | } |
---|
517 | |
---|
518 | #======================================================================= |
---|
519 | function IGCM_comp_Finalize |
---|
520 | { |
---|
521 | IGCM_debug_PushStack "IGCM_comp_Finalize" |
---|
522 | |
---|
523 | # Debug Print : |
---|
524 | echo |
---|
525 | IGCM_debug_Print 1 "IGCM_comp_Finalize :" |
---|
526 | echo |
---|
527 | |
---|
528 | typeset ListTextName TextName0 |
---|
529 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles |
---|
530 | typeset i i_ file_in file_in_ file_out file_out_ generic_file_name nb_rebuild_file |
---|
531 | for comp in ${config_ListOfComponents[*]} ; do |
---|
532 | # Define component |
---|
533 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
534 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
535 | |
---|
536 | # Debug Print |
---|
537 | IGCM_debug_Print 1 "Finalize ${compname} component." |
---|
538 | # FINALIZE component |
---|
539 | ${comp}_Finalize |
---|
540 | |
---|
541 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
542 | |
---|
543 | # Save Restarts files |
---|
544 | #-------------------- |
---|
545 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
546 | ListFilesName=${compname}_RestartFiles_List |
---|
547 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
548 | |
---|
549 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
550 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
551 | |
---|
552 | (( i=0 )) |
---|
553 | until [ $i -ge $NbFiles ]; do |
---|
554 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
555 | eval file_in=${file_in_} |
---|
556 | |
---|
557 | (( i_ = i+1 )) |
---|
558 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
559 | eval file_out=${file_out_} |
---|
560 | |
---|
561 | eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} |
---|
562 | |
---|
563 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 |
---|
564 | |
---|
565 | (( i=i+3 )) |
---|
566 | done |
---|
567 | else |
---|
568 | if [ X${FileName0} != XNONE ] ; then |
---|
569 | IGCM_debug_Exit "IGCM_comp_Finalize : No file in restart list for ${compname}." |
---|
570 | else |
---|
571 | IGCM_debug_Print 1 "IGCM_comp_Finalize : NONE specified in Restart List ${compname}." |
---|
572 | fi |
---|
573 | fi |
---|
574 | |
---|
575 | # Save Output files |
---|
576 | #------------------ |
---|
577 | IGCM_card_DefineArrayFromOption ${card} OutputFiles List |
---|
578 | ListFilesName=${compname}_OutputFiles_List |
---|
579 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
580 | |
---|
581 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
582 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
583 | |
---|
584 | (( i=0 )) |
---|
585 | until [ $i -ge $NbFiles ]; do |
---|
586 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
587 | eval file_in=${file_in_} |
---|
588 | (( i_ = i+1 )) |
---|
589 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
590 | eval file_out=${file_out_} |
---|
591 | |
---|
592 | generic_file_name=$( basename ${file_in} .nc ) |
---|
593 | nb_rebuild_file=$( ls | grep "${generic_file_name}[_0-9]*.nc" | wc -l ) |
---|
594 | if [ ${nb_rebuild_file} -gt 1 ] ; then |
---|
595 | IGCM_debug_Print 2 "Rebuilding ${file_in}" |
---|
596 | IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc |
---|
597 | # DEBUG Rebuild : |
---|
598 | #eval IGCM_sys_Cp ${generic_file_name}_*.nc \${R_OUT_${comp}_O_M}/ |
---|
599 | elif [ -f ${generic_file_name}_0000.nc ] ; then |
---|
600 | IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in} |
---|
601 | fi |
---|
602 | |
---|
603 | IGCM_sys_Put_Out ${file_in} ${file_out} |
---|
604 | if [ $? -eq 0 ] ; then |
---|
605 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 |
---|
606 | if [ ${nb_rebuild_file} -gt 1 ] ; then |
---|
607 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( ls | grep "${generic_file_name}_[0-9]*.nc" ) > /dev/null 2>&1 |
---|
608 | fi |
---|
609 | fi |
---|
610 | (( i=i+3 )) |
---|
611 | done |
---|
612 | fi |
---|
613 | |
---|
614 | # Save Output Text files of models |
---|
615 | #--------------------------------- |
---|
616 | |
---|
617 | IGCM_card_DefineArrayFromOption ${card} OutputText List |
---|
618 | ListTextName=${compname}_OutputText_List |
---|
619 | |
---|
620 | eval TextName0=\${${ListTextName}[0]} > /dev/null 2>&1 |
---|
621 | if [ X${TextName0} != X${NULL_STR} ] ; then |
---|
622 | eval NbFiles=\${#${ListTextName}[@]} > /dev/null 2>&1 |
---|
623 | |
---|
624 | (( i=0 )) |
---|
625 | until [ $i -eq $NbFiles ]; do |
---|
626 | eval file_in=\${${ListTextName}[$i]} > /dev/null 2>&1 |
---|
627 | (( i=i+1 )) |
---|
628 | |
---|
629 | nb_text_file=$( ls ${file_in}* 2>/dev/null | wc -l ) |
---|
630 | if [ ${nb_text_file} -gt 1 ] ; then |
---|
631 | list_file=$( ls ${file_in}* ) |
---|
632 | for file in ${list_file} |
---|
633 | do |
---|
634 | eval IGCM_sys_Put_Out ${file} \${R_OUT_${comp}_D}/${PREFIX}_${file} |
---|
635 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 |
---|
636 | done |
---|
637 | else |
---|
638 | if ( [ -f ${file_in}_0000 ] || [ -f ${file_in}0 ] ) ; then |
---|
639 | eval IGCM_sys_Mv ${file_in}* ${file_in} |
---|
640 | fi |
---|
641 | eval IGCM_sys_Put_Out ${file_in} \${R_OUT_${comp}_D}/${PREFIX}_${file_in} |
---|
642 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 |
---|
643 | fi |
---|
644 | done |
---|
645 | fi |
---|
646 | done |
---|
647 | |
---|
648 | IGCM_debug_PopStack "IGCM_comp_Finalize" |
---|
649 | } |
---|