1 | #!/bin/ksh |
---|
2 | |
---|
3 | #D--------------------------------------------------------------------== |
---|
4 | |
---|
5 | function FLUXNET_initialize |
---|
6 | { |
---|
7 | IGCM_debug_PushStack "FLUXNET_initialize" |
---|
8 | |
---|
9 | # config.card : |
---|
10 | # ------------- |
---|
11 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices |
---|
12 | typeset option |
---|
13 | for option in ${config_UserChoices[*]} ; do |
---|
14 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} |
---|
15 | done |
---|
16 | |
---|
17 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
18 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
19 | |
---|
20 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SubJobPost |
---|
21 | typeset option |
---|
22 | for option in ${config_SubJobPost[*]} ; do |
---|
23 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SubJobPost ${option} |
---|
24 | done |
---|
25 | |
---|
26 | # Subjobs configuration : |
---|
27 | # ----------------------- |
---|
28 | |
---|
29 | # 1) UserChoices section of fluxnet.card |
---|
30 | |
---|
31 | # This section groups standard options to be passed to ORCHIDEE. |
---|
32 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card UserChoices |
---|
33 | set +A fluxnet_UserChoices -- ${fluxnet_UserChoices[*]} > /dev/null 2>&1 |
---|
34 | typeset option |
---|
35 | for option in ${fluxnet_UserChoices[*]} ; do |
---|
36 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card UserChoices ${option} |
---|
37 | done |
---|
38 | |
---|
39 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF |
---|
40 | typeset option |
---|
41 | for option in ${config_SRF[*]} ; do |
---|
42 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option} |
---|
43 | done |
---|
44 | if [ X"${fluxnet_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
45 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG |
---|
46 | typeset option |
---|
47 | for option in ${config_SBG[*]} ; do |
---|
48 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option} |
---|
49 | done |
---|
50 | fi |
---|
51 | |
---|
52 | # 2) FLUXNET section : |
---|
53 | |
---|
54 | # This section groups specific options for FLUXNET spinup : |
---|
55 | # - Fluxnet files path |
---|
56 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET FluxnetPath |
---|
57 | |
---|
58 | # - List of the sites/information to be treated : |
---|
59 | # * Number of PFTs |
---|
60 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbPFTs |
---|
61 | NbPFTs=${fluxnet_FLUXNET_NbPFTs} |
---|
62 | |
---|
63 | # * Number of physical parameters on each sites per PFTs |
---|
64 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NbSitesParam |
---|
65 | # * ORCHIDEE name for physical parameters on each sites |
---|
66 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET NameSitesParam |
---|
67 | # * Sites descriptions |
---|
68 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET Sites |
---|
69 | # * Components for each physical parameter described in NameSitesParam |
---|
70 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/fluxnet.card FLUXNET CompSitesParam |
---|
71 | |
---|
72 | echo ${fluxnet_FLUXNET_Sites[*]} |
---|
73 | |
---|
74 | # Number of columns by site in variable site : name, filename, length, + ${NbPFTs} PFT |
---|
75 | NumInfosBySite=$(( 4 + ( NbPFTs * fluxnet_FLUXNET_NbSitesParam ) )) |
---|
76 | |
---|
77 | # Number of sites : |
---|
78 | NumSites=$(( ${#fluxnet_FLUXNET_Sites[*]} / NumInfosBySite )) |
---|
79 | # Num of Columns : name, filename, length, + ${NbPFTs} PFT |
---|
80 | ColumnName=0 |
---|
81 | ColumnFilename=1 |
---|
82 | ColumnYear=2 |
---|
83 | ColumnLength=3 |
---|
84 | |
---|
85 | # 3) SPINUP section : files path and spinup parameters |
---|
86 | # This section groups specific options for SPINUP : |
---|
87 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SPINUP |
---|
88 | set +A fluxnet_SPINUP -- ${fluxnet_SPINUP[*]} > /dev/null 2>&1 |
---|
89 | typeset option |
---|
90 | for option in ${fluxnet_SPINUP[*]} ; do |
---|
91 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SPINUP ${option} |
---|
92 | done |
---|
93 | |
---|
94 | # 4) Subjob orchidee.def parametrisation : SubJobParams in fluxnet.card |
---|
95 | # This section give flags to put in orchidee.def of Subjobs. |
---|
96 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/fluxnet.card SubJobParams |
---|
97 | set +A fluxnet_SubJobParams -- ${fluxnet_SubJobParams[*]} > /dev/null 2>&1 |
---|
98 | eval first_option=${fluxnet_SubJobParams[0]} > /dev/null 2>&1 |
---|
99 | if [ X${first_option} != X"Error:" ] ; then |
---|
100 | typeset option |
---|
101 | for option in ${fluxnet_SubJobParams[*]} ; do |
---|
102 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/fluxnet.card SubJobParams ${option} |
---|
103 | done |
---|
104 | fi |
---|
105 | |
---|
106 | IGCM_debug_PopStack "FLUXNET_initialize" |
---|
107 | } |
---|
108 | |
---|
109 | # Function to sed parameter files in Subjob dirs |
---|
110 | # For sechiba.def : |
---|
111 | function SECHIBA_sed |
---|
112 | { |
---|
113 | IGCM_debug_PushStack "SECHIBA_sed" |
---|
114 | |
---|
115 | if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then |
---|
116 | sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ |
---|
117 | ${New_SUBMIT_DIR}/PARAM/sechiba.def > ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp |
---|
118 | RET=$? |
---|
119 | echo "SECHIBA_sed : ${1} ${2}" |
---|
120 | \mv ${New_SUBMIT_DIR}/PARAM/sechiba.def.tmp ${New_SUBMIT_DIR}/PARAM/sechiba.def |
---|
121 | fi |
---|
122 | |
---|
123 | IGCM_debug_PopStack "SECHIBA_sed" |
---|
124 | return $RET |
---|
125 | } |
---|
126 | |
---|
127 | # For stomate.def : |
---|
128 | function STOMATE_sed |
---|
129 | { |
---|
130 | IGCM_debug_PushStack "STOMATE_sed" |
---|
131 | |
---|
132 | sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ |
---|
133 | ${New_SUBMIT_DIR}/PARAM/stomate.def > ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp |
---|
134 | RET=$? |
---|
135 | echo "STOMATE_sed : ${1} ${2}" |
---|
136 | \mv ${New_SUBMIT_DIR}/PARAM/stomate.def.tmp ${New_SUBMIT_DIR}/PARAM/stomate.def |
---|
137 | |
---|
138 | IGCM_debug_PopStack "STOMATE_sed" |
---|
139 | return $RET |
---|
140 | } |
---|
141 | |
---|
142 | # For driver.def : |
---|
143 | function DRIVER_sed |
---|
144 | { |
---|
145 | IGCM_debug_PushStack "DRIVER_sed" |
---|
146 | |
---|
147 | if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then |
---|
148 | sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ |
---|
149 | ${New_SUBMIT_DIR}/PARAM/driver.def > ${New_SUBMIT_DIR}/PARAM/driver.def.tmp |
---|
150 | RET=$? |
---|
151 | echo "DRIVER_sed : ${1} ${2}" |
---|
152 | \mv ${New_SUBMIT_DIR}/PARAM/driver.def.tmp ${New_SUBMIT_DIR}/PARAM/driver.def |
---|
153 | fi |
---|
154 | |
---|
155 | IGCM_debug_PopStack "DRIVER_sed" |
---|
156 | return $RET |
---|
157 | } |
---|
158 | |
---|
159 | |
---|
160 | # Function to grep parameter files in Subjob dirs |
---|
161 | # They search for the argmument value in the file. |
---|
162 | # The result of the function is given in ${SearchParam} global variable : |
---|
163 | # * "line" if the parameter is defined with the form |
---|
164 | # PARAM__1=value1 |
---|
165 | # PARAM__2=value2 |
---|
166 | # etc... |
---|
167 | # * "vector" if the parameter is defined with the form |
---|
168 | # PARAM=value1 value2 etc... |
---|
169 | # * "undefined" if the parameter is not definied in the parameters file |
---|
170 | # This should give an error in the script. |
---|
171 | |
---|
172 | # For sechiba.def : |
---|
173 | function SECHIBA_grep |
---|
174 | { |
---|
175 | IGCM_debug_PushStack "SECHIBA_grep" |
---|
176 | typeset Output |
---|
177 | |
---|
178 | if [ -f ${New_SUBMIT_DIR}/PARAM/sechiba.def ] ; then |
---|
179 | set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def ) |
---|
180 | if [ X${Output[0]} != X ] ; then |
---|
181 | SearchParam=line |
---|
182 | else |
---|
183 | unset Output |
---|
184 | set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/sechiba.def ) |
---|
185 | if [ X${Output[0]} != X ] ; then |
---|
186 | SearchParam=vector |
---|
187 | else |
---|
188 | SearchParam=undefined |
---|
189 | fi |
---|
190 | fi |
---|
191 | else |
---|
192 | SearchParam=undefined |
---|
193 | echo "$@ : file not found !!" |
---|
194 | fi |
---|
195 | |
---|
196 | IGCM_debug_PopStack "SECHIBA_grep" |
---|
197 | return $RET |
---|
198 | } |
---|
199 | |
---|
200 | # For stomate.def : |
---|
201 | function STOMATE_grep |
---|
202 | { |
---|
203 | IGCM_debug_PushStack "STOMATE_grep" |
---|
204 | typeset Output |
---|
205 | |
---|
206 | if [ -f ${New_SUBMIT_DIR}/PARAM/stomate.def ] ; then |
---|
207 | set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def ) |
---|
208 | if [ X${Output[0]} != X ] ; then |
---|
209 | SearchParam=line |
---|
210 | else |
---|
211 | unset Output |
---|
212 | set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/stomate.def ) |
---|
213 | if [ X${Output[0]} != X ] ; then |
---|
214 | SearchParam=vector |
---|
215 | else |
---|
216 | SearchParam=undefined |
---|
217 | fi |
---|
218 | fi |
---|
219 | else |
---|
220 | SearchParam=undefined |
---|
221 | echo "$@ : file not found !!" |
---|
222 | fi |
---|
223 | |
---|
224 | IGCM_debug_PopStack "STOMATE_grep" |
---|
225 | return $RET |
---|
226 | } |
---|
227 | |
---|
228 | # For driver.def : |
---|
229 | function DRIVER_grep |
---|
230 | { |
---|
231 | IGCM_debug_PushStack "DRIVER_grep" |
---|
232 | typeset Output |
---|
233 | |
---|
234 | if [ -f ${New_SUBMIT_DIR}/PARAM/driver.def ] ; then |
---|
235 | set +A Output -- $( grep "^${1}__[0-9]*\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def ) |
---|
236 | if [ X${Output[0]} != X ] ; then |
---|
237 | SearchParam=line |
---|
238 | else |
---|
239 | unset Output |
---|
240 | set +A Output -- $( grep "^${1}\ *=" ${New_SUBMIT_DIR}/PARAM/driver.def ) |
---|
241 | if [ X${Output[0]} != X ] ; then |
---|
242 | SearchParam=vector |
---|
243 | else |
---|
244 | SearchParam=undefined |
---|
245 | fi |
---|
246 | fi |
---|
247 | else |
---|
248 | SearchParam=undefined |
---|
249 | echo "$@ : file not found !!" |
---|
250 | fi |
---|
251 | |
---|
252 | IGCM_debug_PopStack "DRIVER_grep" |
---|
253 | return $RET |
---|
254 | } |
---|
255 | |
---|