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

Last change on this file since 1298 was 1298, checked in by sdipsl, 8 years ago
  • bugfix
  • 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 Revision Author Date
File size: 43.5 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=======================================================================
15
16function IGCM_post_Configure
17{
18  IGCM_debug_PushStack "IGCM_post_Configure"
19
20  # Debug Print :
21  echo
22  IGCM_debug_Print 1 "IGCM_post_Configure"
23  #
24  # Initialize
25  #
26  POST=false
27  RebuildFrequency=false
28  PackFrequency=false
29  TimeSeriesFrequency=false
30  SeasonalFrequency=false
31  unset list_post
32  #
33  # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS
34  #
35  if [ X${AsynchronousRebuild} = Xtrue ] ; then
36    list_post="RebuildFrequency"
37  fi
38  #
39  if [ X${Pack} = Xtrue ] ; then
40    list_post="${list_post} PackFrequency"
41  fi
42  #
43  if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] || [ X${TimeSeriesChunck2D} = Xtrue ] || [ X${TimeSeriesChunck3D} = Xtrue ] ) ; then
44    list_post="${list_post} TimeSeriesFrequency"
45  fi
46  #
47  if [ X${Seasonal} = Xtrue ] ; then
48    list_post="${list_post} SeasonalFrequency"
49  fi
50
51  # Overrule Time Series triggering. Special case 1.
52  if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \
53    [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]           && \
54    [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
55    TimeSeriesFrequency=true
56    POST=true
57  fi
58  # Overrule Rebuild triggering. Special case 2.
59  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
60    RebuildFrequency=true
61    POST=true
62  fi
63  # Overrule Pack triggering. Special case 3.
64  if ( [ X${Pack} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
65    PackFrequency=true
66    POST=true
67  fi
68
69  # READ REBUILD OR PACK OR TIME SERIES OR SEASONAL FREQUENCY
70  # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO
71  for post_freq in ${list_post} ; do
72    # Extract frequency from previously defined variable
73    config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} )
74    # Offset for Seasonal Average starting period
75    if [ ${post_freq} = SeasonalFrequency ] ; then
76      if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
77        PeriodOffset=0
78      else
79        PeriodOffset=${config_Post_SeasonalFrequencyOffset}
80      fi
81    else
82      PeriodOffset=0
83    fi
84    # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\)
85    # RebuildFrequency needs additionnal information
86    if [ ${post_freq} = RebuildFrequency ] ; then
87      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbPeriodPerFrequency
88      NbRebuildDir=${NbPeriodPerFrequency}
89    else
90      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength
91    fi
92    #
93    eval IGCM_debug_Print 1 \" "${post_freq} flag value : \${${post_freq}}" \"
94  done
95  #
96  IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}"
97  #
98  # Prepare headers for the shell dedicated to post-processing
99  if ( [ ${PackFrequency} = true ] && ( [ ${TimeSeriesFrequency} = true ] || [ ${SeasonalFrequency} = true ] ) ) ; then
100    if [ $DRYRUN -le 1 ]; then
101      echo "#!/bin/ksh                                     " >  ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
102      echo "function IGCM_FlushPost                        " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
103      echo "{                                              " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
104      echo "IGCM_debug_PushStack \"IGCM_FlushPost\"        " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
105      echo "echo                                           " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
106      echo "IGCM_debug_Print 1 \"IGCM_FlushPost\"          " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
107      echo "echo                                           " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
108    fi
109  fi
110  IGCM_debug_PopStack "IGCM_post_Configure"
111}
112
113function IGCM_post_Submit
114{
115  IGCM_debug_PushStack "IGCM_post_Submit"
116
117  typeset listVarEnv DaysTemp
118
119  POST_DIR=${R_BUF_KSH}
120
121  if [ ${POST} = true ]; then
122    echo
123    IGCM_debug_Print 1 "IGCM_post_Submit"
124    echo
125    IGCM_debug_Print 2 "POST_DIR = ${POST_DIR}"
126  fi
127
128  #============ TIME SERIES POST-PROCESSING ===========#
129  if [ ${TimeSeriesFrequency} = true ] ; then
130
131    IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ACTIVATED"
132    echo
133
134
135
136    # Get information from last execution
137    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
138    CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
139    #
140
141
142
143    listVarEnv="DEBUG_debug,BigBrother,postProcessingStopLevel,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,Script_Post_Output,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,CompletedFlag,TsTask,CompToRead,FlagToRead,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
144    #
145    jLoop=${#ListDimension[*]}
146    j=0
147    until [ $j -ge ${jLoop} ]; do
148      Dimension=${ListDimension[${j}]}
149      #
150      if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then
151      #
152        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED"
153        echo
154        #
155        if [ X${Dimension} = X ] ; then
156          TsTask="empty"
157          Script_Post_Output=create_ts.${PeriodDateEnd}
158        else
159          TsTask=${Dimension}
160          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}
161        fi
162        #
163        if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
164          #
165          if [ ${PackFrequency} = true ] ; then
166            FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
167          else
168            FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
169          fi
170          #
171          if [ -f ${FunctionPath} ] ; then
172#           if [ X${MASTER} = Xtitane ] ; then
173#             echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
174#           fi
175            echo "export DEBUG_debug=${DEBUG_debug}                        " >> ${FunctionPath}
176            echo "export BigBrother=${BigBrother}                          " >> ${FunctionPath}
177            echo "export postProcessingStopLevel=${postProcessingStopLevel}" >> ${FunctionPath}
178            echo "export MODIPSL=${MODIPSL}                                " >> ${FunctionPath}
179            echo "export libIGCM_SX=${libIGCM}                             " >> ${FunctionPath}
180            echo "export libIGCM=${libIGCM_POST}                           " >> ${FunctionPath}
181            echo "export SUBMIT_DIR=${SUBMIT_DIR}                          " >> ${FunctionPath}
182            echo "export POST_DIR=${POST_DIR}                              " >> ${FunctionPath}
183            echo "export MASTER=${MASTER}                                  " >> ${FunctionPath}
184            echo "export RebuildFrequency=${RebuildFrequency}              " >> ${FunctionPath}
185            echo "export DateBegin=${DateBegin}                            " >> ${FunctionPath}
186            echo "export PeriodDateEnd=${PeriodDateEnd}                    " >> ${FunctionPath}
187            echo "export StandAlone=false                                  " >> ${FunctionPath}
188            echo "export CompletedFlag=${CompletedFlag}                    " >> ${FunctionPath}
189            echo "export TsTask=${TsTask}                                  " >> ${FunctionPath}
190            echo "unset  CompToRead                                        " >> ${FunctionPath}
191            echo "unset  FlagToRead                                        " >> ${FunctionPath}
192            echo "export RESOL_ATM=${RESOL_ATM}                            " >> ${FunctionPath}
193            echo "export RESOL_OCE=${RESOL_OCE}                            " >> ${FunctionPath}
194            echo "export RESOL_ICE=${RESOL_ICE}                            " >> ${FunctionPath}
195            echo "export RESOL_MBG=${RESOL_MBG}                            " >> ${FunctionPath}
196            echo "export RESOL_SRF=${RESOL_SRF}                            " >> ${FunctionPath}
197            echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
198            echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
199            echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
200#           if [ X${MASTER} = Xtitane ] ; then
201#             echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
202#             echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
203#           fi
204            echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
205            echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
206            echo "IGCM_sys_QsubPost create_ts                    " >> ${FunctionPath}
207#           if [ X${MASTER} = Xtitane ] ; then
208#             echo "EOF"                                           >> ${FunctionPath}
209#           fi
210          fi
211        else
212          IGCM_sys_RshPost <<-EOF
213                    export DEBUG_debug=${DEBUG_debug}
214                    export BigBrother=${BigBrother}
215                    export postProcessingStopLevel=${postProcessingStopLevel}
216                    export MODIPSL=${MODIPSL}
217                    export libIGCM_SX=${libIGCM}
218                    export libIGCM=${libIGCM_POST}
219                    export SUBMIT_DIR=${SUBMIT_DIR}
220                    export POST_DIR=${POST_DIR}
221                    export MASTER=${MASTER}
222                    export RebuildFrequency=${RebuildFrequency}
223                    export DateBegin=${DateBegin}
224                    export PeriodDateEnd=${PeriodDateEnd}
225                    export StandAlone=false
226                    export CompletedFlag=${CompletedFlag}
227                    export TsTask=${TsTask}
228                    unset  CompToRead
229                    unset  FlagToRead
230                    export RESOL_ATM=${RESOL_ATM}
231                    export RESOL_OCE=${RESOL_OCE}
232                    export RESOL_ICE=${RESOL_ICE}
233                    export RESOL_MBG=${RESOL_MBG}
234                    export RESOL_SRF=${RESOL_SRF}
235                    export RESOL_SBG=${RESOL_SBG}
236                    export listVarEnv=${listVarEnv}
237                    export Script_Post_Output=${Script_Post_Output}
238                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
239                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
240                    IGCM_sys_MkdirWork ${POST_DIR}
241                    IGCM_debug_Verif_Exit
242                    IGCM_sys_QsubPost create_ts
243EOF
244        fi
245      fi
246      #
247      if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
248        #
249        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED"
250        echo
251        # Need to Remember This One
252        SavedDateBegin=${DateBegin}
253        # Kind of task create_ts will perform
254        TsTask=Chunck${Dimension}
255        # Number of chunck jobs to configure and submit
256        eval NbJob=\${#CHUNCK${Dimension}_COMP[@]}
257        typeset i
258        i=0
259        until [ $i -ge $NbJob ]; do
260          CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
261          FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
262          NameToRead=$( eval echo \${CHUNCK${Dimension}_NAME[\${i}]} )
263          ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} )
264          # Chunck Length (mandatory in Year)
265          YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" )
266          #
267          IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin
268          #
269          IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd
270          # How many chunck in total since simulation began
271          NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} ))
272          #  Tweak special case
273          [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
274          # Starting Year of the current chunck
275          ChunckTsYearBegin=$(( ${NbYearsChunckLoop} * ${YearsChunckLength} + ${YearBegin} ))
276          # Starting date of the current chunck
277          ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
278          #
279          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead}
280          #
281          if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
282            #
283            if [ ${PackFrequency} = true ] ; then
284              FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
285            else
286              FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
287            fi
288            #
289            if [ -f ${FunctionPath} ] ; then
290#             if [ X${MASTER} = Xtitane ] ; then
291#               echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
292#             fi
293              echo "export DEBUG_debug=${DEBUG_debug}                        " >> ${FunctionPath}
294              echo "export BigBrother=${BigBrother}                          " >> ${FunctionPath}
295              echo "export postProcessingStopLevel=${postProcessingStopLevel}" >> ${FunctionPath}
296              echo "export MODIPSL=${MODIPSL}                                " >> ${FunctionPath}
297              echo "export libIGCM_SX=${libIGCM}                             " >> ${FunctionPath}
298              echo "export libIGCM=${libIGCM_POST}                           " >> ${FunctionPath}
299              echo "export SUBMIT_DIR=${SUBMIT_DIR}                          " >> ${FunctionPath}
300              echo "export POST_DIR=${POST_DIR}                              " >> ${FunctionPath}
301              echo "export MASTER=${MASTER}                                  " >> ${FunctionPath}
302              echo "export RebuildFrequency=${RebuildFrequency}              " >> ${FunctionPath}
303              echo "export DateBegin=${ChunckTsDateBegin}                    " >> ${FunctionPath}
304              echo "export PeriodDateEnd=${PeriodDateEnd}                    " >> ${FunctionPath}
305              echo "export StandAlone=false                                  " >> ${FunctionPath}
306              echo "export CompletedFlag=${CompletedFlag}                    " >> ${FunctionPath}
307              echo "export TsTask=${TsTask}                                  " >> ${FunctionPath}
308              echo "export CompToRead=${CompToRead}                          " >> ${FunctionPath}
309              echo "export FlagToRead=${FlagToRead}                          " >> ${FunctionPath}
310              echo "export RESOL_ATM=${RESOL_ATM}                            " >> ${FunctionPath}
311              echo "export RESOL_OCE=${RESOL_OCE}                            " >> ${FunctionPath}
312              echo "export RESOL_ICE=${RESOL_ICE}                            " >> ${FunctionPath}
313              echo "export RESOL_MBG=${RESOL_MBG}                            " >> ${FunctionPath}
314              echo "export RESOL_SRF=${RESOL_SRF}                            " >> ${FunctionPath}
315              echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
316              echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
317              echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
318#             if [ X${MASTER} = Xtitane ] ; then
319#               echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
320#               echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
321#             fi
322              echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
323              echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
324              echo "IGCM_sys_QsubPost create_ts                    " >> ${FunctionPath}
325#             if [ X${MASTER} = Xtitane ] ; then
326#               echo "EOF"                                           >> ${FunctionPath}
327#             fi
328            fi
329          else
330            IGCM_sys_RshPost <<-EOF
331                        export DEBUG_debug=${DEBUG_debug}
332                        export BigBrother=${BigBrother}
333                        export postProcessingStopLevel=${postProcessingStopLevel}
334                        export MODIPSL=${MODIPSL}
335                        export libIGCM_SX=${libIGCM}
336                        export libIGCM=${libIGCM_POST}
337                        export SUBMIT_DIR=${SUBMIT_DIR}
338                        export POST_DIR=${POST_DIR}
339                        export MASTER=${MASTER}
340                        export RebuildFrequency=${RebuildFrequency}
341                        export DateBegin=${ChunckTsDateBegin}
342                        export PeriodDateEnd=${PeriodDateEnd}
343                        export StandAlone=false
344                        export CompletedFlag=${CompletedFlag}
345                        export TsTask=${TsTask}
346                        export CompToRead=${CompToRead}
347                        export FlagToRead=${FlagToRead}
348                        export RESOL_ATM=${RESOL_ATM}
349                        export RESOL_OCE=${RESOL_OCE}
350                        export RESOL_ICE=${RESOL_ICE}
351                        export RESOL_MBG=${RESOL_MBG}
352                        export RESOL_SRF=${RESOL_SRF}
353                        export RESOL_SBG=${RESOL_SBG}
354                        export listVarEnv=${listVarEnv}
355                        export Script_Post_Output=${Script_Post_Output}
356                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
357                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
358                        IGCM_sys_MkdirWork ${POST_DIR}
359                        IGCM_debug_Verif_Exit
360                        IGCM_sys_QsubPost create_ts
361EOF
362            #
363          fi
364          #
365          export DateBegin=${SavedDateBegin}
366          #
367          (( i=i+1 ))
368          #
369        done
370      fi
371      (( j=j+1 ))
372    done
373  fi
374
375  #=============  SEASONAL POST-PROCESSING ============#
376  if [ ${SeasonalFrequency} = true ] ; then
377    #
378    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING"
379    echo
380    #
381    Script_Post_Output=create_se.${PeriodDateEnd}
382    #
383    listVarEnv="DEBUG_debug,BigBrother,postProcessingStopLevel,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,Script_Post_Output,MASTER,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
384
385    if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
386      #
387      if [ ${PackFrequency} = true ] ; then
388        FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
389      else
390        FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
391      fi
392      #
393      if [ -f ${FunctionPath} ] ; then
394      #
395#     if [ X${MASTER} = Xtitane ] ; then
396#       echo "IGCM_sys_RshPost <<-EOF"                     >> ${FunctionPath}
397#     fi
398      echo "export DEBUG_debug=${DEBUG_debug}                        " >> ${FunctionPath}
399      echo "export BigBrother=${BigBrother}                          " >> ${FunctionPath}
400      echo "export postProcessingStopLevel=${postProcessingStopLevel}" >> ${FunctionPath}
401      echo "export MODIPSL=${MODIPSL}                                " >> ${FunctionPath}
402      echo "export libIGCM_SX=${libIGCM}                             " >> ${FunctionPath}
403      echo "export libIGCM=${libIGCM_POST}                           " >> ${FunctionPath}
404      echo "export SUBMIT_DIR=${SUBMIT_DIR}                          " >> ${FunctionPath}
405      echo "export POST_DIR=${POST_DIR}                              " >> ${FunctionPath}
406      echo "export MASTER=${MASTER}                                  " >> ${FunctionPath}
407      echo "export DateBegin=${DateBegin}                            " >> ${FunctionPath}
408      echo "export PeriodDateEnd=${PeriodDateEnd}                    " >> ${FunctionPath}
409      echo "export StandAlone=false                                  " >> ${FunctionPath}
410      echo "export RESOL_ATM=${RESOL_ATM}                            " >> ${FunctionPath}
411      echo "export RESOL_OCE=${RESOL_OCE}                            " >> ${FunctionPath}
412      echo "export RESOL_ICE=${RESOL_ICE}                            " >> ${FunctionPath}
413      echo "export RESOL_MBG=${RESOL_MBG}                            " >> ${FunctionPath}
414      echo "export RESOL_SRF=${RESOL_SRF}                            " >> ${FunctionPath}
415      echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
416      echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
417      echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
418#     if [ X${MASTER} = Xtitane ] ; then
419#       echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
420#       echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
421#     fi
422      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
423      echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
424      echo "IGCM_sys_QsubPost create_se                    " >> ${FunctionPath}
425#     if [ X${MASTER} = Xtitane ] ; then
426#       echo "EOF"                                         >> ${FunctionPath}
427#     fi
428      fi
429    else
430      IGCM_sys_RshPost <<-EOF
431            export DEBUG_debug=${DEBUG_debug}
432            export BigBrother=${BigBrother}
433            export postProcessingStopLevel=${postProcessingStopLevel}
434            export MODIPSL=${MODIPSL}
435            export libIGCM_SX=${libIGCM}
436            export libIGCM=${libIGCM_POST}
437            export SUBMIT_DIR=${SUBMIT_DIR}
438            export POST_DIR=${POST_DIR}
439            export MASTER=${MASTER}
440            export DateBegin=${DateBegin}
441            export PeriodDateEnd=${PeriodDateEnd}
442            export StandAlone=false
443            export RESOL_ATM=${RESOL_ATM}
444            export RESOL_OCE=${RESOL_OCE}
445            export RESOL_ICE=${RESOL_ICE}
446            export RESOL_MBG=${RESOL_MBG}
447            export RESOL_SRF=${RESOL_SRF}
448            export RESOL_SBG=${RESOL_SBG}
449            export listVarEnv=${listVarEnv}
450            export Script_Post_Output=${Script_Post_Output}
451            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
452            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
453            IGCM_sys_MkdirWork ${POST_DIR}
454            IGCM_debug_Verif_Exit
455            IGCM_sys_QsubPost create_se
456EOF
457    fi
458  fi
459
460  #============== PACK PROCESSING FOR RESTART, DEBUG AND OUTPUT FILES =============#
461  if [ ${PackFrequency} = true ] ; then
462    IGCM_debug_Print 1 "PACK POST-PROCESSING"
463    # -----------------------------------------------------------------------------------
464    # Function IGCM_FlushPost called by pack_output.job has not been closed yet. Do it now
465    # Will submit Time Series OR Seasonal Average if needed
466    # -----------------------------------------------------------------------------------
467    if [ -f ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh ] ; then
468      echo "IGCM_debug_PopStack \"IGCM_FlushPost\" " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
469      echo "}                                      " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
470    fi
471    echo
472    ## Need to Remember This One
473    SavedDateBegin=${DateBegin}
474    ## Need to Remember This One
475    SavedDateEnd=${DateEnd}
476    #
477    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 ))
478    #
479    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} )
480    #
481    script=pack_debug
482    #
483    Script_Post_Output=${script}.${PeriodDateEnd}
484    #
485    listVarEnv="DEBUG_debug,BigBrother,postProcessingStopLevel,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,Script_Post_Output,MASTER,DateBegin,DateEnd,PeriodPack,StandAlone"
486    IGCM_sys_RshPost <<-EOF
487    export DEBUG_debug=${DEBUG_debug}
488    export BigBrother=${BigBrother}
489    export postProcessingStopLevel=${postProcessingStopLevel}
490    export MODIPSL=${MODIPSL}
491    export libIGCM_SX=${libIGCM}
492    export libIGCM=${libIGCM_POST}
493    export SUBMIT_DIR=${SUBMIT_DIR}
494    export POST_DIR=${POST_DIR}
495    export MASTER=${MASTER}
496    export DateBegin=${PackDateBegin}
497    export DateEnd=${PeriodDateEnd}
498    export PeriodPack=${config_Post_PackFrequency}
499    export StandAlone=false
500    export listVarEnv=${listVarEnv}
501    export Script_Post_Output=${Script_Post_Output}
502    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
503    . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
504    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
505    IGCM_sys_MkdirWork ${POST_DIR}
506    IGCM_debug_Verif_Exit
507    IGCM_sys_QsubPost ${script}
508    IGCM_debug_Verif_Exit
509EOF
510    #
511    script=pack_restart
512    #
513    Script_Post_Output=${script}.${PeriodDateEnd}
514    #
515      IGCM_sys_RshPost <<-EOF
516      export DEBUG_debug=${DEBUG_debug}
517      export BigBrother=${BigBrother}
518      export postProcessingStopLevel=${postProcessingStopLevel}
519      export MODIPSL=${MODIPSL}
520      export libIGCM_SX=${libIGCM}
521      export libIGCM=${libIGCM_POST}
522      export SUBMIT_DIR=${SUBMIT_DIR}
523      export POST_DIR=${POST_DIR}
524      export MASTER=${MASTER}
525      export DateBegin=${PackDateBegin}
526      export DateEnd=${PeriodDateEnd}
527      export PeriodPack=${config_Post_PackFrequency}
528      export StandAlone=false
529      export listVarEnv=${listVarEnv}
530      export Script_Post_Output=${Script_Post_Output}
531      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
532      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
533      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
534      IGCM_sys_MkdirWork ${POST_DIR}
535      IGCM_debug_Verif_Exit
536      IGCM_sys_QsubPost ${script}
537      IGCM_debug_Verif_Exit
538EOF
539    #
540    script=pack_output
541    #
542    Script_Post_Output=${script}.${PeriodDateEnd}
543    #
544    if ( [ ${RebuildFrequency} = true ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
545#       if [ X${MASTER} = Xtitane ] ; then
546#         echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
547#       fi
548      echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
549      echo "export BigBrother=${BigBrother}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
550      echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
551      echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
552      echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
553      echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
554      echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
555      echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
556      echo "export DateBegin=${PackDateBegin}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
557      echo "export DateEnd=${PeriodDateEnd}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
558      echo "export PeriodPack=${config_Post_PackFrequency} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
559      echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
560      echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
561      echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
562      echo "export script=${script}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
563      echo "export postProcessingStopLevel=${postProcessingStopLevel}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
564#       if [ X${MASTER} = Xtitane ] ; then
565#         echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
566#         echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
567#       fi
568      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
569      echo "IGCM_debug_Verif_Exit                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
570      echo "IGCM_sys_QsubPost ${script}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
571#       if [ X${MASTER} = Xtitane ] ; then
572#         echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
573#       fi
574      echo "IGCM_debug_Verif_Exit                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
575    else
576      IGCM_sys_RshPost <<-EOF
577        export DEBUG_debug=${DEBUG_debug}
578        export BigBrother=${BigBrother}
579        export postProcessingStopLevel=${postProcessingStopLevel}
580        export MODIPSL=${MODIPSL}
581        export libIGCM_SX=${libIGCM}
582        export libIGCM=${libIGCM_POST}
583        export SUBMIT_DIR=${SUBMIT_DIR}
584        export POST_DIR=${POST_DIR}
585        export MASTER=${MASTER}
586        export DateBegin=${PackDateBegin}
587        export DateEnd=${PeriodDateEnd}
588        export PeriodPack=${config_Post_PackFrequency}
589        export StandAlone=false
590        export listVarEnv=${listVarEnv}
591        export Script_Post_Output=${Script_Post_Output}
592        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
593        . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
594        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
595        IGCM_sys_MkdirWork ${POST_DIR}
596        IGCM_debug_Verif_Exit
597        IGCM_sys_QsubPost ${script}
598        IGCM_debug_Verif_Exit
599EOF
600      export DateBegin=${SavedDateBegin}
601      export DateEnd=${SavedDateEnd}
602    fi
603  fi
604
605  #============== REBUILD POST-PROCESSING =============#
606  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
607    # -----------------------------------------------------------------------------------
608    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
609    # -----------------------------------------------------------------------------------
610    echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
611    echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
612    IGCM_sys_Mv REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
613  fi
614  #
615  if [ ${RebuildFrequency} = true ] ; then
616    IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
617    echo
618    script=rebuild_fromWorkdir
619    #
620    Script_Post_Output=${script}.${PeriodDateEnd}
621    #
622    listVarEnv="DEBUG_debug,BigBrother,postProcessingStopLevel,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,Script_Post_Output,MASTER,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
623    IGCM_sys_RshPost <<-EOF
624      export DEBUG_debug=${DEBUG_debug}
625      export BigBrother=${BigBrother}
626      export postProcessingStopLevel=${postProcessingStopLevel}
627      export MODIPSL=${MODIPSL}
628      export libIGCM_SX=${libIGCM}
629      export libIGCM=${libIGCM_POST}
630      export SUBMIT_DIR=${SUBMIT_DIR}
631      export REBUILD_DIR=${REBUILD_DIR}
632      export POST_DIR=${POST_DIR}
633      export MASTER=${MASTER}
634      export DateBegin=${DateBegin}
635      export PeriodDateBegin=${PeriodDateBegin}
636      export PeriodDateEnd=${PeriodDateEnd}
637      export NbRebuildDir=${NbRebuildDir}
638      export StandAlone=false
639      export RESOL_ATM=${RESOL_ATM}
640      export RESOL_OCE=${RESOL_OCE}
641      export RESOL_ICE=${RESOL_ICE}
642      export RESOL_MBG=${RESOL_MBG}
643      export RESOL_SRF=${RESOL_SRF}
644      export RESOL_SBG=${RESOL_SBG}
645      export listVarEnv=${listVarEnv}
646      export Script_Post_Output=${Script_Post_Output}
647      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
648      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
649      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
650      IGCM_sys_MkdirWork ${POST_DIR}
651      IGCM_debug_Verif_Exit
652      IGCM_sys_QsubPost ${script}
653      IGCM_debug_Verif_Exit
654EOF
655  fi
656  IGCM_debug_PopStack "IGCM_post_Submit"
657}
658
659#===================================
660function IGCM_post_CheckModuloFrequency
661{
662  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $@
663
664  # Used by IGCM_config_Check
665  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d)
666  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero
667  # Input parameter are the name of the variable, not the frequency value itself
668  # example
669  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
670
671  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
672
673  # Get the name of the variable
674  MasterName=$1
675  SlaveName=$2
676  # Get the value the above name points to
677  MasterFrequency=$( eval echo \${${1}} )
678  SlaveFrequency=$( eval echo \${${2}} )
679
680  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
681
682  case ${MasterFrequency} in
683  *y|*Y)
684    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
685    case ${SlaveFrequency} in
686    *Y|*y)
687      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
688      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \
689      [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] )then
690        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
691        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
692        IGCM_debug_Exit "Check your frequency"
693      else
694        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
695      fi ;;
696    *M|*m)
697      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
698      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
699        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then
700        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
701        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
702        IGCM_debug_Exit "Check your frequency"
703      else
704        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
705      fi ;;
706    *D|*d)
707      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
708      NbDays=$( IGCM_date_DaysInYear ${year} )
709      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
710        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \
711          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then
712          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
713          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
714          IGCM_debug_Exit "Check your frequency"
715        fi
716      else
717        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:"
718        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}"
719        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry"
720        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too."
721      fi ;;
722    esac ;;
723  *M|*m)
724    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
725    case ${SlaveFrequency} in
726    *Y|*y)
727      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
728      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
729        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then
730        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
731        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
732        IGCM_debug_Exit "Check your frequency"
733      else
734        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
735      fi ;;
736    *M|*m)
737      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
738      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
739        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then
740        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
741        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
742        IGCM_debug_Exit "Check your frequency"
743      else
744        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
745      fi ;;
746    *D|*d)
747      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
748      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
749      IGCM_debug_Exit "Check your frequency" ;;
750    esac ;;
751  *D|*d)
752    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
753    case ${SlaveFrequency} in
754    *Y|*y)
755      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
756      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
757      IGCM_debug_Exit "Check your frequency" ;;
758    *M|*m)
759      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
760      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
761      IGCM_debug_Exit "Check your frequency" ;;
762    *D|*d)
763      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
764      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \
765        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then
766        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
767        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
768        IGCM_debug_Exit "Check your frequency"
769      else
770        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
771      fi ;;
772    esac ;;
773  NONE|none)
774    ;;
775  *)
776    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card"
777    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;;
778  esac
779
780  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
781}
782
783#===================================
784function IGCM_post_ModuloRuntimeFrequency
785{
786  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $@
787
788  # Used by IGCM_post_Configure
789  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
790  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
791  # --> turn on post-processing submission when their modulo is zero
792  # Input parameter are the name of the variable, not the frequency value itself
793  # example
794  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength
795
796  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
797
798  # Get the name of the variable
799  MasterName=$1
800  SlaveName=$2
801  # Get the value the above name points to
802  eval MasterFrequency=\${${1}}
803  eval SlaveFrequency=\${${2}}
804
805  echo
806  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
807
808  case ${MasterFrequency} in
809  *y|*Y)
810    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
811    case ${SlaveFrequency} in
812    *Y|*y)
813      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
814      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then
815        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
816          eval ${post_freq}=true ; POST=true
817          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
818        fi
819      fi;;
820    *M|*m)
821      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
822      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
823        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then
824          eval ${post_freq}=true ; POST=true
825          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
826        fi
827      fi;;
828    *D|*d)
829      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
830      NbDays=$( IGCM_date_DaysInYear ${year} )
831      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then
832        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then
833          eval ${post_freq}=true ; POST=true
834          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} ))
835        fi
836      fi;;
837    esac ;;
838  *M|*m)
839    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
840    case ${SlaveFrequency} in
841    *Y|*y)
842      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
843      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then
844        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then
845          eval ${post_freq}=true ; POST=true
846          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
847        fi
848      fi;;
849    *M|*m)
850      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
851      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
852        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then
853          eval ${post_freq}=true ; POST=true
854          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
855        fi
856      fi;;
857    *D|*d)
858      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
859      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
860    esac ;;
861  *D|*d)
862    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
863    case ${SlaveFrequency} in
864    *Y|*y)
865      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
866      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
867    *M|*m)
868      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
869      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
870    *D|*d)
871      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
872      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then
873        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then
874          eval ${post_freq}=true ; POST=true
875          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
876        fi
877      fi;;
878    esac ;;
879  NONE|none)
880    ;;
881  *)
882    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card"
883    ;;
884  esac
885
886  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
887}
Note: See TracBrowser for help on using the repository browser.