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

Last change on this file since 239 was 239, checked in by sdipsl, 14 years ago
  • Hopefully the last step towards backward compatibilty
  • 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: 35.3 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    #
167    # Initialize
168    #
169    POST=false
170    TimeSeriesFrequency=false
171    SeasonalFrequency=false
172    #
173    # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS
174    #
175    if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] ) ; then
176        list_post=TimeSeriesFrequency
177    fi
178    #
179    if [ X${Seasonal} = Xtrue ] ; then
180        list_post="${list_post} SeasonalFrequency"
181    fi
182    #
183    # READ TIME SERIES OR SEASONAL FREQUENCY
184    # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO
185    #
186    for post_freq in ${list_post} ; do
187        #
188        # Extract frequency from previously defined variable
189        #
190        config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} )
191        #
192        # Offset for Seasonal Average starting period
193        #
194        if [ ${post_freq} = SeasonalFrequency ] ; then
195            if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
196                PeriodOffset=0
197            else
198                PeriodOffset=${config_Post_SeasonalFrequencyOffset}
199            fi
200        else
201            PeriodOffset=0
202        fi
203        #
204        if ( [ X${config_Post_post_freq} = X${NULL_STR} ] || [ X${config_Post_post_freq} = XNONE ] ) ; then
205            #
206            continue
207            #
208        fi
209        #
210        case ${config_Post_post_freq} in
211            *y|*Y)
212                PeriodYear=$( echo ${config_Post_post_freq} | sed -e "s/[yY]//" )
213                #
214                case ${config_UserChoices_PeriodLength} in
215                    *Y|*y)
216                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[yY]//" )
217                        if [ ${PeriodPost} -le ${PeriodYear} ] ; then
218                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) % ${PeriodYear} ) -eq 0 ] ;  then
219                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && eval ${post_freq}=true
220                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && POST=true
221                            fi
222                        else
223                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
224                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
225                        fi ;;
226                    *M|*m)
227                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
228                        if [ ${PeriodPost} -le $(( ${PeriodYear} * 12 )) ] ; then
229                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} * 12 )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then
230                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} * 12 )) -ne 0 ] && eval ${post_freq}=true
231                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} * 12 )) -ne 0 ] && POST=true
232                            fi
233                        else
234                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
235                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
236                        fi ;;
237                    *D|*d)
238                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
239                        NbDays=$( IGCM_date_DaysInYear ${year} )
240                        if [ ${config_UserChoices_CalendarType} = 360d ] | [ ${config_UserChoices_CalendarType} = noleap ] ; then
241                            if [ ${PeriodPost} -le $(( ${PeriodYear} * ${NbDays} )) ] ; then
242                                if [ $( expr $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodPost} ) )) % \
243                                    $(( ${NbDays} * ${PeriodYear} / ${PeriodPost} )) ) -eq 0 ] ; then
244                                    [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodPost} ) )) -ne 0 ] && eval ${post_freq}=true
245                                    [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodPost} ) )) -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                        else
252#                                           if [ ${PeriodYear} -eq 1 ] ; then
253#                                               PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
254#                                               PostEndJul=${year}${NbDays}
255#                                                #echo "PeriodYear=${PeriodYear} NbDays=${NbDays}"
256#                                               #echo PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
257#                                               if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then
258#                                                   eval ${post_freq}=true
259#                                                   POST=true
260#                                               fi
261#                                           else
262                            IGCM_debug_Print 3 "For ${post_freq} with leap calendar, for ${comp} and ${file_in} :"
263                            IGCM_debug_Print 3 "We have a daily PeriodLength frequency and RebuildFrequency=${PeriodYear}Y."
264                            IGCM_debug_Print 3 "No post-treatment. Case not properly handle at this moment."
265#                                           fi
266                        fi;;
267                esac ;;
268            *M|*m)
269                PeriodMonth=$( echo ${config_Post_post_freq} | sed -e "s/[mM]//" )
270                case ${config_UserChoices_PeriodLength} in
271                    *Y|*y)
272                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
273                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
274                    *M|*m)
275                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
276                        if [ ${PeriodPost} -le ${PeriodMonth} ] ; then
277                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} -  ${PeriodOffset} )) % ${PeriodMonth}  ) -eq 0 ] ;  then
278                                [ $(( ${CumulPeriod} * ${PeriodPost} -  ${PeriodOffset} )) -ne 0 ] && eval ${post_freq}=true
279                                [ $(( ${CumulPeriod} * ${PeriodPost} -  ${PeriodOffset} )) -ne 0 ] && POST=true
280                            fi
281                        else
282                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
283                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
284                        fi;;
285                    *D|*d)
286                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
287                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
288                esac ;;
289            *D|*d)
290                PeriodDay=$( echo ${config_Post_post_freq} | sed -e "s/[dD]//" )
291                case ${config_UserChoices_PeriodLength} in
292                    *Y|*y)
293                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
294                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
295                    *M|*m)
296                        IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
297                        IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;;
298                    *D|*d)
299                        PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
300                        if [ ${PeriodPost} -le ${PeriodDay} ] ; then
301                            if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) % ${PeriodDay}  ) -eq 0 ] ;  then
302                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && eval ${post_freq}=true
303                                [ $(( ${CumulPeriod} * ${PeriodPost} - ${PeriodOffset} )) -ne 0 ] && POST=true
304                            fi
305                        else
306                            IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with"
307                            IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} "
308                        fi;;
309                esac ;;
310            NONE|none)
311                ;;
312            *)
313                IGCM_debug_Print 3 "KeyWord not allowed for ${post_freq} in config.card"
314                ;;
315        esac
316    done
317    #
318    if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \
319         [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]        && \
320         [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
321        TimeSeriesFrequency=true
322        POST=true
323    fi
324
325    if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && \
326         [ ! X${config_Post_RebuildFrequency} = XNONE ]        && \
327         [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
328        RebuildFrequency=true
329        POST=true
330    fi
331
332    #
333    IGCM_debug_Print 1 "POST-TREATEMENT flag value : ${POST}"
334    #
335    IGCM_post_Submit
336
337    IGCM_debug_PopStack "IGCM_post_Initialize"
338}
339
340function IGCM_post_Submit
341{
342    IGCM_debug_PushStack "IGCM_post_Submit"
343
344    POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
345
346    if [ ${POST} = true ]; then
347        echo
348        IGCM_debug_Print 1 "IGCM_post_Submit :"
349        echo
350        IGCM_debug_Print 1 "POST_DIR = ${POST_DIR}"
351    fi
352
353    #============ TIME SERIES POST-TREATMENT ===========#
354    if [ ${TimeSeriesFrequency} = true ] ; then
355
356        IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ACTIVATED :"
357        echo
358
359
360
361        # Get information from last execution
362        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
363        CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
364        #
365
366
367
368        typeset listVarEnv
369        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_MBG,RESOL_SRF,RESOL_BIOS,config_UserChoices_JobName,R_SAVE"
370        #
371        jLoop=${#ListDimension[*]}
372        j=0
373        until [ $j -ge ${jLoop} ]; do
374            Dimension=${ListDimension[${j}]}
375            #
376            if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then
377                #
378                IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED :"
379                echo
380                #
381                TsTask=${Dimension}
382                #
383                if [ ${RebuildFrequency} = true ] && [ ${DRYRUN} -le 1 ] ; then
384                    #
385                    echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
386                    echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
387                    echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
388                    echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
389                    echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
390                    echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
391                    echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
392                    echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
393                    echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
394                    echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
395                    echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
396                    echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
397                    echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
398                    echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
399                    echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
400                    echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
401                    echo export RESOL_MBG=${RESOL_MBG}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
402                    echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
403                    echo export RESOL_BIOS=${RESOL_BIOS}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
404                    echo export config_UserChoices_JobName=${config_UserChoices_JobName} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
405                    echo export R_SAVE=${R_SAVE}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
406                    echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
407                    echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
408                    echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
409                    echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
410                    #
411                else
412                    #
413                    IGCM_sys_RshPost <<-EOF
414                    export DEBUG_debug=${DEBUG_debug}
415                    export MODIPSL=${MODIPSL}
416                    export libIGCM_SX=${libIGCM}
417                    export libIGCM=${libIGCM_POST}
418                    export SUBMIT_DIR=${SUBMIT_DIR}
419                    export POST_DIR=${POST_DIR}
420                    export MASTER=${MASTER}
421                    export RebuildFrequency=${RebuildFrequency}
422                    export DateBegin=${DateBegin}
423                    export PeriodDateEnd=${PeriodDateEnd}
424                    export StandAlone=false
425                    export CompletedFlag=${CompletedFlag}
426                    export TsTask=${TsTask}
427                    export RESOL_ATM=${RESOL_ATM}
428                    export RESOL_OCE=${RESOL_OCE}
429                    export RESOL_ICE=${RESOL_ICE}
430                    export RESOL_MBG=${RESOL_MBG}
431                    export RESOL_SRF=${RESOL_SRF}
432                    export RESOL_BIOS=${RESOL_BIOS}
433                    export config_UserChoices_JobName=${config_UserChoices_JobName}
434                    export R_SAVE=${R_SAVE}
435                    export listVarEnv=${listVarEnv}
436                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
437                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
438                    IGCM_sys_MkdirWork ${POST_DIR}
439                    IGCM_debug_Verif_Exit
440                    IGCM_sys_QsubPost create_ts
441EOF
442                fi
443            fi
444            #
445            if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
446                #
447                IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED :"
448                echo
449                # Need to Remember This One
450                SavedDateBegin=${DateBegin}
451                # Kind of task create_ts will perform
452                TsTask=Chunck${Dimension}
453                # Number of chunck jobs to configure and submit
454                eval NbJob=\${#CHUNCK${Dimension}_COMP[@]}
455                export i=0
456                until [ $i -ge $NbJob ]; do
457                    CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
458                    FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
459                    ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} )
460                    # Chunck Length (mandatory in Year)
461                    YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" )
462                    #
463                    IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin
464                    #
465                    IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd
466                    # How many chunck in total since simulation began
467                    NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} ))
468                    #  Tweak special case
469                    [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
470                    # Starting Year of the current chunck
471                    ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} ))
472                    # Starting date of the current chunck
473                    ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
474                    #
475                    if [ ${RebuildFrequency} = true ] && [ ${DRYRUN} -le 1 ] ; then
476                        #
477                        echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
478                        echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
479                        echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
480                        echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
481                        echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
482                        echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
483                        echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
484                        echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
485                        echo export DateBegin=${ChunckTsDateBegin}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
486                        echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
487                        echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
488                        echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
489                        echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
490                        echo export CompToRead=${CompToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
491                        echo export FlagToRead=${FlagToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
492                        echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
493                        echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
494                        echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
495                        echo export RESOL_MBG=${RESOL_MBG}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
496                        echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
497                        echo export RESOL_BIOS=${RESOL_BIOS}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
498                        echo export config_UserChoices_JobName=${config_UserChoices_JobName} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
499                        echo export R_SAVE=${R_SAVE}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
500                        echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
501                        echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
502                        echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
503                        echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
504                        #
505                    else
506                        #
507                        IGCM_sys_RshPost <<-EOF
508                        export DEBUG_debug=${DEBUG_debug}
509                        export MODIPSL=${MODIPSL}
510                        export libIGCM_SX=${libIGCM}
511                        export libIGCM=${libIGCM_POST}
512                        export SUBMIT_DIR=${SUBMIT_DIR}
513                        export POST_DIR=${POST_DIR}
514                        export MASTER=${MASTER}
515                        export RebuildFrequency=${RebuildFrequency}
516                        export DateBegin=${ChunckTsDateBegin}
517                        export PeriodDateEnd=${PeriodDateEnd}
518                        export StandAlone=false
519                        export CompletedFlag=${CompletedFlag}
520                        export TsTask=${TsTask}
521                        export CompToRead=${CompToRead}
522                        export FlagToRead=${FlagToRead}
523                        export RESOL_ATM=${RESOL_ATM}
524                        export RESOL_OCE=${RESOL_OCE}
525                        export RESOL_ICE=${RESOL_ICE}
526                        export RESOL_MBG=${RESOL_MBG}
527                        export RESOL_SRF=${RESOL_SRF}
528                        export RESOL_BIOS=${RESOL_BIOS}
529                        export config_UserChoices_JobName=${config_UserChoices_JobName}
530                        export R_SAVE=${R_SAVE}
531                        export listVarEnv=${listVarEnv}
532                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
533                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
534                        IGCM_sys_MkdirWork ${POST_DIR}
535                        IGCM_debug_Verif_Exit
536                        IGCM_sys_QsubPost create_ts
537EOF
538                        #
539                    fi
540                    #
541                    export DateBegin=${SavedDateBegin}
542                    #
543                    (( i=i+1 ))
544                    #
545                done
546            fi
547            (( j=j+1 ))
548        done
549    fi
550
551    #=============  SEASONAL POST-TREATMENT ============#
552    if [ ${SeasonalFrequency} = true ] ; then
553        #
554        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
555        echo
556        #
557        typeset listVarEnv
558        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_BIOS,config_UserChoices_JobName,R_SAVE"
559
560        if [ ${RebuildFrequency} = true ] && [ ${DRYRUN} -le 1 ] ; then
561            #
562            echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
563            echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
564            echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
565            echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
566            echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
567            echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
568            echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
569            echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
570            echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
571            echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
572            echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
573            echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
574            echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
575            echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
576            echo export RESOL_MBG=${RESOL_MBG}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
577            echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
578            echo export RESOL_BIOS=${RESOL_BIOS}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
579            echo export config_UserChoices_JobName=${config_UserChoices_JobName} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
580            echo export R_SAVE=${R_SAVE}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
581            echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
582            echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
583            echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
584            echo IGCM_sys_QsubPost create_se                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
585            #
586        else
587            #
588            IGCM_sys_RshPost <<-EOF
589            export DEBUG_debug=${DEBUG_debug}
590            export MODIPSL=${MODIPSL}
591            export libIGCM_SX=${libIGCM}
592            export libIGCM=${libIGCM_POST}
593            export SUBMIT_DIR=${SUBMIT_DIR}
594            export POST_DIR=${POST_DIR}
595            export MASTER=${MASTER}
596            export RebuildFrequency=${RebuildFrequency}
597            export DateBegin=${DateBegin}
598            export PeriodDateEnd=${PeriodDateEnd}
599            export StandAlone=false
600            export RESOL_ATM=${RESOL_ATM}
601            export RESOL_OCE=${RESOL_OCE}
602            export RESOL_ICE=${RESOL_ICE}
603            export RESOL_MBG=${RESOL_MBG}
604            export RESOL_SRF=${RESOL_SRF}
605            export RESOL_BIOS=${RESOL_BIOS}
606            export config_UserChoices_JobName=${config_UserChoices_JobName}
607            export R_SAVE=${R_SAVE}
608            export listVarEnv=${listVarEnv}
609            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
610            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
611            IGCM_sys_MkdirWork ${POST_DIR}
612            IGCM_debug_Verif_Exit
613            IGCM_sys_QsubPost create_se
614EOF
615        #
616        fi
617    fi
618
619    #============== REBUILD POST-TREATMENT =============#
620    if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
621        # -----------------------------------------------------------------------------------
622        # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
623        # -----------------------------------------------------------------------------------
624        if [ ${DRYRUN} -le 1 ] ; then
625            echo IGCM_debug_PopStack "IGCM_FlushRebuild" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
626            echo }                                       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
627        fi
628        if [ ${config_Post_RebuildFromArchive} = true ] ; then
629            IGCM_sys_Put_Dir REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
630        elif [ ${RebuildFrequency} = true ] ; then
631            IGCM_sys_Mv      REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
632        fi
633    fi
634    #
635    if [ ${RebuildFrequency} = true ] ; then
636        #
637        if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then
638            #
639            IGCM_debug_Print 2 "REBUILD POST-TREATMENT FROM ARCHIVE:"
640            echo
641            #
642            typeset listVarEnv
643            listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,MASTER,RebuildFromArchive,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_BIOS,config_UserChoices_JobName,R_SAVE"
644            IGCM_sys_RshPost <<-EOF
645            export DEBUG_debug=${DEBUG_debug}
646            export MODIPSL=${MODIPSL}
647            export libIGCM_SX=${libIGCM}
648            export libIGCM=${libIGCM_POST}
649            export SUBMIT_DIR=${SUBMIT_DIR}
650            export REBUILD_DIR=${REBUILD_DIR}
651            export POST_DIR=${POST_DIR}
652            export MASTER=${MASTER}
653            export RebuildFromArchive=${config_Post_RebuildFromArchive}
654            export DateBegin=${DateBegin}
655            export PeriodDateBegin=${PeriodDateBegin}
656            export PeriodDateEnd=${PeriodDateEnd}
657            export NbRebuildDir=${NbRebuildDir}
658            export StandAlone=false
659            export RESOL_ATM=${RESOL_ATM}
660            export RESOL_OCE=${RESOL_OCE}
661            export RESOL_ICE=${RESOL_ICE}
662            export RESOL_MBG=${RESOL_MBG}
663            export RESOL_SRF=${RESOL_SRF}
664            export RESOL_BIOS=${RESOL_BIOS}
665            export config_UserChoices_JobName=${config_UserChoices_JobName}
666            export R_SAVE=${R_SAVE}
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,MASTER,RebuildFromArchive,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_BIOS,config_UserChoices_JobName,R_SAVE"
681            IGCM_sys_RshPost <<-EOF
682            export DEBUG_debug=${DEBUG_debug}
683            export MODIPSL=${MODIPSL}
684            export libIGCM_SX=${libIGCM}
685            export libIGCM=${libIGCM_POST}
686            export SUBMIT_DIR=${SUBMIT_DIR}
687            export REBUILD_DIR=${REBUILD_DIR}
688            export POST_DIR=${POST_DIR}
689            export MASTER=${MASTER}
690            export RebuildFromArchive=${config_Post_RebuildFromArchive}
691            export DateBegin=${DateBegin}
692            export PeriodDateBegin=${PeriodDateBegin}
693            export PeriodDateEnd=${PeriodDateEnd}
694            export NbRebuildDir=${NbRebuildDir}
695            export StandAlone=false
696            export RESOL_ATM=${RESOL_ATM}
697            export RESOL_OCE=${RESOL_OCE}
698            export RESOL_ICE=${RESOL_ICE}
699            export RESOL_MBG=${RESOL_MBG}
700            export RESOL_SRF=${RESOL_SRF}
701            export RESOL_BIOS=${RESOL_BIOS}
702            export config_UserChoices_JobName=${config_UserChoices_JobName}
703            export R_SAVE=${R_SAVE}
704            export listVarEnv=${listVarEnv}
705            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
706            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
707            IGCM_sys_MkdirWork ${POST_DIR}
708            IGCM_debug_Verif_Exit
709            IGCM_sys_QsubPost rebuild_fromWorkdir
710EOF
711        fi
712    fi
713
714    IGCM_debug_PopStack "IGCM_post_Submit"
715}
Note: See TracBrowser for help on using the repository browser.