1 | MODULE bdydta |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE bdydta *** |
---|
4 | !! Open boundary data : read the data for the unstructured open boundaries. |
---|
5 | !!====================================================================== |
---|
6 | !! History : 1.0 ! 2005-01 (J. Chanut, A. Sellar) Original code |
---|
7 | !! - ! 2007-01 (D. Storkey) Update to use IOM module |
---|
8 | !! - ! 2007-07 (D. Storkey) add bdy_dta_fla |
---|
9 | !! 3.0 ! 2008-04 (NEMO team) add in the reference version |
---|
10 | !! 3.3 ! 2010-09 (E.O'Dea) modifications for Shelf configurations |
---|
11 | !! 3.3 ! 2010-09 (D.Storkey) add ice boundary conditions |
---|
12 | !! 3.4 ! 2011 (D. Storkey) rewrite in preparation for OBC-BDY merge |
---|
13 | !! 3.6 ! 2012-01 (C. Rousset) add ice boundary conditions for lim3 |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | !! bdy_dta : read external data along open boundaries from file |
---|
16 | !! bdy_dta_init : initialise arrays etc for reading of external data |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | USE timing ! Timing |
---|
19 | USE oce ! ocean dynamics and tracers |
---|
20 | USE dom_oce ! ocean space and time domain |
---|
21 | USE phycst ! physical constants |
---|
22 | USE bdy_oce ! ocean open boundary conditions |
---|
23 | USE bdytides ! tidal forcing at boundaries |
---|
24 | USE fldread ! read input fields |
---|
25 | USE iom ! IOM library |
---|
26 | USE in_out_manager ! I/O logical units |
---|
27 | #if defined key_lim2 |
---|
28 | USE ice_2 |
---|
29 | #elif defined key_lim3 |
---|
30 | USE ice |
---|
31 | USE limvar ! redistribute ice input into categories |
---|
32 | #endif |
---|
33 | USE sbcapr |
---|
34 | USE sbctide ! Tidal forcing or not |
---|
35 | |
---|
36 | IMPLICIT NONE |
---|
37 | PRIVATE |
---|
38 | |
---|
39 | PUBLIC bdy_dta ! routine called by step.F90 and dynspg_ts.F90 |
---|
40 | PUBLIC bdy_dta_init ! routine called by nemogcm.F90 |
---|
41 | |
---|
42 | INTEGER, ALLOCATABLE, DIMENSION(:) :: nb_bdy_fld ! Number of fields to update for each boundary set. |
---|
43 | INTEGER :: nb_bdy_fld_sum ! Total number of fields to update for all boundary sets. |
---|
44 | LOGICAL, DIMENSION(jp_bdy) :: ln_full_vel_array ! =T => full velocities in 3D boundary conditions |
---|
45 | ! =F => baroclinic velocities in 3D boundary conditions |
---|
46 | !$AGRIF_DO_NOT_TREAT |
---|
47 | TYPE(FLD), PUBLIC, ALLOCATABLE, DIMENSION(:), TARGET :: bf ! structure of input fields (file informations, fields read) |
---|
48 | !$AGRIF_END_DO_NOT_TREAT |
---|
49 | TYPE(MAP_POINTER), ALLOCATABLE, DIMENSION(:) :: nbmap_ptr ! array of pointers to nbmap |
---|
50 | |
---|
51 | #if defined key_lim3 |
---|
52 | LOGICAL :: ll_bdylim3 ! determine whether ice input is lim2 (F) or lim3 (T) type |
---|
53 | INTEGER :: jfld_hti, jfld_hts, jfld_ai ! indices of ice thickness, snow thickness and concentration in bf structure |
---|
54 | #endif |
---|
55 | |
---|
56 | !!---------------------------------------------------------------------- |
---|
57 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
58 | !! $Id$ |
---|
59 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
60 | !!---------------------------------------------------------------------- |
---|
61 | CONTAINS |
---|
62 | |
---|
63 | SUBROUTINE bdy_dta( kt, jit, time_offset ) |
---|
64 | !!---------------------------------------------------------------------- |
---|
65 | !! *** SUBROUTINE bdy_dta *** |
---|
66 | !! |
---|
67 | !! ** Purpose : Update external data for open boundary conditions |
---|
68 | !! |
---|
69 | !! ** Method : Use fldread.F90 |
---|
70 | !! |
---|
71 | !!---------------------------------------------------------------------- |
---|
72 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
73 | INTEGER, INTENT(in), OPTIONAL :: jit ! subcycle time-step index (for timesplitting option) |
---|
74 | INTEGER, INTENT(in), OPTIONAL :: time_offset ! time offset in units of timesteps. NB. if jit |
---|
75 | ! ! is present then units = subcycle timesteps. |
---|
76 | ! ! time_offset = 0 => get data at "now" time level |
---|
77 | ! ! time_offset = -1 => get data at "before" time level |
---|
78 | ! ! time_offset = +1 => get data at "after" time level |
---|
79 | ! ! etc. |
---|
80 | ! |
---|
81 | INTEGER :: ib_bdy, jfld, jstart, jend, ib, ii, ij, ik, igrd, jl ! local indices |
---|
82 | INTEGER, DIMENSION(jpbgrd) :: ilen1 |
---|
83 | INTEGER, POINTER, DIMENSION(:) :: nblen, nblenrim ! short cuts |
---|
84 | TYPE(OBC_DATA), POINTER :: dta ! short cut |
---|
85 | !!--------------------------------------------------------------------------- |
---|
86 | ! |
---|
87 | IF( nn_timing == 1 ) CALL timing_start('bdy_dta') |
---|
88 | ! |
---|
89 | ! Initialise data arrays once for all from initial conditions where required |
---|
90 | !--------------------------------------------------------------------------- |
---|
91 | IF( kt == nit000 .AND. .NOT.PRESENT(jit) ) THEN |
---|
92 | |
---|
93 | ! Calculate depth-mean currents |
---|
94 | !----------------------------- |
---|
95 | |
---|
96 | DO ib_bdy = 1, nb_bdy |
---|
97 | ! |
---|
98 | nblen => idx_bdy(ib_bdy)%nblen |
---|
99 | nblenrim => idx_bdy(ib_bdy)%nblenrim |
---|
100 | dta => dta_bdy(ib_bdy) |
---|
101 | |
---|
102 | IF( nn_dyn2d_dta(ib_bdy) == 0 ) THEN |
---|
103 | ilen1(:) = nblen(:) |
---|
104 | IF( dta%ll_ssh ) THEN |
---|
105 | igrd = 1 |
---|
106 | DO ib = 1, ilen1(igrd) |
---|
107 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
108 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
109 | dta_bdy(ib_bdy)%ssh(ib) = sshn(ii,ij) * tmask(ii,ij,1) |
---|
110 | END DO |
---|
111 | END IF |
---|
112 | IF( dta%ll_u2d ) THEN |
---|
113 | igrd = 2 |
---|
114 | DO ib = 1, ilen1(igrd) |
---|
115 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
116 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
117 | dta_bdy(ib_bdy)%u2d(ib) = un_b(ii,ij) * umask(ii,ij,1) |
---|
118 | END DO |
---|
119 | END IF |
---|
120 | IF( dta%ll_v2d ) THEN |
---|
121 | igrd = 3 |
---|
122 | DO ib = 1, ilen1(igrd) |
---|
123 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
124 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
125 | dta_bdy(ib_bdy)%v2d(ib) = vn_b(ii,ij) * vmask(ii,ij,1) |
---|
126 | END DO |
---|
127 | END IF |
---|
128 | ENDIF |
---|
129 | |
---|
130 | IF( nn_dyn3d_dta(ib_bdy) == 0 ) THEN |
---|
131 | ilen1(:) = nblen(:) |
---|
132 | IF( dta%ll_u3d ) THEN |
---|
133 | igrd = 2 |
---|
134 | DO ib = 1, ilen1(igrd) |
---|
135 | DO ik = 1, jpkm1 |
---|
136 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
137 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
138 | dta_bdy(ib_bdy)%u3d(ib,ik) = ( un(ii,ij,ik) - un_b(ii,ij) ) * umask(ii,ij,ik) |
---|
139 | END DO |
---|
140 | END DO |
---|
141 | END IF |
---|
142 | IF( dta%ll_v3d ) THEN |
---|
143 | igrd = 3 |
---|
144 | DO ib = 1, ilen1(igrd) |
---|
145 | DO ik = 1, jpkm1 |
---|
146 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
147 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
148 | dta_bdy(ib_bdy)%v3d(ib,ik) = ( vn(ii,ij,ik) - vn_b(ii,ij) ) * vmask(ii,ij,ik) |
---|
149 | END DO |
---|
150 | END DO |
---|
151 | END IF |
---|
152 | ENDIF |
---|
153 | |
---|
154 | IF( nn_tra_dta(ib_bdy) == 0 ) THEN |
---|
155 | ilen1(:) = nblen(:) |
---|
156 | IF( dta%ll_tem ) THEN |
---|
157 | igrd = 1 |
---|
158 | DO ib = 1, ilen1(igrd) |
---|
159 | DO ik = 1, jpkm1 |
---|
160 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
161 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
162 | dta_bdy(ib_bdy)%tem(ib,ik) = tsn(ii,ij,ik,jp_tem) * tmask(ii,ij,ik) |
---|
163 | END DO |
---|
164 | END DO |
---|
165 | END IF |
---|
166 | IF( dta%ll_sal ) THEN |
---|
167 | igrd = 1 |
---|
168 | DO ib = 1, ilen1(igrd) |
---|
169 | DO ik = 1, jpkm1 |
---|
170 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
171 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
172 | dta_bdy(ib_bdy)%sal(ib,ik) = tsn(ii,ij,ik,jp_sal) * tmask(ii,ij,ik) |
---|
173 | END DO |
---|
174 | END DO |
---|
175 | END IF |
---|
176 | ENDIF |
---|
177 | |
---|
178 | #if defined key_lim2 |
---|
179 | IF( nn_ice_lim_dta(ib_bdy) == 0 ) THEN |
---|
180 | ilen1(:) = nblen(:) |
---|
181 | IF( dta%ll_frld ) THEN |
---|
182 | igrd = 1 |
---|
183 | DO ib = 1, ilen1(igrd) |
---|
184 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
185 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
186 | dta_bdy(ib_bdy)%frld(ib) = frld(ii,ij) * tmask(ii,ij,1) |
---|
187 | END DO |
---|
188 | END IF |
---|
189 | IF( dta%ll_hicif ) THEN |
---|
190 | igrd = 1 |
---|
191 | DO ib = 1, ilen1(igrd) |
---|
192 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
193 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
194 | dta_bdy(ib_bdy)%hicif(ib) = hicif(ii,ij) * tmask(ii,ij,1) |
---|
195 | END DO |
---|
196 | END IF |
---|
197 | IF( dta%ll_hsnif ) THEN |
---|
198 | igrd = 1 |
---|
199 | DO ib = 1, ilen1(igrd) |
---|
200 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
201 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
202 | dta_bdy(ib_bdy)%hsnif(ib) = hsnif(ii,ij) * tmask(ii,ij,1) |
---|
203 | END DO |
---|
204 | END IF |
---|
205 | ENDIF |
---|
206 | #elif defined key_lim3 |
---|
207 | IF( nn_ice_lim_dta(ib_bdy) == 0 ) THEN |
---|
208 | ilen1(:) = nblen(:) |
---|
209 | IF( dta%ll_a_i ) THEN |
---|
210 | igrd = 1 |
---|
211 | DO jl = 1, jpl |
---|
212 | DO ib = 1, ilen1(igrd) |
---|
213 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
214 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
215 | dta_bdy(ib_bdy)%a_i (ib,jl) = a_i(ii,ij,jl) * tmask(ii,ij,1) |
---|
216 | END DO |
---|
217 | END DO |
---|
218 | ENDIF |
---|
219 | IF( dta%ll_ht_i ) THEN |
---|
220 | igrd = 1 |
---|
221 | DO jl = 1, jpl |
---|
222 | DO ib = 1, ilen1(igrd) |
---|
223 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
224 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
225 | dta_bdy(ib_bdy)%ht_i (ib,jl) = ht_i(ii,ij,jl) * tmask(ii,ij,1) |
---|
226 | END DO |
---|
227 | END DO |
---|
228 | ENDIF |
---|
229 | IF( dta%ll_ht_s ) THEN |
---|
230 | igrd = 1 |
---|
231 | DO jl = 1, jpl |
---|
232 | DO ib = 1, ilen1(igrd) |
---|
233 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
234 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
235 | dta_bdy(ib_bdy)%ht_s (ib,jl) = ht_s(ii,ij,jl) * tmask(ii,ij,1) |
---|
236 | END DO |
---|
237 | END DO |
---|
238 | ENDIF |
---|
239 | ENDIF |
---|
240 | #endif |
---|
241 | END DO ! ib_bdy |
---|
242 | ! |
---|
243 | ENDIF ! kt == nit000 |
---|
244 | |
---|
245 | ! update external data from files |
---|
246 | !-------------------------------- |
---|
247 | |
---|
248 | jstart = 1 |
---|
249 | DO ib_bdy = 1, nb_bdy |
---|
250 | dta => dta_bdy(ib_bdy) |
---|
251 | IF( nn_dta(ib_bdy) == 1 ) THEN ! skip this bit if no external data required |
---|
252 | |
---|
253 | IF( PRESENT(jit) ) THEN |
---|
254 | ! Update barotropic boundary conditions only |
---|
255 | ! jit is optional argument for fld_read and bdytide_update |
---|
256 | IF( cn_dyn2d(ib_bdy) /= 'none' ) THEN |
---|
257 | IF( nn_dyn2d_dta(ib_bdy) == 2 ) THEN ! tidal harmonic forcing ONLY: initialise arrays |
---|
258 | IF( dta%ll_ssh ) dta%ssh(:) = 0._wp |
---|
259 | IF( dta%ll_u2d ) dta%u2d(:) = 0._wp |
---|
260 | IF( dta%ll_u3d ) dta%v2d(:) = 0._wp |
---|
261 | ENDIF |
---|
262 | IF (cn_tra(ib_bdy) /= 'runoff') THEN |
---|
263 | IF( nn_dyn2d_dta(ib_bdy) == 1 .OR. nn_dyn2d_dta(ib_bdy) == 3 ) THEN |
---|
264 | |
---|
265 | jend = jstart + dta%nread(2) - 1 |
---|
266 | IF( ln_full_vel_array(ib_bdy) ) THEN |
---|
267 | CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend), & |
---|
268 | & kit=jit, kt_offset=time_offset , jpk_bdy=nb_jpk_bdy, & |
---|
269 | & fvl=ln_full_vel_array(ib_bdy) ) |
---|
270 | ELSE |
---|
271 | CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend), & |
---|
272 | & kit=jit, kt_offset=time_offset ) |
---|
273 | ENDIF |
---|
274 | |
---|
275 | ! If full velocities in boundary data then extract barotropic velocities from 3D fields |
---|
276 | IF( ln_full_vel_array(ib_bdy) .AND. & |
---|
277 | & ( nn_dyn2d_dta(ib_bdy) == 1 .OR. nn_dyn2d_dta(ib_bdy) == 3 .OR. & |
---|
278 | & nn_dyn3d_dta(ib_bdy) == 1 ) )THEN |
---|
279 | |
---|
280 | igrd = 2 ! zonal velocity |
---|
281 | dta%u2d(:) = 0._wp |
---|
282 | DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd) |
---|
283 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
284 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
285 | DO ik = 1, jpkm1 |
---|
286 | dta%u2d(ib) = dta%u2d(ib) & |
---|
287 | & + e3u_n(ii,ij,ik) * umask(ii,ij,ik) * dta%u3d(ib,ik) |
---|
288 | END DO |
---|
289 | dta%u2d(ib) = dta%u2d(ib) * r1_hu_n(ii,ij) |
---|
290 | END DO |
---|
291 | igrd = 3 ! meridional velocity |
---|
292 | dta%v2d(:) = 0._wp |
---|
293 | DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd) |
---|
294 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
295 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
296 | DO ik = 1, jpkm1 |
---|
297 | dta%v2d(ib) = dta%v2d(ib) & |
---|
298 | & + e3v_n(ii,ij,ik) * vmask(ii,ij,ik) * dta%v3d(ib,ik) |
---|
299 | END DO |
---|
300 | dta%v2d(ib) = dta%v2d(ib) * r1_hv_n(ii,ij) |
---|
301 | END DO |
---|
302 | ENDIF |
---|
303 | ENDIF |
---|
304 | IF( nn_dyn2d_dta(ib_bdy) .ge. 2 ) THEN ! update tidal harmonic forcing |
---|
305 | CALL bdytide_update( kt=kt, idx=idx_bdy(ib_bdy), dta=dta, td=tides(ib_bdy), & |
---|
306 | & jit=jit, time_offset=time_offset ) |
---|
307 | ENDIF |
---|
308 | ENDIF |
---|
309 | ENDIF |
---|
310 | ELSE |
---|
311 | IF (cn_tra(ib_bdy) == 'runoff') then ! runoff condition |
---|
312 | jend = nb_bdy_fld(ib_bdy) |
---|
313 | CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), & |
---|
314 | & map=nbmap_ptr(jstart:jend), kt_offset=time_offset ) |
---|
315 | ! |
---|
316 | igrd = 2 ! zonal velocity |
---|
317 | DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd) |
---|
318 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
319 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
320 | dta%u2d(ib) = dta%u2d(ib) / ( e2u(ii,ij) * hu_0(ii,ij) ) |
---|
321 | END DO |
---|
322 | ! |
---|
323 | igrd = 3 ! meridional velocity |
---|
324 | DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd) |
---|
325 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
326 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
327 | dta%v2d(ib) = dta%v2d(ib) / ( e1v(ii,ij) * hv_0(ii,ij) ) |
---|
328 | END DO |
---|
329 | ELSE |
---|
330 | IF( nn_dyn2d_dta(ib_bdy) == 2 ) THEN ! tidal harmonic forcing ONLY: initialise arrays |
---|
331 | IF( dta%ll_ssh ) dta%ssh(:) = 0._wp |
---|
332 | IF( dta%ll_u2d ) dta%u2d(:) = 0._wp |
---|
333 | IF( dta%ll_v2d ) dta%v2d(:) = 0._wp |
---|
334 | ENDIF |
---|
335 | IF( dta%nread(1) .gt. 0 ) THEN ! update external data |
---|
336 | jend = jstart + dta%nread(1) - 1 |
---|
337 | CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), & |
---|
338 | & map=nbmap_ptr(jstart:jend), kt_offset=time_offset, jpk_bdy=nb_jpk_bdy, & |
---|
339 | & fvl=ln_full_vel_array(ib_bdy) ) |
---|
340 | ENDIF |
---|
341 | ! If full velocities in boundary data then split into barotropic and baroclinic data |
---|
342 | IF( ln_full_vel_array(ib_bdy) .and. & |
---|
343 | & ( nn_dyn2d_dta(ib_bdy) == 1 .OR. nn_dyn2d_dta(ib_bdy) == 3 .OR. & |
---|
344 | & nn_dyn3d_dta(ib_bdy) == 1 ) ) THEN |
---|
345 | igrd = 2 ! zonal velocity |
---|
346 | dta%u2d(:) = 0._wp |
---|
347 | DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd) |
---|
348 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
349 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
350 | DO ik = 1, jpkm1 |
---|
351 | dta%u2d(ib) = dta%u2d(ib) & |
---|
352 | & + e3u_n(ii,ij,ik) * umask(ii,ij,ik) * dta%u3d(ib,ik) |
---|
353 | END DO |
---|
354 | dta%u2d(ib) = dta%u2d(ib) * r1_hu_n(ii,ij) |
---|
355 | DO ik = 1, jpkm1 |
---|
356 | dta%u3d(ib,ik) = dta%u3d(ib,ik) - dta%u2d(ib) |
---|
357 | END DO |
---|
358 | END DO |
---|
359 | igrd = 3 ! meridional velocity |
---|
360 | dta%v2d(:) = 0._wp |
---|
361 | DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd) |
---|
362 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
363 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
364 | DO ik = 1, jpkm1 |
---|
365 | dta%v2d(ib) = dta%v2d(ib) & |
---|
366 | & + e3v_n(ii,ij,ik) * vmask(ii,ij,ik) * dta%v3d(ib,ik) |
---|
367 | END DO |
---|
368 | dta%v2d(ib) = dta%v2d(ib) * r1_hv_n(ii,ij) |
---|
369 | DO ik = 1, jpkm1 |
---|
370 | dta%v3d(ib,ik) = dta%v3d(ib,ik) - dta%v2d(ib) |
---|
371 | END DO |
---|
372 | END DO |
---|
373 | ENDIF |
---|
374 | |
---|
375 | ENDIF |
---|
376 | #if defined key_lim3 |
---|
377 | IF( .NOT. ll_bdylim3 .AND. cn_ice_lim(ib_bdy) /= 'none' .AND. nn_ice_lim_dta(ib_bdy) == 1 ) THEN ! bdy ice input (case input is lim2 type) |
---|
378 | CALL lim_var_itd ( bf(jfld_hti)%fnow(:,1,1), bf(jfld_hts)%fnow(:,1,1), bf(jfld_ai)%fnow(:,1,1), & |
---|
379 | & dta_bdy(ib_bdy)%ht_i, dta_bdy(ib_bdy)%ht_s, dta_bdy(ib_bdy)%a_i ) |
---|
380 | ENDIF |
---|
381 | #endif |
---|
382 | ENDIF |
---|
383 | jstart = jstart + dta%nread(1) |
---|
384 | END IF ! nn_dta(ib_bdy) = 1 |
---|
385 | END DO ! ib_bdy |
---|
386 | |
---|
387 | IF ( ln_tide ) THEN |
---|
388 | IF (ln_dynspg_ts) THEN ! Fill temporary arrays with slow-varying bdy data |
---|
389 | DO ib_bdy = 1, nb_bdy ! Tidal component added in ts loop |
---|
390 | IF ( nn_dyn2d_dta(ib_bdy) .ge. 2 ) THEN |
---|
391 | nblen => idx_bdy(ib_bdy)%nblen |
---|
392 | nblenrim => idx_bdy(ib_bdy)%nblenrim |
---|
393 | IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN; ilen1(:)=nblen(:) ; ELSE ; ilen1(:)=nblenrim(:) ; ENDIF |
---|
394 | IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy_s(ib_bdy)%ssh(1:ilen1(1)) = dta_bdy(ib_bdy)%ssh(1:ilen1(1)) |
---|
395 | IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy_s(ib_bdy)%u2d(1:ilen1(2)) = dta_bdy(ib_bdy)%u2d(1:ilen1(2)) |
---|
396 | IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy_s(ib_bdy)%v2d(1:ilen1(3)) = dta_bdy(ib_bdy)%v2d(1:ilen1(3)) |
---|
397 | ENDIF |
---|
398 | END DO |
---|
399 | ELSE ! Add tides if not split-explicit free surface else this is done in ts loop |
---|
400 | ! |
---|
401 | CALL bdy_dta_tides( kt=kt, time_offset=time_offset ) |
---|
402 | ENDIF |
---|
403 | ENDIF |
---|
404 | |
---|
405 | IF ( ln_apr_obc ) THEN |
---|
406 | DO ib_bdy = 1, nb_bdy |
---|
407 | IF (cn_tra(ib_bdy) /= 'runoff')THEN |
---|
408 | igrd = 1 ! meridional velocity |
---|
409 | DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd) |
---|
410 | ii = idx_bdy(ib_bdy)%nbi(ib,igrd) |
---|
411 | ij = idx_bdy(ib_bdy)%nbj(ib,igrd) |
---|
412 | dta_bdy(ib_bdy)%ssh(ib) = dta_bdy(ib_bdy)%ssh(ib) + ssh_ib(ii,ij) |
---|
413 | END DO |
---|
414 | ENDIF |
---|
415 | END DO |
---|
416 | ENDIF |
---|
417 | ! |
---|
418 | IF( nn_timing == 1 ) CALL timing_stop('bdy_dta') |
---|
419 | ! |
---|
420 | END SUBROUTINE bdy_dta |
---|
421 | |
---|
422 | |
---|
423 | SUBROUTINE bdy_dta_init |
---|
424 | !!---------------------------------------------------------------------- |
---|
425 | !! *** SUBROUTINE bdy_dta_init *** |
---|
426 | !! |
---|
427 | !! ** Purpose : Initialise arrays for reading of external data |
---|
428 | !! for open boundary conditions |
---|
429 | !! |
---|
430 | !! ** Method : |
---|
431 | !! |
---|
432 | !!---------------------------------------------------------------------- |
---|
433 | INTEGER :: ib_bdy, jfld, jstart, jend, ierror, ios ! Local integers |
---|
434 | ! |
---|
435 | CHARACTER(len=100) :: cn_dir ! Root directory for location of data files |
---|
436 | CHARACTER(len=100), DIMENSION(nb_bdy) :: cn_dir_array ! Root directory for location of data files |
---|
437 | CHARACTER(len = 256):: clname ! temporary file name |
---|
438 | LOGICAL :: ln_full_vel ! =T => full velocities in 3D boundary data |
---|
439 | ! =F => baroclinic velocities in 3D boundary data |
---|
440 | INTEGER :: ilen_global ! Max length required for global bdy dta arrays |
---|
441 | INTEGER, ALLOCATABLE, DIMENSION(:) :: ilen1, ilen3 ! size of 1st and 3rd dimensions of local arrays |
---|
442 | INTEGER, ALLOCATABLE, DIMENSION(:) :: ibdy ! bdy set for a particular jfld |
---|
443 | INTEGER, ALLOCATABLE, DIMENSION(:) :: igrid ! index for grid type (1,2,3 = T,U,V) |
---|
444 | INTEGER, POINTER, DIMENSION(:) :: nblen, nblenrim ! short cuts |
---|
445 | TYPE(OBC_DATA), POINTER :: dta ! short cut |
---|
446 | #if defined key_lim3 |
---|
447 | INTEGER :: zndims ! number of dimensions in an array (i.e. 3 = wo ice cat; 4 = w ice cat) |
---|
448 | INTEGER :: inum,id1 ! local integer |
---|
449 | #endif |
---|
450 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: blf_i ! array of namelist information structures |
---|
451 | TYPE(FLD_N) :: bn_tem, bn_sal, bn_u3d, bn_v3d ! |
---|
452 | TYPE(FLD_N) :: bn_ssh, bn_u2d, bn_v2d ! informations about the fields to be read |
---|
453 | #if defined key_lim2 |
---|
454 | TYPE(FLD_N) :: bn_frld, bn_hicif, bn_hsnif ! |
---|
455 | #elif defined key_lim3 |
---|
456 | TYPE(FLD_N) :: bn_a_i, bn_ht_i, bn_ht_s |
---|
457 | #endif |
---|
458 | NAMELIST/nambdy_dta/ cn_dir, bn_tem, bn_sal, bn_u3d, bn_v3d, bn_ssh, bn_u2d, bn_v2d |
---|
459 | #if defined key_lim2 |
---|
460 | NAMELIST/nambdy_dta/ bn_frld, bn_hicif, bn_hsnif |
---|
461 | #elif defined key_lim3 |
---|
462 | NAMELIST/nambdy_dta/ bn_a_i, bn_ht_i, bn_ht_s |
---|
463 | #endif |
---|
464 | NAMELIST/nambdy_dta/ ln_full_vel, nb_jpk_bdy |
---|
465 | !!--------------------------------------------------------------------------- |
---|
466 | ! |
---|
467 | IF( nn_timing == 1 ) CALL timing_start('bdy_dta_init') |
---|
468 | ! |
---|
469 | IF(lwp) WRITE(numout,*) |
---|
470 | IF(lwp) WRITE(numout,*) 'bdy_dta_ini : initialization of data at the open boundaries' |
---|
471 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~' |
---|
472 | IF(lwp) WRITE(numout,*) '' |
---|
473 | |
---|
474 | ! Set nn_dta |
---|
475 | DO ib_bdy = 1, nb_bdy |
---|
476 | nn_dta(ib_bdy) = MAX( nn_dyn2d_dta(ib_bdy) & |
---|
477 | ,nn_dyn3d_dta(ib_bdy) & |
---|
478 | ,nn_tra_dta(ib_bdy) & |
---|
479 | #if ( defined key_lim2 || defined key_lim3 ) |
---|
480 | ,nn_ice_lim_dta(ib_bdy) & |
---|
481 | #endif |
---|
482 | ) |
---|
483 | IF(nn_dta(ib_bdy) > 1) nn_dta(ib_bdy) = 1 |
---|
484 | END DO |
---|
485 | |
---|
486 | ! Work out upper bound of how many fields there are to read in and allocate arrays |
---|
487 | ! --------------------------------------------------------------------------- |
---|
488 | ALLOCATE( nb_bdy_fld(nb_bdy) ) |
---|
489 | nb_bdy_fld(:) = 0 |
---|
490 | DO ib_bdy = 1, nb_bdy |
---|
491 | IF( cn_dyn2d(ib_bdy) /= 'none' .and. ( nn_dyn2d_dta(ib_bdy) == 1 .or. nn_dyn2d_dta(ib_bdy) == 3 ) ) THEN |
---|
492 | nb_bdy_fld(ib_bdy) = nb_bdy_fld(ib_bdy) + 3 |
---|
493 | ENDIF |
---|
494 | IF( cn_dyn3d(ib_bdy) /= 'none' .and. nn_dyn3d_dta(ib_bdy) == 1 ) THEN |
---|
495 | nb_bdy_fld(ib_bdy) = nb_bdy_fld(ib_bdy) + 2 |
---|
496 | ENDIF |
---|
497 | IF( cn_tra(ib_bdy) /= 'none' .and. nn_tra_dta(ib_bdy) == 1 ) THEN |
---|
498 | nb_bdy_fld(ib_bdy) = nb_bdy_fld(ib_bdy) + 2 |
---|
499 | ENDIF |
---|
500 | #if ( defined key_lim2 || defined key_lim3 ) |
---|
501 | IF( cn_ice_lim(ib_bdy) /= 'none' .and. nn_ice_lim_dta(ib_bdy) == 1 ) THEN |
---|
502 | nb_bdy_fld(ib_bdy) = nb_bdy_fld(ib_bdy) + 3 |
---|
503 | ENDIF |
---|
504 | #endif |
---|
505 | IF(lwp) WRITE(numout,*) 'Maximum number of files to open =',nb_bdy_fld(ib_bdy) |
---|
506 | END DO |
---|
507 | |
---|
508 | nb_bdy_fld_sum = SUM( nb_bdy_fld ) |
---|
509 | |
---|
510 | ALLOCATE( bf(nb_bdy_fld_sum), STAT=ierror ) |
---|
511 | IF( ierror > 0 ) THEN |
---|
512 | CALL ctl_stop( 'bdy_dta: unable to allocate bf structure' ) ; RETURN |
---|
513 | ENDIF |
---|
514 | ALLOCATE( blf_i(nb_bdy_fld_sum), STAT=ierror ) |
---|
515 | IF( ierror > 0 ) THEN |
---|
516 | CALL ctl_stop( 'bdy_dta: unable to allocate blf_i structure' ) ; RETURN |
---|
517 | ENDIF |
---|
518 | ALLOCATE( nbmap_ptr(nb_bdy_fld_sum), STAT=ierror ) |
---|
519 | IF( ierror > 0 ) THEN |
---|
520 | CALL ctl_stop( 'bdy_dta: unable to allocate nbmap_ptr structure' ) ; RETURN |
---|
521 | ENDIF |
---|
522 | ALLOCATE( ilen1(nb_bdy_fld_sum), ilen3(nb_bdy_fld_sum) ) |
---|
523 | ALLOCATE( ibdy(nb_bdy_fld_sum) ) |
---|
524 | ALLOCATE( igrid(nb_bdy_fld_sum) ) |
---|
525 | |
---|
526 | ! Read namelists |
---|
527 | ! -------------- |
---|
528 | REWIND(numnam_ref) |
---|
529 | REWIND(numnam_cfg) |
---|
530 | jfld = 0 |
---|
531 | DO ib_bdy = 1, nb_bdy |
---|
532 | IF( nn_dta(ib_bdy) == 1 ) THEN |
---|
533 | READ ( numnam_ref, nambdy_dta, IOSTAT = ios, ERR = 901) |
---|
534 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambdy_dta in reference namelist', lwp ) |
---|
535 | |
---|
536 | READ ( numnam_cfg, nambdy_dta, IOSTAT = ios, ERR = 902 ) |
---|
537 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambdy_dta in configuration namelist', lwp ) |
---|
538 | IF(lwm) WRITE( numond, nambdy_dta ) |
---|
539 | |
---|
540 | cn_dir_array(ib_bdy) = cn_dir |
---|
541 | ln_full_vel_array(ib_bdy) = ln_full_vel |
---|
542 | |
---|
543 | nblen => idx_bdy(ib_bdy)%nblen |
---|
544 | nblenrim => idx_bdy(ib_bdy)%nblenrim |
---|
545 | dta => dta_bdy(ib_bdy) |
---|
546 | dta%nread(2) = 0 |
---|
547 | |
---|
548 | ! Only read in necessary fields for this set. |
---|
549 | ! Important that barotropic variables come first. |
---|
550 | IF( nn_dyn2d_dta(ib_bdy) == 1 .or. nn_dyn2d_dta(ib_bdy) == 3 ) THEN |
---|
551 | |
---|
552 | IF( dta%ll_ssh ) THEN |
---|
553 | if(lwp) write(numout,*) '++++++ reading in ssh field' |
---|
554 | jfld = jfld + 1 |
---|
555 | blf_i(jfld) = bn_ssh |
---|
556 | ibdy(jfld) = ib_bdy |
---|
557 | igrid(jfld) = 1 |
---|
558 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
559 | ilen3(jfld) = 1 |
---|
560 | dta%nread(2) = dta%nread(2) + 1 |
---|
561 | ENDIF |
---|
562 | |
---|
563 | IF( dta%ll_u2d .and. .not. ln_full_vel_array(ib_bdy) ) THEN |
---|
564 | if(lwp) write(numout,*) '++++++ reading in u2d field' |
---|
565 | jfld = jfld + 1 |
---|
566 | blf_i(jfld) = bn_u2d |
---|
567 | ibdy(jfld) = ib_bdy |
---|
568 | igrid(jfld) = 2 |
---|
569 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
570 | ilen3(jfld) = 1 |
---|
571 | dta%nread(2) = dta%nread(2) + 1 |
---|
572 | ENDIF |
---|
573 | |
---|
574 | IF( dta%ll_v2d .and. .not. ln_full_vel_array(ib_bdy) ) THEN |
---|
575 | if(lwp) write(numout,*) '++++++ reading in v2d field' |
---|
576 | jfld = jfld + 1 |
---|
577 | blf_i(jfld) = bn_v2d |
---|
578 | ibdy(jfld) = ib_bdy |
---|
579 | igrid(jfld) = 3 |
---|
580 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
581 | ilen3(jfld) = 1 |
---|
582 | dta%nread(2) = dta%nread(2) + 1 |
---|
583 | ENDIF |
---|
584 | |
---|
585 | ENDIF |
---|
586 | |
---|
587 | ! read 3D velocities if baroclinic velocities require OR if |
---|
588 | ! barotropic velocities required and ln_full_vel set to .true. |
---|
589 | IF( nn_dyn3d_dta(ib_bdy) == 1 .OR. & |
---|
590 | & ( ln_full_vel_array(ib_bdy) .AND. ( nn_dyn2d_dta(ib_bdy) == 1 .or. nn_dyn2d_dta(ib_bdy) == 3 ) ) ) THEN |
---|
591 | |
---|
592 | IF( dta%ll_u3d .OR. ( ln_full_vel_array(ib_bdy) .and. dta%ll_u2d ) ) THEN |
---|
593 | if(lwp) write(numout,*) '++++++ reading in u3d field' |
---|
594 | jfld = jfld + 1 |
---|
595 | blf_i(jfld) = bn_u3d |
---|
596 | ibdy(jfld) = ib_bdy |
---|
597 | igrid(jfld) = 2 |
---|
598 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
599 | ilen3(jfld) = jpk |
---|
600 | IF( ln_full_vel_array(ib_bdy) .and. dta%ll_u2d ) dta%nread(2) = dta%nread(2) + 1 |
---|
601 | ENDIF |
---|
602 | |
---|
603 | IF( dta%ll_v3d .OR. ( ln_full_vel_array(ib_bdy) .and. dta%ll_v2d ) ) THEN |
---|
604 | if(lwp) write(numout,*) '++++++ reading in v3d field' |
---|
605 | jfld = jfld + 1 |
---|
606 | blf_i(jfld) = bn_v3d |
---|
607 | ibdy(jfld) = ib_bdy |
---|
608 | igrid(jfld) = 3 |
---|
609 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
610 | ilen3(jfld) = jpk |
---|
611 | IF( ln_full_vel_array(ib_bdy) .and. dta%ll_v2d ) dta%nread(2) = dta%nread(2) + 1 |
---|
612 | ENDIF |
---|
613 | |
---|
614 | ENDIF |
---|
615 | |
---|
616 | ! temperature and salinity |
---|
617 | IF( nn_tra_dta(ib_bdy) == 1 ) THEN |
---|
618 | |
---|
619 | IF( dta%ll_tem ) THEN |
---|
620 | if(lwp) write(numout,*) '++++++ reading in tem field' |
---|
621 | jfld = jfld + 1 |
---|
622 | blf_i(jfld) = bn_tem |
---|
623 | ibdy(jfld) = ib_bdy |
---|
624 | igrid(jfld) = 1 |
---|
625 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
626 | ilen3(jfld) = jpk |
---|
627 | ENDIF |
---|
628 | |
---|
629 | IF( dta%ll_sal ) THEN |
---|
630 | if(lwp) write(numout,*) '++++++ reading in sal field' |
---|
631 | jfld = jfld + 1 |
---|
632 | blf_i(jfld) = bn_sal |
---|
633 | ibdy(jfld) = ib_bdy |
---|
634 | igrid(jfld) = 1 |
---|
635 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
636 | ilen3(jfld) = jpk |
---|
637 | ENDIF |
---|
638 | |
---|
639 | ENDIF |
---|
640 | |
---|
641 | #if defined key_lim2 |
---|
642 | ! sea ice |
---|
643 | IF( nn_ice_lim_dta(ib_bdy) == 1 ) THEN |
---|
644 | |
---|
645 | IF( dta%ll_frld ) THEN |
---|
646 | jfld = jfld + 1 |
---|
647 | blf_i(jfld) = bn_frld |
---|
648 | ibdy(jfld) = ib_bdy |
---|
649 | igrid(jfld) = 1 |
---|
650 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
651 | ilen3(jfld) = 1 |
---|
652 | ENDIF |
---|
653 | |
---|
654 | IF( dta%ll_hicif ) THEN |
---|
655 | jfld = jfld + 1 |
---|
656 | blf_i(jfld) = bn_hicif |
---|
657 | ibdy(jfld) = ib_bdy |
---|
658 | igrid(jfld) = 1 |
---|
659 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
660 | ilen3(jfld) = 1 |
---|
661 | ENDIF |
---|
662 | |
---|
663 | IF( dta%ll_hsnif ) THEN |
---|
664 | jfld = jfld + 1 |
---|
665 | blf_i(jfld) = bn_hsnif |
---|
666 | ibdy(jfld) = ib_bdy |
---|
667 | igrid(jfld) = 1 |
---|
668 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
669 | ilen3(jfld) = 1 |
---|
670 | ENDIF |
---|
671 | |
---|
672 | ENDIF |
---|
673 | #elif defined key_lim3 |
---|
674 | ! sea ice |
---|
675 | IF( nn_ice_lim_dta(ib_bdy) == 1 ) THEN |
---|
676 | ! Test for types of ice input (lim2 or lim3) |
---|
677 | ! Build file name to find dimensions |
---|
678 | clname=TRIM( cn_dir )//TRIM(bn_a_i%clname) |
---|
679 | IF( .NOT. bn_a_i%ln_clim ) THEN |
---|
680 | WRITE(clname, '(a,"_y",i4.4)' ) TRIM( clname ), nyear ! add year |
---|
681 | IF( bn_a_i%cltype /= 'yearly' ) WRITE(clname, '(a,"m" ,i2.2)' ) TRIM( clname ), nmonth ! add month |
---|
682 | ELSE |
---|
683 | IF( bn_a_i%cltype /= 'yearly' ) WRITE(clname, '(a,"_m",i2.2)' ) TRIM( clname ), nmonth ! add month |
---|
684 | ENDIF |
---|
685 | IF( bn_a_i%cltype == 'daily' .OR. bn_a_i%cltype(1:4) == 'week' ) & |
---|
686 | & WRITE(clname, '(a,"d" ,i2.2)' ) TRIM( clname ), nday ! add day |
---|
687 | ! |
---|
688 | CALL iom_open ( clname, inum ) |
---|
689 | id1 = iom_varid( inum, bn_a_i%clvar, kndims=zndims, ldstop = .FALSE. ) |
---|
690 | CALL iom_close ( inum ) |
---|
691 | |
---|
692 | IF ( zndims == 4 ) THEN |
---|
693 | ll_bdylim3 = .TRUE. ! lim3 input |
---|
694 | ELSE |
---|
695 | ll_bdylim3 = .FALSE. ! lim2 input |
---|
696 | ENDIF |
---|
697 | ! End test |
---|
698 | |
---|
699 | IF( dta%ll_a_i ) THEN |
---|
700 | jfld = jfld + 1 |
---|
701 | blf_i(jfld) = bn_a_i |
---|
702 | ibdy(jfld) = ib_bdy |
---|
703 | igrid(jfld) = 1 |
---|
704 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
705 | IF ( ll_bdylim3 ) THEN ; ilen3(jfld)=jpl ; ELSE ; ilen3(jfld)=1 ; ENDIF |
---|
706 | ENDIF |
---|
707 | |
---|
708 | IF( dta%ll_ht_i ) THEN |
---|
709 | jfld = jfld + 1 |
---|
710 | blf_i(jfld) = bn_ht_i |
---|
711 | ibdy(jfld) = ib_bdy |
---|
712 | igrid(jfld) = 1 |
---|
713 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
714 | IF ( ll_bdylim3 ) THEN ; ilen3(jfld)=jpl ; ELSE ; ilen3(jfld)=1 ; ENDIF |
---|
715 | ENDIF |
---|
716 | |
---|
717 | IF( dta%ll_ht_s ) THEN |
---|
718 | jfld = jfld + 1 |
---|
719 | blf_i(jfld) = bn_ht_s |
---|
720 | ibdy(jfld) = ib_bdy |
---|
721 | igrid(jfld) = 1 |
---|
722 | ilen1(jfld) = nblen(igrid(jfld)) |
---|
723 | IF ( ll_bdylim3 ) THEN ; ilen3(jfld)=jpl ; ELSE ; ilen3(jfld)=1 ; ENDIF |
---|
724 | ENDIF |
---|
725 | |
---|
726 | ENDIF |
---|
727 | #endif |
---|
728 | ! Recalculate field counts |
---|
729 | !------------------------- |
---|
730 | IF( ib_bdy == 1 ) THEN |
---|
731 | nb_bdy_fld_sum = 0 |
---|
732 | nb_bdy_fld(ib_bdy) = jfld |
---|
733 | nb_bdy_fld_sum = jfld |
---|
734 | ELSE |
---|
735 | nb_bdy_fld(ib_bdy) = jfld - nb_bdy_fld_sum |
---|
736 | nb_bdy_fld_sum = nb_bdy_fld_sum + nb_bdy_fld(ib_bdy) |
---|
737 | ENDIF |
---|
738 | |
---|
739 | dta%nread(1) = nb_bdy_fld(ib_bdy) |
---|
740 | |
---|
741 | ENDIF ! nn_dta == 1 |
---|
742 | ENDDO ! ib_bdy |
---|
743 | |
---|
744 | DO jfld = 1, nb_bdy_fld_sum |
---|
745 | ALLOCATE( bf(jfld)%fnow(ilen1(jfld),1,ilen3(jfld)) ) |
---|
746 | IF( blf_i(jfld)%ln_tint ) ALLOCATE( bf(jfld)%fdta(ilen1(jfld),1,ilen3(jfld),2) ) |
---|
747 | nbmap_ptr(jfld)%ptr => idx_bdy(ibdy(jfld))%nbmap(:,igrid(jfld)) |
---|
748 | nbmap_ptr(jfld)%ll_unstruc = ln_coords_file(ibdy(jfld)) |
---|
749 | ENDDO |
---|
750 | |
---|
751 | ! fill bf with blf_i and control print |
---|
752 | !------------------------------------- |
---|
753 | jstart = 1 |
---|
754 | DO ib_bdy = 1, nb_bdy |
---|
755 | jend = jstart - 1 + nb_bdy_fld(ib_bdy) |
---|
756 | CALL fld_fill( bf(jstart:jend), blf_i(jstart:jend), cn_dir_array(ib_bdy), 'bdy_dta', & |
---|
757 | & 'open boundary conditions', 'nambdy_dta' ) |
---|
758 | jstart = jend + 1 |
---|
759 | ENDDO |
---|
760 | |
---|
761 | DO jfld = 1, nb_bdy_fld_sum |
---|
762 | bf(jfld)%igrd = igrid(jfld) |
---|
763 | bf(jfld)%ibdy = ibdy(jfld) |
---|
764 | ENDDO |
---|
765 | |
---|
766 | ! Initialise local boundary data arrays |
---|
767 | ! nn_xxx_dta=0 : allocate space - will be filled from initial conditions later |
---|
768 | ! nn_xxx_dta=1 : point to "fnow" arrays |
---|
769 | !------------------------------------- |
---|
770 | |
---|
771 | jfld = 0 |
---|
772 | DO ib_bdy=1, nb_bdy |
---|
773 | |
---|
774 | nblen => idx_bdy(ib_bdy)%nblen |
---|
775 | dta => dta_bdy(ib_bdy) |
---|
776 | |
---|
777 | if(lwp) then |
---|
778 | write(numout,*) '++++++ dta%ll_ssh = ',dta%ll_ssh |
---|
779 | write(numout,*) '++++++ dta%ll_u2d = ',dta%ll_u2d |
---|
780 | write(numout,*) '++++++ dta%ll_v2d = ',dta%ll_v2d |
---|
781 | write(numout,*) '++++++ dta%ll_u3d = ',dta%ll_u3d |
---|
782 | write(numout,*) '++++++ dta%ll_v3d = ',dta%ll_v3d |
---|
783 | write(numout,*) '++++++ dta%ll_tem = ',dta%ll_tem |
---|
784 | write(numout,*) '++++++ dta%ll_sal = ',dta%ll_sal |
---|
785 | endif |
---|
786 | |
---|
787 | IF ( nn_dyn2d_dta(ib_bdy) == 0 .or. nn_dyn2d_dta(ib_bdy) == 2 ) THEN |
---|
788 | if(lwp) write(numout,*) '++++++ dta%ssh/u2d/u3d allocated space' |
---|
789 | IF( dta%ll_ssh ) ALLOCATE( dta%ssh(nblen(1)) ) |
---|
790 | IF( dta%ll_u2d ) ALLOCATE( dta%u2d(nblen(2)) ) |
---|
791 | IF( dta%ll_v2d ) ALLOCATE( dta%v2d(nblen(3)) ) |
---|
792 | ENDIF |
---|
793 | IF ( nn_dyn2d_dta(ib_bdy) == 1 .or. nn_dyn2d_dta(ib_bdy) == 3 ) THEN |
---|
794 | IF( dta%ll_ssh ) THEN |
---|
795 | if(lwp) write(numout,*) '++++++ dta%ssh pointing to fnow' |
---|
796 | jfld = jfld + 1 |
---|
797 | dta%ssh => bf(jfld)%fnow(:,1,1) |
---|
798 | ENDIF |
---|
799 | IF ( dta%ll_u2d ) THEN |
---|
800 | IF ( ln_full_vel_array(ib_bdy) ) THEN |
---|
801 | if(lwp) write(numout,*) '++++++ dta%u2d allocated space' |
---|
802 | ALLOCATE( dta%u2d(nblen(2)) ) |
---|
803 | ELSE |
---|
804 | if(lwp) write(numout,*) '++++++ dta%u2d pointing to fnow' |
---|
805 | jfld = jfld + 1 |
---|
806 | dta%u2d => bf(jfld)%fnow(:,1,1) |
---|
807 | ENDIF |
---|
808 | ENDIF |
---|
809 | IF ( dta%ll_v2d ) THEN |
---|
810 | IF ( ln_full_vel_array(ib_bdy) ) THEN |
---|
811 | if(lwp) write(numout,*) '++++++ dta%v2d allocated space' |
---|
812 | ALLOCATE( dta%v2d(nblen(3)) ) |
---|
813 | ELSE |
---|
814 | if(lwp) write(numout,*) '++++++ dta%v2d pointing to fnow' |
---|
815 | jfld = jfld + 1 |
---|
816 | dta%v2d => bf(jfld)%fnow(:,1,1) |
---|
817 | ENDIF |
---|
818 | ENDIF |
---|
819 | ENDIF |
---|
820 | |
---|
821 | IF ( nn_dyn3d_dta(ib_bdy) == 0 ) THEN |
---|
822 | if(lwp) write(numout,*) '++++++ dta%u3d/v3d allocated space' |
---|
823 | IF( dta%ll_u3d ) ALLOCATE( dta_bdy(ib_bdy)%u3d(nblen(2),jpk) ) |
---|
824 | IF( dta%ll_v3d ) ALLOCATE( dta_bdy(ib_bdy)%v3d(nblen(3),jpk) ) |
---|
825 | ENDIF |
---|
826 | IF ( nn_dyn3d_dta(ib_bdy) == 1 .or. & |
---|
827 | & ( ln_full_vel_array(ib_bdy) .and. ( nn_dyn2d_dta(ib_bdy) == 1 .or. nn_dyn2d_dta(ib_bdy) == 3 ) ) ) THEN |
---|
828 | IF ( dta%ll_u3d .or. ( ln_full_vel_array(ib_bdy) .and. dta%ll_u2d ) ) THEN |
---|
829 | if(lwp) write(numout,*) '++++++ dta%u3d pointing to fnow' |
---|
830 | jfld = jfld + 1 |
---|
831 | dta_bdy(ib_bdy)%u3d => bf(jfld)%fnow(:,1,:) |
---|
832 | ENDIF |
---|
833 | IF ( dta%ll_v3d .or. ( ln_full_vel_array(ib_bdy) .and. dta%ll_v2d ) ) THEN |
---|
834 | if(lwp) write(numout,*) '++++++ dta%v3d pointing to fnow' |
---|
835 | jfld = jfld + 1 |
---|
836 | dta_bdy(ib_bdy)%v3d => bf(jfld)%fnow(:,1,:) |
---|
837 | ENDIF |
---|
838 | ENDIF |
---|
839 | |
---|
840 | IF( nn_tra_dta(ib_bdy) == 0 ) THEN |
---|
841 | if(lwp) write(numout,*) '++++++ dta%tem/sal allocated space' |
---|
842 | IF( dta%ll_tem ) ALLOCATE( dta_bdy(ib_bdy)%tem(nblen(1),jpk) ) |
---|
843 | IF( dta%ll_sal ) ALLOCATE( dta_bdy(ib_bdy)%sal(nblen(1),jpk) ) |
---|
844 | ELSE |
---|
845 | IF( dta%ll_tem ) THEN |
---|
846 | if(lwp) write(numout,*) '++++++ dta%tem pointing to fnow' |
---|
847 | jfld = jfld + 1 |
---|
848 | dta_bdy(ib_bdy)%tem => bf(jfld)%fnow(:,1,:) |
---|
849 | ENDIF |
---|
850 | IF( dta%ll_sal ) THEN |
---|
851 | if(lwp) write(numout,*) '++++++ dta%sal pointing to fnow' |
---|
852 | jfld = jfld + 1 |
---|
853 | dta_bdy(ib_bdy)%sal => bf(jfld)%fnow(:,1,:) |
---|
854 | ENDIF |
---|
855 | ENDIF |
---|
856 | |
---|
857 | #if defined key_lim2 |
---|
858 | IF (cn_ice_lim(ib_bdy) /= 'none') THEN |
---|
859 | IF( nn_ice_lim_dta(ib_bdy) == 0 ) THEN |
---|
860 | ALLOCATE( dta_bdy(ib_bdy)%frld(nblen(1)) ) |
---|
861 | ALLOCATE( dta_bdy(ib_bdy)%hicif(nblen(1)) ) |
---|
862 | ALLOCATE( dta_bdy(ib_bdy)%hsnif(nblen(1)) ) |
---|
863 | ELSE |
---|
864 | jfld = jfld + 1 |
---|
865 | dta_bdy(ib_bdy)%frld => bf(jfld)%fnow(:,1,1) |
---|
866 | jfld = jfld + 1 |
---|
867 | dta_bdy(ib_bdy)%hicif => bf(jfld)%fnow(:,1,1) |
---|
868 | jfld = jfld + 1 |
---|
869 | dta_bdy(ib_bdy)%hsnif => bf(jfld)%fnow(:,1,1) |
---|
870 | ENDIF |
---|
871 | ENDIF |
---|
872 | #elif defined key_lim3 |
---|
873 | IF (cn_ice_lim(ib_bdy) /= 'none') THEN |
---|
874 | IF( nn_ice_lim_dta(ib_bdy) == 0 ) THEN |
---|
875 | ALLOCATE( dta_bdy(ib_bdy)%a_i (nblen(1),jpl) ) |
---|
876 | ALLOCATE( dta_bdy(ib_bdy)%ht_i(nblen(1),jpl) ) |
---|
877 | ALLOCATE( dta_bdy(ib_bdy)%ht_s(nblen(1),jpl) ) |
---|
878 | ELSE |
---|
879 | IF ( ll_bdylim3 ) THEN ! case input is lim3 type |
---|
880 | jfld = jfld + 1 |
---|
881 | dta_bdy(ib_bdy)%a_i => bf(jfld)%fnow(:,1,:) |
---|
882 | jfld = jfld + 1 |
---|
883 | dta_bdy(ib_bdy)%ht_i => bf(jfld)%fnow(:,1,:) |
---|
884 | jfld = jfld + 1 |
---|
885 | dta_bdy(ib_bdy)%ht_s => bf(jfld)%fnow(:,1,:) |
---|
886 | ELSE ! case input is lim2 type |
---|
887 | jfld_ai = jfld + 1 |
---|
888 | jfld_hti = jfld + 2 |
---|
889 | jfld_hts = jfld + 3 |
---|
890 | jfld = jfld + 3 |
---|
891 | ALLOCATE( dta_bdy(ib_bdy)%a_i (nblen(1),jpl) ) |
---|
892 | ALLOCATE( dta_bdy(ib_bdy)%ht_i(nblen(1),jpl) ) |
---|
893 | ALLOCATE( dta_bdy(ib_bdy)%ht_s(nblen(1),jpl) ) |
---|
894 | dta_bdy(ib_bdy)%a_i (:,:) = 0._wp |
---|
895 | dta_bdy(ib_bdy)%ht_i(:,:) = 0._wp |
---|
896 | dta_bdy(ib_bdy)%ht_s(:,:) = 0._wp |
---|
897 | ENDIF |
---|
898 | |
---|
899 | ENDIF |
---|
900 | ENDIF |
---|
901 | #endif |
---|
902 | ! |
---|
903 | END DO ! ib_bdy |
---|
904 | ! |
---|
905 | IF( nn_timing == 1 ) CALL timing_stop('bdy_dta_init') |
---|
906 | ! |
---|
907 | END SUBROUTINE bdy_dta_init |
---|
908 | |
---|
909 | !!============================================================================== |
---|
910 | END MODULE bdydta |
---|