source: tags/libIGCM_v2.0_beta2/libIGCM_post/libIGCM_post.ksh @ 1456

Last change on this file since 1456 was 663, checked in by mafoipsl, 12 years ago

Very small correction to improve information listing.

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