1 | #!/bin/ksh |
---|
2 | |
---|
3 | # $Date: 2010/06/25 18:48:26 $ |
---|
4 | # $Author: ssipsl $ |
---|
5 | # $Revision: 1.5 $ |
---|
6 | # IPSL (2006) |
---|
7 | # This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC |
---|
8 | |
---|
9 | #D--------------------------------------------------------------------== |
---|
10 | #D--------------------------------------------------------------------== |
---|
11 | #D- |
---|
12 | #D- Job to launch FLUXNET spinup simulations |
---|
13 | #D- |
---|
14 | #D--------------------------------------------------------------------== |
---|
15 | #D--------------------------------------------------------------------== |
---|
16 | #D- |
---|
17 | # Job inspired from Sönke Zaehle "site_new.def" job |
---|
18 | # ################################################# |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | MODIPSL=::modipsl:: |
---|
23 | libIGCM=${MODIPSL}/libIGCM |
---|
24 | |
---|
25 | # All SubJobs in SPINUP in ONE OR MORE YEARS run (must be used with libIGCM branches/AllPostFred). |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | #D--------------------------------------------------------------------== |
---|
30 | #D- -1. User modification place |
---|
31 | #D--------------------------------------------------------------------== |
---|
32 | |
---|
33 | #D- Increased verbosity (1, 2, 3) |
---|
34 | #Verbosity=3 |
---|
35 | |
---|
36 | #D- |
---|
37 | # -------------------------------------------------------------------- |
---|
38 | #D- ! Optionnal features /!\ Use with care ! |
---|
39 | # -------------------------------------------------------------------- |
---|
40 | |
---|
41 | #D- Low level debug : to bypass lib test checks and stack construction |
---|
42 | #D- Default=true |
---|
43 | DEBUG_debug=false |
---|
44 | |
---|
45 | #D- Set DEBUG_sys to false to disable output calls of function |
---|
46 | #D- Default=true |
---|
47 | #DEBUG_sys=false |
---|
48 | |
---|
49 | #D- Turn in dry run mode ? (0,1,2,3) |
---|
50 | #D- Default=0 |
---|
51 | #DRYRUN=3 |
---|
52 | # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE ! |
---|
53 | # ------------------------------------------------------------------------------------- |
---|
54 | # | DRYRUN= | Date computations, | sys_Get | Exe | sys_Put_Out; sys_Put_Rest | |
---|
55 | # | | Cp/Exe param files | | Chmod | | |
---|
56 | # | | Qsub | | | | |
---|
57 | # ------------------------------------------------------------------------------------- |
---|
58 | # | 0 | yes | yes | yes | yes | |
---|
59 | # ------------------------------------------------------------------------------------- |
---|
60 | # | 1 | yes | yes | yes | no | |
---|
61 | # ------------------------------------------------------------------------------------- |
---|
62 | # | 2 | yes | yes | no | no | |
---|
63 | # ------------------------------------------------------------------------------------- |
---|
64 | # | 3 | yes | no | no | no | |
---|
65 | # ------------------------------------------------------------------------------------- |
---|
66 | |
---|
67 | |
---|
68 | #D- |
---|
69 | #D--------------------------------------------------------------------== |
---|
70 | #D- 0. System Environment |
---|
71 | #D- - Define variables for Number of processors |
---|
72 | #D- - Define MPI variables |
---|
73 | #D- - Define batch scheduler variables |
---|
74 | #D- - Source IGCM Library |
---|
75 | #D- - Get RESOLution in .resol file (temporary) |
---|
76 | #D--------------------------------------------------------------------== |
---|
77 | |
---|
78 | #D--------------------------------------------------------------------== |
---|
79 | |
---|
80 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
81 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
82 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
83 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
84 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
85 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
86 | #------- |
---|
87 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
88 | |
---|
89 | #set -vx |
---|
90 | R_BC=${R_IN}/BC |
---|
91 | |
---|
92 | . ${SUBMIT_DIR}/fluxnet.ksh |
---|
93 | |
---|
94 | FLUXNET_initialize |
---|
95 | |
---|
96 | |
---|
97 | # Launch ATLAS syncho : we have to wait for the last job ! |
---|
98 | |
---|
99 | # ATLAS fix parameters : |
---|
100 | # Atlas Name : |
---|
101 | AtlasCfg=${fluxnet_SPINUP_AtlasCfg} |
---|
102 | #atlas_FLUXNET.cfg |
---|
103 | |
---|
104 | # observation_file |
---|
105 | observation_file_path=${fluxnet_SPINUP_observation_file_path} |
---|
106 | |
---|
107 | # old history file |
---|
108 | reference_file_path=${fluxnet_SPINUP_reference_file_path} |
---|
109 | reference_config=${fluxnet_SPINUP_reference_config} |
---|
110 | |
---|
111 | # Modulo for SpinUp years |
---|
112 | Modulo=${fluxnet_SPINUP_Modulo} |
---|
113 | |
---|
114 | ATLAS_ARGS="${AtlasCfg} ${observation_file_path} ${reference_file_path} ${reference_config} ${Modulo}" |
---|
115 | |
---|
116 | if [ X${reference_file_path} == X"" ] ; then |
---|
117 | flag_reference=0 |
---|
118 | reference_config="_" |
---|
119 | else |
---|
120 | flag_reference=1 |
---|
121 | fi |
---|
122 | |
---|
123 | NumAllSites=0 |
---|
124 | |
---|
125 | |
---|
126 | echo ${fluxnet_FLUXNET_Groups[*]} |
---|
127 | for group in ${fluxnet_FLUXNET_Groups[*]} ; do |
---|
128 | isite=1 |
---|
129 | index=0 |
---|
130 | |
---|
131 | eval temp=\${fluxnet_FLUXNET_${group}[*]} |
---|
132 | set -A group_site -- $temp |
---|
133 | |
---|
134 | # Number of sites : |
---|
135 | NumSites=$(( ${#group_site[*]} / NumInfosBySite )) |
---|
136 | NumAllSites=$(( NumAllSites + NumSites )) |
---|
137 | |
---|
138 | while [ ${isite} -le ${NumSites} ] ; do |
---|
139 | |
---|
140 | site=${group_site[$index]} |
---|
141 | echo $site |
---|
142 | |
---|
143 | TIME_YEAR=${group_site[ $(( index + ColumnLength )) ]} |
---|
144 | YEAR=${group_site[ $(( index + ColumnYear )) ]} |
---|
145 | |
---|
146 | Site=$site |
---|
147 | echo $YEAR |
---|
148 | DUREE=${TIME_YEAR} |
---|
149 | FYEAR=${YEAR} |
---|
150 | (( LYEAR=FYEAR+DUREE-1 )) |
---|
151 | echo $site |
---|
152 | SpinUpJob=${site}${config_UserChoices_JobName} |
---|
153 | TIME_YEAR=${group_site[ $(( index + ColumnLength )) ]} |
---|
154 | YEAR=${group_site[ $(( index + ColumnYear )) ]} |
---|
155 | |
---|
156 | |
---|
157 | fichier_with_path=$( \ls -rt ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${SpinUpJob}HIST/SRF/Output/MO/*_sechiba_history.nc ) |
---|
158 | |
---|
159 | eval observation_file=${observation_file_path} |
---|
160 | eval reference_file=${reference_file_path} |
---|
161 | |
---|
162 | echo "reference_config=" ${reference_config} |
---|
163 | ferret -script taylor_arrow_fluxnet_final_1.jnl GPP GPP/1800 hour ${flag_reference} GPP ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
164 | ferret -script taylor_arrow_fluxnet_final_1.jnl GPP GPP/1800 day ${flag_reference} GPP ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
165 | ferret -script taylor_arrow_fluxnet_final_1.jnl GPP GPP/1800 month ${flag_reference} GPP ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
166 | ferret -script taylor_arrow_fluxnet_final_1.jnl GPP GPP/1800 year ${flag_reference} GPP ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
167 | |
---|
168 | ferret -script taylor_arrow_fluxnet_final_1.jnl \(maint_resp+hetero_resp+growth_resp\) Reco/1800 hour ${flag_reference} TER ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
169 | ferret -script taylor_arrow_fluxnet_final_1.jnl \(maint_resp+hetero_resp+growth_resp\) Reco/1800 day ${flag_reference} TER ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
170 | ferret -script taylor_arrow_fluxnet_final_1.jnl \(maint_resp+hetero_resp+growth_resp\) Reco/1800 month ${flag_reference} TER ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
171 | ferret -script taylor_arrow_fluxnet_final_1.jnl \(maint_resp+hetero_resp+growth_resp\) Reco/1800 year ${flag_reference} TER ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
172 | |
---|
173 | ferret -script taylor_arrow_fluxnet_final_1.jnl NEE NEE/1800 hour ${flag_reference} NEE ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
174 | ferret -script taylor_arrow_fluxnet_final_1.jnl NEE NEE/1800 day ${flag_reference} NEE ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
175 | ferret -script taylor_arrow_fluxnet_final_1.jnl NEE NEE/1800 month ${flag_reference} NEE ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
176 | ferret -script taylor_arrow_fluxnet_final_1.jnl NEE NEE/1800 year ${flag_reference} NEE ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
177 | |
---|
178 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qh Fh hour ${flag_reference} SH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
179 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qh Fh day ${flag_reference} SH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
180 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qh Fh month ${flag_reference} SH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
181 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qh Fh year ${flag_reference} SH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
182 | |
---|
183 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qle Fle hour ${flag_reference} LH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
184 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qle Fle day ${flag_reference} LH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
185 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qle Fle month ${flag_reference} LH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
186 | ferret -script taylor_arrow_fluxnet_final_1.jnl Qle Fle year ${flag_reference} LH ${config_UserChoices_JobName} ${reference_config} ${group} ${site} ${fichier_with_path} ${observation_file} ${reference_file} |
---|
187 | |
---|
188 | |
---|
189 | # We test if the END step was moved in SpinUp/SPIN/Output directory. |
---|
190 | # Then we are sure the last historical SpinUp step has finished (HIST)... |
---|
191 | |
---|
192 | # Define name of the END SubJob (FIN) in SpinUp |
---|
193 | if [ ${fluxnet_SPINUP_duree_final} -gt 0 ] ; then |
---|
194 | BeforeLastJob=${site}${config_UserChoices_JobName}FIN |
---|
195 | else |
---|
196 | echo "We must have an \"duree_final\" non zero to get historical run and post-treatment" |
---|
197 | exit 1 |
---|
198 | fi |
---|
199 | |
---|
200 | # Wait for the end of the last job : |
---|
201 | ((isleep=0)) |
---|
202 | while [ ! -d ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${site}${config_UserChoices_JobName}/SPIN/Output/${BeforeLastJob} ] ; do |
---|
203 | ls -la ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${site}${config_UserChoices_JobName}/SPIN/Output/${BeforeLastJob} |
---|
204 | sleep 20 |
---|
205 | ((isleep=isleep+1)) |
---|
206 | if [ isleep -gt 200 ] ; then |
---|
207 | break ; |
---|
208 | fi |
---|
209 | done |
---|
210 | |
---|
211 | TIME_YEAR=${group_site[ $(( index + ColumnLength )) ]} |
---|
212 | YEAR=${group_site[ $(( index + ColumnYear )) ]} |
---|
213 | |
---|
214 | # Launch post-treatment for SPINUP ! |
---|
215 | echo "****" |
---|
216 | echo "Launch post-treatment for SPINUP for site ${site} !" |
---|
217 | nohup ${SUBMIT_DIR}/post_FLUXNET ${MODIPSL} ${site} ${TIME_YEAR} ${YEAR} ${ATLAS_ARGS} > ${SUBMIT_DIR}/out_post_${site} 2>&1 |
---|
218 | echo "****" |
---|
219 | |
---|
220 | (( isite=isite+1 )) |
---|
221 | (( index=index+NumInfosBySite )) |
---|
222 | done |
---|
223 | |
---|
224 | if [ ${#fluxnet_FLUXNET_Groups[*]} -ne 1 ] ; then |
---|
225 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_GPP_hour.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_GPP_hour.csv |
---|
226 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_GPP_day.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_GPP_day.csv |
---|
227 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_GPP_month.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_GPP_month.csv |
---|
228 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_GPP_year.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_GPP_year.csv |
---|
229 | |
---|
230 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_TER_hour.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_TER_hour.csv |
---|
231 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_TER_day.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_TER_day.csv |
---|
232 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_TER_month.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_TER_month.csv |
---|
233 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_TER_year.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_TER_year.csv |
---|
234 | |
---|
235 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_NEE_hour.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_NEE_hour.csv |
---|
236 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_NEE_day.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_NEE_day.csv |
---|
237 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_NEE_month.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_NEE_month.csv |
---|
238 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_NEE_year.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_NEE_year.csv |
---|
239 | |
---|
240 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_SH_hour.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_SH_hour.csv |
---|
241 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_SH_day.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_SH_day.csv |
---|
242 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_SH_month.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_SH_month.csv |
---|
243 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_SH_year.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_SH_year.csv |
---|
244 | |
---|
245 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_LH_hour.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_LH_hour.csv |
---|
246 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_LH_day.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_LH_day.csv |
---|
247 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_LH_month.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_LH_month.csv |
---|
248 | cat stat_${config_UserChoices_JobName}_${reference_config}_${group}_LH_year.csv >> stat_${config_UserChoices_JobName}_${reference_config}_ALL_LH_year.csv |
---|
249 | |
---|
250 | fi |
---|
251 | |
---|
252 | |
---|
253 | sed -e "s,\(flag_reference_file=\)\(.*\),\1${flag_reference},g" -e "s,\(NumSites=\)\(.*\),\1${NumSites},g" -e "s,\(group=\)\(.*\),\1\"${group}\",g" -e "s,\(config_eval=\)\(.*\),\1\"${config_UserChoices_JobName}\",g" -e "s,\(config_ref=\)\(.*\),\1\"${reference_config}\",g" atlas_FLUXNET_taylor.cfg > atlas_FLUXNET_taylor_${group}.cfg |
---|
254 | |
---|
255 | atlas -o fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${group} atlas_FLUXNET_taylor_${group}.cfg toto |
---|
256 | |
---|
257 | # Save files |
---|
258 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
259 | IGCM_sys_Put_Dir fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${group} ${R_SAVE} |
---|
260 | |
---|
261 | IGCM_sys_Rm -Rf fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${group} |
---|
262 | |
---|
263 | |
---|
264 | done |
---|
265 | |
---|
266 | if [ ${#fluxnet_FLUXNET_Groups[*]} -ne 1 ] ; then |
---|
267 | group="ALL" |
---|
268 | |
---|
269 | sed -e "s,\(flag_reference_file=\)\(.*\),\1${flag_reference},g" -e "s,\(NumSites=\)\(.*\),\1${NumAllSites},g" -e "s,\(group=\)\(.*\),\1\"${group}\",g" -e "s,\(config_eval=\)\(.*\),\1\"${config_UserChoices_JobName}\",g" -e "s,\(config_ref=\)\(.*\),\1\"${reference_config}\",g" atlas_FLUXNET_taylor.cfg > atlas_FLUXNET_taylor_${group}.cfg |
---|
270 | |
---|
271 | atlas -o fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${group} atlas_FLUXNET_taylor_${group}.cfg toto |
---|
272 | |
---|
273 | # Save files |
---|
274 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
275 | IGCM_sys_Put_Dir fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${group} ${R_SAVE} |
---|
276 | |
---|
277 | IGCM_sys_Rm -Rf fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${group} |
---|
278 | fi |
---|
279 | |
---|
280 | IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH} |
---|