source: tags/libIGCM_v1_9/libIGCM_comp/libIGCM_comp.ksh @ 1435

Last change on this file since 1435 was 365, checked in by mmaipsl, 14 years ago

make some i variables local to there subroutines.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Date Author Revision
File size: 37.8 KB
Line 
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#========================================================================
17function 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 i j
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        # Read UserChoices section of component card
83        IGCM_debug_Print 1 "DefineArrayFromSection : ${compname}_UserChoices ${card}"
84        IGCM_card_DefineArrayFromSection ${card} UserChoices
85        eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1
86        if [ X${first_option} != X"Error:" ] ; then
87            eval IGCM_debug_Print 2 "${compname}_UserChoices_Options:" \${${compname}_UserChoices[*]}
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 3 "${compname}_UserChoices_values: ${option} \${card_UserChoices_${option}}"
96            done
97        fi
98
99        # Read and Build Output File stuff
100        IGCM_debug_Print 1 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}"
101        IGCM_card_DefineArrayFromOption ${card} OutputFiles List
102        ListFilesName=${compname}_OutputFiles_List
103        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
104        #
105        if [ X${FileName0} != X${NULL_STR} ] ; then
106            #
107            #IGCM_debug_Print 1 "Component      : ${compname}"
108            #
109            # INITIALISATION
110            #
111            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
112            #
113            typeset i
114            i=2
115            #
116            until [ $i -ge $NbFiles ]; do
117                #
118                eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
119                #
120                if [ X${flag_post} != XNONE ] ; then
121                    #
122                    # First of all
123                    #
124                    IGCM_card_DefineArrayFromSection ${card} ${flag_post}
125                    #
126                    # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
127                    #
128                    # variable option allready typeset above
129                    for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
130                        if [ ${option} = Seasonal ] ; then
131                            FoundSeasonal=true
132                            IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
133                        fi
134                    done
135                    #
136                    if [ ! X${FoundSeasonal} = Xtrue ] ; then
137                        eval ${compname}_${flag_post}_Seasonal=ON
138                    fi
139                    #
140                    if [ $( eval echo \${${compname}_${flag_post}_Seasonal} ) = ON ] ; then
141                        Seasonal=true
142                    fi
143                   
144                    # Dimension = vide si vieille card.
145                    IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars
146                    IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches
147                    if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not found ${flag_post}" ] ; then
148                        # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob.
149                        ListDimension[0]=2D
150                        ListDimension[1]=3D
151                        TimeSeries=false
152                        iLoop=${#ListDimension[*]}
153                        j=0
154                        until [ $j -ge ${iLoop} ]; do
155                            Dimension=${ListDimension[${j}]}
156                            IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension}
157                            IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension}
158                            #
159                            # Time series WITHOUT chunk
160                            #
161                            if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
162                                if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then
163                                    IGCM_debug_Print 3 "${Dimension} time series activated for ${flag_post} according to ${card}"
164                                    eval TimeSeries${Dimension}=true
165                                fi
166                            fi
167                            #
168                            # Time series WITH chunk
169                            #
170                            if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
171                                chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} )
172                                if [ ! ${chunck_size} = NONE ] &&  [ ! ${chunck_size} = OFF ] ; then
173                                    IGCM_debug_Print 3 "${Dimension} time series activated with chunck for ${flag_post} according to ${card}"
174                                    eval TimeSeriesChunck${Dimension}=true
175                                    eval set +A CHUNCK${Dimension}_COMP \${CHUNCK${Dimension}_COMP[*]} ${comp}
176                                    eval set +A CHUNCK${Dimension}_FLAG \${CHUNCK${Dimension}_FLAG[*]} ${i}
177                                    eval set +A CHUNCK${Dimension}_SIZE \${CHUNCK${Dimension}_SIZE[*]} ${chunck_size}
178                                fi
179                            fi
180                            (( j=j+1 ))
181                        done
182                    else
183                        ListDimension[0]=""
184                        TimeSeries=true
185                        TimeSeries2D=false
186                        TimeSeries3D=false
187                        TimeSeriesChunck2D=false
188                        TimeSeriesChunck3D=false
189                    fi
190                fi
191                (( i=i+3 ))
192            done
193        fi
194        # Debug Print
195        IGCM_debug_Print 3 "Initialize ${compname} with driver."
196        # INIT component
197        ${comp}_Initialize
198        echo
199    done
200    echo "-----"
201    echo
202    IGCM_debug_Print 1 "DefineArrayFromOption  : ListOfComponents"
203    IGCM_debug_PrintVariables 3 config_ListOfComponents
204
205    IGCM_debug_PopStack "IGCM_comp_Initialize"
206}
207
208#=======================================================================
209function IGCM_comp_PrepareDeletedFiles
210{
211    IGCM_debug_PushStack "IGCM_comp_PrepareDeletedFiles" $@
212   
213    if [ X${2} != X. ] ; then
214        eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${2} ) > /dev/null 2>&1
215    else
216        eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${1} ) > /dev/null 2>&1
217    fi
218
219    IGCM_debug_PopStack "IGCM_comp_PrepareDeletedFiles"
220}
221
222#=======================================================================
223function IGCM_comp_GetInputInitialStateFiles
224{
225    IGCM_debug_PushStack "IGCM_comp_GetInputInitialStateFiles"
226
227    # Debug Print :
228    echo
229    IGCM_debug_Print 1 "IGCM_comp_GetInputInitialStateFiles :"
230    echo
231
232    # Only the first time step need InitialStateFiles
233    # otherwise it's BoundaryConditions
234    if ( ${FirstInitialize} ) ; then
235      typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_
236      typeset file_in_ file_in file_out_ file_out do_init
237      for comp in ${config_ListOfComponents[*]} ; do
238          # Initialize
239          do_init="y"
240          # Do we need to bring initial state file for this component
241          if [ "${config_Restarts_OverRule}" = "y" ] ; then
242              eval do_init="n"
243          else
244              # Read component Restarts parameters
245              IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart
246              eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1
247              if [ "${do_start}" = "y" ] ; then
248                    do_init="n"
249              else
250                    do_init="y"
251              fi
252          fi
253
254          if [ "${do_init}" = "y" ] ; then
255              # Define component
256              eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
257              eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
258
259              # Debug Print :
260              IGCM_debug_Print 3 "Initialisation files ${compname}"
261
262              card=${SUBMIT_DIR}/COMP/${compname}.card
263
264              IGCM_card_DefineArrayFromOption ${card} InitialStateFiles List
265              ListFilesName=${compname}_InitialStateFiles_List
266
267              eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
268              if [ X${FileName0} != X${NULL_STR} ] ; then
269                  eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
270                  typeset i
271                  (( i=0 ))
272                  until [ $i -ge $NbFiles ]; do
273                      eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
274                      eval file_in=${file_in_}
275                      (( i_ = i+1 ))
276                      eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
277                      eval file_out=${file_out_}
278                     
279                      IGCM_sys_Get ${file_in} ${file_out}
280                      #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
281
282                      (( i=i+2 ))
283                  done
284              fi
285          fi
286      done
287    fi
288    IGCM_debug_PopStack "IGCM_comp_GetInputInitialStateFiles"
289}
290
291#=======================================================================
292# Definition of Smooth modulo function
293# usage :
294# IGCM_SmoothModulo StringModulo value
295#
296# StringModulo : A string of min max and modulo like definition of Scilab vectors.
297# [min]:[modulo:][max]
298# where :
299# [] value are optionnals;
300# empty min equal 1
301# empty max equal infinity
302# modulo not given or empty equal 1
303# empty string or just ':' equal always.
304#
305# value : the value to test with the definition
306#
307# return : true(1)/false(0)
308function IGCM_SmoothModulo
309{
310    IGCM_debug_PushStack "IGCM_SmoothModulo"
311    typeset defVector ModValue
312
313    eval set +A defVector -- $( echo "${1}" | \
314        gawk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' )
315
316    # Test limits :
317    # ${defVector[0]} <= ${2} <= ${defVector[2]}
318    #                                      or ${defVector[2]} == -1
319    if ( [ ${2} -ge ${defVector[0]} ] && \
320         ( [ ${2} -le ${defVector[2]} ] || \
321           [ ${defVector[2]} -lt 0 ] ) ) ; then
322
323        # Test modulo
324        ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} )
325        if [ ${ModValue} -eq 0 ] ;  then
326            echo true
327            IGCM_debug_PopStack "IGCM_SmoothModulo"
328            return 1
329        else
330            echo false
331            IGCM_debug_PopStack "IGCM_SmoothModulo"
332            return 0
333        fi
334    else
335        echo false
336        IGCM_debug_PopStack "IGCM_SmoothModulo"
337        return 0
338    fi
339}
340
341#=======================================================================
342function IGCM_comp_GetInputSmoothFiles
343{
344    IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles"
345
346    # Debug Print :
347    echo
348    IGCM_debug_Print 1 "IGCM_comp_GetInputSmoothFiles :"
349    echo
350
351    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ i__
352    typeset file_in_ file_in file_out_ file_out ret SmoothDef
353
354    for comp in ${config_ListOfComponents[*]} ; do
355
356        echo "-----"
357        # Define component
358        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
359        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
360
361        # Debug Print :
362        IGCM_debug_Print 3 "Smooth files ${compname}"
363
364        card=${SUBMIT_DIR}/COMP/${compname}.card
365
366        IGCM_card_DefineArrayFromOption ${card} SmoothFiles List
367        ListFilesName=${compname}_SmoothFiles_List
368        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
369
370        if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != X"Section" ] ) ; then
371            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
372
373            typeset i
374            (( i=0 ))
375            until [ $i -ge $NbFiles ]; do
376
377                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
378                eval file_in=${file_in_}
379                (( i_ = i+1 ))
380                eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
381                eval file_out=${file_out_}
382
383                # define CumulPeriod definition for this file
384                (( i__ = i+2 ))
385                eval SmoothDef=\${${ListFilesName}[$i__]}
386                IGCM_debug_Print 3 "  ${file_in} ${SmoothDef}"
387                eval ret=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} )
388                if ( [ X${ret} = Xtrue ] || [ ${Period} -eq 1 ] ) ; then
389                    IGCM_sys_Get ${file_in} ${file_out}
390
391                    #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
392                fi
393                (( i=i+3 ))
394            done
395        fi
396    done
397   
398    IGCM_debug_PopStack "IGCM_comp_GetInputSmoothFiles"
399}
400
401#=======================================================================
402function IGCM_comp_GetInputBoundaryFiles
403{
404    IGCM_debug_PushStack "IGCM_comp_GetInputBoundaryFiles"
405
406    # Debug Print :
407    echo
408    IGCM_debug_Print 1 "IGCM_comp_GetInputBoundaryFiles :"
409    echo
410
411    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_
412    typeset file_in_ file_in file_out_ file_out
413
414    if [ ${Period} = 1 ]; then
415        ListFixBoundary=" "
416    fi
417
418    for comp in ${config_ListOfComponents[*]} ; do
419
420        echo "-----"
421        # Define component
422        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
423        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
424
425        # Debug Print :
426        IGCM_debug_Print 3 "Boundary files ${compname}"
427
428        card=${SUBMIT_DIR}/COMP/${compname}.card
429
430        IGCM_card_DefineArrayFromOption ${card} BoundaryFiles List
431        ListFilesName=${compname}_BoundaryFiles_List
432        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
433
434        if [ X${FileName0} != X${NULL_STR} ] ; then
435            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
436
437            typeset i
438            (( i=0 ))
439            until [ $i -ge $NbFiles ]; do
440                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
441                eval file_in=${file_in_}
442                (( i_ = i+1 ))
443                eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
444                eval file_out=${file_out_}
445
446                IGCM_sys_Get ${file_in} ${file_out}
447                IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
448
449                (( i=i+2 ))
450            done
451        fi
452
453        # Get non deleted files
454        if [ ${Period} = 1 ]; then
455
456            IGCM_card_DefineArrayFromOption ${card} BoundaryFiles ListNonDel
457            ListFilesName=${compname}_BoundaryFiles_ListNonDel
458            eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
459           
460            if [ X${FileName0} != X${NULL_STR} ] ; then
461                eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
462               
463                typeset i
464                (( i=0 ))
465                until [ $i -ge $NbFiles ]; do
466                    eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
467                    eval file_in=${file_in_}
468                    (( i_ = i+1 ))
469                    eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
470                    eval file_out=${file_out_}
471
472                    IGCM_sys_Get ${file_in} ${file_out}
473
474                    if [ X${file_out} != X. ] ; then
475                        ListFixBoundary=${ListFixBoundary}" "${file_out}
476                    else
477                        ListFixBoundary=${ListFixBoundary}" "$( basename ${file_in} )
478                    fi
479
480                    (( i=i+2 ))
481                done
482            fi
483        fi
484    done
485   
486    IGCM_debug_PopStack "IGCM_comp_GetInputBoundaryFiles"
487}
488
489#=======================================================================
490function IGCM_comp_DelFixeBoundaryFiles
491{
492    IGCM_debug_PushStack "IGCM_comp_DelFixeBoundaryFiles"
493
494    # Debug Print :
495    echo
496    IGCM_debug_Print 1 "IGCM_comp_DelFixeBoundaryFiles :"
497    echo
498
499    ls -l ${ListFixBoundary}
500    rm -f ${ListFixBoundary}
501
502    IGCM_debug_PopStack "IGCM_comp_DelFixeBoundaryFiles"
503}
504
505#=======================================================================
506function IGCM_comp_GetInputParametersFiles
507{
508    IGCM_debug_PushStack "IGCM_comp_GetInputParametersFiles"
509
510    # Debug Print :
511    echo
512    IGCM_debug_Print 1 "IGCM_comp_GetInputParametersFiles :"
513    echo
514
515    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ file_in file_out
516    for comp in ${config_ListOfComponents[*]} ; do
517        # Define component
518        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
519        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
520
521        # Debug Print :
522        IGCM_debug_Print 3 "Parameters ${compname}"
523
524        card=${SUBMIT_DIR}/COMP/${compname}.card       
525
526        IGCM_card_DefineArrayFromOption ${card} ParametersFiles List
527        ListFilesName=${compname}_ParametersFiles_List
528        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
529
530        if [ X${FileName0} != X${NULL_STR} ] ; then
531            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
532
533            typeset i
534            (( i=0 ))
535            until [ $i -ge $NbFiles ]; do
536                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
537                eval file_in=${file_in_}
538                (( i_ = i+1 ))
539                eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
540                eval file_out=${file_out_} 
541
542                IGCM_sys_Cp ${file_in} ${file_out} 
543                IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
544
545                (( i=i+2 ))
546            done
547        fi
548    done
549
550    IGCM_debug_PopStack "IGCM_comp_GetInputParametersFiles"
551}
552
553#=======================================================================
554function IGCM_comp_GetInputRestartFiles
555{
556    IGCM_debug_PushStack "IGCM_comp_GetInputRestartFiles"
557
558    # Debug Print :
559    echo
560    IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles :"
561    echo
562
563    typeset Date_tmp Date_r Path_r do_start CompOldName Path_temp
564    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_
565    typeset file_in file_out file_in_ file_out_ file_in_Name
566    typeset -Z4 j4
567
568    for comp in ${config_ListOfComponents[*]} ; do
569        # Define component
570        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
571        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
572        #
573        card=${SUBMIT_DIR}/COMP/${compname}.card
574        #
575        IGCM_card_DefineArrayFromOption ${card} RestartFiles List
576        ListFilesName=${compname}_RestartFiles_List
577        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
578
579        # Debug Print :
580        IGCM_debug_Print 3 "restart ${compname}"
581
582        if ( ${FirstInitialize} ) ; then
583
584            if [ "${config_Restarts_OverRule}" = "y" ] ; then
585                eval config_${comp}_Restart="y"
586                eval config_${comp}_RestartDate=${config_Restarts_RestartDate}
587                eval config_${comp}_RestartJobName=${config_Restarts_RestartJobName}
588                eval config_${comp}_RestartPath=${config_Restarts_RestartPath}
589                eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1
590                eval CompOldName=${comp}
591            else
592                # Read component Restarts parameters
593                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart
594                eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1
595
596                if [ "${do_start}" = "y" ] ; then
597                    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartDate
598                    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartJobName
599                    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartPath
600                else
601                    eval config_${comp}_RestartDate=-1
602                    eval config_${comp}_RestartJobName=${NULL_STR}
603                    eval config_${comp}_RestartPath=${NULL_STR}
604                fi
605                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} OldName
606                eval CompOldName=\${config_${comp}_OldName}
607                if [ X${CompOldName} = X ] ; then
608                    eval CompOldName=${comp}
609                fi
610            fi
611
612            if [ "${do_start}" = "y" ] ; then
613
614                if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
615                    eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
616
617                    typeset i
618                    (( i=1 ))
619                    until [ $i -gt $NbFiles ]; do
620                        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
621                        eval file_in=${file_in_}
622
623                        (( i_ = i+1 ))
624                        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
625                        eval file_out=${file_out_}
626                       
627                        eval Date_tmp=\${config_${comp}_RestartDate}
628                        Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} )
629                        eval Path_r=\${config_${comp}_RestartPath}/\${config_${comp}_RestartJobName}/${CompOldName}/Restart
630                        eval file_in_Name=\${config_${comp}_RestartJobName}_${Date_r}_${file_in}
631
632                        generic_restart_file_name_in=$( basename ${file_in_Name} .nc )
633                        generic_restart_file_name_out=$( basename ${file_out} .nc )
634                       
635                        eval Path_temp=\${Path_r}/${generic_restart_file_name_in}
636                        nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_temp}_????.nc)
637
638                        if [ ${nb_restart_file} -gt 1 ] ; then
639                            j=0
640                            until [ $j -ge $nb_restart_file ]; do
641                                j4=${j}
642                                eval IGCM_sys_Get ${Path_r}/${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc
643                                #IGCM_comp_PrepareDeletedFiles ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc
644                                #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_out}_${j4}.nc" > /dev/null 2>&1
645                                (( j=j+1 ))
646                            done
647                        else
648                            eval IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out} 
649                            #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
650                        fi
651               
652                        (( i=i+3 ))
653                    done
654                else
655                    if [ X${FileName0} != XNONE ] ; then
656                        IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}."
657                    else
658                        IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}."
659                    fi
660                fi
661            fi
662        elif [ ${Period} -eq 1 ] ; then
663            # if not FirstInitialize and first loop of this job
664
665            # Restore Restarts files
666            #-----------------------
667            if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
668                eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
669
670                typeset i
671                (( i=1 ))
672                until [ $i -gt $NbFiles ]; do
673                    eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
674                    eval file_in=${file_in_}
675                    (( i_ = i+1 ))
676                    eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
677                    eval file_out=${file_out_}
678                   
679                    file_in_Name=${run_Configuration_OldPrefix}_${file_in}
680
681                    generic_restart_file_name_in=$( basename ${file_in_Name} .nc )
682                    generic_restart_file_name_out=$( basename ${file_out} .nc )
683
684                    eval Path_temp=\${R_OUT_${comp}_R}/${generic_restart_file_name_in}
685                    nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_temp}_????.nc)
686
687                    if [ ${nb_restart_file} -gt 1 ] ; then
688                        j=0
689                        until [ $j -ge $nb_restart_file ]; do
690                            j4=${j}
691                            eval IGCM_sys_Get \${R_OUT_${comp}_R}/${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc
692                            #IGCM_comp_PrepareDeletedFiles ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_out}_${j4}.nc
693                            #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_out}_${j4}.nc" > /dev/null 2>&1
694
695                            (( j=j+1 ))
696                        done
697                    else
698                        eval IGCM_sys_Get \${R_OUT_${comp}_R}/${file_in_Name} ${file_out}
699                        #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
700                    fi
701
702                    (( i=i+3 ))
703                done
704            else
705                if [ X${FileName0} != XNONE ] ; then
706                    IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}."
707                else
708                    IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}."
709                fi
710            fi
711        fi
712    done
713    IGCM_sys_Chmod u+rw *
714
715    IGCM_debug_PopStack "IGCM_comp_GetInputRestartFiles"
716}
717
718#=======================================================================
719function IGCM_comp_PeriodStart
720{
721    IGCM_debug_PushStack "IGCM_comp_PeriodStart"
722
723    # Debug Print :
724    echo
725    IGCM_debug_Print 1 "IGCM_comp_PeriodStart :"
726    echo
727
728    typeset ExeNameIn ExeNameOut
729    typeset comp compname comptagname
730    for comp in ${config_ListOfComponents[*]} ; do
731        # Define component
732        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
733        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
734
735        # Copy executable for this component
736        eval ExeNameIn=\${config_Executable_${comp}[0]}
737        eval ExeNameOut=\${config_Executable_${comp}[1]}
738
739        # Debug Print
740        IGCM_debug_Print 3 "PeriodStart ${compname} Driver Function (if any)."
741        # UPDATE component
742        ${comp}_PeriodStart 2> /dev/null
743
744    done
745
746    IGCM_debug_PopStack "IGCM_comp_PeriodStart"
747}
748
749#=======================================================================
750function IGCM_comp_Update
751{
752    IGCM_debug_PushStack "IGCM_comp_Update"
753
754    # Debug Print :
755    echo
756    IGCM_debug_Print 1 "IGCM_comp_Update :"
757    echo
758
759    typeset ExeNameIn ExeNameOut
760    typeset comp compname comptagname
761    for comp in ${config_ListOfComponents[*]} ; do
762        # Define component
763        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
764        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
765
766        # Copy executable for this component
767        eval ExeNameIn=\${config_Executable_${comp}[0]}
768        eval ExeNameOut=\${config_Executable_${comp}[1]}
769
770        # If missing executable then stop!
771        #if [ ! X${ExeNameIn} = X ] && [ ! -f ${R_EXE}/${ExeNameIn} ] ; then
772        #    IGCM_debug_Exit "IGCM_comp_Update missing executable ${ExeNameIn}"
773        #fi
774
775        if [ ${Period} -eq 1 ] && [ -f ${R_EXE}/${ExeNameIn} ] ; then
776            eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut}
777            if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then
778                eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut}
779            fi
780        elif [ -f ${R_EXE}/${ExeNameIn} ] && [ ! -f ${RUN_DIR}/${ExeNameOut} ] ; then
781            eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut}
782            if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then
783                eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut}
784            fi
785        fi
786
787        # Debug Print
788        IGCM_debug_Print 3 "Update ${compname} Parameter Files."
789        # UPDATE component
790        ${comp}_Update
791
792    done
793
794    IGCM_debug_PopStack "IGCM_comp_Update"
795}
796
797#=======================================================================
798function IGCM_comp_Finalize
799{
800    IGCM_debug_PushStack "IGCM_comp_Finalize"
801
802    # Debug Print :
803    echo
804    IGCM_debug_Print 1 "IGCM_comp_Finalize :"
805    echo
806
807    typeset ListTextName TextName0
808    typeset comp compname comptagname card ListFilesName FileName0 NbFiles SaveOnArchive
809    typeset i i_ file_in file_in_ file_out file_out_ file_outin file_outin_ generic_file_name nb_rebuild_file
810    typeset -Z4 j4
811    for comp in ${config_ListOfComponents[*]} ; do
812        # Define component
813        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
814        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
815
816        # Debug Print
817        IGCM_debug_Print 1 "Finalize ${compname} component."
818        # FINALIZE component
819        ${comp}_Finalize
820
821        card=${SUBMIT_DIR}/COMP/${compname}.card       
822
823        # Save Restarts files
824        #--------------------
825        IGCM_card_DefineArrayFromOption ${card} RestartFiles List
826        ListFilesName=${compname}_RestartFiles_List
827        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
828       
829        if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
830            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
831           
832            typeset i
833            (( i=0 ))
834            until [ $i -ge $NbFiles ]; do
835                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
836                eval file_in=${file_in_}
837
838                (( i_ = i+1 ))
839                eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
840                eval file_out=${file_out_}
841
842                (( i_ = i+2 ))
843                eval file_outin_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
844                eval file_outin=${file_outin_}
845
846                generic_restart_file_name_in=$(    basename ${file_in} .nc )
847                generic_restart_file_name_out=$(   basename ${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} .nc )
848                generic_restart_file_name_outin=$( basename ${file_outin} .nc )
849                       
850                nb_restart_file=$( ls ${generic_restart_file_name_in}_????.nc 2>/dev/null | wc -l ) 
851                if [ ${nb_restart_file} -gt 1 ] ; then
852                    j=0
853                    until [ $j -ge $nb_restart_file ]; do
854                        j4=${j}
855                        eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc
856                        if [ ! ${file_in} = ${file_outin} ] ; then
857                            if ( ${ExitFlag} ) ; then
858                                echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed."
859                            else
860                                IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc
861                            fi
862                        fi
863                        #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${generic_restart_file_name_in}_${j4}.nc" > /dev/null 2>&1
864                        (( j=j+1 ))
865                    done
866                else
867                    eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out}
868                    if [ ! ${file_in} = ${file_outin} ] ; then
869                        if ( ${ExitFlag} ) ; then
870                            echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed."
871                        else
872                            IGCM_sys_Mv ${file_in} ${file_outin}
873                        fi
874                    fi
875                    #eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1
876                fi
877
878                (( i=i+3 ))
879            done
880        else
881            if [ X${FileName0} != XNONE ] ; then
882                IGCM_debug_Exit "IGCM_comp_Finalize : No file in restart list for ${compname}."
883            else
884                IGCM_debug_Print 1 "IGCM_comp_Finalize : NONE specified in Restart List ${compname}."
885            fi
886        fi
887
888        # Save Output files
889        #------------------
890        IGCM_card_DefineArrayFromOption ${card} OutputFiles List
891        ListFilesName=${compname}_OutputFiles_List
892        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
893
894        if [ X${FileName0} != X${NULL_STR} ] ; then
895            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
896
897            typeset i
898            (( i=0 ))
899            until [ $i -ge $NbFiles ]; do
900                SaveOnArchive=true
901                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
902                eval file_in=${file_in_}
903                (( i_ = i+1 ))
904                eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
905                eval file_out=${file_out_}
906                (( i_ = i+2 ))
907                eval flag_post=\${${ListFilesName}[$i_]} > /dev/null 2>&1
908                #
909                generic_file_name=$( basename ${file_in} .nc )
910                nb_rebuild_file=$( ls | grep "^${generic_file_name}_[0-9]*.nc" | wc -l )
911                #
912                if ( [ ${nb_rebuild_file} -eq 1 ] && [ -f ${generic_file_name}_0000.nc ] ) ; then
913                    IGCM_debug_Print 2 "Parallelism with 1 process. Rebuilding ${file_in} not needed"
914                    IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in}
915                elif [ ${nb_rebuild_file} -gt 1 ] ; then
916                    IGCM_debug_Print 2 "Parallelism detected rebuilding ${file_in} is needed"
917                    if ( [ X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ X${config_Post_RebuildFrequency} = XNONE ] ) ; then
918                        IGCM_debug_Print 2 "Rebuilding ${file_in} online"
919                        IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc
920                    else
921                        IGCM_debug_Print 2 "Preparing offline rebuild for ${file_in}"
922                        [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin}
923                        IGCM_sys_Mv ${generic_file_name}_????.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin}
924
925                        # Prepare headers for the shell dedicated to offline rebuild
926                        if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then
927                            if [ $DRYRUN -le 1 ]; then
928                            echo "#!/bin/ksh                                          " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
929                            echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
930                            echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
931                            echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
932                            echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
933                            echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
934                            echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
935                            fi
936                        fi
937                        # Prepare the shell dedicated to offline rebuild
938                        if [ $DRYRUN -le 1 ]; then
939                            echo "IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
940                            echo "IGCM_debug_Verif_Exit                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
941                        fi
942                        #
943                        # Load Patch we need to apply and apply
944                        if [ $DRYRUN -le 1 ]; then
945                            if [ X$( eval echo \${${compname}_${flag_post}_Patches[0]} ) !=  X${NULL_STR} ]; then
946                                for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do
947                                    echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
948                                    echo "IGCM_${Patch} ${file_in}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
949                                done
950                            fi
951                        fi
952                        #
953                        if [ $DRYRUN -le 1 ]; then
954                            echo "IGCM_sys_Put_Out ${file_in} ${file_out}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
955                            echo "IGCM_debug_Verif_Exit                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
956                            echo "IGCM_sys_Rm ${generic_file_name}_*.nc                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
957                        fi
958                        SaveOnArchive=false
959                    fi
960                fi
961                #
962                if [ ${SaveOnArchive} = true ] ; then
963                    #
964                    # If we need to apply a patch we use TMP DIRECTORY before ARCHIVING if asynchronous rebuild is on
965                    #
966                    thereisapatch=$( eval echo \${${compname}_${flag_post}_Patches[0]} )
967                   
968                    if ( [ ! X${thereisapatch} =  X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = X ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
969                        if [ -f ${file_in} ] ; then
970                            [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin}
971
972                            IGCM_sys_Mv ${file_in} ${RUN_DIR}/REBUILD_${PeriodDateBegin}
973                            eval FileToBeDeleted[${#FileToBeDeleted[@]}]=REBUILD_${PeriodDateBegin}/${file_in} > /dev/null 2>&1
974                            #
975                            if [ $DRYRUN -le 1 ]; then
976                                if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then
977                                    echo "#!/bin/ksh                                          " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
978                                    echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
979                                    echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
980                                    echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
981                                    echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
982                                    echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
983                                    echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
984                                fi
985                                #
986                                for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do
987                                    echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
988                                    echo "IGCM_${Patch} ${file_in}                            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
989                                done
990                                #
991                                echo "IGCM_sys_Put_Out ${file_in} ${file_out}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
992                                echo "IGCM_debug_Verif_Exit                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
993                                #
994                            fi
995                        fi
996                    else
997                        [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin}
998                        if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then
999                            echo "#!/bin/ksh                                          " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1000                            echo "function IGCM_FlushRebuild                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1001                            echo "{                                                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1002                            echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\"          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1003                            echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1004                            echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\"            " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1005                            echo "echo                                                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
1006                        fi
1007
1008                        IGCM_sys_Put_Out ${file_in} ${file_out}
1009                        [ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1
1010                        if [ ${nb_rebuild_file} -gt 1 ] ; then
1011                            for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do
1012                                eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1
1013                            done
1014                        fi
1015                    fi
1016                fi
1017                (( i=i+3 ))
1018            done
1019        fi
1020
1021        # Save Output Text files of models
1022        #---------------------------------
1023       
1024        IGCM_card_DefineArrayFromOption ${card} OutputText List
1025        ListTextName=${compname}_OutputText_List
1026       
1027        eval TextName0=\${${ListTextName}[0]} > /dev/null 2>&1
1028        if [ X${TextName0} != X${NULL_STR} ] ; then
1029            eval NbFiles=\${#${ListTextName}[@]} > /dev/null 2>&1
1030
1031            typeset i
1032            (( i=0 ))
1033            until [ $i -eq $NbFiles ]; do
1034                eval file_in=\${${ListTextName}[$i]} > /dev/null 2>&1
1035                (( i=i+1 ))
1036
1037                nb_text_file=$( ls ${file_in}* 2>/dev/null | wc -l )
1038                if [ ${nb_text_file} -gt 1 ] ; then
1039                    list_file=$( ls ${file_in}* )
1040                    for file in ${list_file}
1041                      do
1042                      eval IGCM_sys_Put_Out ${file} \${R_OUT_${comp}_D}/${PREFIX}_${file}
1043                      eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1
1044                    done
1045                else
1046                    if ( [ -f ${file_in}_0000 ] || [ -f ${file_in}0 ] ) ; then
1047                        eval IGCM_sys_Mv ${file_in}* ${file_in}
1048                    fi
1049                    eval IGCM_sys_Put_Out ${file_in} \${R_OUT_${comp}_D}/${PREFIX}_${file_in}
1050                    [ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1
1051                fi
1052            done
1053        fi
1054    done
1055
1056    IGCM_debug_PopStack "IGCM_comp_Finalize"
1057}
Note: See TracBrowser for help on using the repository browser.