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