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
RevLine 
[2]1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
[373]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
[2]9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=======================================================================
[22]15
16function IGCM_post_Configure
17{
[544]18  IGCM_debug_PushStack "IGCM_post_Configure"
[22]19
[544]20  # Debug Print :
21  echo
22  IGCM_debug_Print 1 "IGCM_post_Configure"
23  #
24  # Initialize
25  #
26  POST=false
27  RebuildFrequency=false
[554]28  PackFrequency=false
[544]29  TimeSeriesFrequency=false
30  SeasonalFrequency=false
[1554]31  CesmepAtEnd=false
[554]32  unset list_post
[544]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  #
[554]40  if [ X${Pack} = Xtrue ] ; then
41    list_post="${list_post} PackFrequency"
42  fi
43  #
[653]44  if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] || [ X${TimeSeriesChunck2D} = Xtrue ] || [ X${TimeSeriesChunck3D} = Xtrue ] ) ; then
[544]45    list_post="${list_post} TimeSeriesFrequency"
46  fi
47  #
48  if [ X${Seasonal} = Xtrue ] ; then
49    list_post="${list_post} SeasonalFrequency"
50  fi
[380]51
[1034]52  # Overrule Time Series triggering. Special case 1.
[544]53  if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \
[545]54    [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]           && \
[544]55    [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
56    TimeSeriesFrequency=true
57    POST=true
58  fi
[1034]59  # Overrule Rebuild triggering. Special case 2.
[545]60  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
[544]61    RebuildFrequency=true
62    POST=true
63  fi
[1034]64  # Overrule Pack triggering. Special case 3.
65  if ( [ X${Pack} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
66    PackFrequency=true
67    POST=true
68  fi
[544]69
[1034]70  # READ REBUILD OR PACK OR TIME SERIES OR SEASONAL FREQUENCY
[544]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
[786]78        PeriodOffset=0
[544]79      else
[786]80        PeriodOffset=${config_Post_SeasonalFrequencyOffset}
[544]81      fi
82    else
83      PeriodOffset=0
[380]84    fi
[544]85    # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\)
86    # RebuildFrequency needs additionnal information
87    if [ ${post_freq} = RebuildFrequency ] ; then
[639]88      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbPeriodPerFrequency
89      NbRebuildDir=${NbPeriodPerFrequency}
[544]90    else
91      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength
[380]92    fi
[34]93    #
[663]94    eval IGCM_debug_Print 1 \" "${post_freq} flag value : \${${post_freq}}" \"
[544]95  done
96  #
97  IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}"
98  #
[653]99  # Prepare headers for the shell dedicated to post-processing
100  if ( [ ${PackFrequency} = true ] && ( [ ${TimeSeriesFrequency} = true ] || [ ${SeasonalFrequency} = true ] ) ) ; then
[628]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
[1554]111
112  if ( [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] && [ X${config_Post_Cesmep} = XAtEnd ] ) ; then
113      CesmepAtEnd=true
114  fi
115 
116 
[544]117  IGCM_debug_PopStack "IGCM_post_Configure"
[2]118}
119
120function IGCM_post_Submit
121{
[544]122  IGCM_debug_PushStack "IGCM_post_Submit"
[2]123
[555]124  typeset listVarEnv DaysTemp
[381]125
[545]126  POST_DIR=${R_BUF_KSH}
[622]127
[544]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
[34]134
[554]135  #============ TIME SERIES POST-PROCESSING ===========#
[544]136  if [ ${TimeSeriesFrequency} = true ] ; then
[2]137
[544]138    IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ACTIVATED"
139    echo
[149]140
141
142
[544]143    # Get information from last execution
144    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
145    CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
146    #
[149]147
148
149
[1290]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"
[544]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
[786]158      #
159        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED"
160        echo
[544]161        #
[786]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        #
[1257]170        if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
[786]171          #
[628]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          #
[786]178          if [ -f ${FunctionPath} ] ; then
179#           if [ X${MASTER} = Xtitane ] ; then
180#             echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
181#           fi
[1290]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}
[1554]206            echo "export PostCesmep=${config_Post_Cesmep}                  " >> ${FunctionPath}
[1290]207            echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
[786]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}
[1206]213            echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
[786]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
[149]221                    export DEBUG_debug=${DEBUG_debug}
[1070]222                    export BigBrother=${BigBrother}
[1290]223                    export postProcessingStopLevel=${postProcessingStopLevel}
[149]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}
[417]236                    unset  CompToRead
[786]237                    unset  FlagToRead
[149]238                    export RESOL_ATM=${RESOL_ATM}
239                    export RESOL_OCE=${RESOL_OCE}
240                    export RESOL_ICE=${RESOL_ICE}
[178]241                    export RESOL_MBG=${RESOL_MBG}
[149]242                    export RESOL_SRF=${RESOL_SRF}
[337]243                    export RESOL_SBG=${RESOL_SBG}
[1554]244                    export PostCesmep=${config_Post_Cesmep}
[149]245                    export listVarEnv=${listVarEnv}
[387]246                    export Script_Post_Output=${Script_Post_Output}
[149]247                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
248                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
249                    IGCM_sys_MkdirWork ${POST_DIR}
[1206]250                    IGCM_debug_Verif_Exit
[149]251                    IGCM_sys_QsubPost create_ts
252EOF
[786]253        fi
[544]254      fi
255      #
256      if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
[786]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          #
[1257]290          if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
[786]291            #
[628]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            #
[786]298            if [ -f ${FunctionPath} ] ; then
299#             if [ X${MASTER} = Xtitane ] ; then
300#               echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
301#             fi
[1290]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}
[1554]326              echo "export PostCesmep=${config_Post_Cesmep}                  " >> ${FunctionPath}
[1290]327              echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
[786]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}
[1206]333              echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
[786]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
[149]341                        export DEBUG_debug=${DEBUG_debug}
[1070]342                        export BigBrother=${BigBrother}
[1298]343                        export postProcessingStopLevel=${postProcessingStopLevel}
[149]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}
[178]361                        export RESOL_MBG=${RESOL_MBG}
[149]362                        export RESOL_SRF=${RESOL_SRF}
[337]363                        export RESOL_SBG=${RESOL_SBG}
[149]364                        export listVarEnv=${listVarEnv}
[1554]365                        export PostCesmep=${config_Post_Cesmep}
[387]366                        export Script_Post_Output=${Script_Post_Output}
[149]367                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
368                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
369                        IGCM_sys_MkdirWork ${POST_DIR}
[1206]370                        IGCM_debug_Verif_Exit
[149]371                        IGCM_sys_QsubPost create_ts
[2]372EOF
[786]373            #
374          fi
375          #
376          export DateBegin=${SavedDateBegin}
377          #
378          (( i=i+1 ))
379          #
380        done
[544]381      fi
382      (( j=j+1 ))
383    done
384  fi
[149]385
[554]386  #=============  SEASONAL POST-PROCESSING ============#
[544]387  if [ ${SeasonalFrequency} = true ] ; then
388    #
[554]389    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING"
[544]390    echo
391    #
392    Script_Post_Output=create_se.${PeriodDateEnd}
393    #
[1290]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"
[544]395
[1257]396    if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
[544]397      #
[628]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
[786]405      #
406#     if [ X${MASTER} = Xtitane ] ; then
407#       echo "IGCM_sys_RshPost <<-EOF"                     >> ${FunctionPath}
408#     fi
[1290]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}
[1554]428      echo "export PostCesmep=${config_Post_Cesmep}                  " >> ${FunctionPath}
[1290]429      echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
[786]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}
[1206]435      echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
[786]436      echo "IGCM_sys_QsubPost create_se                    " >> ${FunctionPath}
437#     if [ X${MASTER} = Xtitane ] ; then
438#       echo "EOF"                                         >> ${FunctionPath}
439#     fi
[544]440      fi
441    else
442      IGCM_sys_RshPost <<-EOF
[36]443            export DEBUG_debug=${DEBUG_debug}
[1070]444            export BigBrother=${BigBrother}
[1290]445            export postProcessingStopLevel=${postProcessingStopLevel}
[22]446            export MODIPSL=${MODIPSL}
[1070]447            export libIGCM_SX=${libIGCM}
[22]448            export libIGCM=${libIGCM_POST}
449            export SUBMIT_DIR=${SUBMIT_DIR}
450            export POST_DIR=${POST_DIR}
[72]451            export MASTER=${MASTER}
[22]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}
[178]458            export RESOL_MBG=${RESOL_MBG}
[22]459            export RESOL_SRF=${RESOL_SRF}
[337]460            export RESOL_SBG=${RESOL_SBG}
[22]461            export listVarEnv=${listVarEnv}
[1554]462            export PostCesmep=${config_Post_Cesmep}
[387]463            export Script_Post_Output=${Script_Post_Output}
[22]464            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
465            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
466            IGCM_sys_MkdirWork ${POST_DIR}
[1206]467            IGCM_debug_Verif_Exit
[22]468            IGCM_sys_QsubPost create_se
469EOF
470    fi
[544]471  fi
[22]472
[628]473  #============== PACK PROCESSING FOR RESTART, DEBUG AND OUTPUT FILES =============#
[554]474  if [ ${PackFrequency} = true ] ; then
475    IGCM_debug_Print 1 "PACK POST-PROCESSING"
[628]476    # -----------------------------------------------------------------------------------
477    # Function IGCM_FlushPost called by pack_output.job has not been closed yet. Do it now
[1077]478    # Will submit Time Series OR Seasonal Average if needed
[628]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
[554]484    echo
485    ## Need to Remember This One
486    SavedDateBegin=${DateBegin}
487    ## Need to Remember This One
488    SavedDateEnd=${DateEnd}
489    #
[555]490    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 ))
[554]491    #
[565]492    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} )
[555]493    #
[554]494    script=pack_debug
495    #
496    Script_Post_Output=${script}.${PeriodDateEnd}
497    #
[1290]498    listVarEnv="DEBUG_debug,BigBrother,postProcessingStopLevel,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,Script_Post_Output,MASTER,DateBegin,DateEnd,PeriodPack,StandAlone"
[554]499    IGCM_sys_RshPost <<-EOF
500    export DEBUG_debug=${DEBUG_debug}
[1070]501    export BigBrother=${BigBrother}
[1290]502    export postProcessingStopLevel=${postProcessingStopLevel}
[554]503    export MODIPSL=${MODIPSL}
504    export libIGCM_SX=${libIGCM}
505    export libIGCM=${libIGCM_POST}
506    export SUBMIT_DIR=${SUBMIT_DIR}
[568]507    export POST_DIR=${POST_DIR}
[554]508    export MASTER=${MASTER}
509    export DateBegin=${PackDateBegin}
510    export DateEnd=${PeriodDateEnd}
[569]511    export PeriodPack=${config_Post_PackFrequency}
[554]512    export StandAlone=false
513    export listVarEnv=${listVarEnv}
[1554]514    export PostCesmep=${config_Post_Cesmep}
[554]515    export Script_Post_Output=${Script_Post_Output}
516    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
[985]517    . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
[554]518    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
519    IGCM_sys_MkdirWork ${POST_DIR}
[1206]520    IGCM_debug_Verif_Exit
[565]521    IGCM_sys_QsubPost ${script}
[985]522    IGCM_debug_Verif_Exit
[554]523EOF
[565]524    #
525    script=pack_restart
526    #
527    Script_Post_Output=${script}.${PeriodDateEnd}
528    #
[786]529      IGCM_sys_RshPost <<-EOF
530      export DEBUG_debug=${DEBUG_debug}
[1070]531      export BigBrother=${BigBrother}
[1290]532      export postProcessingStopLevel=${postProcessingStopLevel}
[786]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}
[1396]539      export PeriodDateBegin=${PeriodDateBegin}
[786]540      export DateBegin=${PackDateBegin}
541      export DateEnd=${PeriodDateEnd}
542      export PeriodPack=${config_Post_PackFrequency}
543      export StandAlone=false
544      export listVarEnv=${listVarEnv}
[1554]545      export PostCesmep=${config_Post_Cesmep}
[786]546      export Script_Post_Output=${Script_Post_Output}
547      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
[985]548      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
[786]549      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
550      IGCM_sys_MkdirWork ${POST_DIR}
[1206]551      IGCM_debug_Verif_Exit
[786]552      IGCM_sys_QsubPost ${script}
[985]553      IGCM_debug_Verif_Exit
[565]554EOF
[583]555    #
556    script=pack_output
557    #
558    Script_Post_Output=${script}.${PeriodDateEnd}
559    #
[804]560    if ( [ ${RebuildFrequency} = true ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
[786]561#       if [ X${MASTER} = Xtitane ] ; then
562#         echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
563#       fi
[804]564      echo "export DEBUG_debug=${DEBUG_debug}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[1070]565      echo "export BigBrother=${BigBrother}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[804]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
[1554]577      echo "export PostCesmep=${config_Post_Cesmep}        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[804]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
[1290]580      echo "export postProcessingStopLevel=${postProcessingStopLevel}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[786]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
[804]585      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[1206]586      echo "IGCM_debug_Verif_Exit                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[804]587      echo "IGCM_sys_QsubPost ${script}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[786]588#       if [ X${MASTER} = Xtitane ] ; then
589#         echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
590#       fi
[985]591      echo "IGCM_debug_Verif_Exit                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
[590]592    else
593      IGCM_sys_RshPost <<-EOF
[786]594        export DEBUG_debug=${DEBUG_debug}
[1070]595        export BigBrother=${BigBrother}
[1290]596        export postProcessingStopLevel=${postProcessingStopLevel}
[786]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}
[1554]608        export PostCesmep=${config_Post_Cesmep}
[786]609        export Script_Post_Output=${Script_Post_Output}
610        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
[985]611        . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
[786]612        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
613        IGCM_sys_MkdirWork ${POST_DIR}
[1206]614        IGCM_debug_Verif_Exit
[786]615        IGCM_sys_QsubPost ${script}
[985]616        IGCM_debug_Verif_Exit
[583]617EOF
[786]618      export DateBegin=${SavedDateBegin}
619      export DateEnd=${SavedDateEnd}
[590]620    fi
[554]621  fi
[590]622
623  #============== REBUILD POST-PROCESSING =============#
[804]624  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
[590]625    # -----------------------------------------------------------------------------------
626    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
627    # -----------------------------------------------------------------------------------
[1043]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}
[590]631  fi
632  #
633  if [ ${RebuildFrequency} = true ] ; then
[1031]634    IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
635    echo
[927]636    script=rebuild_fromWorkdir
[590]637    #
638    Script_Post_Output=${script}.${PeriodDateEnd}
639    #
[1290]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"
[590]641    IGCM_sys_RshPost <<-EOF
[786]642      export DEBUG_debug=${DEBUG_debug}
[1070]643      export BigBrother=${BigBrother}
[1290]644      export postProcessingStopLevel=${postProcessingStopLevel}
[786]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}
[1554]664      export PostCesmep=${config_Post_Cesmep}
[786]665      export Script_Post_Output=${Script_Post_Output}
666      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
[985]667      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
[786]668      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
669      IGCM_sys_MkdirWork ${POST_DIR}
[1206]670      IGCM_debug_Verif_Exit
[786]671      IGCM_sys_QsubPost ${script}
[985]672      IGCM_debug_Verif_Exit
[590]673EOF
674  fi
[1554]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
[544]684  IGCM_debug_PopStack "IGCM_post_Submit"
[2]685}
[380]686
687#===================================
688function IGCM_post_CheckModuloFrequency
689{
[1057]690  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $@
[380]691
[544]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
[380]698
[544]699  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
[380]700
[544]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}} )
[380]707
[544]708  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
[380]709
[544]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} ] || \
[786]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"
[639]721      else
722        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
[544]723      fi ;;
724    *M|*m)
725      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
726      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
[786]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"
[639]731      else
732        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
[544]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
[786]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
[544]744      else
[786]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."
[544]749      fi ;;
750    esac ;;
751  *M|*m)
752    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
[590]753    case ${SlaveFrequency} in
[544]754    *Y|*y)
755      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
756      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
[786]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"
[639]761      else
762        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
[544]763      fi ;;
764    *M|*m)
765      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
766      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
[1077]767        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then
[786]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"
[639]771      else
772        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
[544]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}"
[786]796        IGCM_debug_Exit "Check your frequency"
[639]797      else
798        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
[544]799      fi ;;
800    esac ;;
[545]801  NONE|none)
[544]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
[380]807
[544]808  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
[380]809}
810
811#===================================
812function IGCM_post_ModuloRuntimeFrequency
813{
[1057]814  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $@
[380]815
[544]816  # Used by IGCM_post_Configure
[1077]817  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
[544]818  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
[1554]819  # --> turn on post-processing submission when their modulo is zero by
820  # setting env variable post_freq
[544]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
[380]824
[544]825  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
[380]826
[544]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}}
[380]833
[544]834  echo
835  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
[380]836
[544]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
[786]844        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
845          eval ${post_freq}=true ; POST=true
846          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
847        fi
[544]848      fi;;
849    *M|*m)
850      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
851      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
[786]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
[544]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
[786]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
[544]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
[786]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
[544]877      fi;;
878    *M|*m)
879      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
880      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
[1077]881        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then
[786]882          eval ${post_freq}=true ; POST=true
883          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
884        fi
[544]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
[786]903          eval ${post_freq}=true ; POST=true
904          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
905        fi
[544]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
[380]914
[544]915  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
[380]916}
Note: See TracBrowser for help on using the repository browser.