bdydta.F90 40 KB

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