1 | #!/bin/ksh |
---|
2 | |
---|
3 | #----------------------------------- |
---|
4 | function MBG_Initialize |
---|
5 | { |
---|
6 | IGCM_debug_PushStack "MBG_Initialize" |
---|
7 | |
---|
8 | # Local function to find namelists parameters |
---|
9 | supergrep () { |
---|
10 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
11 | } |
---|
12 | |
---|
13 | if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then |
---|
14 | |
---|
15 | if [ X$ResolOce != X ]; then |
---|
16 | #ResolOce is set in config.card |
---|
17 | RESOL_OCE=${ResolOce} |
---|
18 | else |
---|
19 | RESOL_OCE=${config_UserChoices_ExpType%%_*} |
---|
20 | fi |
---|
21 | ORCAGRID=${opa9_UserChoices_ORCA_version%%.*} |
---|
22 | exptype=${config_UserChoices_ExpType##*/} |
---|
23 | |
---|
24 | IGCM_debug_Print 1 " " |
---|
25 | IGCM_debug_Print 1 "RESOL_OCE : ${RESOL_OCE}" |
---|
26 | IGCM_debug_Print 1 "ORCAGRID : ${ORCAGRID}" |
---|
27 | IGCM_debug_Print 1 "EXPERIMENT TYPE : ${exptype}" |
---|
28 | |
---|
29 | |
---|
30 | OPA_RDT=$( supergrep rn_rdt ${SUBMIT_DIR}/PARAM/NAMELIST/${RESOL_OCE}/namelist_offline_${exptype}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' ) |
---|
31 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
32 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
33 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
34 | |
---|
35 | (( OPA_NPDT_DAY = 86400 / OPA_RDT )) |
---|
36 | (( OPA_NPDT_YEAR = OPA_NPDT_DAY * 365 )) |
---|
37 | |
---|
38 | |
---|
39 | IGCM_debug_Print 1 " " |
---|
40 | IGCM_debug_Print 1 "OPA_RDT ${OPA_RDT}" |
---|
41 | IGCM_debug_Print 1 "OPA_NPDT_DAY ${OPA_NPDT_DAY}" |
---|
42 | IGCM_debug_Print 1 "OPA_NPDT_YEAR ${OPA_NPDT_YEAR}" |
---|
43 | |
---|
44 | fi |
---|
45 | |
---|
46 | IGCM_debug_PopStack "MBG_Initialize" |
---|
47 | } |
---|
48 | |
---|
49 | #----------------------------------- |
---|
50 | function MBG_Update |
---|
51 | { |
---|
52 | IGCM_debug_PushStack "MBG_Update" |
---|
53 | |
---|
54 | |
---|
55 | ##--Write Frequency for iomput |
---|
56 | ## Differents frequencies are allowed for MBG files |
---|
57 | |
---|
58 | VT1D_ENABLE=".FALSE." |
---|
59 | VT5D_ENABLE=".FALSE." |
---|
60 | VT1M_ENABLE=".FALSE." |
---|
61 | VT1Y_ENABLE=".FALSE." |
---|
62 | |
---|
63 | for frequency in ${config_MBG_WriteFrequency} ; do |
---|
64 | case ${frequency} in |
---|
65 | ( 1D|1d ) VT1D_ENABLE=".TRUE." ;; |
---|
66 | ( 5D|5d ) VT5D_ENABLE=".TRUE." ;; |
---|
67 | ( 1M|1m ) VT1M_ENABLE=".TRUE." ;; |
---|
68 | ( *[yY] ) VT1Y_ENABLE=".TRUE." ;; |
---|
69 | esac |
---|
70 | done |
---|
71 | |
---|
72 | |
---|
73 | if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then |
---|
74 | |
---|
75 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
76 | # Needed by OPA namelist to compute correct file names |
---|
77 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
78 | |
---|
79 | ## Count of number of time steps from begin of OPA job |
---|
80 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 )) |
---|
81 | (( OPA_NDT = PeriodLengthInDays * OPA_NPDT_DAY )) |
---|
82 | (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1)) |
---|
83 | |
---|
84 | ## Forcing to write one restart file at the end of period |
---|
85 | OPA_NSTOCK="${OPA_NITEND}" |
---|
86 | |
---|
87 | # nleapy configuration |
---|
88 | case ${config_UserChoices_CalendarType} in |
---|
89 | leap) |
---|
90 | OPA_NLEAPY=1;; |
---|
91 | noleap) |
---|
92 | OPA_NLEAPY=0;; |
---|
93 | 360d) |
---|
94 | OPA_NLEAPY=30;; |
---|
95 | esac |
---|
96 | |
---|
97 | typeset -r PRECIS=8 |
---|
98 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
99 | |
---|
100 | |
---|
101 | DYN_SSH_INI=.TRUE. |
---|
102 | if [ "${exptype}" = "ia" ] ; then |
---|
103 | NbDynFile=${#pisces_UserChoices_DynFiles[*]} |
---|
104 | (( LengthForcing=${pisces_UserChoices_DynYearEnd} - ${pisces_UserChoices_DynYearStart} + 1 )) |
---|
105 | (( DiffForcing=abs( ${pisces_UserChoices_DynYearEnd} - ${year} ) )) |
---|
106 | (( ModuloForcing=${DiffForcing} % ${LengthForcing} )) |
---|
107 | if [ ${ModuloForcing} -eq 0 ] ; then |
---|
108 | (( year_forcing=${pisces_UserChoices_DynYearEnd} )) |
---|
109 | else |
---|
110 | if [ ${year} -ge ${pisces_UserChoices_DynYearStart} ] && [ ${year} -le ${pisces_UserChoices_DynYearEnd} ] ; then |
---|
111 | year_forcing=${year} |
---|
112 | elif [ ${year} -lt ${pisces_UserChoices_DynYearStart} ] ; then |
---|
113 | (( year_forcing=${pisces_UserChoices_DynYearEnd} - ${ModuloForcing} )) |
---|
114 | else |
---|
115 | (( year_forcing=${pisces_UserChoices_DynYearStart} + ${ModuloForcing} - 1 )) |
---|
116 | fi |
---|
117 | fi |
---|
118 | (( year_forcing_m1 = ${year_forcing} - 1)) |
---|
119 | (( year_forcing_p1 = ${year_forcing} + 1)) |
---|
120 | eval CurrDateFor=${year_forcing}0101_${year_forcing}1231 |
---|
121 | eval PrevDateFor=${year_forcing_m1}0101_${year_forcing_m1}1231 |
---|
122 | eval NextDateFor=${year_forcing_p1}0101_${year_forcing_p1}1231 |
---|
123 | (( i = 0 )) |
---|
124 | while [ $i -lt ${NbDynFile} ] ; do |
---|
125 | eval Suffix=${pisces_UserChoices_DynFiles[$i]} |
---|
126 | eval RunFileName=${pisces_UserChoices_DynRunName}_${Suffix} |
---|
127 | eval PrevDynFileName=${pisces_UserChoices_DynName}_${PrevDateFor}_${pisces_UserChoices_DynFreq}_${Suffix} |
---|
128 | eval CurrDynFileName=${pisces_UserChoices_DynName}_${CurrDateFor}_${pisces_UserChoices_DynFreq}_${Suffix} |
---|
129 | eval NextDynFileName=${pisces_UserChoices_DynName}_${NextDateFor}_${pisces_UserChoices_DynFreq}_${Suffix} |
---|
130 | IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${PrevDynFileName}.nc ${RunFileName}_y${year_m1}.nc |
---|
131 | IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${CurrDynFileName}.nc ${RunFileName}_y${year}.nc |
---|
132 | IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${NextDynFileName}.nc ${RunFileName}_y${year_p1}.nc |
---|
133 | ln -sf ${RunFileName}_y${year}.nc ${RunFileName}.nc |
---|
134 | (( i = i + 1 )) |
---|
135 | done |
---|
136 | if [ ${year_forcing} = ${pisces_UserChoices_DynYearStart} ] ; then |
---|
137 | DYN_SSH_INI=.TRUE. |
---|
138 | else |
---|
139 | DYN_SSH_INI=.FALSE |
---|
140 | fi |
---|
141 | fi |
---|
142 | fi |
---|
143 | |
---|
144 | ##-- Restart configuration |
---|
145 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then |
---|
146 | |
---|
147 | #echo "NO RESTART FOR TOP" |
---|
148 | TOP_LRSTTR=.FALSE. |
---|
149 | TOP_NRSTTR=0 |
---|
150 | |
---|
151 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then |
---|
152 | |
---|
153 | #echo "RESTART TOP" |
---|
154 | TOP_LRSTTR=.TRUE. |
---|
155 | TOP_NRSTTR=0 |
---|
156 | |
---|
157 | else |
---|
158 | |
---|
159 | #echo "RESTART TOP" |
---|
160 | TOP_LRSTTR=.TRUE. |
---|
161 | TOP_NRSTTR=2 |
---|
162 | fi |
---|
163 | |
---|
164 | # on force les sorties PISCES comme les sorties OPA |
---|
165 | if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then |
---|
166 | IGCM_comp_modifyNamelist blocker namelist_cfg cn_exp ${config_UserChoices_JobName} |
---|
167 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_it000 ${OPA_NIT000} |
---|
168 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_itend ${OPA_NITEND} |
---|
169 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_stock ${OPA_NSTOCK} |
---|
170 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_date0 ${PeriodDateBegin} |
---|
171 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_leapy ${OPA_NLEAPY} |
---|
172 | |
---|
173 | # update domain_def.xml file |
---|
174 | case ${RESOL_OCE} in |
---|
175 | ( *ORCA025* ) |
---|
176 | sed -e 's/<zoom_domain id="1point" ibegin="139" jbegin="119"/<zoom_domain id="1point" ibegin="600" jbegin="600"/' domain_def_nemo.xml > domain_def.xml.tmp |
---|
177 | IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml ; |
---|
178 | esac |
---|
179 | |
---|
180 | IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${InitYear} |
---|
181 | |
---|
182 | fi |
---|
183 | |
---|
184 | if [ X"${pisces_UserChoices_pis}" = X"n" ] ; then |
---|
185 | echo "DeActivate pisces outputs" |
---|
186 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file33 enabled .FALSE. |
---|
187 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file34 enabled .FALSE. |
---|
188 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file35 enabled .FALSE. |
---|
189 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file36 enabled .FALSE. |
---|
190 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file37 enabled .FALSE. |
---|
191 | fi |
---|
192 | |
---|
193 | if [ X"${pisces_UserChoices_age}" = X"y" ] ; then |
---|
194 | echo "Activate age tracer" |
---|
195 | TOP_AGE=.TRUE. |
---|
196 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file38 enabled .TRUE. |
---|
197 | else |
---|
198 | TOP_AGE=.FALSE. |
---|
199 | fi |
---|
200 | ## |
---|
201 | if [ X"${pisces_UserChoices_cfc11}" = X"y" ] ; then |
---|
202 | echo "Activate CFC11 tracer" |
---|
203 | TOP_CFC11=.TRUE. |
---|
204 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file39 enabled .FALSE. |
---|
205 | else |
---|
206 | TOP_CFC11=.FALSE. |
---|
207 | fi |
---|
208 | ## |
---|
209 | if [ X"${pisces_UserChoices_cfc12}" = X"y" ] ; then |
---|
210 | echo "Activate CFC12 tracer" |
---|
211 | TOP_CFC12=.TRUE. |
---|
212 | IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file40 enabled .TRUE. |
---|
213 | else |
---|
214 | TOP_CFC12=.FALSE. |
---|
215 | fi |
---|
216 | ## |
---|
217 | if [ X"${pisces_UserChoices_Co2Anthr}" = X"y" ] ; then |
---|
218 | LCO2INT=.TRUE. |
---|
219 | else |
---|
220 | LCO2INT=.FALSE. |
---|
221 | fi |
---|
222 | ##-- Update namelist_top_cfg and namelist_pisces_cfg |
---|
223 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_rsttr ${TOP_LRSTTR} |
---|
224 | IGCM_comp_modifyNamelist blocker namelist_top_cfg nn_rsttr ${TOP_NRSTTR} |
---|
225 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_age ${TOP_AGE} |
---|
226 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_cfc11 ${TOP_CFC11} |
---|
227 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_cfc12 ${TOP_CFC12} |
---|
228 | if [ X"${pisces_UserChoices_pis}" = X"y" ] ; then |
---|
229 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg ln_co2int ${LCO2INT} |
---|
230 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg atcco2 ${pisces_UserChoices_AtmCo2} |
---|
231 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg nrdttrc ${pisces_UserChoices_PisFreq} |
---|
232 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg nn_pisdmp ${OPA_NPDT_YEAR} |
---|
233 | fi |
---|
234 | |
---|
235 | # Update iodef.xml |
---|
236 | |
---|
237 | IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE ' |
---|
238 | IGCM_debug_Print 1 ${VT1D_ENABLE} ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE} |
---|
239 | |
---|
240 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1d_pis enabled ${VT1D_ENABLE} |
---|
241 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 5d_pis enabled ${VT5D_ENABLE} |
---|
242 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1m_pis enabled ${VT1M_ENABLE} |
---|
243 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1y_pis enabled ${VT1Y_ENABLE} |
---|
244 | |
---|
245 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1d_pis output_level ${pisces_UserChoices_OutputLevel} |
---|
246 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 5d_pis output_level ${pisces_UserChoices_OutputLevel} |
---|
247 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1m_pis output_level ${pisces_UserChoices_OutputLevel} |
---|
248 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1y_pis output_level ${pisces_UserChoices_OutputLevel} |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | IGCM_debug_PopStack "MBG_Update" |
---|
253 | } |
---|
254 | |
---|
255 | #----------------------------------- |
---|
256 | function MBG_Finalize |
---|
257 | { |
---|
258 | IGCM_debug_PushStack "MBG_Finalize" |
---|
259 | |
---|
260 | echo FINALIZE MBG !!! |
---|
261 | |
---|
262 | IGCM_debug_PopStack "MBG_Finalize" |
---|
263 | } |
---|
264 | |
---|