source: tags/libIGCM_v3.0_beta1/libIGCM_post/libIGCM_post.ksh @ 1399

Last change on this file since 1399 was 1399, checked in by sdipsl, 7 years ago

CMIP6 workflow. Merging trunk into branch 'branch' r:1375:1398

  • 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: 26.4 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  SeasonalFrequency=false
30  unset list_post
31  #
32  # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS
33  #
34  if [ X${AsynchronousRebuild} = Xtrue ] ; then
35    list_post="RebuildFrequency"
36  fi
37  #
38  if [ X${Pack} = Xtrue ] ; then
39    list_post="${list_post} PackFrequency"
40  fi
41  #
42  if [ X${Seasonal} = Xtrue ] ; then
43    list_post="${list_post} SeasonalFrequency"
44  fi
45
46  # Overrule Rebuild triggering. Special case 1.
47  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
48    RebuildFrequency=true
49    POST=true
50  fi
51  # Overrule Pack triggering. Special case 2.
52  if ( [ X${Pack} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
53    PackFrequency=true
54    POST=true
55  fi
56
57  # READ REBUILD OR PACK OR TIME SERIES OR SEASONAL FREQUENCY
58  # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO
59  for post_freq in ${list_post} ; do
60    # Extract frequency from previously defined variable
61    config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} )
62    # Offset for Seasonal Average starting period
63    if [ ${post_freq} = SeasonalFrequency ] ; then
64      if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
65        PeriodOffset=0
66      else
67        PeriodOffset=${config_Post_SeasonalFrequencyOffset}
68      fi
69    else
70      PeriodOffset=0
71    fi
72    # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\)
73    # RebuildFrequency needs additionnal information
74    if [ ${post_freq} = RebuildFrequency ] ; then
75      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbPeriodPerFrequency
76      NbRebuildDir=${NbPeriodPerFrequency}
77    else
78      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength
79    fi
80    #
81    eval IGCM_debug_Print 1 \" "${post_freq} flag value : \${${post_freq}}" \"
82  done
83  #
84  IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}"
85  #
86  # Prepare headers for the shell dedicated to post-processing
87  if ( [ ${PackFrequency} = true ] && [ ${SeasonalFrequency} = true ] ) ; then
88    if [ $DRYRUN -le 1 ]; then
89      echo "#!/bin/ksh                                     " >  ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
90      echo "function IGCM_FlushPost                        " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
91      echo "{                                              " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
92      echo "IGCM_debug_PushStack \"IGCM_FlushPost\"        " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
93      echo "echo                                           " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
94      echo "IGCM_debug_Print 1 \"IGCM_FlushPost\"          " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
95      echo "echo                                           " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
96    fi
97  fi
98  IGCM_debug_PopStack "IGCM_post_Configure"
99}
100
101function IGCM_post_Submit
102{
103  IGCM_debug_PushStack "IGCM_post_Submit"
104
105  typeset listVarEnv DaysTemp
106
107  POST_DIR=${R_BUF_KSH}
108
109  if [ ${POST} = true ]; then
110    echo
111    IGCM_debug_Print 1 "IGCM_post_Submit"
112    echo
113    IGCM_debug_Print 2 "POST_DIR = ${POST_DIR}"
114  fi
115
116  #=============  SEASONAL POST-PROCESSING ============#
117  if [ ${SeasonalFrequency} = true ] ; then
118    #
119    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING"
120    echo
121    #
122    Script_Post_Output=create_se.${PeriodDateEnd}
123    #
124    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"
125
126    if ( [ ${RebuildFrequency} = true ] || [ ${PackFrequency} = true ] ) ; then
127      #
128      if [ ${PackFrequency} = true ] ; then
129        FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
130      else
131        FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
132      fi
133      #
134      if [ -f ${FunctionPath} ] ; then
135      #
136#     if [ X${MASTER} = Xtitane ] ; then
137#       echo "IGCM_sys_RshPost <<-EOF"                     >> ${FunctionPath}
138#     fi
139      echo "export DEBUG_debug=${DEBUG_debug}                        " >> ${FunctionPath}
140      echo "export BigBrother=${BigBrother}                          " >> ${FunctionPath}
141      echo "export postProcessingStopLevel=${postProcessingStopLevel}" >> ${FunctionPath}
142      echo "export MODIPSL=${MODIPSL}                                " >> ${FunctionPath}
143      echo "export libIGCM_SX=${libIGCM}                             " >> ${FunctionPath}
144      echo "export libIGCM=${libIGCM_POST}                           " >> ${FunctionPath}
145      echo "export SUBMIT_DIR=${SUBMIT_DIR}                          " >> ${FunctionPath}
146      echo "export POST_DIR=${POST_DIR}                              " >> ${FunctionPath}
147      echo "export MASTER=${MASTER}                                  " >> ${FunctionPath}
148      echo "export DateBegin=${DateBegin}                            " >> ${FunctionPath}
149      echo "export PeriodDateEnd=${PeriodDateEnd}                    " >> ${FunctionPath}
150      echo "export StandAlone=false                                  " >> ${FunctionPath}
151      echo "export RESOL_ATM=${RESOL_ATM}                            " >> ${FunctionPath}
152      echo "export RESOL_OCE=${RESOL_OCE}                            " >> ${FunctionPath}
153      echo "export RESOL_ICE=${RESOL_ICE}                            " >> ${FunctionPath}
154      echo "export RESOL_MBG=${RESOL_MBG}                            " >> ${FunctionPath}
155      echo "export RESOL_SRF=${RESOL_SRF}                            " >> ${FunctionPath}
156      echo "export RESOL_SBG=${RESOL_SBG}                            " >> ${FunctionPath}
157      echo "export listVarEnv=${listVarEnv}                          " >> ${FunctionPath}
158      echo "export Script_Post_Output=${Script_Post_Output}          " >> ${FunctionPath}
159#     if [ X${MASTER} = Xtitane ] ; then
160#       echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
161#       echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
162#     fi
163      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
164      echo "IGCM_debug_Verif_Exit                          " >> ${FunctionPath}
165      echo "IGCM_sys_QsubPost create_se                    " >> ${FunctionPath}
166#     if [ X${MASTER} = Xtitane ] ; then
167#       echo "EOF"                                         >> ${FunctionPath}
168#     fi
169      fi
170    else
171      IGCM_sys_RshPost <<-EOF
172            export DEBUG_debug=${DEBUG_debug}
173            export BigBrother=${BigBrother}
174            export postProcessingStopLevel=${postProcessingStopLevel}
175            export MODIPSL=${MODIPSL}
176            export libIGCM_SX=${libIGCM}
177            export libIGCM=${libIGCM_POST}
178            export SUBMIT_DIR=${SUBMIT_DIR}
179            export POST_DIR=${POST_DIR}
180            export MASTER=${MASTER}
181            export DateBegin=${DateBegin}
182            export PeriodDateEnd=${PeriodDateEnd}
183            export StandAlone=false
184            export RESOL_ATM=${RESOL_ATM}
185            export RESOL_OCE=${RESOL_OCE}
186            export RESOL_ICE=${RESOL_ICE}
187            export RESOL_MBG=${RESOL_MBG}
188            export RESOL_SRF=${RESOL_SRF}
189            export RESOL_SBG=${RESOL_SBG}
190            export listVarEnv=${listVarEnv}
191            export Script_Post_Output=${Script_Post_Output}
192            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
193            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
194            IGCM_sys_MkdirWork ${POST_DIR}
195            IGCM_debug_Verif_Exit
196            IGCM_sys_QsubPost create_se
197EOF
198    fi
199  fi
200
201  #============== PACK PROCESSING FOR RESTART, DEBUG AND OUTPUT FILES =============#
202  if [ ${PackFrequency} = true ] ; then
203    IGCM_debug_Print 1 "PACK POST-PROCESSING"
204    # -----------------------------------------------------------------------------------
205    # Function IGCM_FlushPost called by pack_output.job has not been closed yet. Do it now
206    # Will submit Seasonal Average if needed
207    # -----------------------------------------------------------------------------------
208    if [ -f ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh ] ; then
209      echo "IGCM_debug_PopStack \"IGCM_FlushPost\" " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
210      echo "}                                      " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
211    fi
212    echo
213    ## Need to Remember This One
214    SavedDateBegin=${DateBegin}
215    ## Need to Remember This One
216    SavedDateEnd=${DateEnd}
217    #
218    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 ))
219    #
220    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} )
221    #
222    script=pack_debug
223    #
224    Script_Post_Output=${script}.${PeriodDateEnd}
225    #
226    listVarEnv="DEBUG_debug,BigBrother,postProcessingStopLevel,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,Script_Post_Output,MASTER,DateBegin,DateEnd,PeriodPack,StandAlone"
227    IGCM_sys_RshPost <<-EOF
228    export DEBUG_debug=${DEBUG_debug}
229    export BigBrother=${BigBrother}
230    export postProcessingStopLevel=${postProcessingStopLevel}
231    export MODIPSL=${MODIPSL}
232    export libIGCM_SX=${libIGCM}
233    export libIGCM=${libIGCM_POST}
234    export SUBMIT_DIR=${SUBMIT_DIR}
235    export POST_DIR=${POST_DIR}
236    export MASTER=${MASTER}
237    export DateBegin=${PackDateBegin}
238    export DateEnd=${PeriodDateEnd}
239    export PeriodPack=${config_Post_PackFrequency}
240    export StandAlone=false
241    export listVarEnv=${listVarEnv}
242    export Script_Post_Output=${Script_Post_Output}
243    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
244    . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
245    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
246    IGCM_sys_MkdirWork ${POST_DIR}
247    IGCM_debug_Verif_Exit
248    IGCM_sys_QsubPost ${script}
249    IGCM_debug_Verif_Exit
250EOF
251    #
252    script=pack_restart
253    #
254    Script_Post_Output=${script}.${PeriodDateEnd}
255    #
256    IGCM_sys_RshPost <<-EOF
257      export DEBUG_debug=${DEBUG_debug}
258      export BigBrother=${BigBrother}
259      export postProcessingStopLevel=${postProcessingStopLevel}
260      export MODIPSL=${MODIPSL}
261      export libIGCM_SX=${libIGCM}
262      export libIGCM=${libIGCM_POST}
263      export SUBMIT_DIR=${SUBMIT_DIR}
264      export POST_DIR=${POST_DIR}
265      export MASTER=${MASTER}
266      export PeriodDateBegin=${PeriodDateBegin}
267      export DateBegin=${PackDateBegin}
268      export DateEnd=${PeriodDateEnd}
269      export PeriodPack=${config_Post_PackFrequency}
270      export StandAlone=false
271      export listVarEnv=${listVarEnv}
272      export Script_Post_Output=${Script_Post_Output}
273      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
274      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
275      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
276      IGCM_sys_MkdirWork ${POST_DIR}
277      IGCM_debug_Verif_Exit
278      IGCM_sys_QsubPost ${script}
279      IGCM_debug_Verif_Exit
280EOF
281    #
282    script=pack_output
283    #
284    Script_Post_Output=${script}.${PeriodDateEnd}
285    #
286    IGCM_sys_RshPost <<-EOF
287        export DEBUG_debug=${DEBUG_debug}
288        export BigBrother=${BigBrother}
289        export postProcessingStopLevel=${postProcessingStopLevel}
290        export MODIPSL=${MODIPSL}
291        export libIGCM_SX=${libIGCM}
292        export libIGCM=${libIGCM_POST}
293        export SUBMIT_DIR=${SUBMIT_DIR}
294        export POST_DIR=${POST_DIR}
295        export MASTER=${MASTER}
296        export DateBegin=${PackDateBegin}
297        export DateEnd=${PeriodDateEnd}
298        export PeriodPack=${config_Post_PackFrequency}
299        export StandAlone=false
300        export listVarEnv=${listVarEnv}
301        export Script_Post_Output=${Script_Post_Output}
302        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
303        . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
304        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
305        IGCM_sys_MkdirWork ${POST_DIR}
306        IGCM_debug_Verif_Exit
307        IGCM_sys_QsubPost ${script}
308        IGCM_debug_Verif_Exit
309EOF
310    export DateBegin=${SavedDateBegin}
311    export DateEnd=${SavedDateEnd}
312  fi
313
314  #============== REBUILD POST-PROCESSING =============#
315  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
316    # -----------------------------------------------------------------------------------
317    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
318    # -----------------------------------------------------------------------------------
319    echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
320    echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
321    IGCM_sys_Mv REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
322  fi
323  #
324  if [ ${RebuildFrequency} = true ] ; then
325    IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
326    echo
327    script=rebuild_fromWorkdir
328    #
329    Script_Post_Output=${script}.${PeriodDateEnd}
330    #
331    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"
332    IGCM_sys_RshPost <<-EOF
333      export DEBUG_debug=${DEBUG_debug}
334      export BigBrother=${BigBrother}
335      export postProcessingStopLevel=${postProcessingStopLevel}
336      export MODIPSL=${MODIPSL}
337      export libIGCM_SX=${libIGCM}
338      export libIGCM=${libIGCM_POST}
339      export SUBMIT_DIR=${SUBMIT_DIR}
340      export REBUILD_DIR=${REBUILD_DIR}
341      export POST_DIR=${POST_DIR}
342      export MASTER=${MASTER}
343      export DateBegin=${DateBegin}
344      export PeriodDateBegin=${PeriodDateBegin}
345      export PeriodDateEnd=${PeriodDateEnd}
346      export NbRebuildDir=${NbRebuildDir}
347      export StandAlone=false
348      export RESOL_ATM=${RESOL_ATM}
349      export RESOL_OCE=${RESOL_OCE}
350      export RESOL_ICE=${RESOL_ICE}
351      export RESOL_MBG=${RESOL_MBG}
352      export RESOL_SRF=${RESOL_SRF}
353      export RESOL_SBG=${RESOL_SBG}
354      export listVarEnv=${listVarEnv}
355      export Script_Post_Output=${Script_Post_Output}
356      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
357      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
358      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
359      IGCM_sys_MkdirWork ${POST_DIR}
360      IGCM_debug_Verif_Exit
361      IGCM_sys_QsubPost ${script}
362      IGCM_debug_Verif_Exit
363EOF
364  fi
365  IGCM_debug_PopStack "IGCM_post_Submit"
366}
367
368#===================================
369function IGCM_post_CheckModuloFrequency
370{
371  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $@
372
373  # Used by IGCM_config_Check
374  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d)
375  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero
376  # Input parameter are the name of the variable, not the frequency value itself
377  # example
378  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
379
380  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
381
382  # Get the name of the variable
383  MasterName=$1
384  SlaveName=$2
385  # Get the value the above name points to
386  MasterFrequency=$( eval echo \${${1}} )
387  SlaveFrequency=$( eval echo \${${2}} )
388
389  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
390
391  case ${MasterFrequency} in
392  *y|*Y)
393    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
394    case ${SlaveFrequency} in
395    *Y|*y)
396      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
397      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \
398      [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] )then
399        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
400        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
401        IGCM_debug_Exit "Check your frequency"
402      else
403        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
404      fi ;;
405    *M|*m)
406      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
407      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
408        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then
409        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
410        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
411        IGCM_debug_Exit "Check your frequency"
412      else
413        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
414      fi ;;
415    *D|*d)
416      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
417      NbDays=$( IGCM_date_DaysInYear ${year} )
418      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
419        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \
420          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then
421          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
422          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
423          IGCM_debug_Exit "Check your frequency"
424        fi
425      else
426        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:"
427        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}"
428        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry"
429        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too."
430      fi ;;
431    esac ;;
432  *M|*m)
433    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
434    case ${SlaveFrequency} in
435    *Y|*y)
436      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
437      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
438        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then
439        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
440        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
441        IGCM_debug_Exit "Check your frequency"
442      else
443        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
444      fi ;;
445    *M|*m)
446      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
447      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
448        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then
449        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
450        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
451        IGCM_debug_Exit "Check your frequency"
452      else
453        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
454      fi ;;
455    *D|*d)
456      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
457      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
458      IGCM_debug_Exit "Check your frequency" ;;
459    esac ;;
460  *D|*d)
461    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
462    case ${SlaveFrequency} in
463    *Y|*y)
464      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
465      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
466      IGCM_debug_Exit "Check your frequency" ;;
467    *M|*m)
468      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
469      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
470      IGCM_debug_Exit "Check your frequency" ;;
471    *D|*d)
472      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
473      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \
474        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then
475        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
476        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
477        IGCM_debug_Exit "Check your frequency"
478      else
479        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
480      fi ;;
481    esac ;;
482  NONE|none)
483    ;;
484  *)
485    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card"
486    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;;
487  esac
488
489  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
490}
491
492#===================================
493function IGCM_post_ModuloRuntimeFrequency
494{
495  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $@
496
497  # Used by IGCM_post_Configure
498  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
499  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
500  # --> turn on post-processing submission when their modulo is zero
501  # Input parameter are the name of the variable, not the frequency value itself
502  # example
503  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength
504
505  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
506
507  # Get the name of the variable
508  MasterName=$1
509  SlaveName=$2
510  # Get the value the above name points to
511  eval MasterFrequency=\${${1}}
512  eval SlaveFrequency=\${${2}}
513
514  echo
515  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
516
517  case ${MasterFrequency} in
518  *y|*Y)
519    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
520    case ${SlaveFrequency} in
521    *Y|*y)
522      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
523      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then
524        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
525          eval ${post_freq}=true ; POST=true
526          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
527        fi
528      fi;;
529    *M|*m)
530      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
531      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
532        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then
533          eval ${post_freq}=true ; POST=true
534          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
535        fi
536      fi;;
537    *D|*d)
538      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
539      NbDays=$( IGCM_date_DaysInYear ${year} )
540      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then
541        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then
542          eval ${post_freq}=true ; POST=true
543          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} ))
544        fi
545      fi;;
546    esac ;;
547  *M|*m)
548    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
549    case ${SlaveFrequency} in
550    *Y|*y)
551      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
552      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then
553        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then
554          eval ${post_freq}=true ; POST=true
555          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
556        fi
557      fi;;
558    *M|*m)
559      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
560      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
561        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then
562          eval ${post_freq}=true ; POST=true
563          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
564        fi
565      fi;;
566    *D|*d)
567      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
568      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
569    esac ;;
570  *D|*d)
571    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
572    case ${SlaveFrequency} in
573    *Y|*y)
574      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
575      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
576    *M|*m)
577      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
578      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
579    *D|*d)
580      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
581      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then
582        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then
583          eval ${post_freq}=true ; POST=true
584          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
585        fi
586      fi;;
587    esac ;;
588  NONE|none)
589    ;;
590  *)
591    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card"
592    ;;
593  esac
594
595  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
596}
Note: See TracBrowser for help on using the repository browser.