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

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

cosmetics (white space clean-up)

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