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 | #======================================================================= |
---|
17 | function 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 | |
---|
183 | function 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 |
---|
238 | EOF |
---|
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 |
---|
269 | EOF |
---|
270 | fi |
---|
271 | |
---|
272 | IGCM_debug_PopStack "IGCM_post_Submit" |
---|
273 | } |
---|
274 | |
---|
275 | |
---|