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

Last change on this file since 149 was 149, checked in by sdipsl, 15 years ago
  • New post-processing functionnality for cmip5 like post-processing
    • You can ask for fixed lenght time series (10 years chunck or 50 years chunck or ...) and specify it for each files.
    • Separation of concern between 2D and 3D fields.
    • Backward compatible with previous style comp.card
    • example : TimeSeriesVars2D = (cldt, psol, q2m, slp, SWnetOR, SWdownOR, LWdownOR, precip) ChunckJob2D = NONE TimeSeriesVars3D = (temp, theta, ovap, ovapinit, geop, vitu, vitv, vitw, pres) ChunckJob3D = 10Y
  • In case of asynchronous rebuild save patched files on archive filesystem. (so that they have good time axis)
  • 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.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    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        for Dimension in ${ListDimension} ; do
403            #
404            if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then
405                #
406                IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED :"
407                echo
408                #
409                TsTask=${Dimension}
410                #
411                if [ ${RebuildFrequency} = true ] ; then
412                    #
413                    echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
414                    echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
415                    echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
416                    echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
417                    echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
418                    echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
419                    echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
420                    echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
421                    echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
422                    echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
423                    echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
424                    echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
425                    echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
426                    echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
427                    echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
428                    echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
429                    echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
430                    echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
431                    echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
432                    echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
433                    echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
434                    #
435                else
436                    #
437                    IGCM_sys_RshPost <<-EOF
438                    export DEBUG_debug=${DEBUG_debug}
439                    export MODIPSL=${MODIPSL}
440                    export libIGCM_SX=${libIGCM}
441                    export libIGCM=${libIGCM_POST}
442                    export SUBMIT_DIR=${SUBMIT_DIR}
443                    export POST_DIR=${POST_DIR}
444                    export MASTER=${MASTER}
445                    export RebuildFrequency=${RebuildFrequency}
446                    export DateBegin=${DateBegin}
447                    export PeriodDateEnd=${PeriodDateEnd}
448                    export StandAlone=false
449                    export CompletedFlag=${CompletedFlag}
450                    export TsTask=${TsTask}
451                    export RESOL_ATM=${RESOL_ATM}
452                    export RESOL_OCE=${RESOL_OCE}
453                    export RESOL_ICE=${RESOL_ICE}
454                    export RESOL_SRF=${RESOL_SRF}
455                    export listVarEnv=${listVarEnv}
456                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
457                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
458                    IGCM_sys_MkdirWork ${POST_DIR}
459                    IGCM_debug_Verif_Exit
460                    IGCM_sys_QsubPost create_ts
461EOF
462                fi
463            fi
464            #
465            if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
466                #
467                IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED :"
468                echo
469                # Need to Remember This One
470                SavedDateBegin=${DateBegin}
471                # Kind of task create_ts will perform
472                TsTask=Chunck${Dimension}
473                # Number of chunck jobs to configure and submit
474                eval NbJob=\${#CHUNCK${Dimension}_COMP[@]}
475                i=0
476                until [ $i -ge $NbJob ]; do
477                    CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
478                    FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
479                    ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} )
480                    # Chunck Length (mandatory in Year)
481                    YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" )
482                    #
483                    IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin
484                    #
485                    IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd
486                    # How many chunck in total since simulation began
487                    NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} ))
488                    #  Tweak special case
489                    [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
490                    # Starting Year of the current chunck
491                    ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} ))
492                    # Starting date of the current chunck
493                    ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
494                    #
495                    if [ ${RebuildFrequency} = true ] ; then
496                        #
497                        echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
498                        echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
499                        echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
500                        echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
501                        echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
502                        echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
503                        echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
504                        echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
505                        echo export DateBegin=${ChunckTsDateBegin}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
506                        echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
507                        echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
508                        echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
509                        echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
510                        echo export CompToRead=${CompToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
511                        echo export FlagToRead=${FlagToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
512                        echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
513                        echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
514                        echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
515                        echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
516                        echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
517                        echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
518                        echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
519                        echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
520                        #
521                    else
522                        #
523                        IGCM_sys_RshPost <<-EOF
524                        export DEBUG_debug=${DEBUG_debug}
525                        export MODIPSL=${MODIPSL}
526                        export libIGCM_SX=${libIGCM}
527                        export libIGCM=${libIGCM_POST}
528                        export SUBMIT_DIR=${SUBMIT_DIR}
529                        export POST_DIR=${POST_DIR}
530                        export MASTER=${MASTER}
531                        export RebuildFrequency=${RebuildFrequency}
532                        export DateBegin=${ChunckTsDateBegin}
533                        export PeriodDateEnd=${PeriodDateEnd}
534                        export StandAlone=false
535                        export CompletedFlag=${CompletedFlag}
536                        export TsTask=${TsTask}
537                        export CompToRead=${CompToRead}
538                        export FlagToRead=${FlagToRead}
539                        export RESOL_ATM=${RESOL_ATM}
540                        export RESOL_OCE=${RESOL_OCE}
541                        export RESOL_ICE=${RESOL_ICE}
542                        export RESOL_SRF=${RESOL_SRF}
543                        export listVarEnv=${listVarEnv}
544                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
545                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
546                        IGCM_sys_MkdirWork ${POST_DIR}
547                        IGCM_debug_Verif_Exit
548                        IGCM_sys_QsubPost create_ts
549EOF
550                        #
551                    fi
552                    #
553                    export DateBegin=${SavedDateBegin}
554                    #
555                    (( i=i+1 ))
556                    #
557                done
558            fi
559        done
560    fi
561
562    set +vx
563
564    #=============  SEASONAL POST-TREATMENT ============#
565    if [ ${SeasonalFrequency} = true ] ; then
566        #
567        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
568        echo
569        #
570        typeset listVarEnv
571        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
572
573        if [ ${RebuildFrequency} = true ] ; then
574            #
575            echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
576            echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
577            echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
578            echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
579            echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
580            echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
581            echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
582            echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
583            echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
584            echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
585            echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
586            echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
587            echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
588            echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
589            echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
590            echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
591            echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
592            echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
593            echo IGCM_sys_QsubPost create_se                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
594            #
595        else
596            #
597            IGCM_sys_RshPost <<-EOF
598            export DEBUG_debug=${DEBUG_debug}
599            export MODIPSL=${MODIPSL}
600            export libIGCM_SX=${libIGCM}
601            export libIGCM=${libIGCM_POST}
602            export SUBMIT_DIR=${SUBMIT_DIR}
603            export POST_DIR=${POST_DIR}
604            export MASTER=${MASTER}
605            export RebuildFrequency=${RebuildFrequency}
606            export DateBegin=${DateBegin}
607            export PeriodDateEnd=${PeriodDateEnd}
608            export StandAlone=false
609            export RESOL_ATM=${RESOL_ATM}
610            export RESOL_OCE=${RESOL_OCE}
611            export RESOL_ICE=${RESOL_ICE}
612            export RESOL_SRF=${RESOL_SRF}
613            export listVarEnv=${listVarEnv}
614            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
615            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
616            IGCM_sys_MkdirWork ${POST_DIR}
617            IGCM_debug_Verif_Exit
618            IGCM_sys_QsubPost create_se
619EOF
620        #
621        fi
622    fi
623
624    #============== REBUILD POST-TREATMENT =============#
625
626    if ( [ ${config_Post_RebuildFromArchive} = true ] && [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
627        IGCM_sys_Put_Dir REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
628    fi
629    #
630    if [ ${RebuildFrequency} = true ] ; then
631        #
632        if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then
633        #
634        IGCM_debug_Print 2 "REBUILD POST-TREATMENT FROM ARCHIVE:"
635        echo
636        #
637        typeset listVarEnv
638        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,RebuildFromArchive,POST_DIR,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
639        IGCM_sys_RshPost <<-EOF
640        export DEBUG_debug=${DEBUG_debug}
641        export MODIPSL=${MODIPSL}
642        export libIGCM_SX=${libIGCM}
643        export libIGCM=${libIGCM_POST}
644        export SUBMIT_DIR=${SUBMIT_DIR}
645        export RebuildFromArchive=${config_Post_RebuildFromArchive}
646        export REBUILD_DIR=${REBUILD_DIR}
647        export POST_DIR=${POST_DIR}
648        export DateBegin=${DateBegin}
649        export PeriodDateBegin=${PeriodDateBegin}
650        export PeriodDateEnd=${PeriodDateEnd}
651        export NbRebuildDir=${NbRebuildDir}
652        export StandAlone=false
653        export RESOL_ATM=${RESOL_ATM}
654        export RESOL_OCE=${RESOL_OCE}
655        export RESOL_ICE=${RESOL_ICE}
656        export RESOL_SRF=${RESOL_SRF}
657        export listVarEnv=${listVarEnv}
658        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
659        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
660        IGCM_sys_MkdirWork ${POST_DIR}
661        IGCM_debug_Verif_Exit
662        IGCM_sys_QsubPost rebuild_fromArchive
663EOF
664
665        else 
666        #
667        IGCM_debug_Print 2 "REBUILD POST-TREATMENT FROM WORKDIR :"
668        echo
669        IGCM_debug_Print 2 "NOT FULLY SUPPORTED"
670        IGCM_debug_Print 2 "EXIT NOW TO AVOID BIG PROBLEM"
671        IGCM_debug_Print 2 "Contact libIGCM developpers"
672        #
673        IGCM_debug_Exit "FATAL ERROR IN REBUILD CONFIGURATION"
674        IGCM_debug_Verif_Exit
675        #
676
677#        typeset listVarEnv
678#        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,RebuildFromArchive,POST_DIR,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
679#        export DEBUG_debug=${DEBUG_debug}
680#        export MODIPSL=${MODIPSL}
681#        export libIGCM_SX=${libIGCM}
682#        export libIGCM=${libIGCM}
683#        export SUBMIT_DIR=${SUBMIT_DIR}
684#        export RebuildFromArchive=${config_Post_RebuildFromArchive}
685#        export REBUILD_DIR=${REBUILD_DIR}
686#        export POST_DIR=${libIGCM}
687#        export DateBegin=${DateBegin}
688#        export PeriodDateBegin=${PeriodDateBegin}
689#        export PeriodDateEnd=${PeriodDateEnd}
690#        export NbRebuildDir=${NbRebuildDir}
691#        export StandAlone=false
692#        export RESOL_ATM=${RESOL_ATM}
693#        export RESOL_OCE=${RESOL_OCE}
694#        export RESOL_ICE=${RESOL_ICE}
695#        export RESOL_SRF=${RESOL_SRF}
696#        export listVarEnv=${listVarEnv}
697#        IGCM_sys_Qsub rebuild_fromWorkdir ${libIGCM}
698
699        fi
700    fi
701
702    IGCM_debug_PopStack "IGCM_post_Submit"
703}
Note: See TracBrowser for help on using the repository browser.