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

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