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 | RESOL_OCE=${config_UserChoices_ExpType%%_*} |
---|
15 | EXPTYPE=${config_UserChoices_ExpType##*/} |
---|
16 | |
---|
17 | IGCM_debug_Print 1 " " |
---|
18 | IGCM_debug_Print 1 "RESOL_OCE : ${RESOL_OCE}" |
---|
19 | IGCM_debug_Print 1 "EXPERIMENT TYPE : ${EXPTYPE}" |
---|
20 | |
---|
21 | OPA_RDT=$( supergrep rn_rdt ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}${EXPTYPE}_offline_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' ) |
---|
22 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
23 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
24 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
25 | |
---|
26 | (( OPA_NPDT_DAY = 86400 / OPA_RDT )) |
---|
27 | (( OPA_NPDT_YEAR = OPA_NPDT_DAY * 365 )) |
---|
28 | |
---|
29 | |
---|
30 | IGCM_debug_Print 1 " " |
---|
31 | IGCM_debug_Print 1 "OPA_RDT ${OPA_RDT}" |
---|
32 | IGCM_debug_Print 1 "OPA_NPDT_DAY ${OPA_NPDT_DAY}" |
---|
33 | IGCM_debug_Print 1 "OPA_NPDT_YEAR ${OPA_NPDT_YEAR}" |
---|
34 | |
---|
35 | fi |
---|
36 | |
---|
37 | IGCM_debug_PopStack "MBG_Initialize" |
---|
38 | } |
---|
39 | |
---|
40 | #----------------------------------- |
---|
41 | function MBG_Update |
---|
42 | { |
---|
43 | IGCM_debug_PushStack "MBG_Update" |
---|
44 | |
---|
45 | |
---|
46 | ##--Write Frequency for iomput |
---|
47 | ## Differents frequencies are allowed for MBG files |
---|
48 | |
---|
49 | VT1D_ENABLE=".FALSE." |
---|
50 | VT5D_ENABLE=".FALSE." |
---|
51 | VT1M_ENABLE=".FALSE." |
---|
52 | VT1Y_ENABLE=".FALSE." |
---|
53 | |
---|
54 | for frequency in ${config_MBG_WriteFrequency} ; do |
---|
55 | case ${frequency} in |
---|
56 | ( 1D|1d ) VT1D_ENABLE=".TRUE." ;; |
---|
57 | ( 5D|5d ) VT5D_ENABLE=".TRUE." ;; |
---|
58 | ( 1M|1m ) VT1M_ENABLE=".TRUE." ;; |
---|
59 | ( *[yY] ) VT1Y_ENABLE=".TRUE." ;; |
---|
60 | esac |
---|
61 | done |
---|
62 | |
---|
63 | |
---|
64 | if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then |
---|
65 | |
---|
66 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
67 | # Needed by OPA namelist to compute correct file names |
---|
68 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
69 | |
---|
70 | ## Count of number of time steps from begin of OPA job |
---|
71 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 )) |
---|
72 | (( OPA_NDT = PeriodLengthInDays * OPA_NPDT_DAY )) |
---|
73 | (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1)) |
---|
74 | |
---|
75 | ## Forcing to write one restart file at the end of period |
---|
76 | OPA_NSTOCK="${OPA_NITEND}" |
---|
77 | |
---|
78 | # nleapy configuration |
---|
79 | case ${config_UserChoices_CalendarType} in |
---|
80 | leap) |
---|
81 | OPA_NLEAPY=1;; |
---|
82 | noleap) |
---|
83 | OPA_NLEAPY=0;; |
---|
84 | 360d) |
---|
85 | OPA_NLEAPY=30;; |
---|
86 | esac |
---|
87 | |
---|
88 | typeset -r PRECIS=8 |
---|
89 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
90 | |
---|
91 | |
---|
92 | DYN_SSH_INI=.TRUE. |
---|
93 | if [ "${EXPTYPE}" = "ia" ] ; then |
---|
94 | NbDynFile=${#pisces_UserChoices_DynFiles[*]} |
---|
95 | (( LengthForcing=${pisces_UserChoices_DynYearEnd} - ${pisces_UserChoices_DynYearStart} + 1 )) |
---|
96 | (( DiffForcing=abs( ${pisces_UserChoices_DynYearEnd} - ${year} ) )) |
---|
97 | (( ModuloForcing=${DiffForcing} % ${LengthForcing} )) |
---|
98 | if [ ${ModuloForcing} -eq 0 ] ; then |
---|
99 | (( year_forcing=${pisces_UserChoices_DynYearEnd} )) |
---|
100 | else |
---|
101 | if [ ${year} -ge ${pisces_UserChoices_DynYearStart} ] && [ ${year} -le ${pisces_UserChoices_DynYearEnd} ] ; then |
---|
102 | year_forcing=${year} |
---|
103 | elif [ ${year} -lt ${pisces_UserChoices_DynYearStart} ] ; then |
---|
104 | (( year_forcing=${pisces_UserChoices_DynYearEnd} - ${ModuloForcing} )) |
---|
105 | else |
---|
106 | (( year_forcing=${pisces_UserChoices_DynYearStart} + ${ModuloForcing} - 1 )) |
---|
107 | fi |
---|
108 | fi |
---|
109 | (( year_forcing_m1 = ${year_forcing} - 1)) |
---|
110 | (( year_forcing_p1 = ${year_forcing} + 1)) |
---|
111 | eval CurrDateFor=${year_forcing}0101_${year_forcing}1231 |
---|
112 | eval PrevDateFor=${year_forcing_m1}0101_${year_forcing_m1}1231 |
---|
113 | eval NextDateFor=${year_forcing_p1}0101_${year_forcing_p1}1231 |
---|
114 | (( i = 0 )) |
---|
115 | while [ $i -lt ${NbDynFile} ] ; do |
---|
116 | eval Suffix=${pisces_UserChoices_DynFiles[$i]} |
---|
117 | eval RunFileName=${pisces_UserChoices_DynRunName}_${Suffix} |
---|
118 | eval PrevDynFileName=${pisces_UserChoices_DynName}_${PrevDateFor}_${pisces_UserChoices_DynFreq}_${Suffix} |
---|
119 | eval CurrDynFileName=${pisces_UserChoices_DynName}_${CurrDateFor}_${pisces_UserChoices_DynFreq}_${Suffix} |
---|
120 | eval NextDynFileName=${pisces_UserChoices_DynName}_${NextDateFor}_${pisces_UserChoices_DynFreq}_${Suffix} |
---|
121 | ## IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${PrevDynFileName}.nc ${RunFileName}_y${year_m1}.nc |
---|
122 | IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${CurrDynFileName}.nc ${RunFileName}_y${year}.nc |
---|
123 | ## IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${NextDynFileName}.nc ${RunFileName}_y${year_p1}.nc |
---|
124 | (( i = i + 1 )) |
---|
125 | done |
---|
126 | if [ ${year_forcing} = ${pisces_UserChoices_DynYearStart} ] ; then |
---|
127 | DYN_SSH_INI=.TRUE. |
---|
128 | else |
---|
129 | DYN_SSH_INI=.FALSE |
---|
130 | fi |
---|
131 | fi |
---|
132 | fi |
---|
133 | |
---|
134 | ##-- Restart configuration |
---|
135 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then |
---|
136 | |
---|
137 | #echo "NO RESTART FOR TOP" |
---|
138 | TOP_LRSTTR=.FALSE. |
---|
139 | TOP_NRSTTR=0 |
---|
140 | |
---|
141 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then |
---|
142 | |
---|
143 | #echo "RESTART TOP" |
---|
144 | TOP_LRSTTR=.TRUE. |
---|
145 | TOP_NRSTTR=0 |
---|
146 | |
---|
147 | else |
---|
148 | |
---|
149 | #echo "RESTART TOP" |
---|
150 | TOP_LRSTTR=.TRUE. |
---|
151 | TOP_NRSTTR=2 |
---|
152 | fi |
---|
153 | |
---|
154 | # on force les sorties PISCES comme les sorties OPA |
---|
155 | if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then |
---|
156 | IGCM_comp_modifyNamelist blocker namelist_cfg cn_exp ${config_UserChoices_JobName} |
---|
157 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_it000 ${OPA_NIT000} |
---|
158 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_itend ${OPA_NITEND} |
---|
159 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_stock ${OPA_NSTOCK} |
---|
160 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_date0 ${PeriodDateBegin} |
---|
161 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_leapy ${OPA_NLEAPY} |
---|
162 | |
---|
163 | # update domain_def.xml file |
---|
164 | case ${RESOL_OCE} in |
---|
165 | ( *ORCA025* ) |
---|
166 | 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 |
---|
167 | IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml ; |
---|
168 | esac |
---|
169 | |
---|
170 | fi |
---|
171 | |
---|
172 | ##-- Update namelist_top_cfg and namelist_pisces_cfg |
---|
173 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_rsttr ${TOP_LRSTTR} |
---|
174 | IGCM_comp_modifyNamelist blocker namelist_top_cfg nn_rsttr ${TOP_NRSTTR} |
---|
175 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg atcco2 ${pisces_UserChoices_AtmCo2} |
---|
176 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg nn_pisdmp ${OPA_NPDT_YEAR} |
---|
177 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg nrdttrc ${pisces_UserChoices_PisFreq} |
---|
178 | |
---|
179 | |
---|
180 | # Update iodef.xml |
---|
181 | |
---|
182 | IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE ' |
---|
183 | IGCM_debug_Print 1 ${VT1D_ENABLE} ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE} |
---|
184 | |
---|
185 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis enabled ${VT1D_ENABLE} |
---|
186 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis enabled ${VT5D_ENABLE} |
---|
187 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis enabled ${VT1M_ENABLE} |
---|
188 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis enabled ${VT1Y_ENABLE} |
---|
189 | |
---|
190 | |
---|
191 | |
---|
192 | IGCM_debug_PopStack "MBG_Update" |
---|
193 | } |
---|
194 | |
---|
195 | #----------------------------------- |
---|
196 | function MBG_Finalize |
---|
197 | { |
---|
198 | IGCM_debug_PushStack "MBG_Finalize" |
---|
199 | |
---|
200 | echo FINALIZE MBG !!! |
---|
201 | |
---|
202 | IGCM_debug_PopStack "MBG_Finalize" |
---|
203 | } |
---|
204 | |
---|