source: branches/AllPostFred/libIGCM_post/libIGCM_post.ksh @ 1494

Last change on this file since 1494 was 12, checked in by mmaipsl, 16 years ago

In AllPostFred? branch, correct post-treatment launched in case of multi-years PeriodLength?.

  • 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 Date Author Revision
File size: 9.9 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
5# Contact: Sebastien.Denvil@ipsl.jussieu.fr
6# $Date$
7# $Author$
8# $Revision$
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11# History:
12# Modification:
13#
14#**************************************************************
15
16#=======================================================================
17function IGCM_post_Initialize
18{
19    IGCM_debug_PushStack "IGCM_post_Initialize"
20
21    # Debug Print :
22    echo
23    IGCM_debug_Print 1 "IGCM_post_Initialize :"
24    echo
25
26    typeset POST NbDays PeriodEndJul PostEndJul LengthDays
27    POST=false
28
29    # READ TIME SERIES OR SEASONAL FREQUENCY
30    # AND TURN ON THE FLAG WHEN MODULO IS ZERO
31    for post_freq in RebuildFrequency TimeSeriesFrequency SeasonalFrequency ; do
32        #
33        # Initialize
34        #
35        eval ${post_freq}=false
36        #
37        # Define the variable ${config_Post_${post_freq}}
38        # who contains frequency for specific post-treatment
39        #
40        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${post_freq}
41        #
42        # Extract frequency from above variable
43        #
44        config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} )
45        #
46        if ( [ X${config_Post_post_freq} = X${NULL_STR} ] || [ X${config_Post_post_freq} = XNONE ] ) ; then
47          #
48          continue
49          #
50        fi
51        #
52        # For each componant select determine which files need post-processing
53        #
54        for comp in ${config_ListOfComponents[*]} ; do
55            #
56            #echo "-----"
57            eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
58            ListFilesName=${compname}_OutputFiles_List
59            eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
60            #
61            if [ X${FileName0} != X${NULL_STR} ] ; then
62              #
63              #IGCM_debug_Print 1 "Component      : ${compname}"
64              #
65              # INITIALISATION
66              #
67              eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
68              typeset i=0
69              #
70              until [ $i -eq $NbFiles ]; do
71                #
72                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
73                eval file_in=${file_in_}
74                let $(( i_ = i+2 ))
75                eval flag_post_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
76                eval flag_post=${flag_post_}
77                #
78                if [ X${flag_post} != XNONE ] ; then
79                  #
80                  # Initialize ${flag_post}_${compname}_${post_freq}
81                  #
82                  eval ${flag_post}_${compname}_${post_freq}=false
83                  #
84                  case ${config_Post_post_freq} in
85                    *y|*Y)
86                      PeriodYear=$( echo ${config_Post_post_freq} | sed -e "s/[yY]//" )
87                      case ${config_UserChoices_PeriodLength} in
88                        *Y|*y)
89                          NbYear=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[yY]//" )
90                          echo "POST : Y->Y = " $( expr ${CumulPeriod} \* ${NbYear} ) ',' ${PeriodYear} "," \
91                                                $( expr ${CumulPeriod} \* ${NbYear} % ${PeriodYear}  )
92                          if [ $( expr ${CumulPeriod} \* ${NbYear} % ${PeriodYear}  ) -eq 0 ] ;  then
93                             eval ${flag_post}_${compname}_${post_freq}=true
94                             eval ${post_freq}=true
95                             POST=true
96                          fi ;;
97                        1M|1m)
98                          if [ $( expr ${CumulPeriod} % $( expr ${PeriodYear} \* 12 ) ) -eq 0 ] ; then
99                             eval ${flag_post}_${compname}_${post_freq}=true
100                             eval ${post_freq}=true
101                             POST=true
102                          fi ;;
103                        *M|*m)
104                          PeriodMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
105                          if [ $( expr $(( ${CumulPeriod} * ${PeriodMonths} )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then
106                             eval ${flag_post}_${compname}_${post_freq}=true
107                             eval ${post_freq}=true
108                             POST=true
109                          fi ;;
110                        *D|*d)
111                          LengthDays=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
112                          NbDays=$( IGCM_date_DaysInYear ${year} )
113                          if [ ${config_UserChoices_CalendarType} = 360d ] | [ ${config_UserChoices_CalendarType} = noleap ] ; then
114                             if [ $( expr ${CumulPeriod} % $( expr \( ${NbDays} \* ${PeriodYear} \/ ${LengthDays} \) ) ) -eq 0 ] ; then
115                                eval ${flag_post}_${compname}_${post_freq}=true
116                                eval ${post_freq}=true
117                                POST=true
118                             fi
119                          else
120                              if [ ${PeriodYear} -eq 1 ] ; then
121                                PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
122                                PostEndJul=${year}${NbDays}
123                                #echo "PeriodYear=${PeriodYear} Year ; NbDays${NbDays} PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
124                                if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then
125                                   eval ${flag_post}_${compname}_${post_freq}=true
126                                   eval ${post_freq}=true
127                                   POST=true
128                                fi
129                              else
130                                echo "For ${post_freq}, for ${comp} and ${file_in} :"
131                                echo "We have a daily WriteFrequency and ${post_freq}=${PeriodYear}Y."
132                                echo "No post-treatment."
133                              fi
134                            fi;;
135                      esac ;;
136                    1M|1m)
137                      case ${config_UserChoices_PeriodLength} in
138                        *Y|*y)
139                          IGCM_debug_Print 3 "Frequency not allowed for TimeSeriesFrequency in ${flag_post}" ;;
140                        *M|*m)
141                          eval ${flag_post}_${compname}_${post_freq}=true
142                          eval ${post_freq}=true
143                          POST=true;;
144                        *D|*d)
145                          NbDays=$( IGCM_date_DaysInMonth ${year} ${month} )
146                          PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
147                          PostEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${year}${month}${NbDays} )
148                          #echo "year_month=${year}_${month} Month ; NbDays${NbDays} PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
149                          if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then
150                            eval ${flag_post}_${compname}_${post_freq}=true
151                            eval ${post_freq}=true
152                            POST=true
153                          fi
154                          ;;
155                      esac
156                        ;;
157                    *M|*m)
158                      case ${config_UserChoices_PeriodLength} in
159                        *Y|*y)
160                          IGCM_debug_Print 3 "Frequency not allowed for TimeSeriesFrequency in ${flag_post}" ;;
161                        *M|*m)
162                          eval ${flag_post}_${compname}_${post_freq}=true
163                          eval ${post_freq}=true
164                          POST=true;;
165                      esac
166                      ;;
167                    NONE|none)
168                      ;;
169                    *)
170                      IGCM_debug_Print 3 "KeyWord not allowed for ${post_freq} in config.card"
171                      ;;
172                  esac
173                fi
174                let $(( i=i+3 ))
175              done
176            fi
177        done
178    done
179    IGCM_debug_Print 1 "POST-TREATEMENT flag value : ${POST}"
180    [ ${POST} = true ] && IGCM_post_Submit
181
182    IGCM_debug_PopStack "IGCM_post_Initialize"
183}
184
185function IGCM_post_Submit
186{
187    IGCM_debug_PushStack "IGCM_post_Submit"
188
189    # Debug Print :
190    echo
191    IGCM_debug_Print 1 "IGCM_post_Submit :"
192    echo
193
194    typeset comp
195
196    POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
197    echo "POST_DIR = ${POST_DIR}"
198
199    #============== REBUILD POST-TREATMENT =============#
200    if [ ${RebuildFrequency} = true ] ; then
201        #
202        IGCM_debug_Print 2 "REBUILD POST-TREATMENT :"
203        echo
204        #
205        # BUILD A PACKED LIST FOR POST-TREATMENT JOB
206        # BECAUSE IT'S NOT POSSIBLE TO DEFINE DYNAMICAL
207        # VARIABLE NAME THROUGHT RSH !!
208        #
209        LISTE_PACK=" "
210        #
211    fi
212
213    #============ TIME SERIES POST-TREATMENT ===========#
214    if [ ${TimeSeriesFrequency} = true ] ; then
215
216        IGCM_debug_Print 2 "TIME SERIES POST-TREATMENT :"
217        echo
218        #
219        typeset listVarEnv
220        listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
221        IGCM_sys_RshPost <<-EOF
222        export MODIPSL=${MODIPSL}
223        export libIGCM_SX=${libIGCM}
224        export libIGCM=${libIGCM_POST}
225        export SUBMIT_DIR=${SUBMIT_DIR}
226        export POST_DIR=${POST_DIR}
227        export DateBegin=${DateBegin}
228        export PeriodDateEnd=${PeriodDateEnd}
229        export StandAlone=false
230        export RESOL_ATM=${RESOL_ATM}
231        export RESOL_OCE=${RESOL_OCE}
232        export RESOL_ICE=${RESOL_ICE}
233        export RESOL_SRF=${RESOL_SRF}
234        export listVarEnv=${listVarEnv}
235        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
236        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
237        IGCM_sys_MkdirWork ${POST_DIR}
238        IGCM_debug_Verif_Exit
239        IGCM_sys_QsubPost create_ts
240EOF
241    fi
242
243    #=============  SEASONAL POST-TREATMENT ============#
244    if [ ${SeasonalFrequency} = true ] ; then
245        #
246        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
247        echo
248        #
249        typeset listVarEnv
250        listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
251        IGCM_sys_RshPost <<-EOF
252        export MODIPSL=${MODIPSL}
253        export SUBMIT_DIR=${SUBMIT_DIR}
254        export libIGCM_SX=${libIGCM}
255        export libIGCM=${libIGCM_POST}
256        export SUBMIT_DIR=${SUBMIT_DIR}
257        export POST_DIR=${POST_DIR}
258        export DateBegin=${DateBegin}
259        export PeriodDateEnd=${PeriodDateEnd}
260        export StandAlone=false
261        export RESOL_ATM=${RESOL_ATM}
262        export RESOL_OCE=${RESOL_OCE}
263        export RESOL_ICE=${RESOL_ICE}
264        export RESOL_SRF=${RESOL_SRF}
265        export listVarEnv=${listVarEnv}
266        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
267        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
268        IGCM_sys_MkdirWork ${POST_DIR}
269        IGCM_debug_Verif_Exit
270        IGCM_sys_QsubPost create_se
271EOF
272    fi
273
274    IGCM_debug_PopStack "IGCM_post_Submit"
275}
276
277
Note: See TracBrowser for help on using the repository browser.