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

Last change on this file since 1034 was 1034, checked in by sdipsl, 10 years ago

See #188 Even if SimulationLength? < PackFrequency? we have to submit pack! Handy to help with quick setup

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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