source: branches/libIGCM_CESMEP/libIGCM_post/libIGCM_post.ksh @ 1561

Last change on this file since 1561 was 1561, checked in by ssenesi, 20 months ago

Cesmep : fix case AtEnd?

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