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

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

Handle C-ESM-EP atlas in post-processing

  • 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.7 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  IGCM_debug_Print 1 "Possibly launching C-ESM-EP run script"
679  if [ ${CesmepAtEnd} = true ] ; then
680      #
681      IGCM_debug_Print 1 "Launching C-ESM-EP run script"
682      ${SUBMIT_DIR}/cesmep_lite/libIGCM_post.sh $DateBegin $PeriodDateEnd
683  fi
684
685 
686  IGCM_debug_PopStack "IGCM_post_Submit"
687}
688
689#===================================
690function IGCM_post_CheckModuloFrequency
691{
692  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $@
693
694  # Used by IGCM_config_Check
695  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d)
696  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero
697  # Input parameter are the name of the variable, not the frequency value itself
698  # example
699  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
700
701  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
702
703  # Get the name of the variable
704  MasterName=$1
705  SlaveName=$2
706  # Get the value the above name points to
707  MasterFrequency=$( eval echo \${${1}} )
708  SlaveFrequency=$( eval echo \${${2}} )
709
710  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
711
712  case ${MasterFrequency} in
713  *y|*Y)
714    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
715    case ${SlaveFrequency} in
716    *Y|*y)
717      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
718      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \
719      [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] )then
720        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
721        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
722        IGCM_debug_Exit "Check your frequency"
723      else
724        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
725      fi ;;
726    *M|*m)
727      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
728      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
729        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then
730        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
731        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
732        IGCM_debug_Exit "Check your frequency"
733      else
734        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
735      fi ;;
736    *D|*d)
737      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
738      NbDays=$( IGCM_date_DaysInYear ${year} )
739      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
740        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \
741          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then
742          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
743          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
744          IGCM_debug_Exit "Check your frequency"
745        fi
746      else
747        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:"
748        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}"
749        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry"
750        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too."
751      fi ;;
752    esac ;;
753  *M|*m)
754    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
755    case ${SlaveFrequency} in
756    *Y|*y)
757      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
758      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
759        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then
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      else
764        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
765      fi ;;
766    *M|*m)
767      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
768      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
769        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then
770        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
771        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
772        IGCM_debug_Exit "Check your frequency"
773      else
774        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
775      fi ;;
776    *D|*d)
777      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
778      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
779      IGCM_debug_Exit "Check your frequency" ;;
780    esac ;;
781  *D|*d)
782    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
783    case ${SlaveFrequency} in
784    *Y|*y)
785      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
786      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
787      IGCM_debug_Exit "Check your frequency" ;;
788    *M|*m)
789      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
790      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
791      IGCM_debug_Exit "Check your frequency" ;;
792    *D|*d)
793      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
794      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \
795        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then
796        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
797        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
798        IGCM_debug_Exit "Check your frequency"
799      else
800        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
801      fi ;;
802    esac ;;
803  NONE|none)
804    ;;
805  *)
806    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card"
807    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;;
808  esac
809
810  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
811}
812
813#===================================
814function IGCM_post_ModuloRuntimeFrequency
815{
816  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $@
817
818  # Used by IGCM_post_Configure
819  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
820  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
821  # --> turn on post-processing submission when their modulo is zero by
822  # setting env variable post_freq
823  # Input parameter are the name of the variable, not the frequency value itself
824  # example
825  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength
826
827  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
828
829  # Get the name of the variable
830  MasterName=$1
831  SlaveName=$2
832  # Get the value the above name points to
833  eval MasterFrequency=\${${1}}
834  eval SlaveFrequency=\${${2}}
835
836  echo
837  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
838
839  case ${MasterFrequency} in
840  *y|*Y)
841    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
842    case ${SlaveFrequency} in
843    *Y|*y)
844      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
845      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then
846        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
847          eval ${post_freq}=true ; POST=true
848          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
849        fi
850      fi;;
851    *M|*m)
852      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
853      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
854        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then
855          eval ${post_freq}=true ; POST=true
856          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
857        fi
858      fi;;
859    *D|*d)
860      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
861      NbDays=$( IGCM_date_DaysInYear ${year} )
862      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then
863        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then
864          eval ${post_freq}=true ; POST=true
865          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} ))
866        fi
867      fi;;
868    esac ;;
869  *M|*m)
870    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
871    case ${SlaveFrequency} in
872    *Y|*y)
873      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
874      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then
875        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then
876          eval ${post_freq}=true ; POST=true
877          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
878        fi
879      fi;;
880    *M|*m)
881      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
882      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
883        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then
884          eval ${post_freq}=true ; POST=true
885          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
886        fi
887      fi;;
888    *D|*d)
889      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
890      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
891    esac ;;
892  *D|*d)
893    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
894    case ${SlaveFrequency} in
895    *Y|*y)
896      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
897      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
898    *M|*m)
899      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
900      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
901    *D|*d)
902      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
903      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then
904        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then
905          eval ${post_freq}=true ; POST=true
906          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
907        fi
908      fi;;
909    esac ;;
910  NONE|none)
911    ;;
912  *)
913    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card"
914    ;;
915  esac
916
917  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
918}
Note: See TracBrowser for help on using the repository browser.