1 | #!/bin/ksh |
---|
2 | #----------------------------------------------------------------- |
---|
3 | function OCE_Initialize |
---|
4 | { |
---|
5 | IGCM_debug_PushStack "OCE_Initialize" |
---|
6 | |
---|
7 | JOB_NAME=${config_UserChoices_JobName} |
---|
8 | |
---|
9 | RESOL_OCE_ICE=$( echo ${RESOL} | awk "-Fx" '{print $1}' ) |
---|
10 | case ${RESOL_OCE_ICE} in |
---|
11 | ( *LIM2* ) |
---|
12 | SEAICE_MODEL=LIM2 |
---|
13 | LIM_VERSION=2 |
---|
14 | ;; |
---|
15 | |
---|
16 | ( *LIM3* ) |
---|
17 | SEAICE_MODEL=LIM3 |
---|
18 | LIM_VERSION=3 |
---|
19 | ;; |
---|
20 | ( *CICE*) SEAICE_MODEL=CICE ;; |
---|
21 | ( * ) SEAICE_MODEL=UNKNOWN ;; |
---|
22 | esac |
---|
23 | RESOL_OCE=$( echo ${RESOL_OCE_ICE} | sed "s/${SEAICE_MODEL}//" ) |
---|
24 | |
---|
25 | IGCM_debug_Print 1 "RESOL : ${RESOL}" |
---|
26 | IGCM_debug_Print 1 "RESOL_OCE_ICE : ${RESOL_OCE_ICE}" |
---|
27 | IGCM_debug_Print 1 "SEAICE_MODEL : ${SEAICE_MODEL}" |
---|
28 | IGCM_debug_Print 1 "LIM_VERSION : ${LIM_VERSION}" |
---|
29 | IGCM_debug_Print 1 "RESOL_OCE : ${RESOL_OCE}" |
---|
30 | |
---|
31 | # Local function to find namelists parameters |
---|
32 | supergrep () { |
---|
33 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
34 | } |
---|
35 | |
---|
36 | ##--Variables used by OPA -- |
---|
37 | |
---|
38 | # cn_exp experience name |
---|
39 | # nn_it000 number of the first time step |
---|
40 | # nn_itend number of the last time step |
---|
41 | # nn_date0 initial calendar date yymmdd (used if nn_rstctl=1) |
---|
42 | # nn_leapy Leap year calendar (1) or not (0), or 360 days calendar (30) |
---|
43 | # nn_stock frequency of creation of a restart file (modulo referenced to 1) |
---|
44 | # nn_write frequency of write in the output file (modulo referenced to nn_it000) |
---|
45 | # ln_rstart start from rest (F) or from a restart file (T) |
---|
46 | # nn_rstctl restart control = 0 nn_it000 is not compared to the restart file value |
---|
47 | # = 1 use nn_date0 in namelist_cfg (not the value in the restart file) |
---|
48 | # = 2 calendar parameters read in the restart file |
---|
49 | # nn_msh =1 create a mesh file (coordinates, scale factors, masks) |
---|
50 | # rn_rdt time step in seconds for the dynamics (and tracer if nacc=0) ==> 5760 (coming from namelist) |
---|
51 | # nn_prg time-step frequency of gap print in model output |
---|
52 | # nn_fwri frequency of zonal means and transport output |
---|
53 | |
---|
54 | NAMELIST_OPA_CFG=${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_cfg |
---|
55 | NAMELIST_OPA_REF=${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_ref |
---|
56 | IGCM_debug_Print 1 "namelist_ref : ${NAMELIST_OPA_REF}" |
---|
57 | if [ ! -r ${NAMELIST_OPA_REF} ] ; then |
---|
58 | echo "${NAMELIST_OPA_REF} non trouve" |
---|
59 | fi |
---|
60 | IGCM_debug_Print 1 "namelist_cfg : ${NAMELIST_OPA_CFG}" |
---|
61 | if [ ! -r ${NAMELIST_OPA_CFG} ] ; then |
---|
62 | echo "${NAMELIST_OPA_CFG} non trouve" |
---|
63 | fi |
---|
64 | |
---|
65 | PAT_CEXPER=$( supergrep cn_exp ${NAMELIST_OPA_CFG} ) |
---|
66 | PAT_NIT000=$( supergrep nn_it000 ${NAMELIST_OPA_CFG} ) |
---|
67 | PAT_NITEND=$( supergrep nn_itend ${NAMELIST_OPA_CFG} ) |
---|
68 | PAT_NDATE0=$( supergrep nn_date0 ${NAMELIST_OPA_CFG} ) |
---|
69 | PAT_NLEAPY=$( supergrep nn_leapy ${NAMELIST_OPA_CFG} ) |
---|
70 | PAT_NSTOCK=$( supergrep nn_stock ${NAMELIST_OPA_CFG} ) |
---|
71 | PAT_RESTAR=$( supergrep ln_rstart ${NAMELIST_OPA_CFG} ) |
---|
72 | PAT_NRSTAR=$( supergrep nn_rstctl ${NAMELIST_OPA_CFG} ) |
---|
73 | PAT_NMSH=$( supergrep nn_msh ${NAMELIST_OPA_CFG} ) |
---|
74 | PAT_ICE_EMBD=$( supergrep nn_ice_embd ${NAMELIST_OPA_CFG} ) |
---|
75 | PAT_ICEFLX=$( supergrep cn_iceflx ${NAMELIST_OPA_CFG} ) |
---|
76 | PAT_JPNI=$( supergrep jpni ${NAMELIST_OPA_CFG} ) |
---|
77 | PAT_JPNJ=$( supergrep jpnj ${NAMELIST_OPA_CFG} ) |
---|
78 | PAT_JPNIJ=$( supergrep jpnij ${NAMELIST_OPA_CFG} ) |
---|
79 | PAT_NN_FSBC=$( supergrep nn_fsbc ${NAMELIST_OPA_CFG} ) |
---|
80 | |
---|
81 | ORCA_RDT=$( supergrep rn_rdt ${NAMELIST_OPA_CFG} | sed 's/ *rn_rdt *=//' | sed 's/\. *//' ) |
---|
82 | ORCA_NN_FSBC=$( supergrep nn_fsbc ${NAMELIST_OPA_CFG} | sed 's/ *nn_fsbc *=//' | sed 's/\. *//' ) |
---|
83 | (( ORCA_NPDT_JOUR = 86400 / ORCA_RDT )) |
---|
84 | #(( ORCA_NPDT_SBC = ORCA_NPDT_JOUR / ORCA_NN_FSBC )) |
---|
85 | (( ORCA_RDT_SBC = ORCA_RDT * ORCA_NN_FSBC )) |
---|
86 | |
---|
87 | |
---|
88 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
89 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
90 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
91 | |
---|
92 | IGCM_debug_Print 1 "PAT_CEXPER $PAT_CEXPER " |
---|
93 | IGCM_debug_Print 1 "PAT_NIT000 $PAT_NIT000" |
---|
94 | IGCM_debug_Print 1 "PAT_NITEND $PAT_NITEND" |
---|
95 | IGCM_debug_Print 1 "PAT_NDATE0 $PAT_NDATE0" |
---|
96 | IGCM_debug_Print 1 "PAT_NLEAPY $PAT_NLEAPY" |
---|
97 | IGCM_debug_Print 1 "PAT_NSTOCK $PAT_NSTOCK" |
---|
98 | IGCM_debug_Print 1 "PAT_RESTAR $PAT_RESTAR" |
---|
99 | IGCM_debug_Print 1 "PAT_NRSTAR $PAT_NRSTAR" |
---|
100 | IGCM_debug_Print 1 "PAT_NMSH $PAT_NMSH" |
---|
101 | IGCM_debug_Print 1 "PAT_ICE_EMBD $PAT_ICE_EMBD" |
---|
102 | IGCM_debug_Print 1 "PAT_ICEFLX $PAT_ICEFLX" |
---|
103 | IGCM_debug_Print 1 "PAT_JPNI $PAT_JPNI" |
---|
104 | IGCM_debug_Print 1 "PAT_JPNJ $PAT_JPNJ" |
---|
105 | IGCM_debug_Print 1 "PAT_JPNIJ $PAT_JPNIJ" |
---|
106 | IGCM_debug_Print 1 "PAT_NN_FSBC $PAT_NN_FSBC" |
---|
107 | IGCM_debug_Print 1 " " |
---|
108 | IGCM_debug_Print 1 "ORCA_RDT $ORCA_RDT" |
---|
109 | IGCM_debug_Print 1 "ORCA_NN_FSBC $ORCA_NN_FSBC" |
---|
110 | IGCM_debug_Print 1 "ORCA_RDT_SBC $ORCA_RDT_SBC" |
---|
111 | IGCM_debug_Print 1 "ORCA_NPDT_JOUR $ORCA_NPDT_JOUR" |
---|
112 | IGCM_debug_Print 1 "DaysSinceJC $DaysSinceJC" |
---|
113 | |
---|
114 | IGCM_debug_PopStack "OCE_Initialize" |
---|
115 | |
---|
116 | } |
---|
117 | |
---|
118 | #----------------------------------------------------------------- |
---|
119 | function OCE_Update |
---|
120 | { |
---|
121 | IGCM_debug_PushStack "OCE_Update" |
---|
122 | |
---|
123 | ## Check that nn_fsbc is correct compare to coupling frequency |
---|
124 | |
---|
125 | FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400} |
---|
126 | |
---|
127 | ## This informations are used for diaptr, trends and diagap files |
---|
128 | ## only the first frequency is used for this files |
---|
129 | |
---|
130 | IGCM_debug_Print 1 "FreqCoupling $FreqCoupling" |
---|
131 | IGCM_debug_Print 1 "ORCA_NN_FSBC $ORCA_NN_FSBC" |
---|
132 | IGCM_debug_Print 1 "ORCA_RDT $ORCA_RDT" |
---|
133 | IGCM_debug_Print 1 "ORCA_RDT_SBC $ORCA_RDT_SBC" |
---|
134 | |
---|
135 | if [[ ${ORCA_RDT_SBC} -gt ${FreqCoupling} ]] ; then |
---|
136 | IGCM_debug_Exit "ORCA_RDT_SBC=${ORCA_RDT_SBC} is greater than FreqCoupling=${FreqCoupling}" |
---|
137 | IGCM_debug_Verif_Exit |
---|
138 | fi |
---|
139 | |
---|
140 | ##--Write Frequency for iomput |
---|
141 | ## Differents frequencies are allowed for grid_[TUVW] and icemod files |
---|
142 | |
---|
143 | V1D_ENABLE=".FALSE." |
---|
144 | V1M_ENABLE=".FALSE." |
---|
145 | V1Y_ENABLE=".FALSE." |
---|
146 | |
---|
147 | for frequency in ${config_OCE_WriteFrequency} ; do |
---|
148 | case ${frequency} in |
---|
149 | 1D|1d) V1D_ENABLE=".TRUE." ;; |
---|
150 | esac |
---|
151 | case ${frequency} in |
---|
152 | 1M|1m) V1M_ENABLE=".TRUE." ;; |
---|
153 | esac |
---|
154 | case ${frequency} in |
---|
155 | *[yY]) V1Y_ENABLE=".TRUE." ;; |
---|
156 | esac |
---|
157 | done |
---|
158 | |
---|
159 | |
---|
160 | ##-- Output level : 3 for more 1D variables |
---|
161 | OUTPUT_LEVEL=${opa9_UserChoices_OUTPUT_LEVEL} |
---|
162 | |
---|
163 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
164 | # Needed by OPA namelist to compute correct file names |
---|
165 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
166 | |
---|
167 | ##-- Number of time steps updated : the first, the last and the number of time steps |
---|
168 | (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 )) |
---|
169 | (( ORCA_NPDT = PeriodLengthInDays * ORCA_NPDT_JOUR )) |
---|
170 | (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1)) |
---|
171 | |
---|
172 | ##-- We force one restart file at the end of the trunk |
---|
173 | ORCA_NSTOCK="${ORCA_NITEND}" |
---|
174 | |
---|
175 | ##-- Restart configuration |
---|
176 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then |
---|
177 | ORCA_LRSTAR=.FALSE. |
---|
178 | ORCA_NRSTDT=0 |
---|
179 | # Put ORCA_NMSH=0 when OPA running in parallel mode |
---|
180 | ORCA_NMSH=1 |
---|
181 | #echo "NO OPA RESTART" |
---|
182 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then |
---|
183 | ORCA_LRSTAR=.TRUE. |
---|
184 | ORCA_NRSTDT=0 |
---|
185 | ORCA_NMSH=1 |
---|
186 | #echo "OPA RESTART" |
---|
187 | else |
---|
188 | ORCA_LRSTAR=.TRUE. |
---|
189 | ORCA_NRSTDT=2 |
---|
190 | ORCA_NMSH=0 |
---|
191 | #echo "OPA RESTART" |
---|
192 | fi |
---|
193 | |
---|
194 | ##-- Meshmask option |
---|
195 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask |
---|
196 | |
---|
197 | if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then |
---|
198 | ORCA_NMSH=1 |
---|
199 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n" |
---|
200 | fi |
---|
201 | |
---|
202 | # nleapy configuration |
---|
203 | case ${config_UserChoices_CalendarType} in |
---|
204 | leap|gregorian) |
---|
205 | ORCA_NLEAPY=1;; |
---|
206 | noleap) |
---|
207 | ORCA_NLEAPY=0;; |
---|
208 | 360d) |
---|
209 | ORCA_NLEAPY=30;; |
---|
210 | *) |
---|
211 | ORCA_NLEAPY=30 |
---|
212 | esac |
---|
213 | |
---|
214 | typeset -r PRECIS=8 |
---|
215 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) |
---|
216 | |
---|
217 | |
---|
218 | case ${SEAICE_MODEL} in |
---|
219 | ( LIM2 ) |
---|
220 | NN_ICE_EMBD=0 |
---|
221 | ICEFLX=none |
---|
222 | ;; |
---|
223 | ( LIM3 ) |
---|
224 | NN_ICE_EMBD=2 |
---|
225 | ICEFLX=${opa9_UserChoices_iceflx:-linear} |
---|
226 | ;; |
---|
227 | esac |
---|
228 | |
---|
229 | IGCM_debug_Print 1 "NUM_PROC_OCE : " ${NUM_PROC_OCE} |
---|
230 | |
---|
231 | sed -e "s/${PAT_CEXPER}/ cn_exp=\"${config_UserChoices_JobName}\"/" \ |
---|
232 | -e "s/${PAT_NIT000}/ nn_it000=${ORCA_NIT000}/" \ |
---|
233 | -e "s/${PAT_NITEND}/ nn_itend=${ORCA_NITEND}/" \ |
---|
234 | -e "s/${PAT_NDATE0}/ nn_date0=${PeriodDateBegin}/" \ |
---|
235 | -e "s%${PAT_NLEAPY}% nn_leapy=${ORCA_NLEAPY}%" \ |
---|
236 | -e "s/${PAT_NSTOCK}/ nn_stock=${ORCA_NSTOCK}/" \ |
---|
237 | -e "s/${PAT_RESTAR}/ ln_rstart=${ORCA_LRSTAR}/" \ |
---|
238 | -e "s/${PAT_NRSTAR}/ nn_rstctl=${ORCA_NRSTDT}/" \ |
---|
239 | -e "s/${PAT_NMSH}/ nn_msh=${ORCA_NMSH}/" \ |
---|
240 | -e "s/${PAT_NN_FSBC}/ nn_fsbc=${ORCA_NN_FSBC}/" \ |
---|
241 | -e "s/${PAT_ICE_EMBD}/ nn_ice_embd=${NN_ICE_EMBD}/" \ |
---|
242 | -e "s/${PAT_ICEFLX}/ cn_iceflx=\'${ICEFLX}'/" \ |
---|
243 | -e "s/${PAT_JPNI}/ jpni=1/" \ |
---|
244 | -e "s/${PAT_JPNJ}/ jpnj=${NUM_PROC_OCE}/" \ |
---|
245 | -e "s/${PAT_JPNIJ}/ jpnij=${NUM_PROC_OCE}/" \ |
---|
246 | namelist_cfg > namelist_cfg.tmp |
---|
247 | |
---|
248 | IGCM_sys_Mv namelist_cfg.tmp namelist_cfg |
---|
249 | |
---|
250 | IGCM_debug_Print 1 'Variables automatically updated in ORCA namelist_cfg' |
---|
251 | grep AUTO namelist_cfg |
---|
252 | |
---|
253 | # update iodef.xml |
---|
254 | |
---|
255 | IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V1M_ENABLE V1Y_ENABLE OUTPUT_LEVEL' |
---|
256 | IGCM_debug_Print 1 ${V1D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE} ${OUTPUT_LEVEL} |
---|
257 | |
---|
258 | sed -e "s/_1D_ENABLE_/${V1D_ENABLE}/" \ |
---|
259 | -e "s/_1M_ENABLE_/${V1M_ENABLE}/" \ |
---|
260 | -e "s/_1Y_ENABLE_/${V1Y_ENABLE}/" \ |
---|
261 | context_nemo.xml > context_nemo.xml.tmp |
---|
262 | |
---|
263 | IGCM_sys_Mv context_nemo.xml.tmp context_nemo.xml |
---|
264 | |
---|
265 | # vargas/titane/MPP and switch from 1 proc to 5 procs. We need to suppres restartopa the second month, if restartopa_0000 exist |
---|
266 | # same thing for restart_trc and restart_ice_in |
---|
267 | |
---|
268 | for restartfilenemo in restartopa restart_trc restart_ice_in ; do |
---|
269 | [ -f ${restartfilenemo}.nc ] && [ -f ${restartfilenemo}_0000.nc ] && IGCM_sys_Rm -f ${restartfilenemo}.nc |
---|
270 | done |
---|
271 | |
---|
272 | # Add include of nemo context in iodef.xml |
---|
273 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
274 | # <context id="nemo" src="./context_nemo.xml"/> |
---|
275 | echo '<context id="nemo" src="./context_nemo.xml"/>' > add.tmp |
---|
276 | cp iodef.xml iodef.xml.tmp |
---|
277 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
278 | rm iodef.xml.tmp add.tmp |
---|
279 | |
---|
280 | IGCM_debug_PopStack "OCE_Update" |
---|
281 | } |
---|
282 | |
---|
283 | #----------------------------------- |
---|
284 | function OCE_Finalize |
---|
285 | { |
---|
286 | IGCM_debug_PushStack "OCE_Finalize" |
---|
287 | |
---|
288 | if [ -f date.file ] ; then |
---|
289 | # Prefix use in opa9.card AND in lim2.card : |
---|
290 | DATE_OPA=$( cat date.file | \ |
---|
291 | sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" ) |
---|
292 | MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA} |
---|
293 | SecondPrefix=${config_UserChoices_JobName}_1m_${DATE_OPA} |
---|
294 | fi |
---|
295 | |
---|
296 | IGCM_debug_Print 1 FINALIZE OCE !!! |
---|
297 | |
---|
298 | IGCM_debug_PopStack "OCE_Finalize" |
---|
299 | } |
---|