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

Last change on this file since 1375 was 1375, checked in by sdipsl, 7 years ago
  • Populate the first bunch of modifications in libIGCM_v3.0_beta1 repo
  • 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.3 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 DateBegin=${PackDateBegin}
267      export DateEnd=${PeriodDateEnd}
268      export PeriodPack=${config_Post_PackFrequency}
269      export StandAlone=false
270      export listVarEnv=${listVarEnv}
271      export Script_Post_Output=${Script_Post_Output}
272      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
273      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
274      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
275      IGCM_sys_MkdirWork ${POST_DIR}
276      IGCM_debug_Verif_Exit
277      IGCM_sys_QsubPost ${script}
278      IGCM_debug_Verif_Exit
279EOF
280    #
281    script=pack_output
282    #
283    Script_Post_Output=${script}.${PeriodDateEnd}
284    #
285    IGCM_sys_RshPost <<-EOF
286        export DEBUG_debug=${DEBUG_debug}
287        export BigBrother=${BigBrother}
288        export postProcessingStopLevel=${postProcessingStopLevel}
289        export MODIPSL=${MODIPSL}
290        export libIGCM_SX=${libIGCM}
291        export libIGCM=${libIGCM_POST}
292        export SUBMIT_DIR=${SUBMIT_DIR}
293        export POST_DIR=${POST_DIR}
294        export MASTER=${MASTER}
295        export DateBegin=${PackDateBegin}
296        export DateEnd=${PeriodDateEnd}
297        export PeriodPack=${config_Post_PackFrequency}
298        export StandAlone=false
299        export listVarEnv=${listVarEnv}
300        export Script_Post_Output=${Script_Post_Output}
301        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
302        . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
303        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
304        IGCM_sys_MkdirWork ${POST_DIR}
305        IGCM_debug_Verif_Exit
306        IGCM_sys_QsubPost ${script}
307        IGCM_debug_Verif_Exit
308EOF
309    export DateBegin=${SavedDateBegin}
310    export DateEnd=${SavedDateEnd}
311  fi
312
313  #============== REBUILD POST-PROCESSING =============#
314  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
315    # -----------------------------------------------------------------------------------
316    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
317    # -----------------------------------------------------------------------------------
318    echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
319    echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
320    IGCM_sys_Mv REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
321  fi
322  #
323  if [ ${RebuildFrequency} = true ] ; then
324    IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
325    echo
326    script=rebuild_fromWorkdir
327    #
328    Script_Post_Output=${script}.${PeriodDateEnd}
329    #
330    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"
331    IGCM_sys_RshPost <<-EOF
332      export DEBUG_debug=${DEBUG_debug}
333      export BigBrother=${BigBrother}
334      export postProcessingStopLevel=${postProcessingStopLevel}
335      export MODIPSL=${MODIPSL}
336      export libIGCM_SX=${libIGCM}
337      export libIGCM=${libIGCM_POST}
338      export SUBMIT_DIR=${SUBMIT_DIR}
339      export REBUILD_DIR=${REBUILD_DIR}
340      export POST_DIR=${POST_DIR}
341      export MASTER=${MASTER}
342      export DateBegin=${DateBegin}
343      export PeriodDateBegin=${PeriodDateBegin}
344      export PeriodDateEnd=${PeriodDateEnd}
345      export NbRebuildDir=${NbRebuildDir}
346      export StandAlone=false
347      export RESOL_ATM=${RESOL_ATM}
348      export RESOL_OCE=${RESOL_OCE}
349      export RESOL_ICE=${RESOL_ICE}
350      export RESOL_MBG=${RESOL_MBG}
351      export RESOL_SRF=${RESOL_SRF}
352      export RESOL_SBG=${RESOL_SBG}
353      export listVarEnv=${listVarEnv}
354      export Script_Post_Output=${Script_Post_Output}
355      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
356      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
357      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
358      IGCM_sys_MkdirWork ${POST_DIR}
359      IGCM_debug_Verif_Exit
360      IGCM_sys_QsubPost ${script}
361      IGCM_debug_Verif_Exit
362EOF
363  fi
364  IGCM_debug_PopStack "IGCM_post_Submit"
365}
366
367#===================================
368function IGCM_post_CheckModuloFrequency
369{
370  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $@
371
372  # Used by IGCM_config_Check
373  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d)
374  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero
375  # Input parameter are the name of the variable, not the frequency value itself
376  # example
377  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
378
379  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
380
381  # Get the name of the variable
382  MasterName=$1
383  SlaveName=$2
384  # Get the value the above name points to
385  MasterFrequency=$( eval echo \${${1}} )
386  SlaveFrequency=$( eval echo \${${2}} )
387
388  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
389
390  case ${MasterFrequency} in
391  *y|*Y)
392    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
393    case ${SlaveFrequency} in
394    *Y|*y)
395      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
396      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \
397      [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] )then
398        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
399        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
400        IGCM_debug_Exit "Check your frequency"
401      else
402        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
403      fi ;;
404    *M|*m)
405      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
406      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
407        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then
408        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
409        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
410        IGCM_debug_Exit "Check your frequency"
411      else
412        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
413      fi ;;
414    *D|*d)
415      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
416      NbDays=$( IGCM_date_DaysInYear ${year} )
417      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
418        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \
419          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then
420          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
421          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
422          IGCM_debug_Exit "Check your frequency"
423        fi
424      else
425        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:"
426        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}"
427        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry"
428        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too."
429      fi ;;
430    esac ;;
431  *M|*m)
432    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
433    case ${SlaveFrequency} in
434    *Y|*y)
435      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
436      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
437        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then
438        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
439        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
440        IGCM_debug_Exit "Check your frequency"
441      else
442        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
443      fi ;;
444    *M|*m)
445      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
446      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
447        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then
448        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
449        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
450        IGCM_debug_Exit "Check your frequency"
451      else
452        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
453      fi ;;
454    *D|*d)
455      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
456      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
457      IGCM_debug_Exit "Check your frequency" ;;
458    esac ;;
459  *D|*d)
460    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
461    case ${SlaveFrequency} in
462    *Y|*y)
463      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
464      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
465      IGCM_debug_Exit "Check your frequency" ;;
466    *M|*m)
467      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
468      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
469      IGCM_debug_Exit "Check your frequency" ;;
470    *D|*d)
471      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
472      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \
473        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then
474        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
475        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
476        IGCM_debug_Exit "Check your frequency"
477      else
478        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
479      fi ;;
480    esac ;;
481  NONE|none)
482    ;;
483  *)
484    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card"
485    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;;
486  esac
487
488  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
489}
490
491#===================================
492function IGCM_post_ModuloRuntimeFrequency
493{
494  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $@
495
496  # Used by IGCM_post_Configure
497  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and
498  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
499  # --> turn on post-processing submission when their modulo is zero
500  # Input parameter are the name of the variable, not the frequency value itself
501  # example
502  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength
503
504  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
505
506  # Get the name of the variable
507  MasterName=$1
508  SlaveName=$2
509  # Get the value the above name points to
510  eval MasterFrequency=\${${1}}
511  eval SlaveFrequency=\${${2}}
512
513  echo
514  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
515
516  case ${MasterFrequency} in
517  *y|*Y)
518    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
519    case ${SlaveFrequency} in
520    *Y|*y)
521      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
522      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then
523        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
524          eval ${post_freq}=true ; POST=true
525          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
526        fi
527      fi;;
528    *M|*m)
529      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
530      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
531        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then
532          eval ${post_freq}=true ; POST=true
533          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
534        fi
535      fi;;
536    *D|*d)
537      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
538      NbDays=$( IGCM_date_DaysInYear ${year} )
539      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then
540        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then
541          eval ${post_freq}=true ; POST=true
542          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} ))
543        fi
544      fi;;
545    esac ;;
546  *M|*m)
547    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
548    case ${SlaveFrequency} in
549    *Y|*y)
550      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
551      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then
552        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then
553          eval ${post_freq}=true ; POST=true
554          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
555        fi
556      fi;;
557    *M|*m)
558      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
559      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
560        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then
561          eval ${post_freq}=true ; POST=true
562          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
563        fi
564      fi;;
565    *D|*d)
566      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
567      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
568    esac ;;
569  *D|*d)
570    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
571    case ${SlaveFrequency} in
572    *Y|*y)
573      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
574      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
575    *M|*m)
576      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
577      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
578    *D|*d)
579      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
580      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then
581        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then
582          eval ${post_freq}=true ; POST=true
583          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
584        fi
585      fi;;
586    esac ;;
587  NONE|none)
588    ;;
589  *)
590    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card"
591    ;;
592  esac
593
594  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
595}
Note: See TracBrowser for help on using the repository browser.