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

Last change on this file since 1059 was 1057, checked in by sdipsl, 10 years ago
  • refactor archive and storage path definition. They can be defined using UserChoices? from config.card. Very easy now to decide where to store everything. There is a single place to look at : IGCM_sys_defineArchives. see #221
  • clean up IGCM_debug_PushStack arguments
  • 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: 41.1 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,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,CompletedFlag,TsTask,CompToRead,FlagToRead,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_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 ] ; 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 MODIPSL=${MODIPSL}                      " >> ${FunctionPath}
177            echo "export libIGCM_SX=${libIGCM}                   " >> ${FunctionPath}
178            echo "export libIGCM=${libIGCM_POST}                 " >> ${FunctionPath}
179            echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${FunctionPath}
180            echo "export POST_DIR=${POST_DIR}                    " >> ${FunctionPath}
181            echo "export MASTER=${MASTER}                        " >> ${FunctionPath}
182            echo "export RebuildFrequency=${RebuildFrequency}    " >> ${FunctionPath}
183            echo "export DateBegin=${DateBegin}                  " >> ${FunctionPath}
184            echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${FunctionPath}
185            echo "export StandAlone=false                        " >> ${FunctionPath}
186            echo "export CompletedFlag=${CompletedFlag}          " >> ${FunctionPath}
187            echo "export TsTask=${TsTask}                        " >> ${FunctionPath}
188            echo "unset  CompToRead                              " >> ${FunctionPath}
189            echo "unset  FlagToRead                              " >> ${FunctionPath}
190            echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${FunctionPath}
191            echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${FunctionPath}
192            echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${FunctionPath}
193            echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${FunctionPath}
194            echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${FunctionPath}
195            echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${FunctionPath}
196            echo "export listVarEnv=${listVarEnv}                " >> ${FunctionPath}
197            echo "export Script_Post_Output=${Script_Post_Output}" >> ${FunctionPath}
198#           if [ X${MASTER} = Xtitane ] ; then
199#             echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
200#             echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
201#           fi
202            echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
203            echo "IGCM_debug_Verif_Exit_Post                     " >> ${FunctionPath}
204            echo "IGCM_sys_QsubPost create_ts                    " >> ${FunctionPath}
205#           if [ X${MASTER} = Xtitane ] ; then
206#             echo "EOF"                                           >> ${FunctionPath}
207#           fi
208          fi
209        else
210          IGCM_sys_RshPost <<-EOF
211                    export DEBUG_debug=${DEBUG_debug}
212                    export MODIPSL=${MODIPSL}
213                    export libIGCM_SX=${libIGCM}
214                    export libIGCM=${libIGCM_POST}
215                    export SUBMIT_DIR=${SUBMIT_DIR}
216                    export POST_DIR=${POST_DIR}
217                    export MASTER=${MASTER}
218                    export RebuildFrequency=${RebuildFrequency}
219                    export DateBegin=${DateBegin}
220                    export PeriodDateEnd=${PeriodDateEnd}
221                    export StandAlone=false
222                    export CompletedFlag=${CompletedFlag}
223                    export TsTask=${TsTask}
224                    unset  CompToRead
225                    unset  FlagToRead
226                    export RESOL_ATM=${RESOL_ATM}
227                    export RESOL_OCE=${RESOL_OCE}
228                    export RESOL_ICE=${RESOL_ICE}
229                    export RESOL_MBG=${RESOL_MBG}
230                    export RESOL_SRF=${RESOL_SRF}
231                    export RESOL_SBG=${RESOL_SBG}
232                    export listVarEnv=${listVarEnv}
233                    export Script_Post_Output=${Script_Post_Output}
234                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
235                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
236                    IGCM_sys_MkdirWork ${POST_DIR}
237                    IGCM_debug_Verif_Exit_Post
238                    IGCM_sys_QsubPost create_ts
239EOF
240        fi
241      fi
242      #
243      if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
244        #
245        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED"
246        echo
247        # Need to Remember This One
248        SavedDateBegin=${DateBegin}
249        # Kind of task create_ts will perform
250        TsTask=Chunck${Dimension}
251        # Number of chunck jobs to configure and submit
252        eval NbJob=\${#CHUNCK${Dimension}_COMP[@]}
253        typeset i
254        i=0
255        until [ $i -ge $NbJob ]; do
256          CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
257          FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
258          NameToRead=$( eval echo \${CHUNCK${Dimension}_NAME[\${i}]} )
259          ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} )
260          # Chunck Length (mandatory in Year)
261          YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" )
262          #
263          IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin
264          #
265          IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd
266          # How many chunck in total since simulation began
267          NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} ))
268          #  Tweak special case
269          [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
270          # Starting Year of the current chunck
271          ChunckTsYearBegin=$(( ${NbYearsChunckLoop} * ${YearsChunckLength} + ${YearBegin} ))
272          # Starting date of the current chunck
273          ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
274          #
275          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead}
276          #
277          if [ ${RebuildFrequency} = true ] ; then
278            #
279            if [ ${PackFrequency} = true ] ; then
280              FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
281            else
282              FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
283            fi
284            #
285            if [ -f ${FunctionPath} ] ; then
286#             if [ X${MASTER} = Xtitane ] ; then
287#               echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
288#             fi
289              echo "export DEBUG_debug=${DEBUG_debug}              " >> ${FunctionPath}
290              echo "export MODIPSL=${MODIPSL}                      " >> ${FunctionPath}
291              echo "export libIGCM_SX=${libIGCM}                   " >> ${FunctionPath}
292              echo "export libIGCM=${libIGCM_POST}                 " >> ${FunctionPath}
293              echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${FunctionPath}
294              echo "export POST_DIR=${POST_DIR}                    " >> ${FunctionPath}
295              echo "export MASTER=${MASTER}                        " >> ${FunctionPath}
296              echo "export RebuildFrequency=${RebuildFrequency}    " >> ${FunctionPath}
297              echo "export DateBegin=${ChunckTsDateBegin}          " >> ${FunctionPath}
298              echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${FunctionPath}
299              echo "export StandAlone=false                        " >> ${FunctionPath}
300              echo "export CompletedFlag=${CompletedFlag}          " >> ${FunctionPath}
301              echo "export TsTask=${TsTask}                        " >> ${FunctionPath}
302              echo "export CompToRead=${CompToRead}                " >> ${FunctionPath}
303              echo "export FlagToRead=${FlagToRead}                " >> ${FunctionPath}
304              echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${FunctionPath}
305              echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${FunctionPath}
306              echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${FunctionPath}
307              echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${FunctionPath}
308              echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${FunctionPath}
309              echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${FunctionPath}
310              echo "export listVarEnv=${listVarEnv}                " >> ${FunctionPath}
311              echo "export Script_Post_Output=${Script_Post_Output}" >> ${FunctionPath}
312#             if [ X${MASTER} = Xtitane ] ; then
313#               echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
314#               echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
315#             fi
316              echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
317              echo "IGCM_debug_Verif_Exit_Post                     " >> ${FunctionPath}
318              echo "IGCM_sys_QsubPost create_ts                    " >> ${FunctionPath}
319#             if [ X${MASTER} = Xtitane ] ; then
320#               echo "EOF"                                           >> ${FunctionPath}
321#             fi
322            fi
323          else
324            IGCM_sys_RshPost <<-EOF
325                        export DEBUG_debug=${DEBUG_debug}
326                        export MODIPSL=${MODIPSL}
327                        export libIGCM_SX=${libIGCM}
328                        export libIGCM=${libIGCM_POST}
329                        export SUBMIT_DIR=${SUBMIT_DIR}
330                        export POST_DIR=${POST_DIR}
331                        export MASTER=${MASTER}
332                        export RebuildFrequency=${RebuildFrequency}
333                        export DateBegin=${ChunckTsDateBegin}
334                        export PeriodDateEnd=${PeriodDateEnd}
335                        export StandAlone=false
336                        export CompletedFlag=${CompletedFlag}
337                        export TsTask=${TsTask}
338                        export CompToRead=${CompToRead}
339                        export FlagToRead=${FlagToRead}
340                        export RESOL_ATM=${RESOL_ATM}
341                        export RESOL_OCE=${RESOL_OCE}
342                        export RESOL_ICE=${RESOL_ICE}
343                        export RESOL_MBG=${RESOL_MBG}
344                        export RESOL_SRF=${RESOL_SRF}
345                        export RESOL_SBG=${RESOL_SBG}
346                        export listVarEnv=${listVarEnv}
347                        export Script_Post_Output=${Script_Post_Output}
348                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
349                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
350                        IGCM_sys_MkdirWork ${POST_DIR}
351                        IGCM_debug_Verif_Exit_Post
352                        IGCM_sys_QsubPost create_ts
353EOF
354            #
355          fi
356          #
357          export DateBegin=${SavedDateBegin}
358          #
359          (( i=i+1 ))
360          #
361        done
362      fi
363      (( j=j+1 ))
364    done
365  fi
366
367  #=============  SEASONAL POST-PROCESSING ============#
368  if [ ${SeasonalFrequency} = true ] ; then
369    #
370    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING"
371    echo
372    #
373    Script_Post_Output=create_se.${PeriodDateEnd}
374    #
375    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
376
377    if [ ${RebuildFrequency} = true ] ; then
378      #
379      if [ ${PackFrequency} = true ] ; then
380        FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
381      else
382        FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
383      fi
384      #
385      if [ -f ${FunctionPath} ] ; then
386      #
387#     if [ X${MASTER} = Xtitane ] ; then
388#       echo "IGCM_sys_RshPost <<-EOF"                     >> ${FunctionPath}
389#     fi
390      echo "export DEBUG_debug=${DEBUG_debug}              " >> ${FunctionPath}
391      echo "export MODIPSL=${MODIPSL}                      " >> ${FunctionPath}
392      echo "export libIGCM_SX=${libIGCM}                   " >> ${FunctionPath}
393      echo "export libIGCM=${libIGCM_POST}                 " >> ${FunctionPath}
394      echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${FunctionPath}
395      echo "export POST_DIR=${POST_DIR}                    " >> ${FunctionPath}
396      echo "export MASTER=${MASTER}                        " >> ${FunctionPath}
397      echo "export RebuildFrequency=${RebuildFrequency}    " >> ${FunctionPath}
398      echo "export DateBegin=${DateBegin}                  " >> ${FunctionPath}
399      echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${FunctionPath}
400      echo "export StandAlone=false                        " >> ${FunctionPath}
401      echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${FunctionPath}
402      echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${FunctionPath}
403      echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${FunctionPath}
404      echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${FunctionPath}
405      echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${FunctionPath}
406      echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${FunctionPath}
407      echo "export listVarEnv=${listVarEnv}                " >> ${FunctionPath}
408      echo "export Script_Post_Output=${Script_Post_Output}" >> ${FunctionPath}
409#     if [ X${MASTER} = Xtitane ] ; then
410#       echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
411#       echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
412#     fi
413      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
414      echo "IGCM_debug_Verif_Exit_Post                     " >> ${FunctionPath}
415      echo "IGCM_sys_QsubPost create_se                    " >> ${FunctionPath}
416#     if [ X${MASTER} = Xtitane ] ; then
417#       echo "EOF"                                         >> ${FunctionPath}
418#     fi
419      fi
420    else
421      IGCM_sys_RshPost <<-EOF
422            export DEBUG_debug=${DEBUG_debug}
423            export MODIPSL=${MODIPSL}
424          export libIGCM_SX=${libIGCM}
425            export libIGCM=${libIGCM_POST}
426            export SUBMIT_DIR=${SUBMIT_DIR}
427            export POST_DIR=${POST_DIR}
428            export MASTER=${MASTER}
429            export RebuildFrequency=${RebuildFrequency}
430            export DateBegin=${DateBegin}
431            export PeriodDateEnd=${PeriodDateEnd}
432            export StandAlone=false
433            export RESOL_ATM=${RESOL_ATM}
434            export RESOL_OCE=${RESOL_OCE}
435            export RESOL_ICE=${RESOL_ICE}
436            export RESOL_MBG=${RESOL_MBG}
437            export RESOL_SRF=${RESOL_SRF}
438            export RESOL_SBG=${RESOL_SBG}
439            export listVarEnv=${listVarEnv}
440            export Script_Post_Output=${Script_Post_Output}
441            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
442            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
443            IGCM_sys_MkdirWork ${POST_DIR}
444            IGCM_debug_Verif_Exit_Post
445            IGCM_sys_QsubPost create_se
446EOF
447    fi
448  fi
449
450  #============== PACK PROCESSING FOR RESTART, DEBUG AND OUTPUT FILES =============#
451  if [ ${PackFrequency} = true ] ; then
452    IGCM_debug_Print 1 "PACK POST-PROCESSING"
453    # -----------------------------------------------------------------------------------
454    # Function IGCM_FlushPost called by pack_output.job has not been closed yet. Do it now
455    # Will submit Time Series OR Seasonal Average if needed
456    # -----------------------------------------------------------------------------------
457    if [ -f ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh ] ; then
458      echo "IGCM_debug_PopStack \"IGCM_FlushPost\" " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
459      echo "}                                      " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
460    fi
461    echo
462    ## Need to Remember This One
463    SavedDateBegin=${DateBegin}
464    ## Need to Remember This One
465    SavedDateEnd=${DateEnd}
466    #
467    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 ))
468    #
469    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} )
470    #
471    script=pack_debug
472    #
473    Script_Post_Output=${script}.${PeriodDateEnd}
474    #
475    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,DateBegin,DateEnd,PeriodPack,StandAlone"
476    IGCM_sys_RshPost <<-EOF
477    export DEBUG_debug=${DEBUG_debug}
478    export MODIPSL=${MODIPSL}
479    export libIGCM_SX=${libIGCM}
480    export libIGCM=${libIGCM_POST}
481    export SUBMIT_DIR=${SUBMIT_DIR}
482    export POST_DIR=${POST_DIR}
483    export MASTER=${MASTER}
484    export DateBegin=${PackDateBegin}
485    export DateEnd=${PeriodDateEnd}
486    export PeriodPack=${config_Post_PackFrequency}
487    export StandAlone=false
488    export listVarEnv=${listVarEnv}
489    export Script_Post_Output=${Script_Post_Output}
490    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
491    . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
492    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
493    IGCM_sys_MkdirWork ${POST_DIR}
494    IGCM_debug_Verif_Exit_Post
495    IGCM_sys_QsubPost ${script}
496    IGCM_debug_Verif_Exit
497EOF
498    #
499    script=pack_restart
500    #
501    Script_Post_Output=${script}.${PeriodDateEnd}
502    #
503      IGCM_sys_RshPost <<-EOF
504      export DEBUG_debug=${DEBUG_debug}
505      export MODIPSL=${MODIPSL}
506      export libIGCM_SX=${libIGCM}
507      export libIGCM=${libIGCM_POST}
508      export SUBMIT_DIR=${SUBMIT_DIR}
509      export POST_DIR=${POST_DIR}
510      export MASTER=${MASTER}
511      export DateBegin=${PackDateBegin}
512      export DateEnd=${PeriodDateEnd}
513      export PeriodPack=${config_Post_PackFrequency}
514      export StandAlone=false
515      export listVarEnv=${listVarEnv}
516      export Script_Post_Output=${Script_Post_Output}
517      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
518      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
519      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
520      IGCM_sys_MkdirWork ${POST_DIR}
521      IGCM_debug_Verif_Exit_Post
522      IGCM_sys_QsubPost ${script}
523      IGCM_debug_Verif_Exit
524EOF
525    #
526    script=pack_output
527    #
528    Script_Post_Output=${script}.${PeriodDateEnd}
529    #
530    if ( [ ${RebuildFrequency} = true ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
531#       if [ X${MASTER} = Xtitane ] ; then
532#         echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
533#       fi
534      echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
535      echo "export MODIPSL=${MODIPSL}                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
536      echo "export libIGCM_SX=${libIGCM}                   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
537      echo "export libIGCM=${libIGCM_POST}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
538      echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
539      echo "export POST_DIR=${POST_DIR}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
540      echo "export MASTER=${MASTER}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
541      echo "export DateBegin=${PackDateBegin}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
542      echo "export DateEnd=${PeriodDateEnd}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
543      echo "export PeriodPack=${config_Post_PackFrequency} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
544      echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
545      echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
546      echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
547      echo "export script=${script}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
548#       if [ X${MASTER} = Xtitane ] ; then
549#         echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
550#         echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
551#       fi
552      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
553      echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
554      echo "IGCM_sys_QsubPost ${script}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
555#       if [ X${MASTER} = Xtitane ] ; then
556#         echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
557#       fi
558      echo "IGCM_debug_Verif_Exit                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
559    else
560      IGCM_sys_RshPost <<-EOF
561        export DEBUG_debug=${DEBUG_debug}
562        export MODIPSL=${MODIPSL}
563        export libIGCM_SX=${libIGCM}
564        export libIGCM=${libIGCM_POST}
565        export SUBMIT_DIR=${SUBMIT_DIR}
566        export POST_DIR=${POST_DIR}
567        export MASTER=${MASTER}
568        export DateBegin=${PackDateBegin}
569        export DateEnd=${PeriodDateEnd}
570        export PeriodPack=${config_Post_PackFrequency}
571        export StandAlone=false
572        export listVarEnv=${listVarEnv}
573        export Script_Post_Output=${Script_Post_Output}
574        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
575        . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
576        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
577        IGCM_sys_MkdirWork ${POST_DIR}
578        IGCM_debug_Verif_Exit_Post
579        IGCM_sys_QsubPost ${script}
580        IGCM_debug_Verif_Exit
581EOF
582      export DateBegin=${SavedDateBegin}
583      export DateEnd=${SavedDateEnd}
584    fi
585  fi
586
587  #============== REBUILD POST-PROCESSING =============#
588  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
589    # -----------------------------------------------------------------------------------
590    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
591    # -----------------------------------------------------------------------------------
592    echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
593    echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
594    IGCM_sys_Mv REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
595  fi
596  #
597  if [ ${RebuildFrequency} = true ] ; then
598    IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
599    echo
600    script=rebuild_fromWorkdir
601    #
602    Script_Post_Output=${script}.${PeriodDateEnd}
603    #
604    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,MASTER,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
605    IGCM_sys_RshPost <<-EOF
606      export DEBUG_debug=${DEBUG_debug}
607      export MODIPSL=${MODIPSL}
608      export libIGCM_SX=${libIGCM}
609      export libIGCM=${libIGCM_POST}
610      export SUBMIT_DIR=${SUBMIT_DIR}
611      export REBUILD_DIR=${REBUILD_DIR}
612      export POST_DIR=${POST_DIR}
613      export MASTER=${MASTER}
614      export DateBegin=${DateBegin}
615      export PeriodDateBegin=${PeriodDateBegin}
616      export PeriodDateEnd=${PeriodDateEnd}
617      export NbRebuildDir=${NbRebuildDir}
618      export StandAlone=false
619      export RESOL_ATM=${RESOL_ATM}
620      export RESOL_OCE=${RESOL_OCE}
621      export RESOL_ICE=${RESOL_ICE}
622      export RESOL_MBG=${RESOL_MBG}
623      export RESOL_SRF=${RESOL_SRF}
624      export RESOL_SBG=${RESOL_SBG}
625      export listVarEnv=${listVarEnv}
626      export Script_Post_Output=${Script_Post_Output}
627      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
628      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
629      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
630      IGCM_sys_MkdirWork ${POST_DIR}
631      IGCM_debug_Verif_Exit_Post
632      IGCM_sys_QsubPost ${script}
633      IGCM_debug_Verif_Exit
634EOF
635  fi
636  IGCM_debug_PopStack "IGCM_post_Submit"
637}
638
639#===================================
640function IGCM_post_CheckModuloFrequency
641{
642  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $@
643
644  # Used by IGCM_config_Check
645  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d)
646  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero
647  # Input parameter are the name of the variable, not the frequency value itself
648  # example
649  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
650
651  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
652
653  # Get the name of the variable
654  MasterName=$1
655  SlaveName=$2
656  # Get the value the above name points to
657  MasterFrequency=$( eval echo \${${1}} )
658  SlaveFrequency=$( eval echo \${${2}} )
659
660  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
661
662  case ${MasterFrequency} in
663  *y|*Y)
664    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
665    case ${SlaveFrequency} in
666    *Y|*y)
667      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
668      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \
669      [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] )then
670        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
671        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
672        IGCM_debug_Exit "Check your frequency"
673      else
674        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
675      fi ;;
676    *M|*m)
677      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
678      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
679        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then
680        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
681        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
682        IGCM_debug_Exit "Check your frequency"
683      else
684        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
685      fi ;;
686    *D|*d)
687      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
688      NbDays=$( IGCM_date_DaysInYear ${year} )
689      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
690        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \
691          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then
692          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
693          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
694          IGCM_debug_Exit "Check your frequency"
695        fi
696      else
697        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:"
698        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}"
699        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry"
700        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too."
701      fi ;;
702    esac ;;
703  *M|*m)
704    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
705    case ${SlaveFrequency} in
706    *Y|*y)
707      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
708      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
709        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then
710        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
711        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
712        IGCM_debug_Exit "Check your frequency"
713      else
714        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
715      fi ;;
716    *M|*m)
717      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
718      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
719        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then         
720        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
721        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
722        IGCM_debug_Exit "Check your frequency"
723      else
724        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
725      fi ;;
726    *D|*d)
727      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
728      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
729      IGCM_debug_Exit "Check your frequency" ;;
730    esac ;;
731  *D|*d)
732    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
733    case ${SlaveFrequency} in
734    *Y|*y)
735      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
736      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
737      IGCM_debug_Exit "Check your frequency" ;;
738    *M|*m)
739      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
740      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
741      IGCM_debug_Exit "Check your frequency" ;;
742    *D|*d)
743      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
744      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \
745        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then
746        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
747        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
748        IGCM_debug_Exit "Check your frequency"
749      else
750        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
751      fi ;;
752    esac ;;
753  NONE|none)
754    ;;
755  *)
756    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card"
757    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;;
758  esac
759
760  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
761}
762
763#===================================
764function IGCM_post_ModuloRuntimeFrequency
765{
766  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $@
767
768  # Used by IGCM_post_Configure
769  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
770  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
771  # --> turn on post-processing submission when their modulo is zero
772  # Input parameter are the name of the variable, not the frequency value itself
773  # example
774  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength
775
776  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
777
778  # Get the name of the variable
779  MasterName=$1
780  SlaveName=$2
781  # Get the value the above name points to
782  eval MasterFrequency=\${${1}}
783  eval SlaveFrequency=\${${2}}
784
785  echo
786  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
787
788  case ${MasterFrequency} in
789  *y|*Y)
790    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
791    case ${SlaveFrequency} in
792    *Y|*y)
793      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
794      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then
795        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
796          eval ${post_freq}=true ; POST=true
797          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
798        fi
799      fi;;
800    *M|*m)
801      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
802      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
803        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then
804          eval ${post_freq}=true ; POST=true
805          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
806        fi
807      fi;;
808    *D|*d)
809      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
810      NbDays=$( IGCM_date_DaysInYear ${year} )
811      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then
812        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then
813          eval ${post_freq}=true ; POST=true
814          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} ))
815        fi
816      fi;;
817    esac ;;
818  *M|*m)
819    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
820    case ${SlaveFrequency} in
821    *Y|*y)
822      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
823      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then
824        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then
825          eval ${post_freq}=true ; POST=true
826          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
827        fi
828      fi;;
829    *M|*m)
830      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
831      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
832        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then
833          eval ${post_freq}=true ; POST=true
834          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
835        fi
836      fi;;
837    *D|*d)
838      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
839      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
840    esac ;;
841  *D|*d)
842    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
843    case ${SlaveFrequency} in
844    *Y|*y)
845      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
846      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
847    *M|*m)
848      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
849      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
850    *D|*d)
851      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
852      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then
853        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then
854          eval ${post_freq}=true ; POST=true
855          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
856        fi
857      fi;;
858    esac ;;
859  NONE|none)
860    ;;
861  *)
862    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card"
863    ;;
864  esac
865
866  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
867}
Note: See TracBrowser for help on using the repository browser.