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

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