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