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_bt |
---|
9 | !! 3.0 ! 2008-04 (NEMO team) add in the reference version |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | #if defined key_bdy |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | !! 'key_bdy' Unstructured Open Boundary Conditions |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | !! bdy_dta : read u, v, t, s data along open boundaries |
---|
16 | !! bdy_dta_bt : read depth-mean velocities and elevation along open |
---|
17 | !! boundaries |
---|
18 | !!---------------------------------------------------------------------- |
---|
19 | USE oce ! ocean dynamics and tracers |
---|
20 | USE dom_oce ! ocean space and time domain |
---|
21 | USE daymod ! calendar |
---|
22 | USE phycst ! physical constants |
---|
23 | USE bdy_oce ! ocean open boundary conditions |
---|
24 | USE bdytides ! tidal forcing at boundaries |
---|
25 | USE iom |
---|
26 | USE ioipsl |
---|
27 | USE in_out_manager ! I/O logical units |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | PRIVATE |
---|
31 | |
---|
32 | PUBLIC bdy_dta ! routines called by step.F90 |
---|
33 | PUBLIC bdy_dta_bt |
---|
34 | |
---|
35 | INTEGER :: numbdyt, numbdyu, numbdyv !: logical units for T-, U-, & V-points data file, resp. |
---|
36 | INTEGER :: ntimes_bdy !: exact number of time dumps in data files |
---|
37 | INTEGER :: nbdy_b, nbdy_a !: record of bdy data file for before and after model time step |
---|
38 | INTEGER :: numbdyt_bt, numbdyu_bt, numbdyv_bt !: logical unit for T-, U- & V-points data file, resp. |
---|
39 | INTEGER :: ntimes_bdy_bt !: exact number of time dumps in data files |
---|
40 | INTEGER :: nbdy_b_bt, nbdy_a_bt !: record of bdy data file for before and after model time step |
---|
41 | |
---|
42 | INTEGER, DIMENSION (jpbtime) :: istep, istep_bt !: time array in seconds in each data file |
---|
43 | |
---|
44 | REAL(wp) :: zoffset !: time offset between time origin in file & start time of model run |
---|
45 | |
---|
46 | REAL(wp), DIMENSION(jpbdim,jpk,2) :: tbdydta, sbdydta !: time interpolated values of T and S bdy data |
---|
47 | REAL(wp), DIMENSION(jpbdim,jpk,2) :: ubdydta, vbdydta !: time interpolated values of U and V bdy data |
---|
48 | REAL(wp), DIMENSION(jpbdim,2) :: ubtbdydta, vbtbdydta !: Arrays used for time interpolation of bdy data |
---|
49 | REAL(wp), DIMENSION(jpbdim,2) :: sshbdydta !: bdy data of ssh |
---|
50 | |
---|
51 | !!---------------------------------------------------------------------- |
---|
52 | !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) |
---|
53 | !! $Id$ |
---|
54 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
55 | !!---------------------------------------------------------------------- |
---|
56 | |
---|
57 | CONTAINS |
---|
58 | |
---|
59 | SUBROUTINE bdy_dta( kt ) |
---|
60 | !!---------------------------------------------------------------------- |
---|
61 | !! *** SUBROUTINE bdy_dta *** |
---|
62 | !! |
---|
63 | !! ** Purpose : Read unstructured boundary data for FRS condition. |
---|
64 | !! |
---|
65 | !! ** Method : At the first timestep, read in boundary data for two |
---|
66 | !! times from the file and time-interpolate. At other |
---|
67 | !! timesteps, check to see if we need another time from |
---|
68 | !! the file. If so read it in. Time interpolate. |
---|
69 | !!---------------------------------------------------------------------- |
---|
70 | INTEGER, INTENT( in ) :: kt ! ocean time-step index (for timesplitting option, otherwise zero) |
---|
71 | !! |
---|
72 | CHARACTER(LEN=80), DIMENSION(3) :: clfile ! names of input files |
---|
73 | CHARACTER(LEN=70 ) :: clunits ! units attribute of time coordinate |
---|
74 | LOGICAL :: lect ! flag for reading |
---|
75 | INTEGER :: it, ib, ik, igrd ! dummy loop indices |
---|
76 | INTEGER :: igrd_start, igrd_end ! start and end of loops on igrd |
---|
77 | INTEGER :: idvar ! netcdf var ID |
---|
78 | INTEGER :: iman, i15, imois ! Time variables for monthly clim forcing |
---|
79 | INTEGER :: ntimes_bdyt, ntimes_bdyu, ntimes_bdyv |
---|
80 | INTEGER :: itimer, totime |
---|
81 | INTEGER :: ii, ij ! array addresses |
---|
82 | INTEGER :: ipi, ipj, ipk, inum ! temporary integers (NetCDF read) |
---|
83 | INTEGER :: iyear0, imonth0, iday0 |
---|
84 | INTEGER :: ihours0, iminutes0, isec0 |
---|
85 | INTEGER :: iyear, imonth, iday, isecs |
---|
86 | INTEGER, DIMENSION(jpbtime) :: istept, istepu, istepv ! time arrays from data files |
---|
87 | REAL(wp) :: dayfrac, zxy, zoffsett |
---|
88 | REAL(wp) :: zoffsetu, zoffsetv |
---|
89 | REAL(wp) :: dayjul0, zdayjulini |
---|
90 | REAL(wp), DIMENSION(jpbtime) :: zstepr ! REAL time array from data files |
---|
91 | REAL(wp), DIMENSION(jpbdta,1,jpk) :: zdta ! temporary array for data fields |
---|
92 | !!--------------------------------------------------------------------------- |
---|
93 | |
---|
94 | IF( ln_bdy_dyn_frs .OR. ln_bdy_tra_frs ) THEN ! If these are both false then this routine |
---|
95 | ! does nothing. |
---|
96 | |
---|
97 | ! -------------------- ! |
---|
98 | ! Initialization ! |
---|
99 | ! -------------------- ! |
---|
100 | |
---|
101 | lect = .false. ! If true, read a time record |
---|
102 | |
---|
103 | ! Some time variables for monthly climatological forcing: |
---|
104 | ! ******************************************************* |
---|
105 | !!gm here use directely daymod variables |
---|
106 | |
---|
107 | iman = INT( raamo ) ! Number of months in a year |
---|
108 | |
---|
109 | i15 = INT( 2*FLOAT( nday ) / ( FLOAT( nobis(nmonth) ) + 0.5 ) ) |
---|
110 | ! i15=0 if the current day is in the first half of the month, else i15=1 |
---|
111 | |
---|
112 | imois = nmonth + i15 - 1 ! imois is the first month record |
---|
113 | IF( imois == 0 ) imois = iman |
---|
114 | |
---|
115 | ! Time variable for non-climatological forcing: |
---|
116 | ! ********************************************* |
---|
117 | itimer = (kt-nit000+1)*rdt ! current time in seconds for interpolation |
---|
118 | |
---|
119 | |
---|
120 | ! !-------------------! |
---|
121 | IF( kt == nit000 ) THEN ! First call only ! |
---|
122 | ! !-------------------! |
---|
123 | istep(:) = 0 |
---|
124 | nbdy_b = 0 |
---|
125 | nbdy_a = 0 |
---|
126 | |
---|
127 | ! Get time information from bdy data file |
---|
128 | ! *************************************** |
---|
129 | |
---|
130 | IF(lwp) WRITE(numout,*) |
---|
131 | IF(lwp) WRITE(numout,*) 'bdy_dta : Initialize unstructured boundary data' |
---|
132 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
133 | |
---|
134 | IF ( nbdy_dta == 0 ) THEN |
---|
135 | ! |
---|
136 | IF(lwp) WRITE(numout,*) ' Bdy data are taken from initial conditions' |
---|
137 | ! |
---|
138 | ELSEIF (nbdy_dta == 1) THEN |
---|
139 | ! |
---|
140 | IF(lwp) WRITE(numout,*) ' Bdy data are read in netcdf files' |
---|
141 | ! |
---|
142 | dayfrac = adatrj - FLOAT( itimer ) / 86400. ! day fraction at time step kt-1 |
---|
143 | dayfrac = dayfrac - INT ( dayfrac ) ! |
---|
144 | totime = ( nitend - nit000 + 1 ) * rdt ! Total time of the run to verify that all the |
---|
145 | ! ! necessary time dumps in file are included |
---|
146 | ! |
---|
147 | clfile(1) = filbdy_data_T |
---|
148 | clfile(2) = filbdy_data_U |
---|
149 | clfile(3) = filbdy_data_V |
---|
150 | ! |
---|
151 | ! how many files are we to read in? |
---|
152 | igrd_start = 1 |
---|
153 | igrd_end = 3 |
---|
154 | IF(.NOT. ln_bdy_tra_frs .AND. .NOT. ln_bdy_ice_frs) THEN |
---|
155 | ! No T-grid file. |
---|
156 | igrd_start = 2 |
---|
157 | ELSEIF ( .NOT. ln_bdy_dyn_frs ) THEN |
---|
158 | ! No U-grid or V-grid file. |
---|
159 | igrd_end = 1 |
---|
160 | ENDIF |
---|
161 | |
---|
162 | DO igrd = igrd_start, igrd_end ! loop over T, U & V grid ! |
---|
163 | ! !---------------------------! |
---|
164 | CALL iom_open( clfile(igrd), inum ) |
---|
165 | CALL iom_gettime( inum, zstepr, kntime=ntimes_bdy, cdunits=clunits ) |
---|
166 | |
---|
167 | SELECT CASE( igrd ) |
---|
168 | CASE (1) |
---|
169 | numbdyt = inum |
---|
170 | CASE (2) |
---|
171 | numbdyu = inum |
---|
172 | CASE (3) |
---|
173 | numbdyv = inum |
---|
174 | END SELECT |
---|
175 | |
---|
176 | ! Calculate time offset |
---|
177 | READ(clunits,7000) iyear0, imonth0, iday0, ihours0, iminutes0, isec0 |
---|
178 | ! Convert time origin in file to julian days |
---|
179 | isec0 = isec0 + ihours0*60.*60. + iminutes0*60. |
---|
180 | CALL ymds2ju(iyear0, imonth0, iday0, real(isec0), dayjul0) |
---|
181 | ! Compute model initialization time |
---|
182 | iyear = ndastp / 10000 |
---|
183 | imonth = ( ndastp - iyear * 10000 ) / 100 |
---|
184 | iday = ndastp - iyear * 10000 - imonth * 100 |
---|
185 | isecs = dayfrac * 86400 |
---|
186 | CALL ymds2ju(iyear, imonth, iday, real(isecs) , zdayjulini) |
---|
187 | ! offset from initialization date: |
---|
188 | zoffset = (dayjul0-zdayjulini)*86400 |
---|
189 | ! |
---|
190 | 7000 FORMAT('seconds since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2) |
---|
191 | |
---|
192 | !! TO BE DONE... Check consistency between calendar from file |
---|
193 | !! (available optionally from iom_gettime) and calendar in model |
---|
194 | !! when calendar in model available outside of IOIPSL. |
---|
195 | |
---|
196 | IF(lwp) WRITE(numout,*) 'number of times: ',ntimes_bdy |
---|
197 | IF(lwp) WRITE(numout,*) 'offset: ',zoffset |
---|
198 | IF(lwp) WRITE(numout,*) 'totime: ',totime |
---|
199 | IF(lwp) WRITE(numout,*) 'zstepr: ',zstepr |
---|
200 | |
---|
201 | ! Check that there are not too many times in the file. |
---|
202 | IF( ntimes_bdy > jpbtime ) THEN |
---|
203 | WRITE(ctmp1,*) 'Check file: ', clfile(igrd), 'jpbtime= ', jpbtime, ' ntimes_bdy= ', ntimes_bdy |
---|
204 | CALL ctl_stop( 'Number of time dumps in files exceed jpbtime parameter', ctmp1 ) |
---|
205 | ENDIF |
---|
206 | |
---|
207 | ! Check that time array increases: |
---|
208 | |
---|
209 | it = 1 |
---|
210 | DO WHILE( zstepr(it+1) > zstepr(it) .AND. it /= ntimes_bdy - 1 ) |
---|
211 | it = it + 1 |
---|
212 | END DO |
---|
213 | |
---|
214 | IF( it.NE.ntimes_bdy-1 .AND. ntimes_bdy > 1 ) THEN |
---|
215 | WRITE(ctmp1,*) 'Check file: ', clfile(igrd) |
---|
216 | CALL ctl_stop( 'Time array in unstructured boundary data files', & |
---|
217 | & 'does not continuously increase.' , ctmp1 ) |
---|
218 | ENDIF |
---|
219 | ! |
---|
220 | ! Check that times in file span model run time: |
---|
221 | IF( zstepr(1) + zoffset > 0 ) THEN |
---|
222 | WRITE(ctmp1,*) 'Check file: ', clfile(igrd) |
---|
223 | CALL ctl_stop( 'First time dump in bdy file is after model initial time', ctmp1 ) |
---|
224 | END IF |
---|
225 | IF( zstepr(ntimes_bdy) + zoffset < totime ) THEN |
---|
226 | WRITE(ctmp1,*) 'Check file: ', clfile(igrd) |
---|
227 | CALL ctl_stop( 'Last time dump in bdy file is before model final time', ctmp1 ) |
---|
228 | END IF |
---|
229 | ! |
---|
230 | IF ( igrd == 1 ) THEN |
---|
231 | ntimes_bdyt = ntimes_bdy |
---|
232 | zoffsett = zoffset |
---|
233 | istept(:) = INT( zstepr(:) + zoffset ) |
---|
234 | ELSEIF(igrd == 2 ) THEN |
---|
235 | ntimes_bdyu = ntimes_bdy |
---|
236 | zoffsetu = zoffset |
---|
237 | istepu(:) = INT( zstepr(:) + zoffset ) |
---|
238 | ELSEIF(igrd == 3 ) THEN |
---|
239 | ntimes_bdyv = ntimes_bdy |
---|
240 | zoffsetv = zoffset |
---|
241 | istepv(:) = INT( zstepr(:) + zoffset ) |
---|
242 | ENDIF |
---|
243 | ! |
---|
244 | END DO ! end loop over T, U & V grid |
---|
245 | |
---|
246 | IF (igrd_start == 1 .and. igrd_end == 3) THEN |
---|
247 | ! Only test differences if we are reading in 3 files |
---|
248 | ! Verify time consistency between files |
---|
249 | IF( ntimes_bdyu /= ntimes_bdyt .OR. ntimes_bdyv /= ntimes_bdyt ) THEN |
---|
250 | CALL ctl_stop( 'Bdy data files must have the same number of time dumps', & |
---|
251 | & 'Multiple time frequencies not implemented yet' ) |
---|
252 | ENDIF |
---|
253 | ntimes_bdy = ntimes_bdyt |
---|
254 | ! |
---|
255 | IF( zoffsetu /= zoffsett .OR. zoffsetv /= zoffsett ) THEN |
---|
256 | CALL ctl_stop( 'Bdy data files must have the same time origin', & |
---|
257 | & 'Multiple time frequencies not implemented yet' ) |
---|
258 | ENDIF |
---|
259 | zoffset = zoffsett |
---|
260 | ENDIF |
---|
261 | |
---|
262 | IF( igrd_start == 1 ) THEN |
---|
263 | istep(:) = istept(:) |
---|
264 | ELSE |
---|
265 | istep(:) = istepu(:) |
---|
266 | ENDIF |
---|
267 | |
---|
268 | ! Check number of time dumps: |
---|
269 | IF( ntimes_bdy == 1 .AND. .NOT. ln_bdy_clim ) THEN |
---|
270 | CALL ctl_stop( 'There is only one time dump in data files', & |
---|
271 | & 'Choose ln_bdy_clim=.true. in namelist for constant bdy forcing.' ) |
---|
272 | ENDIF |
---|
273 | |
---|
274 | IF( ln_bdy_clim ) THEN |
---|
275 | IF( ntimes_bdy /= 1 .AND. ntimes_bdy /= 12 ) THEN |
---|
276 | CALL ctl_stop( 'For climatological boundary forcing (ln_bdy_clim=.true.),', & |
---|
277 | & 'bdy data files must contain 1 or 12 time dumps.' ) |
---|
278 | ELSEIF( ntimes_bdy == 1 ) THEN |
---|
279 | IF(lwp) WRITE(numout,*) |
---|
280 | IF(lwp) WRITE(numout,*) 'We assume constant boundary forcing from bdy data files' |
---|
281 | ELSEIF( ntimes_bdy == 12 ) THEN |
---|
282 | IF(lwp) WRITE(numout,*) |
---|
283 | IF(lwp) WRITE(numout,*) 'We assume monthly (and cyclic) boundary forcing from bdy data files' |
---|
284 | ENDIF |
---|
285 | ENDIF |
---|
286 | |
---|
287 | ! Find index of first record to read (before first model time). |
---|
288 | it = 1 |
---|
289 | DO WHILE( istep(it+1) <= 0 .AND. it <= ntimes_bdy - 1 ) |
---|
290 | it = it + 1 |
---|
291 | END DO |
---|
292 | nbdy_b = it |
---|
293 | ! |
---|
294 | WRITE(numout,*) 'Time offset is ',zoffset |
---|
295 | WRITE(numout,*) 'First record to read is ',nbdy_b |
---|
296 | |
---|
297 | ENDIF ! endif (nbdy_dta == 1) |
---|
298 | |
---|
299 | |
---|
300 | ! 1.2 Read first record in file if necessary (ie if nbdy_dta == 1) |
---|
301 | ! ***************************************************************** |
---|
302 | |
---|
303 | IF( nbdy_dta == 0) THEN ! boundary data arrays are filled with initial conditions |
---|
304 | ! |
---|
305 | IF (ln_bdy_tra_frs) THEN |
---|
306 | igrd = 1 ! T-points data |
---|
307 | DO ib = 1, nblen(igrd) |
---|
308 | ii = nbi(ib,igrd) |
---|
309 | ij = nbj(ib,igrd) |
---|
310 | DO ik = 1, jpkm1 |
---|
311 | tbdy(ib,ik) = tn(ii, ij, ik) |
---|
312 | sbdy(ib,ik) = sn(ii, ij, ik) |
---|
313 | ENDDO |
---|
314 | END DO |
---|
315 | ENDIF |
---|
316 | |
---|
317 | IF(ln_bdy_dyn_frs) THEN |
---|
318 | igrd = 2 ! U-points data |
---|
319 | DO ib = 1, nblen(igrd) |
---|
320 | ii = nbi(ib,igrd) |
---|
321 | ij = nbj(ib,igrd) |
---|
322 | DO ik = 1, jpkm1 |
---|
323 | ubdy(ib,ik) = un(ii, ij, ik) |
---|
324 | ENDDO |
---|
325 | END DO |
---|
326 | |
---|
327 | igrd = 3 ! V-points data |
---|
328 | DO ib = 1, nblen(igrd) |
---|
329 | ii = nbi(ib,igrd) |
---|
330 | ij = nbj(ib,igrd) |
---|
331 | DO ik = 1, jpkm1 |
---|
332 | vbdy(ib,ik) = vn(ii, ij, ik) |
---|
333 | ENDDO |
---|
334 | END DO |
---|
335 | ENDIF |
---|
336 | ! |
---|
337 | ELSEIF( nbdy_dta == 1 ) THEN ! Set first record in the climatological case: |
---|
338 | ! |
---|
339 | IF( ln_bdy_clim .AND. ntimes_bdy == 1 ) THEN |
---|
340 | nbdy_a = 1 |
---|
341 | ELSEIF( ln_bdy_clim .AND. ntimes_bdy == iman ) THEN |
---|
342 | nbdy_b = 0 |
---|
343 | nbdy_a = imois |
---|
344 | ELSE |
---|
345 | nbdy_a = nbdy_b |
---|
346 | ENDIF |
---|
347 | |
---|
348 | ! Read first record: |
---|
349 | ipj = 1 |
---|
350 | ipk = jpk |
---|
351 | igrd = 1 |
---|
352 | ipi = nblendta(igrd) |
---|
353 | |
---|
354 | IF(ln_bdy_tra_frs) THEN |
---|
355 | igrd = 1 ! Temperature |
---|
356 | IF( nblendta(igrd) <= 0 ) THEN |
---|
357 | idvar = iom_varid( numbdyt, 'votemper' ) |
---|
358 | nblendta(igrd) = iom_file(numbdyt)%dimsz(1,idvar) |
---|
359 | ENDIF |
---|
360 | WRITE(numout,*) 'Dim size for votemper is ', nblendta(igrd) |
---|
361 | ipi = nblendta(igrd) |
---|
362 | CALL iom_get ( numbdyt, jpdom_unknown, 'votemper', zdta(1:ipi,1:ipj,1:ipk), nbdy_a ) |
---|
363 | |
---|
364 | DO ib = 1, nblen(igrd) |
---|
365 | DO ik = 1, jpkm1 |
---|
366 | tbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
367 | END DO |
---|
368 | END DO |
---|
369 | ! |
---|
370 | igrd = 1 ! salinity |
---|
371 | IF( nblendta(igrd) .le. 0 ) THEN |
---|
372 | idvar = iom_varid( numbdyt, 'vosaline' ) |
---|
373 | nblendta(igrd) = iom_file(numbdyt)%dimsz(1,idvar) |
---|
374 | ENDIF |
---|
375 | WRITE(numout,*) 'Dim size for vosaline is ', nblendta(igrd) |
---|
376 | ipi = nblendta(igrd) |
---|
377 | CALL iom_get ( numbdyt, jpdom_unknown, 'vosaline', zdta(1:ipi,1:ipj,1:ipk), nbdy_a ) |
---|
378 | |
---|
379 | DO ib = 1, nblen(igrd) |
---|
380 | DO ik = 1, jpkm1 |
---|
381 | sbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
382 | END DO |
---|
383 | END DO |
---|
384 | ENDIF ! ln_bdy_tra_frs |
---|
385 | |
---|
386 | IF(ln_bdy_dyn_frs) THEN |
---|
387 | |
---|
388 | igrd = 2 ! u-velocity |
---|
389 | IF ( nblendta(igrd) .le. 0 ) THEN |
---|
390 | idvar = iom_varid( numbdyu,'vozocrtx' ) |
---|
391 | nblendta(igrd) = iom_file(numbdyu)%dimsz(1,idvar) |
---|
392 | ENDIF |
---|
393 | WRITE(numout,*) 'Dim size for vozocrtx is ', nblendta(igrd) |
---|
394 | ipi = nblendta(igrd) |
---|
395 | CALL iom_get ( numbdyu, jpdom_unknown,'vozocrtx',zdta(1:ipi,1:ipj,1:ipk),nbdy_a ) |
---|
396 | DO ib = 1, nblen(igrd) |
---|
397 | DO ik = 1, jpkm1 |
---|
398 | ubdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
399 | END DO |
---|
400 | END DO |
---|
401 | ! |
---|
402 | igrd = 3 ! v-velocity |
---|
403 | IF ( nblendta(igrd) .le. 0 ) THEN |
---|
404 | idvar = iom_varid( numbdyv,'vomecrty' ) |
---|
405 | nblendta(igrd) = iom_file(numbdyv)%dimsz(1,idvar) |
---|
406 | ENDIF |
---|
407 | WRITE(numout,*) 'Dim size for vomecrty is ', nblendta(igrd) |
---|
408 | ipi = nblendta(igrd) |
---|
409 | CALL iom_get ( numbdyv, jpdom_unknown,'vomecrty',zdta(1:ipi,1:ipj,1:ipk),nbdy_a ) |
---|
410 | DO ib = 1, nblen(igrd) |
---|
411 | DO ik = 1, jpkm1 |
---|
412 | vbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
413 | END DO |
---|
414 | END DO |
---|
415 | ENDIF ! ln_bdy_dyn_frs |
---|
416 | |
---|
417 | |
---|
418 | IF ((.NOT.ln_bdy_clim) .AND. (istep(1) > 0)) THEN |
---|
419 | ! First data time is after start of run |
---|
420 | ! Put first value in both time levels |
---|
421 | nbdy_b = nbdy_a |
---|
422 | IF(ln_bdy_tra_frs) THEN |
---|
423 | tbdydta(:,:,1) = tbdydta(:,:,2) |
---|
424 | sbdydta(:,:,1) = sbdydta(:,:,2) |
---|
425 | ENDIF |
---|
426 | IF(ln_bdy_dyn_frs) THEN |
---|
427 | ubdydta(:,:,1) = ubdydta(:,:,2) |
---|
428 | vbdydta(:,:,1) = vbdydta(:,:,2) |
---|
429 | ENDIF |
---|
430 | END IF |
---|
431 | |
---|
432 | END IF ! nbdy_dta == 0/1 |
---|
433 | |
---|
434 | ! In the case of constant boundary forcing fill bdy arrays once for all |
---|
435 | IF ((ln_bdy_clim).AND.(ntimes_bdy==1)) THEN |
---|
436 | IF(ln_bdy_tra_frs) THEN |
---|
437 | tbdy (:,:) = tbdydta (:,:,2) |
---|
438 | sbdy (:,:) = sbdydta (:,:,2) |
---|
439 | ENDIF |
---|
440 | IF(ln_bdy_dyn_frs) THEN |
---|
441 | ubdy (:,:) = ubdydta (:,:,2) |
---|
442 | vbdy (:,:) = vbdydta (:,:,2) |
---|
443 | ENDIF |
---|
444 | |
---|
445 | IF(ln_bdy_tra_frs .or. ln_bdy_ice_frs) CALL iom_close( numbdyt ) |
---|
446 | IF(ln_bdy_dyn_frs) CALL iom_close( numbdyu ) |
---|
447 | IF(ln_bdy_dyn_frs) CALL iom_close( numbdyv ) |
---|
448 | END IF |
---|
449 | |
---|
450 | ENDIF ! End if nit000 |
---|
451 | |
---|
452 | |
---|
453 | ! !---------------------! |
---|
454 | ! ! at each time step ! |
---|
455 | ! !---------------------! |
---|
456 | |
---|
457 | IF( nbdy_dta == 1 .AND. ntimes_bdy > 1 ) THEN |
---|
458 | ! |
---|
459 | ! Read one more record if necessary |
---|
460 | !********************************** |
---|
461 | |
---|
462 | IF( ln_bdy_clim .AND. imois /= nbdy_b ) THEN ! remember that nbdy_b=0 for kt=nit000 |
---|
463 | nbdy_b = imois |
---|
464 | nbdy_a = imois + 1 |
---|
465 | nbdy_b = MOD( nbdy_b, iman ) ; IF( nbdy_b == 0 ) nbdy_b = iman |
---|
466 | nbdy_a = MOD( nbdy_a, iman ) ; IF( nbdy_a == 0 ) nbdy_a = iman |
---|
467 | lect=.true. |
---|
468 | ELSEIF( .NOT.ln_bdy_clim .AND. itimer >= istep(nbdy_a) ) THEN |
---|
469 | |
---|
470 | IF ( nbdy_a < ntimes_bdy ) THEN |
---|
471 | nbdy_b = nbdy_a |
---|
472 | nbdy_a = nbdy_a + 1 |
---|
473 | lect =.true. |
---|
474 | ELSE |
---|
475 | ! We have reached the end of the file |
---|
476 | ! put the last data time into both time levels |
---|
477 | nbdy_b = nbdy_a |
---|
478 | IF(ln_bdy_tra_frs) THEN |
---|
479 | tbdydta(:,:,1) = tbdydta(:,:,2) |
---|
480 | sbdydta(:,:,1) = sbdydta(:,:,2) |
---|
481 | ENDIF |
---|
482 | IF(ln_bdy_dyn_frs) THEN |
---|
483 | ubdydta(:,:,1) = ubdydta(:,:,2) |
---|
484 | vbdydta(:,:,1) = vbdydta(:,:,2) |
---|
485 | ENDIF |
---|
486 | END IF ! nbdy_a < ntimes_bdy |
---|
487 | |
---|
488 | END IF |
---|
489 | |
---|
490 | IF( lect ) THEN |
---|
491 | ! Swap arrays |
---|
492 | IF(ln_bdy_tra_frs) THEN |
---|
493 | tbdydta(:,:,1) = tbdydta(:,:,2) |
---|
494 | sbdydta(:,:,1) = sbdydta(:,:,2) |
---|
495 | ENDIF |
---|
496 | IF(ln_bdy_dyn_frs) THEN |
---|
497 | ubdydta(:,:,1) = ubdydta(:,:,2) |
---|
498 | vbdydta(:,:,1) = vbdydta(:,:,2) |
---|
499 | ENDIF |
---|
500 | |
---|
501 | ! read another set |
---|
502 | ipj = 1 |
---|
503 | ipk = jpk |
---|
504 | |
---|
505 | IF(ln_bdy_tra_frs) THEN |
---|
506 | ! |
---|
507 | igrd = 1 ! temperature |
---|
508 | ipi = nblendta(igrd) |
---|
509 | CALL iom_get ( numbdyt, jpdom_unknown, 'votemper', zdta(1:ipi,1:ipj,1:ipk), nbdy_a ) |
---|
510 | DO ib = 1, nblen(igrd) |
---|
511 | DO ik = 1, jpkm1 |
---|
512 | tbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
513 | END DO |
---|
514 | END DO |
---|
515 | ! |
---|
516 | igrd = 1 ! salinity |
---|
517 | ipi = nblendta(igrd) |
---|
518 | CALL iom_get ( numbdyt, jpdom_unknown, 'vosaline', zdta(1:ipi,1:ipj,1:ipk), nbdy_a ) |
---|
519 | DO ib = 1, nblen(igrd) |
---|
520 | DO ik = 1, jpkm1 |
---|
521 | sbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
522 | END DO |
---|
523 | END DO |
---|
524 | ENDIF ! ln_bdy_tra_frs |
---|
525 | |
---|
526 | IF(ln_bdy_dyn_frs) THEN |
---|
527 | ! |
---|
528 | igrd = 2 ! u-velocity |
---|
529 | ipi = nblendta(igrd) |
---|
530 | CALL iom_get ( numbdyu, jpdom_unknown,'vozocrtx',zdta(1:ipi,1:ipj,1:ipk),nbdy_a ) |
---|
531 | DO ib = 1, nblen(igrd) |
---|
532 | DO ik = 1, jpkm1 |
---|
533 | ubdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
534 | END DO |
---|
535 | END DO |
---|
536 | ! |
---|
537 | igrd = 3 ! v-velocity |
---|
538 | ipi = nblendta(igrd) |
---|
539 | CALL iom_get ( numbdyv, jpdom_unknown,'vomecrty',zdta(1:ipi,1:ipj,1:ipk),nbdy_a ) |
---|
540 | DO ib = 1, nblen(igrd) |
---|
541 | DO ik = 1, jpkm1 |
---|
542 | vbdydta(ib,ik,2) = zdta(nbmap(ib,igrd),1,ik) |
---|
543 | END DO |
---|
544 | END DO |
---|
545 | ENDIF ! ln_bdy_dyn_frs |
---|
546 | |
---|
547 | ! |
---|
548 | IF(lwp) WRITE(numout,*) 'bdy_dta : first record file used nbdy_b ',nbdy_b |
---|
549 | IF(lwp) WRITE(numout,*) '~~~~~~~~ last record file used nbdy_a ',nbdy_a |
---|
550 | IF (.NOT.ln_bdy_clim) THEN |
---|
551 | IF(lwp) WRITE(numout,*) 'first record time (s): ', istep(nbdy_b) |
---|
552 | IF(lwp) WRITE(numout,*) 'model time (s) : ', itimer |
---|
553 | IF(lwp) WRITE(numout,*) 'second record time (s): ', istep(nbdy_a) |
---|
554 | ENDIF |
---|
555 | ! |
---|
556 | ENDIF ! end lect=.true. |
---|
557 | |
---|
558 | |
---|
559 | ! Interpolate linearly |
---|
560 | ! ******************** |
---|
561 | ! |
---|
562 | IF( ln_bdy_clim ) THEN ; zxy = FLOAT( nday ) / FLOAT( nobis(nbdy_b) ) + 0.5 - i15 |
---|
563 | ELSE ; zxy = FLOAT( istep(nbdy_b) - itimer ) / FLOAT( istep(nbdy_b) - istep(nbdy_a) ) |
---|
564 | END IF |
---|
565 | |
---|
566 | IF(ln_bdy_tra_frs) THEN |
---|
567 | igrd = 1 ! temperature & salinity |
---|
568 | DO ib = 1, nblen(igrd) |
---|
569 | DO ik = 1, jpkm1 |
---|
570 | tbdy(ib,ik) = zxy * tbdydta(ib,ik,2) + (1.-zxy) * tbdydta(ib,ik,1) |
---|
571 | sbdy(ib,ik) = zxy * sbdydta(ib,ik,2) + (1.-zxy) * sbdydta(ib,ik,1) |
---|
572 | END DO |
---|
573 | END DO |
---|
574 | ENDIF |
---|
575 | |
---|
576 | IF(ln_bdy_dyn_frs) THEN |
---|
577 | igrd = 2 ! u-velocity |
---|
578 | DO ib = 1, nblen(igrd) |
---|
579 | DO ik = 1, jpkm1 |
---|
580 | ubdy(ib,ik) = zxy * ubdydta(ib,ik,2) + (1.-zxy) * ubdydta(ib,ik,1) |
---|
581 | END DO |
---|
582 | END DO |
---|
583 | ! |
---|
584 | igrd = 3 ! v-velocity |
---|
585 | DO ib = 1, nblen(igrd) |
---|
586 | DO ik = 1, jpkm1 |
---|
587 | vbdy(ib,ik) = zxy * vbdydta(ib,ik,2) + (1.-zxy) * vbdydta(ib,ik,1) |
---|
588 | END DO |
---|
589 | END DO |
---|
590 | ENDIF |
---|
591 | |
---|
592 | END IF !end if ((nbdy_dta==1).AND.(ntimes_bdy>1)) |
---|
593 | |
---|
594 | |
---|
595 | ! !---------------------! |
---|
596 | ! ! last call ! |
---|
597 | ! !---------------------! |
---|
598 | IF( kt == nitend ) THEN |
---|
599 | IF(ln_bdy_tra_frs .or. ln_bdy_ice_frs) CALL iom_close( numbdyt ) ! Closing of the 3 files |
---|
600 | IF(ln_bdy_dyn_frs) CALL iom_close( numbdyu ) |
---|
601 | IF(ln_bdy_dyn_frs) CALL iom_close( numbdyv ) |
---|
602 | ENDIF |
---|
603 | ! |
---|
604 | ENDIF ! ln_bdy_dyn_frs .OR. ln_bdy_tra_frs |
---|
605 | |
---|
606 | END SUBROUTINE bdy_dta |
---|
607 | |
---|
608 | |
---|
609 | SUBROUTINE bdy_dta_bt( kt, jit ) |
---|
610 | !!--------------------------------------------------------------------------- |
---|
611 | !! *** SUBROUTINE bdy_dta_bt *** |
---|
612 | !! |
---|
613 | !! ** Purpose : Read unstructured boundary data for Flather condition |
---|
614 | !! |
---|
615 | !! ** Method : At the first timestep, read in boundary data for two |
---|
616 | !! times from the file and time-interpolate. At other |
---|
617 | !! timesteps, check to see if we need another time from |
---|
618 | !! the file. If so read it in. Time interpolate. |
---|
619 | !!--------------------------------------------------------------------------- |
---|
620 | !!gm DOCTOR names : argument integer : start with "k" |
---|
621 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
622 | INTEGER, INTENT( in ) :: jit ! barotropic time step index |
---|
623 | ! ! (for timesplitting option, otherwise zero) |
---|
624 | !! |
---|
625 | LOGICAL :: lect ! flag for reading |
---|
626 | INTEGER :: it, ib, igrd ! dummy loop indices |
---|
627 | INTEGER :: idvar ! netcdf var ID |
---|
628 | INTEGER :: iman, i15, imois ! Time variables for monthly clim forcing |
---|
629 | INTEGER :: ntimes_bdyt, ntimes_bdyu, ntimes_bdyv |
---|
630 | INTEGER :: itimer, totime |
---|
631 | INTEGER :: ipi, ipj, ipk, inum ! temporary integers (NetCDF read) |
---|
632 | INTEGER :: iyear0, imonth0, iday0 |
---|
633 | INTEGER :: ihours0, iminutes0, isec0 |
---|
634 | INTEGER :: iyear, imonth, iday, isecs |
---|
635 | INTEGER, DIMENSION(jpbtime) :: istept, istepu, istepv ! time arrays from data files |
---|
636 | REAL(wp) :: dayfrac, zxy, zoffsett |
---|
637 | REAL(wp) :: zoffsetu, zoffsetv |
---|
638 | REAL(wp) :: dayjul0, zdayjulini |
---|
639 | REAL(wp) :: zinterval_s, zinterval_e ! First and last interval in time axis |
---|
640 | REAL(wp), DIMENSION(jpbtime) :: zstepr ! REAL time array from data files |
---|
641 | REAL(wp), DIMENSION(jpbdta,1) :: zdta ! temporary array for data fields |
---|
642 | CHARACTER(LEN=80), DIMENSION(3) :: clfile |
---|
643 | CHARACTER(LEN=70 ) :: clunits ! units attribute of time coordinate |
---|
644 | !!--------------------------------------------------------------------------- |
---|
645 | |
---|
646 | !!gm add here the same style as in bdy_dta |
---|
647 | !!gm clearly bdy_dta_bt and bdy_dta can be combined... |
---|
648 | !!gm too many things duplicated in the read of data... simplification can be done |
---|
649 | |
---|
650 | ! -------------------- ! |
---|
651 | ! Initialization ! |
---|
652 | ! -------------------- ! |
---|
653 | |
---|
654 | lect = .false. ! If true, read a time record |
---|
655 | |
---|
656 | ! Some time variables for monthly climatological forcing: |
---|
657 | ! ******************************************************* |
---|
658 | !!gm here use directely daymod variables |
---|
659 | |
---|
660 | iman = INT( raamo ) ! Number of months in a year |
---|
661 | |
---|
662 | i15 = INT( 2*FLOAT( nday ) / ( FLOAT( nobis(nmonth) ) + 0.5 ) ) |
---|
663 | ! i15=0 if the current day is in the first half of the month, else i15=1 |
---|
664 | |
---|
665 | imois = nmonth + i15 - 1 ! imois is the first month record |
---|
666 | IF( imois == 0 ) imois = iman |
---|
667 | |
---|
668 | ! Time variable for non-climatological forcing: |
---|
669 | ! ********************************************* |
---|
670 | |
---|
671 | itimer = ((kt-1)-nit000+1)*rdt ! current time in seconds for interpolation |
---|
672 | itimer = itimer + jit*rdt/REAL(nn_baro,wp) ! in non-climatological case |
---|
673 | |
---|
674 | IF ( ln_bdy_tides ) THEN |
---|
675 | |
---|
676 | ! -------------------------------------! |
---|
677 | ! Update BDY fields with tidal forcing ! |
---|
678 | ! -------------------------------------! |
---|
679 | |
---|
680 | CALL tide_update( kt, jit ) |
---|
681 | |
---|
682 | ENDIF |
---|
683 | |
---|
684 | IF ( ln_bdy_dyn_fla ) THEN |
---|
685 | |
---|
686 | ! -------------------------------------! |
---|
687 | ! Update BDY fields with model data ! |
---|
688 | ! -------------------------------------! |
---|
689 | |
---|
690 | ! !-------------------! |
---|
691 | IF( kt == nit000 ) THEN ! First call only ! |
---|
692 | ! !-------------------! |
---|
693 | istep_bt(:) = 0 |
---|
694 | nbdy_b_bt = 0 |
---|
695 | nbdy_a_bt = 0 |
---|
696 | |
---|
697 | ! Get time information from bdy data file |
---|
698 | ! *************************************** |
---|
699 | |
---|
700 | IF(lwp) WRITE(numout,*) |
---|
701 | IF(lwp) WRITE(numout,*) 'bdy_dta_bt :Initialize unstructured boundary data for barotropic variables.' |
---|
702 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
703 | |
---|
704 | IF( nbdy_dta == 0 ) THEN |
---|
705 | IF(lwp) WRITE(numout,*) 'Bdy data are taken from initial conditions' |
---|
706 | |
---|
707 | ELSEIF (nbdy_dta == 1) THEN |
---|
708 | IF(lwp) WRITE(numout,*) 'Bdy data are read in netcdf files' |
---|
709 | |
---|
710 | dayfrac = adatrj-float(itimer)/86400. ! day fraction at time step kt-1 |
---|
711 | dayfrac = dayfrac - INT(dayfrac) ! |
---|
712 | totime = (nitend-nit000+1)*rdt ! Total time of the run to verify that all the |
---|
713 | ! necessary time dumps in file are included |
---|
714 | |
---|
715 | clfile(1) = filbdy_data_bt_T |
---|
716 | clfile(2) = filbdy_data_bt_U |
---|
717 | clfile(3) = filbdy_data_bt_V |
---|
718 | |
---|
719 | DO igrd = 1,3 |
---|
720 | |
---|
721 | CALL iom_open( clfile(igrd), inum ) |
---|
722 | CALL iom_gettime( inum, zstepr, kntime=ntimes_bdy, cdunits=clunits ) |
---|
723 | |
---|
724 | SELECT CASE( igrd ) |
---|
725 | CASE (1) |
---|
726 | numbdyt = inum |
---|
727 | CASE (2) |
---|
728 | numbdyu = inum |
---|
729 | CASE (3) |
---|
730 | numbdyv = inum |
---|
731 | END SELECT |
---|
732 | |
---|
733 | ! Calculate time offset |
---|
734 | READ(clunits,7000) iyear0, imonth0, iday0, ihours0, iminutes0, isec0 |
---|
735 | ! Convert time origin in file to julian days |
---|
736 | isec0 = isec0 + ihours0*60.*60. + iminutes0*60. |
---|
737 | CALL ymds2ju(iyear0, imonth0, iday0, real(isec0), dayjul0) |
---|
738 | ! Compute model initialization time |
---|
739 | iyear = ndastp / 10000 |
---|
740 | imonth = ( ndastp - iyear * 10000 ) / 100 |
---|
741 | iday = ndastp - iyear * 10000 - imonth * 100 |
---|
742 | isecs = dayfrac * 86400 |
---|
743 | CALL ymds2ju(iyear, imonth, iday, real(isecs) , zdayjulini) |
---|
744 | ! zoffset from initialization date: |
---|
745 | zoffset = (dayjul0-zdayjulini)*86400 |
---|
746 | ! |
---|
747 | |
---|
748 | 7000 FORMAT('seconds since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2) |
---|
749 | |
---|
750 | !! TO BE DONE... Check consistency between calendar from file |
---|
751 | !! (available optionally from iom_gettime) and calendar in model |
---|
752 | !! when calendar in model available outside of IOIPSL. |
---|
753 | |
---|
754 | ! Check that there are not too many times in the file. |
---|
755 | IF (ntimes_bdy_bt > jpbtime) CALL ctl_stop( & |
---|
756 | 'Number of time dumps in bdy file exceed jpbtime parameter', & |
---|
757 | 'Check file:' // TRIM(clfile(igrd)) ) |
---|
758 | |
---|
759 | ! Check that time array increases (or interp will fail): |
---|
760 | DO it = 2, ntimes_bdy |
---|
761 | IF ( zstepr(it-1) >= zstepr(it) ) THEN |
---|
762 | CALL ctl_stop('Time array in unstructured boundary data file', & |
---|
763 | 'does not continuously increase.', & |
---|
764 | 'Check file:' // TRIM(clfile(igrd)) ) |
---|
765 | EXIT |
---|
766 | END IF |
---|
767 | END DO |
---|
768 | |
---|
769 | IF ( .NOT. ln_bdy_clim ) THEN |
---|
770 | ! Check that times in file span model run time: |
---|
771 | |
---|
772 | ! Note: the fields may be time means, so we allow nit000 to be before |
---|
773 | ! first time in the file, provided that it falls inside the meaning |
---|
774 | ! period of the first field. Until we can get the meaning period |
---|
775 | ! from the file, use the interval between fields as a proxy. |
---|
776 | ! If nit000 is before the first time, use the value at first time |
---|
777 | ! instead of extrapolating. This is done by putting time 1 into |
---|
778 | ! both time levels. |
---|
779 | ! The same applies to the last time level: see setting of lect below. |
---|
780 | |
---|
781 | IF ( ntimes_bdy == 1 ) CALL ctl_stop( & |
---|
782 | 'There is only one time dump in data files', & |
---|
783 | 'Set ln_bdy_clim=.true. in namelist for constant bdy forcing.' ) |
---|
784 | |
---|
785 | zinterval_s = zstepr(2) - zstepr(1) |
---|
786 | zinterval_e = zstepr(ntimes_bdy) - zstepr(ntimes_bdy-1) |
---|
787 | |
---|
788 | IF ( zstepr(1) - zinterval_s / 2.0 > 0 ) THEN |
---|
789 | IF(lwp) WRITE(numout,*) 'First bdy time relative to nit000:', zstepr(1) |
---|
790 | IF(lwp) WRITE(numout,*) 'Interval between first two times: ', zinterval_s |
---|
791 | CALL ctl_stop( 'First data time is after start of run', & |
---|
792 | 'by more than half a meaning period', & |
---|
793 | 'Check file: ' // TRIM(clfile(igrd)) ) |
---|
794 | END IF |
---|
795 | |
---|
796 | IF ( zstepr(ntimes_bdy) + zinterval_e / 2.0 < totime ) THEN |
---|
797 | IF(lwp) WRITE(numout,*) 'Last bdy time relative to nit000:', zstepr(ntimes_bdy) |
---|
798 | IF(lwp) WRITE(numout,*) 'Interval between last two times: ', zinterval_e |
---|
799 | CALL ctl_stop( 'Last data time is before end of run', & |
---|
800 | 'by more than half a meaning period', & |
---|
801 | 'Check file: ' // TRIM(clfile(igrd)) ) |
---|
802 | END IF |
---|
803 | |
---|
804 | END IF ! .NOT. ln_bdy_clim |
---|
805 | |
---|
806 | IF ( igrd .EQ. 1) THEN |
---|
807 | ntimes_bdyt = ntimes_bdy_bt |
---|
808 | zoffsett = zoffset |
---|
809 | istept(:) = INT( zstepr(:) + zoffset ) |
---|
810 | ELSE IF (igrd .EQ. 2) THEN |
---|
811 | ntimes_bdyu = ntimes_bdy_bt |
---|
812 | zoffsetu = zoffset |
---|
813 | istepu(:) = INT( zstepr(:) + zoffset ) |
---|
814 | ELSE IF (igrd .EQ. 3) THEN |
---|
815 | ntimes_bdyv = ntimes_bdy_bt |
---|
816 | zoffsetv = zoffset |
---|
817 | istepv(:) = INT( zstepr(:) + zoffset ) |
---|
818 | ENDIF |
---|
819 | |
---|
820 | ENDDO |
---|
821 | |
---|
822 | ! Verify time consistency between files |
---|
823 | |
---|
824 | IF ( ntimes_bdyu /= ntimes_bdyt .OR. ntimes_bdyv /= ntimes_bdyt ) THEN |
---|
825 | CALL ctl_stop( & |
---|
826 | 'Time axis lengths differ between bdy data files', & |
---|
827 | 'Multiple time frequencies not implemented yet' ) |
---|
828 | ELSE |
---|
829 | ntimes_bdy_bt = ntimes_bdyt |
---|
830 | ENDIF |
---|
831 | |
---|
832 | IF (zoffsetu.NE.zoffsett .OR. zoffsetv.NE.zoffsett) THEN |
---|
833 | CALL ctl_stop( & |
---|
834 | 'Bdy data files must have the same time origin', & |
---|
835 | 'Multiple time frequencies not implemented yet' ) |
---|
836 | ENDIF |
---|
837 | zoffset = zoffsett |
---|
838 | |
---|
839 | !! Check that times are the same in the three files... HERE. |
---|
840 | istep_bt(:) = istept(:) |
---|
841 | |
---|
842 | ! Check number of time dumps: |
---|
843 | IF (ln_bdy_clim) THEN |
---|
844 | SELECT CASE ( ntimes_bdy_bt ) |
---|
845 | CASE( 1 ) |
---|
846 | IF(lwp) WRITE(numout,*) |
---|
847 | IF(lwp) WRITE(numout,*) 'We assume constant boundary forcing from bdy data files' |
---|
848 | IF(lwp) WRITE(numout,*) |
---|
849 | CASE( 12 ) |
---|
850 | IF(lwp) WRITE(numout,*) |
---|
851 | IF(lwp) WRITE(numout,*) 'We assume monthly (and cyclic) boundary forcing from bdy data files' |
---|
852 | IF(lwp) WRITE(numout,*) |
---|
853 | CASE DEFAULT |
---|
854 | CALL ctl_stop( & |
---|
855 | 'For climatological boundary forcing (ln_bdy_clim=.true.),',& |
---|
856 | 'bdy data files must contain 1 or 12 time dumps.' ) |
---|
857 | END SELECT |
---|
858 | ENDIF |
---|
859 | |
---|
860 | ! Find index of first record to read (before first model time). |
---|
861 | |
---|
862 | it=1 |
---|
863 | DO WHILE ( ((istep_bt(it+1)) <= 0 ).AND.(it.LE.(ntimes_bdy_bt-1))) |
---|
864 | it=it+1 |
---|
865 | END DO |
---|
866 | nbdy_b_bt = it |
---|
867 | |
---|
868 | WRITE(numout,*) 'Time offset is ',zoffset |
---|
869 | WRITE(numout,*) 'First record to read is ',nbdy_b_bt |
---|
870 | |
---|
871 | ENDIF ! endif (nbdy_dta == 1) |
---|
872 | |
---|
873 | ! 1.2 Read first record in file if necessary (ie if nbdy_dta == 1) |
---|
874 | ! ***************************************************************** |
---|
875 | |
---|
876 | IF ( nbdy_dta == 0) THEN |
---|
877 | ! boundary data arrays are filled with initial conditions |
---|
878 | igrd = 2 ! U-points data |
---|
879 | DO ib = 1, nblen(igrd) |
---|
880 | ubtbdy(ib) = un(nbi(ib,igrd), nbj(ib,igrd), 1) |
---|
881 | END DO |
---|
882 | |
---|
883 | igrd = 3 ! V-points data |
---|
884 | DO ib = 1, nblen(igrd) |
---|
885 | vbtbdy(ib) = vn(nbi(ib,igrd), nbj(ib,igrd), 1) |
---|
886 | END DO |
---|
887 | |
---|
888 | igrd = 1 ! T-points data |
---|
889 | DO ib = 1, nblen(igrd) |
---|
890 | sshbdy(ib) = sshn(nbi(ib,igrd), nbj(ib,igrd)) |
---|
891 | END DO |
---|
892 | |
---|
893 | ELSEIF (nbdy_dta == 1) THEN |
---|
894 | |
---|
895 | ! Set first record in the climatological case: |
---|
896 | IF ((ln_bdy_clim).AND.(ntimes_bdy_bt==1)) THEN |
---|
897 | nbdy_a_bt = 1 |
---|
898 | ELSEIF ((ln_bdy_clim).AND.(ntimes_bdy_bt==iman)) THEN |
---|
899 | nbdy_b_bt = 0 |
---|
900 | nbdy_a_bt = imois |
---|
901 | ELSE |
---|
902 | nbdy_a_bt = nbdy_b_bt |
---|
903 | END IF |
---|
904 | |
---|
905 | ! Open Netcdf files: |
---|
906 | |
---|
907 | CALL iom_open ( filbdy_data_bt_T, numbdyt_bt ) |
---|
908 | CALL iom_open ( filbdy_data_bt_U, numbdyu_bt ) |
---|
909 | CALL iom_open ( filbdy_data_bt_V, numbdyv_bt ) |
---|
910 | |
---|
911 | ! Read first record: |
---|
912 | ipj=1 |
---|
913 | igrd=1 |
---|
914 | ipi=nblendta(igrd) |
---|
915 | |
---|
916 | ! ssh |
---|
917 | igrd=1 |
---|
918 | IF ( nblendta(igrd) .le. 0 ) THEN |
---|
919 | idvar = iom_varid( numbdyt_bt,'sossheig' ) |
---|
920 | nblendta(igrd) = iom_file(numbdyt_bt)%dimsz(1,idvar) |
---|
921 | ENDIF |
---|
922 | WRITE(numout,*) 'Dim size for sossheig is ',nblendta(igrd) |
---|
923 | ipi=nblendta(igrd) |
---|
924 | |
---|
925 | CALL iom_get ( numbdyt_bt, jpdom_unknown,'sossheig',zdta(1:ipi,1:ipj),nbdy_a_bt ) |
---|
926 | |
---|
927 | DO ib=1, nblen(igrd) |
---|
928 | sshbdydta(ib,2) = zdta(nbmap(ib,igrd),1) |
---|
929 | END DO |
---|
930 | |
---|
931 | ! u-velocity |
---|
932 | igrd=2 |
---|
933 | IF ( nblendta(igrd) .le. 0 ) THEN |
---|
934 | idvar = iom_varid( numbdyu_bt,'vobtcrtx' ) |
---|
935 | nblendta(igrd) = iom_file(numbdyu_bt)%dimsz(1,idvar) |
---|
936 | ENDIF |
---|
937 | WRITE(numout,*) 'Dim size for vobtcrtx is ',nblendta(igrd) |
---|
938 | ipi=nblendta(igrd) |
---|
939 | |
---|
940 | CALL iom_get ( numbdyu_bt, jpdom_unknown,'vobtcrtx',zdta(1:ipi,1:ipj),nbdy_a_bt ) |
---|
941 | |
---|
942 | DO ib=1, nblen(igrd) |
---|
943 | ubtbdydta(ib,2) = zdta(nbmap(ib,igrd),1) |
---|
944 | END DO |
---|
945 | |
---|
946 | ! v-velocity |
---|
947 | igrd=3 |
---|
948 | IF ( nblendta(igrd) .le. 0 ) THEN |
---|
949 | idvar = iom_varid( numbdyv_bt,'vobtcrty' ) |
---|
950 | nblendta(igrd) = iom_file(numbdyv_bt)%dimsz(1,idvar) |
---|
951 | ENDIF |
---|
952 | WRITE(numout,*) 'Dim size for vobtcrty is ',nblendta(igrd) |
---|
953 | ipi=nblendta(igrd) |
---|
954 | |
---|
955 | CALL iom_get ( numbdyv_bt, jpdom_unknown,'vobtcrty',zdta(1:ipi,1:ipj),nbdy_a_bt ) |
---|
956 | |
---|
957 | DO ib=1, nblen(igrd) |
---|
958 | vbtbdydta(ib,2) = zdta(nbmap(ib,igrd),1) |
---|
959 | END DO |
---|
960 | |
---|
961 | END IF |
---|
962 | |
---|
963 | ! In the case of constant boundary forcing fill bdy arrays once for all |
---|
964 | IF ((ln_bdy_clim).AND.(ntimes_bdy_bt==1)) THEN |
---|
965 | |
---|
966 | ubtbdy (:) = ubtbdydta (:,2) |
---|
967 | vbtbdy (:) = vbtbdydta (:,2) |
---|
968 | sshbdy (:) = sshbdydta (:,2) |
---|
969 | |
---|
970 | CALL iom_close( numbdyt_bt ) |
---|
971 | CALL iom_close( numbdyu_bt ) |
---|
972 | CALL iom_close( numbdyv_bt ) |
---|
973 | |
---|
974 | END IF |
---|
975 | |
---|
976 | ENDIF ! End if nit000 |
---|
977 | |
---|
978 | ! -------------------- ! |
---|
979 | ! 2. At each time step ! |
---|
980 | ! -------------------- ! |
---|
981 | |
---|
982 | IF ((nbdy_dta==1).AND.(ntimes_bdy_bt>1)) THEN |
---|
983 | |
---|
984 | ! 2.1 Read one more record if necessary |
---|
985 | !************************************** |
---|
986 | |
---|
987 | IF ( (ln_bdy_clim).AND.(imois/=nbdy_b_bt) ) THEN ! remember that nbdy_b_bt=0 for kt=nit000 |
---|
988 | nbdy_b_bt = imois |
---|
989 | nbdy_a_bt = imois+1 |
---|
990 | nbdy_b_bt = MOD( nbdy_b_bt, iman ) |
---|
991 | IF( nbdy_b_bt == 0 ) nbdy_b_bt = iman |
---|
992 | nbdy_a_bt = MOD( nbdy_a_bt, iman ) |
---|
993 | IF( nbdy_a_bt == 0 ) nbdy_a_bt = iman |
---|
994 | lect=.true. |
---|
995 | |
---|
996 | ELSEIF ((.NOT.ln_bdy_clim).AND.(itimer >= istep_bt(nbdy_a_bt))) THEN |
---|
997 | nbdy_b_bt=nbdy_a_bt |
---|
998 | nbdy_a_bt=nbdy_a_bt+1 |
---|
999 | lect=.true. |
---|
1000 | END IF |
---|
1001 | |
---|
1002 | IF (lect) THEN |
---|
1003 | |
---|
1004 | ! Swap arrays |
---|
1005 | sshbdydta(:,1) = sshbdydta(:,2) |
---|
1006 | ubtbdydta(:,1) = ubtbdydta(:,2) |
---|
1007 | vbtbdydta(:,1) = vbtbdydta(:,2) |
---|
1008 | |
---|
1009 | ! read another set |
---|
1010 | |
---|
1011 | ipj=1 |
---|
1012 | ipk=jpk |
---|
1013 | igrd=1 |
---|
1014 | ipi=nblendta(igrd) |
---|
1015 | |
---|
1016 | |
---|
1017 | ! ssh |
---|
1018 | igrd=1 |
---|
1019 | ipi=nblendta(igrd) |
---|
1020 | |
---|
1021 | CALL iom_get ( numbdyt_bt, jpdom_unknown,'sossheig',zdta(1:ipi,1:ipj),nbdy_a_bt ) |
---|
1022 | |
---|
1023 | DO ib=1, nblen(igrd) |
---|
1024 | sshbdydta(ib,2) = zdta(nbmap(ib,igrd),1) |
---|
1025 | END DO |
---|
1026 | |
---|
1027 | ! u-velocity |
---|
1028 | igrd=2 |
---|
1029 | ipi=nblendta(igrd) |
---|
1030 | |
---|
1031 | CALL iom_get ( numbdyu_bt, jpdom_unknown,'vobtcrtx',zdta(1:ipi,1:ipj),nbdy_a_bt ) |
---|
1032 | |
---|
1033 | DO ib=1, nblen(igrd) |
---|
1034 | ubtbdydta(ib,2) = zdta(nbmap(ib,igrd),1) |
---|
1035 | END DO |
---|
1036 | |
---|
1037 | ! v-velocity |
---|
1038 | igrd=3 |
---|
1039 | ipi=nblendta(igrd) |
---|
1040 | |
---|
1041 | CALL iom_get ( numbdyv_bt, jpdom_unknown,'vobtcrty',zdta(1:ipi,1:ipj),nbdy_a_bt ) |
---|
1042 | |
---|
1043 | DO ib=1, nblen(igrd) |
---|
1044 | vbtbdydta(ib,2) = zdta(nbmap(ib,igrd),1) |
---|
1045 | END DO |
---|
1046 | |
---|
1047 | |
---|
1048 | IF(lwp) WRITE(numout,*) 'bdy_dta : first record file used nbdy_b_bt ',nbdy_b_bt |
---|
1049 | IF(lwp) WRITE(numout,*) '~~~~~~~~ last record file used nbdy_a_bt ',nbdy_a_bt |
---|
1050 | IF (.NOT.ln_bdy_clim) THEN |
---|
1051 | IF(lwp) WRITE(numout,*) 'first record time (s): ', istep_bt(nbdy_b_bt) |
---|
1052 | IF(lwp) WRITE(numout,*) 'model time (s) : ', itimer |
---|
1053 | IF(lwp) WRITE(numout,*) 'second record time (s): ', istep_bt(nbdy_a_bt) |
---|
1054 | ENDIF |
---|
1055 | END IF ! end lect=.true. |
---|
1056 | |
---|
1057 | |
---|
1058 | ! 2.2 Interpolate linearly: |
---|
1059 | ! *************************** |
---|
1060 | |
---|
1061 | IF (ln_bdy_clim) THEN |
---|
1062 | zxy = FLOAT( nday ) / FLOAT( nobis(nbdy_b_bt) ) + 0.5 - i15 |
---|
1063 | ELSE |
---|
1064 | zxy = FLOAT(istep_bt(nbdy_b_bt)-itimer) / FLOAT(istep_bt(nbdy_b_bt)-istep_bt(nbdy_a_bt)) |
---|
1065 | END IF |
---|
1066 | |
---|
1067 | igrd=1 |
---|
1068 | DO ib=1, nblen(igrd) |
---|
1069 | sshbdy(ib) = zxy * sshbdydta(ib,2) + & |
---|
1070 | (1.-zxy) * sshbdydta(ib,1) |
---|
1071 | END DO |
---|
1072 | |
---|
1073 | igrd=2 |
---|
1074 | DO ib=1, nblen(igrd) |
---|
1075 | ubtbdy(ib) = zxy * ubtbdydta(ib,2) + & |
---|
1076 | (1.-zxy) * ubtbdydta(ib,1) |
---|
1077 | END DO |
---|
1078 | |
---|
1079 | igrd=3 |
---|
1080 | DO ib=1, nblen(igrd) |
---|
1081 | vbtbdy(ib) = zxy * vbtbdydta(ib,2) + & |
---|
1082 | (1.-zxy) * vbtbdydta(ib,1) |
---|
1083 | END DO |
---|
1084 | |
---|
1085 | |
---|
1086 | END IF !end if ((nbdy_dta==1).AND.(ntimes_bdy_bt>1)) |
---|
1087 | |
---|
1088 | ! ------------------- ! |
---|
1089 | ! Last call kt=nitend ! |
---|
1090 | ! ------------------- ! |
---|
1091 | |
---|
1092 | ! Closing of the 3 files |
---|
1093 | IF( kt == nitend ) THEN |
---|
1094 | CALL iom_close( numbdyt_bt ) |
---|
1095 | CALL iom_close( numbdyu_bt ) |
---|
1096 | CALL iom_close( numbdyv_bt ) |
---|
1097 | ENDIF |
---|
1098 | |
---|
1099 | ENDIF ! ln_bdy_dyn_frs |
---|
1100 | |
---|
1101 | END SUBROUTINE bdy_dta_bt |
---|
1102 | |
---|
1103 | |
---|
1104 | #else |
---|
1105 | !!---------------------------------------------------------------------- |
---|
1106 | !! Dummy module NO Unstruct Open Boundary Conditions |
---|
1107 | !!---------------------------------------------------------------------- |
---|
1108 | CONTAINS |
---|
1109 | SUBROUTINE bdy_dta( kt ) ! Empty routine |
---|
1110 | WRITE(*,*) 'bdy_dta: You should not have seen this print! error?', kt |
---|
1111 | END SUBROUTINE bdy_dta |
---|
1112 | SUBROUTINE bdy_dta_bt( kt, kit ) ! Empty routine |
---|
1113 | WRITE(*,*) 'bdy_dta: You should not have seen this print! error?', kt, kit |
---|
1114 | END SUBROUTINE bdy_dta_bt |
---|
1115 | #endif |
---|
1116 | |
---|
1117 | !!============================================================================== |
---|
1118 | END MODULE bdydta |
---|