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