source: trunk/libIGCM/libIGCM_post/libIGCM_post.ksh @ 157

Last change on this file since 157 was 157, checked in by sdipsl, 15 years ago
  • RebuildFromWorkdir? is back. Will use BIG_DIR as temp storage directory
    • ideally RUN_DIR_PATH and BIG_DIR are on the same filesystem (mv REBUILD_DIR BIG_DIR)
    • save lot of time between iteration for IO intensive simulation up to 3 minutes by iteration for CMIP5 like IO.
  • rebuild.ksh will be usable as it is (in case you need to run it by hand)
  • clean Up : if rebuild run smoothly we clean everything (either FromArchive? or FromWorkdir?)
  • Watch your quota on the BIG_DIR (SCRATCHDIR OR WORKDIR depending on machine) before you play with that.
  • 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: 33.9 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
5# Contact: Sebastien.Denvil@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
18function IGCM_post_Configure
19{
20    IGCM_debug_PushStack "IGCM_post_Configure"
21
22    # Debug Print :
23    echo
24    IGCM_debug_Print 1 "IGCM_post_Configure :"
25    echo
26
27    typeset NbDays PeriodEndJul PostEndJul PeriodPost
28    RebuildFrequency=false
29
30    if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
31
32        IGCM_debug_Print 1 "Asynchronous rebuild has been activated."
33        echo
34
35        case ${config_Post_RebuildFrequency} in
36            *y|*Y)
37                PeriodYear=$( echo ${config_Post_RebuildFrequency} | sed -e "s/[yY]//" )
38                case ${config_UserChoices_PeriodLength} in
39                    *Y|*y)
40                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[yY]//" )
41                        if [ ${PeriodPost} -le ${PeriodYear} ] ; then
42                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodYear}  ) -eq 0 ] ;  then
43                                RebuildFrequency=true
44                                NbRebuildDir=$( expr ${PeriodYear} / ${PeriodPost} )
45                            fi
46                        else
47                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
48                            IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}"
49                        fi ;;
50                    *M|*m)
51                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
52                        if [ ${PeriodPost} -le $(( ${PeriodYear} * 12 )) ] ; then
53                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then
54                                RebuildFrequency=true
55                                NbRebuildDir=$( expr $(( 12 * ${PeriodYear} )) / ${PeriodPost} )
56                            fi
57                        else
58                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
59                            IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}"
60                        fi ;;
61                    *D|*d)
62                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
63                        NbDays=$( IGCM_date_DaysInYear ${year} )
64                        if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
65                            if [ ${PeriodPost} -le $(( ${PeriodYear} * ${NbDays} )) ] ; then
66                                if [ $( expr ${CumulPeriod} % $( expr \( ${NbDays} \* ${PeriodYear} \/ ${PeriodPost} \) ) ) -eq 0 ] ; then
67                                    RebuildFrequency=true
68                                    NbRebuildDir=$( expr $(( ${NbDays} * ${PeriodYear} )) / ${PeriodPost} )
69                                fi
70                            else
71                                IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
72                                IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}"
73                            fi
74                        else
75#                           if [ ${PeriodYear} -eq 1 ] ; then
76#                               PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
77#                               PostEndJul=${year}${NbDays}
78#                               #echo "PeriodYear=${PeriodYear} NbDays=${NbDays}"
79#                               #echo "PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
80#                               if [ ${PostEndJul} -eq ${PeriodEndJul} ] ; then
81#                                   RebuildFrequency=true
82#                                   NbRebuildDir=$( expr ${NbDays} / ${PeriodPost} )
83#                               fi
84#                           else
85                            IGCM_debug_Print 3 "For RebuildFrequency with leap calendar:"
86                            IGCM_debug_Print 3 "We have a daily PeriodLength frequency and RebuildFrequency=${PeriodYear}Y."
87                            IGCM_debug_Print 3 "No post-treatment. Case not properly handle at this moment."
88#                           fi
89                        fi;;
90                esac ;;
91            *M|*m)
92                PeriodMonth=$( echo ${config_Post_RebuildFrequency} | sed -e "s/[mM]//" )
93                case ${config_UserChoices_PeriodLength} in
94                    *Y|*y)
95                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
96                        IGCM_debug_Print 3 "RebuildFrequency frequency ${config_Post_RebuildFrequency}" ;;
97                    *M|*m)
98                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
99                        if [ ${PeriodPost} -le ${PeriodMonth} ] ; then
100                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodMonth}  ) -eq 0 ] ;  then
101                                RebuildFrequency=true
102                                NbRebuildDir=$( expr ${PeriodMonth} / ${PeriodPost} )
103                            fi
104                        else
105                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
106                            IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}"
107                        fi ;;
108                    *D|*d)
109                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
110                        IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}" ;;
111                esac
112                ;;
113            *D|*d)
114                PeriodDay=$( echo ${config_Post_RebuildFrequency} | sed -e "s/[dD]//" )
115                case ${config_UserChoices_PeriodLength} in
116                    *Y|*y)
117                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
118                        IGCM_debug_Print 3 "RebuildFrequency frequency ${config_Post_RebuildFrequency}" ;;
119                    *M|*m)
120                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
121                        IGCM_debug_Print 3 "RebuildFrequency frequency ${config_Post_RebuildFrequency}" ;;
122                    *D|*d)
123                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
124                        if [ ${PeriodPost} -le ${PeriodDay} ] ; then
125                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodDay}  ) -eq 0 ] ;  then
126                                RebuildFrequency=true
127                                NbRebuildDir=$( expr ${PeriodDay} / ${PeriodPost} )
128                            fi
129                        else
130                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
131                            IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}"
132                        fi ;;
133
134                esac
135                ;;
136            NONE|none)
137                ;;
138            *)
139                IGCM_debug_Print 3 "KeyWord not allowed for RebuildFrequency in config.card"
140                ;;
141        esac
142    else
143        #
144        IGCM_debug_Print 1 "Asynchronous rebuild has not been activated"
145        IGCM_debug_Print 1 "Proceed with standard post-treatment pathway"
146        echo
147        #
148    fi
149
150    IGCM_debug_Print 1 "RebuildFrequency flag value : ${RebuildFrequency}"
151    IGCM_post_Initialize
152
153    IGCM_debug_PopStack "IGCM_post_Configure"
154}
155
156function IGCM_post_Initialize
157{
158    IGCM_debug_PushStack "IGCM_post_Initialize"
159
160    # Debug Print :
161    echo
162    IGCM_debug_Print 1 "IGCM_post_Initialize :"
163    echo
164
165    typeset POST NbDays PeriodEndJul PostEndJul LengthDays
166    POST=false
167
168    #==================================
169    # Define variable ${config_Post_${post_freq}}
170    # who contains frequency for specific post-treatment
171    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post
172
173    for option in ${config_Post[*]} ; do
174        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option}
175    done
176
177    # READ TIME SERIES OR SEASONAL FREQUENCY
178    # AND TURN ON THE FLAG WHEN MODULO IS ZERO
179    for post_freq in TimeSeriesFrequency SeasonalFrequency ; do
180        #
181        # Initialize
182        #
183        eval ${post_freq}=false
184        #
185        # Extract frequency from previously defined variable
186        #
187        config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} )
188        #
189        # Offset for Seasonal Average starting period
190        #
191        if [ ${post_freq} = SeasonalFrequency ] ; then
192            if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
193                PeriodOffset=0
194            else
195                PeriodOffset=${config_Post_SeasonalFrequencyOffset}
196            fi
197        else
198            PeriodOffset=0
199        fi
200        #
201        if ( [ X${config_Post_post_freq} = X${NULL_STR} ] || [ X${config_Post_post_freq} = XNONE ] ) ; then
202            #
203            continue
204            #
205        fi
206        #
207        # For each componant select determine which files need post-processing
208        #
209        for comp in ${config_ListOfComponents[*]} ; do
210            #
211            #echo "-----"
212            eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
213            ListFilesName=${compname}_OutputFiles_List
214            eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
215            #
216            if [ X${FileName0} != X${NULL_STR} ] ; then
217                #
218                #IGCM_debug_Print 1 "Component      : ${compname}"
219                #
220                # INITIALISATION
221                #
222                eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
223                typeset i=0
224                #
225                until [ $i -eq $NbFiles ]; do
226                    #
227                    eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
228                    eval file_in=${file_in_}
229                    let $(( i_ = i+2 ))
230                    eval flag_post_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
231                    eval flag_post=${flag_post_}
232                    #
233                    if [ X${flag_post} != XNONE ] ; then
234                    #
235                        case ${config_Post_post_freq} in
236                            *y|*Y)
237                                PeriodYear=$( echo ${config_Post_post_freq} | sed -e "s/[yY]//" )
238                                #
239                                case ${config_UserChoices_PeriodLength} in
240                                    *Y|*y)
241                                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[yY]//" )
242                                        if [ ${PeriodPost} -le ${PeriodYear} ] ; then
243                                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) % ${PeriodYear} ) -eq 0 ] ;  then
244                                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && eval ${post_freq}=true
245                                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && POST=true
246                                            fi
247                                        else
248                                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
249                                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
250                                        fi ;;
251                                    *M|*m)
252                                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
253                                        if [ ${PeriodPost} -le $(( ${PeriodYear} * 12 )) ] ; then
254                                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} * 12 )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then
255                                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} * 12 )) -ne 0 ] && eval ${post_freq}=true
256                                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} * 12 )) -ne 0 ] && POST=true
257                                            fi
258                                        else
259                                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
260                                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
261                                        fi ;;
262                                    *D|*d)
263                                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
264                                        NbDays=$( IGCM_date_DaysInYear ${year} )
265                                        if [ ${config_UserChoices_CalendarType} = 360d ] | [ ${config_UserChoices_CalendarType} = noleap ] ; then
266                                            if [ ${PeriodPost} -le $(( ${PeriodYear} * ${NbDays} )) ] ; then
267                                                if [ $( expr $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodPost} ) )) % \
268                                                     $(( ${NbDays} * ${PeriodYear} / ${PeriodPost} )) ) -eq 0 ] ; then
269                                                    [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodPost} ) )) -ne 0 ] && eval ${post_freq}=true
270                                                    [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodPost} ) )) -ne 0 ] POST=true
271                                                fi
272                                            else
273                                                IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
274                                                IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
275                                            fi
276                                        else
277#                                           if [ ${PeriodYear} -eq 1 ] ; then
278#                                               PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
279#                                               PostEndJul=${year}${NbDays}
280#                                                #echo "PeriodYear=${PeriodYear} NbDays=${NbDays}"
281#                                               #echo PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
282#                                               if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then
283#                                                   eval ${post_freq}=true
284#                                                   POST=true
285#                                               fi
286#                                           else
287                                            IGCM_debug_Print 3 "For ${post_freq} with leap calendar, for ${comp} and ${file_in} :"
288                                            IGCM_debug_Print 3 "We have a daily PeriodLength frequency and RebuildFrequency=${PeriodYear}Y."
289                                            IGCM_debug_Print 3 "No post-treatment. Case not properly handle at this moment."
290#                                           fi
291                                        fi;;
292                                esac ;;
293                            *M|*m)
294                                PeriodMonth=$( echo ${config_Post_post_freq} | sed -e "s/[mM]//" )
295                                case ${config_UserChoices_PeriodLength} in
296                                    *Y|*y)
297                                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
298                                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
299                                    *M|*m)
300                                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
301                                        if [ ${PeriodPost} -le ${PeriodMonth} ] ; then
302                                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} -  ${PeriodOffset} )) % ${PeriodMonth}  ) -eq 0 ] ;  then
303                                                [ $(( ${CumulPeriod} * ${PeriodPost} -  ${PeriodOffset} )) -ne 0 ] && eval ${post_freq}=true
304                                                [ $(( ${CumulPeriod} * ${PeriodPost} -  ${PeriodOffset} )) -ne 0 ] && POST=true
305                                            fi
306                                        else
307                                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
308                                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
309                                        fi;;
310                                    *D|*d)
311                                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
312                                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
313                                esac ;;
314                            *D|*d)
315                                PeriodDay=$( echo ${config_Post_post_freq} | sed -e "s/[dD]//" )
316                                case ${config_UserChoices_PeriodLength} in
317                                    *Y|*y)
318                                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
319                                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
320                                    *M|*m)
321                                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
322                                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
323                                    *D|*d)
324                                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
325                                        if [ ${PeriodPost} -le ${PeriodDay} ] ; then
326                                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) % ${PeriodDay}  ) -eq 0 ] ;  then
327                                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && eval ${post_freq}=true
328                                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && POST=true
329                                            fi
330                                        else
331                                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
332                                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
333                                        fi;;
334                                esac ;;
335                            NONE|none)
336                                ;;
337                            *)
338                                IGCM_debug_Print 3 "KeyWord not allowed for ${post_freq} in config.card"
339                                ;;
340                        esac
341                    fi
342                    let $(( i=i+3 ))
343                done
344            fi
345        done
346    done
347    #
348    if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \
349         [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]        && \
350         [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
351        TimeSeriesFrequency=true
352        POST=true
353    fi
354
355    if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && \
356         [ ! X${config_Post_RebuildFrequency} = XNONE ]        && \
357         [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
358        RebuildFrequency=true
359        POST=true
360    fi
361
362    #
363    IGCM_debug_Print 1 "POST-TREATEMENT flag value : ${POST}"
364    #
365    IGCM_post_Submit
366
367    IGCM_debug_PopStack "IGCM_post_Initialize"
368}
369
370function IGCM_post_Submit
371{
372    IGCM_debug_PushStack "IGCM_post_Submit"
373
374    POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
375
376    if [ ${POST} = true ]; then
377        echo
378        IGCM_debug_Print 1 "IGCM_post_Submit :"
379        echo
380        IGCM_debug_Print 1 "POST_DIR = ${POST_DIR}"
381    fi
382
383    #============ TIME SERIES POST-TREATMENT ===========#
384    if [ ${TimeSeriesFrequency} = true ] ; then
385
386        set -vx
387        IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ACTIVATED :"
388        echo
389
390
391
392        # Get information from last execution
393        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
394        CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
395        #
396
397
398
399        typeset listVarEnv
400        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,CompletedFlag,TsTask,CompToRead,FlagToRead,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
401        #
402        jLoop=${#ListDimension[*]}
403        j=0
404        until [ $j -ge ${jLoop} ]; do
405            Dimension=${ListDimension[${j}]}
406            #
407            if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then
408                #
409                IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED :"
410                echo
411                #
412                TsTask=${Dimension}
413                #
414                if [ ${RebuildFrequency} = true ] ; then
415                    #
416                    echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
417                    echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
418                    echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
419                    echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
420                    echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
421                    echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
422                    echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
423                    echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
424                    echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
425                    echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
426                    echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
427                    echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
428                    echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
429                    echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
430                    echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
431                    echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
432                    echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
433                    echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
434                    echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
435                    echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
436                    echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
437                    #
438                else
439                    #
440                    IGCM_sys_RshPost <<-EOF
441                    export DEBUG_debug=${DEBUG_debug}
442                    export MODIPSL=${MODIPSL}
443                    export libIGCM_SX=${libIGCM}
444                    export libIGCM=${libIGCM_POST}
445                    export SUBMIT_DIR=${SUBMIT_DIR}
446                    export POST_DIR=${POST_DIR}
447                    export MASTER=${MASTER}
448                    export RebuildFrequency=${RebuildFrequency}
449                    export DateBegin=${DateBegin}
450                    export PeriodDateEnd=${PeriodDateEnd}
451                    export StandAlone=false
452                    export CompletedFlag=${CompletedFlag}
453                    export TsTask=${TsTask}
454                    export RESOL_ATM=${RESOL_ATM}
455                    export RESOL_OCE=${RESOL_OCE}
456                    export RESOL_ICE=${RESOL_ICE}
457                    export RESOL_SRF=${RESOL_SRF}
458                    export listVarEnv=${listVarEnv}
459                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
460                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
461                    IGCM_sys_MkdirWork ${POST_DIR}
462                    IGCM_debug_Verif_Exit
463                    IGCM_sys_QsubPost create_ts
464EOF
465                fi
466            fi
467            #
468            if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
469                #
470                IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED :"
471                echo
472                # Need to Remember This One
473                SavedDateBegin=${DateBegin}
474                # Kind of task create_ts will perform
475                TsTask=Chunck${Dimension}
476                # Number of chunck jobs to configure and submit
477                eval NbJob=\${#CHUNCK${Dimension}_COMP[@]}
478                i=0
479                until [ $i -ge $NbJob ]; do
480                    CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
481                    FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
482                    ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} )
483                    # Chunck Length (mandatory in Year)
484                    YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" )
485                    #
486                    IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin
487                    #
488                    IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd
489                    # How many chunck in total since simulation began
490                    NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} ))
491                    #  Tweak special case
492                    [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
493                    # Starting Year of the current chunck
494                    ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} ))
495                    # Starting date of the current chunck
496                    ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
497                    #
498                    if [ ${RebuildFrequency} = true ] ; then
499                        #
500                        echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
501                        echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
502                        echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
503                        echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
504                        echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
505                        echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
506                        echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
507                        echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
508                        echo export DateBegin=${ChunckTsDateBegin}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
509                        echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
510                        echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
511                        echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
512                        echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
513                        echo export CompToRead=${CompToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
514                        echo export FlagToRead=${FlagToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
515                        echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
516                        echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
517                        echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
518                        echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
519                        echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
520                        echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
521                        echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
522                        echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
523                        #
524                    else
525                        #
526                        IGCM_sys_RshPost <<-EOF
527                        export DEBUG_debug=${DEBUG_debug}
528                        export MODIPSL=${MODIPSL}
529                        export libIGCM_SX=${libIGCM}
530                        export libIGCM=${libIGCM_POST}
531                        export SUBMIT_DIR=${SUBMIT_DIR}
532                        export POST_DIR=${POST_DIR}
533                        export MASTER=${MASTER}
534                        export RebuildFrequency=${RebuildFrequency}
535                        export DateBegin=${ChunckTsDateBegin}
536                        export PeriodDateEnd=${PeriodDateEnd}
537                        export StandAlone=false
538                        export CompletedFlag=${CompletedFlag}
539                        export TsTask=${TsTask}
540                        export CompToRead=${CompToRead}
541                        export FlagToRead=${FlagToRead}
542                        export RESOL_ATM=${RESOL_ATM}
543                        export RESOL_OCE=${RESOL_OCE}
544                        export RESOL_ICE=${RESOL_ICE}
545                        export RESOL_SRF=${RESOL_SRF}
546                        export listVarEnv=${listVarEnv}
547                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
548                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
549                        IGCM_sys_MkdirWork ${POST_DIR}
550                        IGCM_debug_Verif_Exit
551                        IGCM_sys_QsubPost create_ts
552EOF
553                        #
554                    fi
555                    #
556                    export DateBegin=${SavedDateBegin}
557                    #
558                    (( i=i+1 ))
559                    #
560                done
561            fi
562            (( j=j+1 ))
563        done
564    fi
565    set +vx
566
567    #=============  SEASONAL POST-TREATMENT ============#
568    if [ ${SeasonalFrequency} = true ] ; then
569        #
570        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
571        echo
572        #
573        typeset listVarEnv
574        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
575
576        if [ ${RebuildFrequency} = true ] ; then
577            #
578            echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
579            echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
580            echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
581            echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
582            echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
583            echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
584            echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
585            echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
586            echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
587            echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
588            echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
589            echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
590            echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
591            echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
592            echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
593            echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
594            echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
595            echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
596            echo IGCM_sys_QsubPost create_se                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
597            #
598        else
599            #
600            IGCM_sys_RshPost <<-EOF
601            export DEBUG_debug=${DEBUG_debug}
602            export MODIPSL=${MODIPSL}
603            export libIGCM_SX=${libIGCM}
604            export libIGCM=${libIGCM_POST}
605            export SUBMIT_DIR=${SUBMIT_DIR}
606            export POST_DIR=${POST_DIR}
607            export MASTER=${MASTER}
608            export RebuildFrequency=${RebuildFrequency}
609            export DateBegin=${DateBegin}
610            export PeriodDateEnd=${PeriodDateEnd}
611            export StandAlone=false
612            export RESOL_ATM=${RESOL_ATM}
613            export RESOL_OCE=${RESOL_OCE}
614            export RESOL_ICE=${RESOL_ICE}
615            export RESOL_SRF=${RESOL_SRF}
616            export listVarEnv=${listVarEnv}
617            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
618            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
619            IGCM_sys_MkdirWork ${POST_DIR}
620            IGCM_debug_Verif_Exit
621            IGCM_sys_QsubPost create_se
622EOF
623        #
624        fi
625    fi
626
627    #============== REBUILD POST-TREATMENT =============#
628    if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
629        # -----------------------------------------------------------------------------------
630        # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
631        # -----------------------------------------------------------------------------------
632        echo IGCM_debug_PopStack "IGCM_FlushRebuild" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
633        echo }                                       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
634        if [ ${config_Post_RebuildFromArchive} = true ] ; then
635            IGCM_sys_Put_Dir REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
636        else
637            IGCM_sys_Mv      REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
638        fi
639    fi
640    #
641    if [ ${RebuildFrequency} = true ] ; then
642        #
643        if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then
644            #
645            IGCM_debug_Print 2 "REBUILD POST-TREATMENT FROM ARCHIVE:"
646            echo
647            #
648            typeset listVarEnv
649            listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
650            IGCM_sys_RshPost <<-EOF
651            export DEBUG_debug=${DEBUG_debug}
652            export MODIPSL=${MODIPSL}
653            export libIGCM_SX=${libIGCM}
654            export libIGCM=${libIGCM_POST}
655            export SUBMIT_DIR=${SUBMIT_DIR}
656            export REBUILD_DIR=${REBUILD_DIR}
657            export POST_DIR=${POST_DIR}
658            export DateBegin=${DateBegin}
659            export PeriodDateBegin=${PeriodDateBegin}
660            export PeriodDateEnd=${PeriodDateEnd}
661            export NbRebuildDir=${NbRebuildDir}
662            export StandAlone=false
663            export RESOL_ATM=${RESOL_ATM}
664            export RESOL_OCE=${RESOL_OCE}
665            export RESOL_ICE=${RESOL_ICE}
666            export RESOL_SRF=${RESOL_SRF}
667            export listVarEnv=${listVarEnv}
668            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
669            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
670            IGCM_sys_MkdirWork ${POST_DIR}
671            IGCM_debug_Verif_Exit
672            IGCM_sys_QsubPost rebuild_fromArchive
673EOF
674        else
675            #
676            IGCM_debug_Print 2 "REBUILD POST-TREATMENT FROM WORKDIR:"
677            echo
678            #
679            typeset listVarEnv
680            listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
681            IGCM_sys_RshPost <<-EOF
682            export DEBUG_debug=${DEBUG_debug}
683            export MODIPSL=${MODIPSL}
684            export libIGCM_SX=${libIGCM}
685            export libIGCM=${libIGCM}
686            export SUBMIT_DIR=${SUBMIT_DIR}
687            export REBUILD_DIR=${REBUILD_DIR}
688            export POST_DIR=${libIGCM}
689            export DateBegin=${DateBegin}
690            export PeriodDateBegin=${PeriodDateBegin}
691            export PeriodDateEnd=${PeriodDateEnd}
692            export NbRebuildDir=${NbRebuildDir}
693            export StandAlone=false
694            export RESOL_ATM=${RESOL_ATM}
695            export RESOL_OCE=${RESOL_OCE}
696            export RESOL_ICE=${RESOL_ICE}
697            export RESOL_SRF=${RESOL_SRF}
698            export listVarEnv=${listVarEnv}
699            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
700            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
701            IGCM_sys_MkdirWork ${POST_DIR}
702            IGCM_debug_Verif_Exit
703            IGCM_sys_QsubPost rebuild_fromWorkdir
704EOF
705        fi
706    fi
707
708    IGCM_debug_PopStack "IGCM_post_Submit"
709}
Note: See TracBrowser for help on using the repository browser.