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

Last change on this file since 10 was 10, checked in by mmaipsl, 17 years ago

MM: All frequencies in post-treatement.

  • 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.8 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                          echo "POST : Y->Y = " ${CumulPeriod} ',' ${PeriodYear} "," $( expr ${CumulPeriod} % ${PeriodYear}  )
90                          if [ $( expr ${CumulPeriod} % ${PeriodYear}  ) -eq 0 ] ;  then
91                             eval ${flag_post}_${compname}_${post_freq}=true
92                             eval ${post_freq}=true
93                             POST=true
94                          fi ;;
95                        1M|1m)
96                          if [ $( expr ${CumulPeriod} % $( expr ${PeriodYear} \* 12 ) ) -eq 0 ] ; then
97                             eval ${flag_post}_${compname}_${post_freq}=true
98                             eval ${post_freq}=true
99                             POST=true
100                          fi ;;
101                        *M|*m)
102                          PeriodMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" )
103                          if [ $( expr $(( ${CumulPeriod} * ${PeriodMonths} )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then
104                             eval ${flag_post}_${compname}_${post_freq}=true
105                             eval ${post_freq}=true
106                             POST=true
107                          fi ;;
108                        *D|*d)
109                          LengthDays=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" )
110                          NbDays=$( IGCM_date_DaysInYear ${year} )
111                          if [ ${config_UserChoices_CalendarType} = 360d ] | [ ${config_UserChoices_CalendarType} = noleap ] ; then
112                             if [ $( expr ${CumulPeriod} % $( expr \( ${NbDays} \* ${PeriodYear} \/ ${LengthDays} \) ) ) -eq 0 ] ; then
113                                eval ${flag_post}_${compname}_${post_freq}=true
114                                eval ${post_freq}=true
115                                POST=true
116                             fi
117                          else
118                              if [ ${PeriodYear} -eq 1 ] ; then
119                                PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
120                                PostEndJul=${year}${NbDays}
121                                #echo "PeriodYear=${PeriodYear} Year ; NbDays${NbDays} PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
122                                if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then
123                                   eval ${flag_post}_${compname}_${post_freq}=true
124                                   eval ${post_freq}=true
125                                   POST=true
126                                fi
127                              else
128                                echo "For ${post_freq}, for ${comp} and ${file_in} :"
129                                echo "We have a daily WriteFrequency and ${post_freq}=${PeriodYear}Y."
130                                echo "No post-treatment."
131                              fi
132                            fi;;
133                      esac ;;
134                    1M|1m)
135                      case ${config_UserChoices_PeriodLength} in
136                        *Y|*y)
137                          IGCM_debug_Print 3 "Frequency not allowed for TimeSeriesFrequency in ${flag_post}" ;;
138                        *M|*m)
139                          eval ${flag_post}_${compname}_${post_freq}=true
140                          eval ${post_freq}=true
141                          POST=true;;
142                        *D|*d)
143                          NbDays=$( IGCM_date_DaysInMonth ${year} ${month} )
144                          PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} )
145                          PostEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${year}${month}${NbDays} )
146                          #echo "year_month=${year}_${month} Month ; NbDays${NbDays} PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}"
147                          if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then
148                            eval ${flag_post}_${compname}_${post_freq}=true
149                            eval ${post_freq}=true
150                            POST=true
151                          fi
152                          ;;
153                      esac
154                        ;;
155                    *M|*m)
156                      case ${config_UserChoices_PeriodLength} in
157                        *Y|*y)
158                          IGCM_debug_Print 3 "Frequency not allowed for TimeSeriesFrequency in ${flag_post}" ;;
159                        *M|*m)
160                          eval ${flag_post}_${compname}_${post_freq}=true
161                          eval ${post_freq}=true
162                          POST=true;;
163                      esac
164                      ;;
165                    NONE|none)
166                      ;;
167                    *)
168                      IGCM_debug_Print 3 "KeyWord not allowed for ${post_freq} in config.card"
169                      ;;
170                  esac
171                fi
172                let $(( i=i+3 ))
173              done
174            fi
175        done
176    done
177    IGCM_debug_Print 1 "POST-TREATEMENT flag value : ${POST}"
178    [ ${POST} = true ] && IGCM_post_Submit
179
180    IGCM_debug_PopStack "IGCM_post_Initialize"
181}
182
183function IGCM_post_Submit
184{
185    IGCM_debug_PushStack "IGCM_post_Submit"
186
187    # Debug Print :
188    echo
189    IGCM_debug_Print 1 "IGCM_post_Submit :"
190    echo
191
192    typeset comp
193
194    POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
195    echo "POST_DIR = ${POST_DIR}"
196
197    #============== REBUILD POST-TREATMENT =============#
198    if [ ${RebuildFrequency} = true ] ; then
199        #
200        IGCM_debug_Print 2 "REBUILD POST-TREATMENT :"
201        echo
202        #
203        # BUILD A PACKED LIST FOR POST-TREATMENT JOB
204        # BECAUSE IT'S NOT POSSIBLE TO DEFINE DYNAMICAL
205        # VARIABLE NAME THROUGHT RSH !!
206        #
207        LISTE_PACK=" "
208        #
209    fi
210
211    #============ TIME SERIES POST-TREATMENT ===========#
212    if [ ${TimeSeriesFrequency} = true ] ; then
213
214        IGCM_debug_Print 2 "TIME SERIES POST-TREATMENT :"
215        echo
216        #
217        typeset listVarEnv
218        listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
219        IGCM_sys_RshPost <<-EOF
220        export MODIPSL=${MODIPSL}
221        export libIGCM_SX=${libIGCM}
222        export libIGCM=${libIGCM_POST}
223        export SUBMIT_DIR=${SUBMIT_DIR}
224        export POST_DIR=${POST_DIR}
225        export DateBegin=${DateBegin}
226        export PeriodDateEnd=${PeriodDateEnd}
227        export StandAlone=false
228        export RESOL_ATM=${RESOL_ATM}
229        export RESOL_OCE=${RESOL_OCE}
230        export RESOL_ICE=${RESOL_ICE}
231        export RESOL_SRF=${RESOL_SRF}
232        export listVarEnv=${listVarEnv}
233        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
234        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
235        IGCM_sys_MkdirWork ${POST_DIR}
236        IGCM_debug_Verif_Exit
237        IGCM_sys_QsubPost create_ts
238EOF
239    fi
240
241    #=============  SEASONAL POST-TREATMENT ============#
242    if [ ${SeasonalFrequency} = true ] ; then
243        #
244        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
245        echo
246        #
247        typeset listVarEnv
248        listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
249        IGCM_sys_RshPost <<-EOF
250        export MODIPSL=${MODIPSL}
251        export SUBMIT_DIR=${SUBMIT_DIR}
252        export libIGCM_SX=${libIGCM}
253        export libIGCM=${libIGCM_POST}
254        export SUBMIT_DIR=${SUBMIT_DIR}
255        export POST_DIR=${POST_DIR}
256        export DateBegin=${DateBegin}
257        export PeriodDateEnd=${PeriodDateEnd}
258        export StandAlone=false
259        export RESOL_ATM=${RESOL_ATM}
260        export RESOL_OCE=${RESOL_OCE}
261        export RESOL_ICE=${RESOL_ICE}
262        export RESOL_SRF=${RESOL_SRF}
263        export listVarEnv=${listVarEnv}
264        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
265        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
266        IGCM_sys_MkdirWork ${POST_DIR}
267        IGCM_debug_Verif_Exit
268        IGCM_sys_QsubPost create_se
269EOF
270    fi
271
272    IGCM_debug_PopStack "IGCM_post_Submit"
273}
274
275
Note: See TracBrowser for help on using the repository browser.