1 | MODULE sbcwave |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE sbcwave *** |
---|
4 | !! Wave module |
---|
5 | !!====================================================================== |
---|
6 | !! History : 3.3 ! 2011-09 (M. Adani) Original code: Drag Coefficient |
---|
7 | !! : 3.4 ! 2012-10 (M. Adani) Stokes Drift |
---|
8 | !! 3.6 ! 2014-09 (E. Clementi,P. Oddo) New Stokes Drift Computation |
---|
9 | !! - ! 2016-12 (G. Madec, E. Clementi) update Stoke drift computation |
---|
10 | !! + add sbc_wave_ini routine |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | !! sbc_stokes : calculate 3D Stokes-drift velocities |
---|
15 | !! sbc_wave : wave data from wave model in netcdf files |
---|
16 | !! sbc_wave_init : initialisation fo surface waves |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | USE phycst ! physical constants |
---|
19 | USE oce ! ocean variables |
---|
20 | USE sbc_oce ! Surface boundary condition: ocean fields |
---|
21 | USE zdf_oce, ONLY : ln_zdfswm |
---|
22 | USE bdy_oce ! open boundary condition variables |
---|
23 | USE domvvl ! domain: variable volume layers |
---|
24 | ! |
---|
25 | USE iom ! I/O manager library |
---|
26 | USE in_out_manager ! I/O manager |
---|
27 | USE lib_mpp ! distribued memory computing library |
---|
28 | USE fldread ! read input fields |
---|
29 | USE wrk_nemo ! |
---|
30 | |
---|
31 | IMPLICIT NONE |
---|
32 | PRIVATE |
---|
33 | |
---|
34 | PUBLIC sbc_stokes ! routine called in sbccpl |
---|
35 | PUBLIC sbc_wstress ! routine called in sbcmod |
---|
36 | PUBLIC sbc_wave ! routine called in sbcmod |
---|
37 | PUBLIC sbc_wave_init ! routine called in sbcmod |
---|
38 | |
---|
39 | ! Variables checking if the wave parameters are coupled (if not, they are read from file) |
---|
40 | LOGICAL, PUBLIC :: cpl_hsig = .FALSE. |
---|
41 | LOGICAL, PUBLIC :: cpl_phioc = .FALSE. |
---|
42 | LOGICAL, PUBLIC :: cpl_sdrftx = .FALSE. |
---|
43 | LOGICAL, PUBLIC :: cpl_sdrfty = .FALSE. |
---|
44 | LOGICAL, PUBLIC :: cpl_wper = .FALSE. |
---|
45 | LOGICAL, PUBLIC :: cpl_wfreq = .FALSE. |
---|
46 | LOGICAL, PUBLIC :: cpl_wnum = .FALSE. |
---|
47 | LOGICAL, PUBLIC :: cpl_tauoc = .FALSE. |
---|
48 | LOGICAL, PUBLIC :: cpl_tauw = .FALSE. |
---|
49 | LOGICAL, PUBLIC :: cpl_wdrag = .FALSE. |
---|
50 | |
---|
51 | INTEGER :: jpfld ! number of files to read for stokes drift |
---|
52 | INTEGER :: jp_usd ! index of stokes drift (i-component) (m/s) at T-point |
---|
53 | INTEGER :: jp_vsd ! index of stokes drift (j-component) (m/s) at T-point |
---|
54 | INTEGER :: jp_hsw ! index of significant wave hight (m) at T-point |
---|
55 | INTEGER :: jp_wmp ! index of mean wave period (s) at T-point |
---|
56 | INTEGER :: jp_wfr ! index of wave peak frequency (1/s) at T-point |
---|
57 | |
---|
58 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_cd ! structure of input fields (file informations, fields read) Drag Coefficient |
---|
59 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_sd ! structure of input fields (file informations, fields read) Stokes Drift |
---|
60 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_wn ! structure of input fields (file informations, fields read) wave number for Qiao |
---|
61 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_tauoc ! structure of input fields (file informations, fields read) normalized wave stress into the ocean |
---|
62 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_tauw ! structure of input fields (file informations, fields read) ocean stress components from wave model |
---|
63 | |
---|
64 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: cdn_wave !: |
---|
65 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: hsw, wmp, wnum !: |
---|
66 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: wfreq !: |
---|
67 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: tauoc_wave !: |
---|
68 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: tauw_x, tauw_y !: |
---|
69 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: tsd2d !: |
---|
70 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: div_sd !: barotropic stokes drift divergence |
---|
71 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: ut0sd, vt0sd !: surface Stokes drift velocities at t-point |
---|
72 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:) :: usd , vsd , wsd !: Stokes drift velocities at u-, v- & w-points, resp. |
---|
73 | |
---|
74 | !! * Substitutions |
---|
75 | # include "vectopt_loop_substitute.h90" |
---|
76 | !!---------------------------------------------------------------------- |
---|
77 | !! NEMO/OPA 3.7 , NEMO Consortium (2014) |
---|
78 | !! $Id$ |
---|
79 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
80 | !!---------------------------------------------------------------------- |
---|
81 | CONTAINS |
---|
82 | |
---|
83 | SUBROUTINE sbc_stokes( ) |
---|
84 | !!--------------------------------------------------------------------- |
---|
85 | !! *** ROUTINE sbc_stokes *** |
---|
86 | !! |
---|
87 | !! ** Purpose : compute the 3d Stokes Drift according to Breivik et al., |
---|
88 | !! 2014 (DOI: 10.1175/JPO-D-14-0020.1) |
---|
89 | !! |
---|
90 | !! ** Method : - Calculate Stokes transport speed |
---|
91 | !! - Calculate horizontal divergence |
---|
92 | !! - Integrate the horizontal divergenze from the bottom |
---|
93 | !! ** action |
---|
94 | !!--------------------------------------------------------------------- |
---|
95 | INTEGER :: jj, ji, jk ! dummy loop argument |
---|
96 | INTEGER :: ik ! local integer |
---|
97 | REAL(wp) :: ztransp, zfac, zsp0 |
---|
98 | REAL(wp) :: zdepth, zsqrt_depth, zexp_depth, z_two_thirds, zsqrtpi !sqrt of pi |
---|
99 | REAL(wp) :: zbot_u, zbot_v, zkb_u, zkb_v, zke3_u, zke3_v, zda_u, zda_v |
---|
100 | REAL(wp) :: zstokes_psi_u_bot, zstokes_psi_v_bot |
---|
101 | REAL(wp) :: zdep_u, zdep_v, zkh_u, zkh_v |
---|
102 | REAL(wp), DIMENSION(:,:) , POINTER :: zk_t, zk_u, zk_v, zu0_sd, zv0_sd ! 2D workspace |
---|
103 | REAL(wp), DIMENSION(:,:) , POINTER :: zstokes_psi_u_top, zstokes_psi_v_top ! 2D workspace |
---|
104 | REAL(wp), DIMENSION(:,:,:), POINTER :: ze3divh ! 3D workspace |
---|
105 | !!--------------------------------------------------------------------- |
---|
106 | ! |
---|
107 | CALL wrk_alloc( jpi,jpj,jpk, ze3divh ) |
---|
108 | CALL wrk_alloc( jpi,jpj, zk_t, zk_u, zk_v, zu0_sd, zv0_sd ) |
---|
109 | CALL wrk_alloc( jpi,jpj, zstokes_psi_u_top, zstokes_psi_v_top) |
---|
110 | ! |
---|
111 | ! select parameterization for the calculation of vertical Stokes drift |
---|
112 | ! exp. wave number at t-point |
---|
113 | IF( nn_sdrift==jp_breivik .OR. nn_sdrift==jp_phillips ) THEN ! (Eq. (19) in Breivick et al. (2014) ) |
---|
114 | zfac = 2.0_wp * rpi / 16.0_wp |
---|
115 | DO jj = 1, jpj |
---|
116 | DO ji = 1, jpi |
---|
117 | ! Stokes drift velocity estimated from Hs and Tmean |
---|
118 | ztransp = zfac * hsw(ji,jj)*hsw(ji,jj) / MAX( wmp(ji,jj), 0.0000001_wp ) |
---|
119 | ! Stokes surface speed |
---|
120 | tsd2d(ji,jj) = SQRT( ut0sd(ji,jj)*ut0sd(ji,jj) + vt0sd(ji,jj)*vt0sd(ji,jj)) |
---|
121 | ! Wavenumber scale |
---|
122 | zk_t(ji,jj) = ABS( tsd2d(ji,jj) ) / MAX( ABS( 5.97_wp*ztransp ), 0.0000001_wp ) |
---|
123 | END DO |
---|
124 | END DO |
---|
125 | DO jj = 1, jpjm1 ! exp. wave number & Stokes drift velocity at u- & v-points |
---|
126 | DO ji = 1, jpim1 |
---|
127 | zk_u(ji,jj) = 0.5_wp * ( zk_t(ji,jj) + zk_t(ji+1,jj) ) |
---|
128 | zk_v(ji,jj) = 0.5_wp * ( zk_t(ji,jj) + zk_t(ji,jj+1) ) |
---|
129 | ! |
---|
130 | zu0_sd(ji,jj) = 0.5_wp * ( ut0sd(ji,jj) + ut0sd(ji+1,jj) ) |
---|
131 | zv0_sd(ji,jj) = 0.5_wp * ( vt0sd(ji,jj) + vt0sd(ji,jj+1) ) |
---|
132 | END DO |
---|
133 | END DO |
---|
134 | ELSE IF( nn_sdrift==jp_peakfr ) THEN ! peak wave number calculated from the peak frequency received by the wave model |
---|
135 | DO jj = 1, jpjm1 |
---|
136 | DO ji = 1, jpim1 |
---|
137 | zk_u(ji,jj) = 0.5_wp * ( wfreq(ji,jj)*wfreq(ji,jj) + wfreq(ji+1,jj)*wfreq(ji+1,jj) ) / grav |
---|
138 | zk_v(ji,jj) = 0.5_wp * ( wfreq(ji,jj)*wfreq(ji,jj) + wfreq(ji,jj+1)*wfreq(ji,jj+1) ) / grav |
---|
139 | ! |
---|
140 | zu0_sd(ji,jj) = 0.5_wp * ( ut0sd(ji,jj) + ut0sd(ji+1,jj) ) |
---|
141 | zv0_sd(ji,jj) = 0.5_wp * ( vt0sd(ji,jj) + vt0sd(ji,jj+1) ) |
---|
142 | END DO |
---|
143 | END DO |
---|
144 | ENDIF |
---|
145 | ! |
---|
146 | ! !== horizontal Stokes Drift 3D velocity ==! |
---|
147 | IF( nn_sdrift==jp_breivik ) THEN |
---|
148 | DO jk = 1, jpkm1 |
---|
149 | DO jj = 2, jpjm1 |
---|
150 | DO ji = 2, jpim1 |
---|
151 | zdep_u = 0.5_wp * ( gdept_n(ji,jj,jk) + gdept_n(ji+1,jj,jk) ) |
---|
152 | zdep_v = 0.5_wp * ( gdept_n(ji,jj,jk) + gdept_n(ji,jj+1,jk) ) |
---|
153 | ! |
---|
154 | zkh_u = zk_u(ji,jj) * zdep_u ! k * depth |
---|
155 | zkh_v = zk_v(ji,jj) * zdep_v |
---|
156 | ! ! Depth attenuation |
---|
157 | zda_u = EXP( -2.0_wp*zkh_u ) / ( 1.0_wp + 8.0_wp*zkh_u ) |
---|
158 | zda_v = EXP( -2.0_wp*zkh_v ) / ( 1.0_wp + 8.0_wp*zkh_v ) |
---|
159 | ! |
---|
160 | usd(ji,jj,jk) = zda_u * zu0_sd(ji,jj) * umask(ji,jj,jk) |
---|
161 | vsd(ji,jj,jk) = zda_v * zv0_sd(ji,jj) * vmask(ji,jj,jk) |
---|
162 | END DO |
---|
163 | END DO |
---|
164 | END DO |
---|
165 | ELSE IF( nn_sdrift==jp_phillips .OR. nn_sdrift==jp_peakfr ) THEN |
---|
166 | DO jk = 1, jpkm1 |
---|
167 | DO jj = 2, jpjm1 |
---|
168 | DO ji = 2, jpim1 |
---|
169 | zdep_u = 0.5_wp * ( gdept_n(ji,jj,jk) + gdept_n(ji+1,jj,jk) ) |
---|
170 | zdep_v = 0.5_wp * ( gdept_n(ji,jj,jk) + gdept_n(ji,jj+1,jk) ) |
---|
171 | ! |
---|
172 | zkh_u = zk_u(ji,jj) * zdep_u ! k * depth |
---|
173 | zkh_v = zk_v(ji,jj) * zdep_v |
---|
174 | ! ! Depth attenuation |
---|
175 | zda_u = EXP( -2.0_wp*zkh_u ) - SQRT(2.0_wp*rpi*zkh_u) * ERFC(SQRT(2.0_wp*zkh_u)) |
---|
176 | zda_v = EXP( -2.0_wp*zkh_v ) - SQRT(2.0_wp*rpi*zkh_v) * ERFC(SQRT(2.0_wp*zkh_v)) |
---|
177 | ! |
---|
178 | usd(ji,jj,jk) = zda_u * zu0_sd(ji,jj) * umask(ji,jj,jk) |
---|
179 | vsd(ji,jj,jk) = zda_v * zv0_sd(ji,jj) * vmask(ji,jj,jk) |
---|
180 | END DO |
---|
181 | END DO |
---|
182 | END DO |
---|
183 | ENDIF |
---|
184 | |
---|
185 | CALL lbc_lnk( usd(:,:,:), 'U', -1. ) |
---|
186 | CALL lbc_lnk( vsd(:,:,:), 'V', -1. ) |
---|
187 | |
---|
188 | |
---|
189 | ! |
---|
190 | ! !== vertical Stokes Drift 3D velocity ==! |
---|
191 | ! |
---|
192 | DO jk = 1, jpkm1 ! Horizontal e3*divergence |
---|
193 | DO jj = 2, jpj |
---|
194 | DO ji = fs_2, jpi |
---|
195 | ze3divh(ji,jj,jk) = ( e2u(ji ,jj) * e3u_n(ji ,jj,jk) * usd(ji ,jj,jk) & |
---|
196 | & - e2u(ji-1,jj) * e3u_n(ji-1,jj,jk) * usd(ji-1,jj,jk) & |
---|
197 | & + e1v(ji,jj ) * e3v_n(ji,jj ,jk) * vsd(ji,jj ,jk) & |
---|
198 | & - e1v(ji,jj-1) * e3v_n(ji,jj-1,jk) * vsd(ji,jj-1,jk) ) * r1_e1e2t(ji,jj) |
---|
199 | END DO |
---|
200 | END DO |
---|
201 | END DO |
---|
202 | ! |
---|
203 | #if defined key_agrif |
---|
204 | IF( .NOT. Agrif_Root() ) THEN |
---|
205 | IF( nbondi == -1 .OR. nbondi == 2 ) ze3divh( 2:nbghostcells+1,: ,:) = 0._wp ! west |
---|
206 | IF( nbondi == 1 .OR. nbondi == 2 ) ze3divh( nlci-nbghostcells:nlci-1,:,:) = 0._wp ! east |
---|
207 | IF( nbondj == -1 .OR. nbondj == 2 ) ze3divh( :,2:nbghostcells+1 ,:) = 0._wp ! south |
---|
208 | IF( nbondj == 1 .OR. nbondj == 2 ) ze3divh( :,nlcj-nbghostcells:nlcj-1,:) = 0._wp ! north |
---|
209 | ENDIF |
---|
210 | #endif |
---|
211 | ! |
---|
212 | CALL lbc_lnk( ze3divh, 'T', 1. ) |
---|
213 | ! |
---|
214 | IF( ln_linssh ) THEN ; ik = 1 ! none zero velocity through the sea surface |
---|
215 | ELSE ; ik = 2 ! w=0 at the surface (set one for all in sbc_wave_init) |
---|
216 | ENDIF |
---|
217 | DO jk = jpkm1, ik, -1 ! integrate from the bottom the hor. divergence (NB: at k=jpk w is always zero) |
---|
218 | wsd(:,:,jk) = wsd(:,:,jk+1) - ze3divh(:,:,jk) |
---|
219 | END DO |
---|
220 | ! |
---|
221 | IF( ln_bdy ) THEN |
---|
222 | DO jk = 1, jpkm1 |
---|
223 | wsd(:,:,jk) = wsd(:,:,jk) * bdytmask(:,:) |
---|
224 | END DO |
---|
225 | ENDIF |
---|
226 | ! !== Horizontal divergence of barotropic Stokes transport ==! |
---|
227 | div_sd(:,:) = 0._wp |
---|
228 | DO jk = 1, jpkm1 ! |
---|
229 | div_sd(:,:) = div_sd(:,:) + ze3divh(:,:,jk) |
---|
230 | END DO |
---|
231 | ! |
---|
232 | CALL iom_put( "ustokes", usd ) |
---|
233 | CALL iom_put( "vstokes", vsd ) |
---|
234 | CALL iom_put( "wstokes", wsd ) |
---|
235 | ! |
---|
236 | CALL wrk_dealloc( jpi,jpj,jpk, ze3divh ) |
---|
237 | CALL wrk_dealloc( jpi,jpj, zk_t, zk_u, zk_v, zu0_sd, zv0_sd ) |
---|
238 | CALL wrk_dealloc( jpi,jpj, zstokes_psi_u_top, zstokes_psi_v_top) |
---|
239 | ! |
---|
240 | END SUBROUTINE sbc_stokes |
---|
241 | |
---|
242 | |
---|
243 | SUBROUTINE sbc_wstress( ) |
---|
244 | !!--------------------------------------------------------------------- |
---|
245 | !! *** ROUTINE sbc_wstress *** |
---|
246 | !! |
---|
247 | !! ** Purpose : Updates the ocean momentum modified by waves |
---|
248 | !! |
---|
249 | !! ** Method : - Calculate u,v components of stress depending on stress |
---|
250 | !! model |
---|
251 | !! - Calculate the stress module |
---|
252 | !! - The wind module is not modified by waves |
---|
253 | !! ** action |
---|
254 | !!--------------------------------------------------------------------- |
---|
255 | INTEGER :: jj, ji ! dummy loop argument |
---|
256 | ! |
---|
257 | IF( ln_tauoc ) THEN |
---|
258 | utau(:,:) = utau(:,:)*tauoc_wave(:,:) |
---|
259 | vtau(:,:) = vtau(:,:)*tauoc_wave(:,:) |
---|
260 | taum(:,:) = taum(:,:)*tauoc_wave(:,:) |
---|
261 | ENDIF |
---|
262 | ! |
---|
263 | IF( ln_tauw ) THEN |
---|
264 | DO jj = 1, jpjm1 |
---|
265 | DO ji = 1, jpim1 |
---|
266 | ! Stress components at u- & v-points |
---|
267 | utau(ji,jj) = 0.5_wp * ( tauw_x(ji,jj) + tauw_x(ji+1,jj) ) |
---|
268 | vtau(ji,jj) = 0.5_wp * ( tauw_y(ji,jj) + tauw_y(ji,jj+1) ) |
---|
269 | ! |
---|
270 | ! Stress module at t points |
---|
271 | taum(ji,jj) = SQRT( tauw_x(ji,jj)*tauw_x(ji,jj) + tauw_y(ji,jj)*tauw_y(ji,jj) ) |
---|
272 | END DO |
---|
273 | END DO |
---|
274 | CALL lbc_lnk_multi( utau(:,:), 'U', -1. , vtau(:,:), 'V', -1. , taum(:,:) , 'T', -1. ) |
---|
275 | ENDIF |
---|
276 | ! |
---|
277 | END SUBROUTINE sbc_wstress |
---|
278 | |
---|
279 | |
---|
280 | SUBROUTINE sbc_wave( kt ) |
---|
281 | !!--------------------------------------------------------------------- |
---|
282 | !! *** ROUTINE sbc_wave *** |
---|
283 | !! |
---|
284 | !! ** Purpose : read wave parameters from wave model in netcdf files. |
---|
285 | !! |
---|
286 | !! ** Method : - Read namelist namsbc_wave |
---|
287 | !! - Read Cd_n10 fields in netcdf files |
---|
288 | !! - Read stokes drift 2d in netcdf files |
---|
289 | !! - Read wave number in netcdf files |
---|
290 | !! - Compute 3d stokes drift using Breivik et al.,2014 |
---|
291 | !! formulation |
---|
292 | !! ** action |
---|
293 | !!--------------------------------------------------------------------- |
---|
294 | INTEGER, INTENT(in ) :: kt ! ocean time step |
---|
295 | !!--------------------------------------------------------------------- |
---|
296 | ! |
---|
297 | IF( ln_cdgw .AND. .NOT. cpl_wdrag ) THEN !== Neutral drag coefficient ==! |
---|
298 | CALL fld_read( kt, nn_fsbc, sf_cd ) ! read from external forcing |
---|
299 | cdn_wave(:,:) = sf_cd(1)%fnow(:,:,1) |
---|
300 | ENDIF |
---|
301 | |
---|
302 | IF( ln_tauoc .AND. .NOT. cpl_tauoc ) THEN !== Wave induced stress ==! |
---|
303 | CALL fld_read( kt, nn_fsbc, sf_tauoc ) ! read wave norm stress from external forcing |
---|
304 | tauoc_wave(:,:) = sf_tauoc(1)%fnow(:,:,1) |
---|
305 | ENDIF |
---|
306 | |
---|
307 | IF( ln_tauw .AND. .NOT. cpl_tauw ) THEN !== Wave induced stress ==! |
---|
308 | CALL fld_read( kt, nn_fsbc, sf_tauw ) ! read ocean stress components from external forcing (T grid) |
---|
309 | tauw_x(:,:) = sf_tauw(1)%fnow(:,:,1) |
---|
310 | tauw_y(:,:) = sf_tauw(2)%fnow(:,:,1) |
---|
311 | ENDIF |
---|
312 | |
---|
313 | IF( ln_sdw ) THEN !== Computation of the 3d Stokes Drift ==! |
---|
314 | ! |
---|
315 | IF( jpfld > 0 ) THEN ! Read from file only if the field is not coupled |
---|
316 | CALL fld_read( kt, nn_fsbc, sf_sd ) ! read wave parameters from external forcing |
---|
317 | IF( jp_hsw > 0 ) hsw (:,:) = sf_sd(jp_hsw)%fnow(:,:,1) ! significant wave height |
---|
318 | IF( jp_wmp > 0 ) wmp (:,:) = sf_sd(jp_wmp)%fnow(:,:,1) ! wave mean period |
---|
319 | IF( jp_wfr > 0 ) wfreq(:,:) = sf_sd(jp_wfr)%fnow(:,:,1) ! Peak wave frequency |
---|
320 | IF( jp_usd > 0 ) ut0sd(:,:) = sf_sd(jp_usd)%fnow(:,:,1) ! 2D zonal Stokes Drift at T point |
---|
321 | IF( jp_vsd > 0 ) vt0sd(:,:) = sf_sd(jp_vsd)%fnow(:,:,1) ! 2D meridional Stokes Drift at T point |
---|
322 | ENDIF |
---|
323 | ! |
---|
324 | ! Read also wave number if needed, so that it is available in coupling routines |
---|
325 | IF( ln_zdfswm .AND. .NOT.cpl_wnum ) THEN |
---|
326 | CALL fld_read( kt, nn_fsbc, sf_wn ) ! read wave parameters from external forcing |
---|
327 | wnum(:,:) = sf_wn(1)%fnow(:,:,1) |
---|
328 | ENDIF |
---|
329 | |
---|
330 | ! !== Computation of the 3d Stokes Drift ==! |
---|
331 | ! |
---|
332 | IF( ((nn_sdrift==jp_breivik .OR. nn_sdrift==jp_phillips) .AND. & |
---|
333 | jp_hsw>0 .AND. jp_wmp>0 .AND. jp_usd>0 .AND. jp_vsd>0) .OR. & |
---|
334 | (nn_sdrift==jp_peakfr .AND. jp_wfr>0 .AND. jp_usd>0 .AND. jp_vsd>0) ) & |
---|
335 | CALL sbc_stokes() ! Calculate only if required fields are read |
---|
336 | ! ! In coupled wave model-NEMO case the call is done after coupling |
---|
337 | ! |
---|
338 | ENDIF |
---|
339 | ! |
---|
340 | END SUBROUTINE sbc_wave |
---|
341 | |
---|
342 | |
---|
343 | SUBROUTINE sbc_wave_init |
---|
344 | !!--------------------------------------------------------------------- |
---|
345 | !! *** ROUTINE sbc_wave_init *** |
---|
346 | !! |
---|
347 | !! ** Purpose : read wave parameters from wave model in netcdf files. |
---|
348 | !! |
---|
349 | !! ** Method : - Read namelist namsbc_wave |
---|
350 | !! - Read Cd_n10 fields in netcdf files |
---|
351 | !! - Read stokes drift 2d in netcdf files |
---|
352 | !! - Read wave number in netcdf files |
---|
353 | !! - Compute 3d stokes drift using Breivik et al.,2014 |
---|
354 | !! formulation |
---|
355 | !! ** action |
---|
356 | !!--------------------------------------------------------------------- |
---|
357 | INTEGER :: ierror, ios ! local integer |
---|
358 | INTEGER :: ifpr |
---|
359 | !! |
---|
360 | CHARACTER(len=100) :: cn_dir ! Root directory for location of drag coefficient files |
---|
361 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_i, slf_j ! array of namelist informations on the fields to read |
---|
362 | TYPE(FLD_N) :: sn_cdg, sn_usd, sn_vsd, & |
---|
363 | & sn_hsw, sn_wmp, sn_wfr, sn_wnum, & |
---|
364 | & sn_tauoc, sn_tauwx, sn_tauwy ! informations about the fields to be read |
---|
365 | ! |
---|
366 | NAMELIST/namsbc_wave/ sn_cdg, cn_dir, sn_usd, sn_vsd, sn_hsw, sn_wmp, sn_wfr, & |
---|
367 | sn_wnum, sn_tauoc, sn_tauwx, sn_tauwy |
---|
368 | !!--------------------------------------------------------------------- |
---|
369 | ! |
---|
370 | REWIND( numnam_ref ) ! Namelist namsbc_wave in reference namelist : File for drag coeff. from wave model |
---|
371 | READ ( numnam_ref, namsbc_wave, IOSTAT = ios, ERR = 901) |
---|
372 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_wave in reference namelist', lwp ) |
---|
373 | |
---|
374 | REWIND( numnam_cfg ) ! Namelist namsbc_wave in configuration namelist : File for drag coeff. from wave model |
---|
375 | READ ( numnam_cfg, namsbc_wave, IOSTAT = ios, ERR = 902 ) |
---|
376 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_wave in configuration namelist', lwp ) |
---|
377 | IF(lwm) WRITE ( numond, namsbc_wave ) |
---|
378 | ! |
---|
379 | IF( ln_cdgw ) THEN |
---|
380 | IF( .NOT. cpl_wdrag ) THEN |
---|
381 | ALLOCATE( sf_cd(1), STAT=ierror ) !* allocate and fill sf_wave with sn_cdg |
---|
382 | IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave_init: unable to allocate sf_wave structure' ) |
---|
383 | ! |
---|
384 | ALLOCATE( sf_cd(1)%fnow(jpi,jpj,1) ) |
---|
385 | IF( sn_cdg%ln_tint ) ALLOCATE( sf_cd(1)%fdta(jpi,jpj,1,2) ) |
---|
386 | CALL fld_fill( sf_cd, (/ sn_cdg /), cn_dir, 'sbc_wave_init', 'Wave module ', 'namsbc_wave' ) |
---|
387 | ENDIF |
---|
388 | ALLOCATE( cdn_wave(jpi,jpj) ) |
---|
389 | ENDIF |
---|
390 | |
---|
391 | IF( ln_tauoc ) THEN |
---|
392 | IF( .NOT. cpl_tauoc ) THEN |
---|
393 | ALLOCATE( sf_tauoc(1), STAT=ierror ) !* allocate and fill sf_wave with sn_tauoc |
---|
394 | IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave_init: unable to allocate sf_wave structure' ) |
---|
395 | ! |
---|
396 | ALLOCATE( sf_tauoc(1)%fnow(jpi,jpj,1) ) |
---|
397 | IF( sn_tauoc%ln_tint ) ALLOCATE( sf_tauoc(1)%fdta(jpi,jpj,1,2) ) |
---|
398 | CALL fld_fill( sf_tauoc, (/ sn_tauoc /), cn_dir, 'sbc_wave_init', 'Wave module', 'namsbc_wave' ) |
---|
399 | ENDIF |
---|
400 | ALLOCATE( tauoc_wave(jpi,jpj) ) |
---|
401 | ENDIF |
---|
402 | |
---|
403 | IF( ln_tauw ) THEN |
---|
404 | IF( .NOT. cpl_tauw ) THEN |
---|
405 | ALLOCATE( sf_tauw(2), STAT=ierror ) !* allocate and fill sf_wave with sn_tauwx/y |
---|
406 | IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave_init: unable to allocate sf_tauw structure' ) |
---|
407 | ! |
---|
408 | ALLOCATE( slf_j(2) ) |
---|
409 | slf_j(1) = sn_tauwx |
---|
410 | slf_j(2) = sn_tauwy |
---|
411 | ALLOCATE( sf_tauw(1)%fnow(jpi,jpj,1) ) |
---|
412 | ALLOCATE( sf_tauw(2)%fnow(jpi,jpj,1) ) |
---|
413 | IF( slf_j(1)%ln_tint ) ALLOCATE( sf_tauw(1)%fdta(jpi,jpj,1,2) ) |
---|
414 | IF( slf_j(2)%ln_tint ) ALLOCATE( sf_tauw(2)%fdta(jpi,jpj,1,2) ) |
---|
415 | CALL fld_fill( sf_tauw, (/ slf_j /), cn_dir, 'sbc_wave_init', 'read wave input', 'namsbc_wave' ) |
---|
416 | ENDIF |
---|
417 | ALLOCATE( tauw_x(jpi,jpj) ) |
---|
418 | ALLOCATE( tauw_y(jpi,jpj) ) |
---|
419 | ENDIF |
---|
420 | |
---|
421 | IF( ln_sdw ) THEN ! Find out how many fields have to be read from file if not coupled |
---|
422 | jpfld=0 |
---|
423 | jp_usd=0 ; jp_vsd=0 ; jp_hsw=0 ; jp_wmp=0 ; jp_wfr=0 |
---|
424 | IF( .NOT. cpl_sdrftx ) THEN |
---|
425 | jpfld = jpfld + 1 |
---|
426 | jp_usd = jpfld |
---|
427 | ENDIF |
---|
428 | IF( .NOT. cpl_sdrfty ) THEN |
---|
429 | jpfld = jpfld + 1 |
---|
430 | jp_vsd = jpfld |
---|
431 | ENDIF |
---|
432 | IF( .NOT. cpl_hsig .AND. (nn_sdrift==jp_breivik .OR. nn_sdrift==jp_phillips) ) THEN |
---|
433 | jpfld = jpfld + 1 |
---|
434 | jp_hsw = jpfld |
---|
435 | ENDIF |
---|
436 | IF( .NOT. cpl_wper .AND. (nn_sdrift==jp_breivik .OR. nn_sdrift==jp_phillips) ) THEN |
---|
437 | jpfld = jpfld + 1 |
---|
438 | jp_wmp = jpfld |
---|
439 | ENDIF |
---|
440 | IF( .NOT. cpl_wfreq .AND. nn_sdrift==jp_peakfr ) THEN |
---|
441 | jpfld = jpfld + 1 |
---|
442 | jp_wfr = jpfld |
---|
443 | ENDIF |
---|
444 | |
---|
445 | ! Read from file only the non-coupled fields |
---|
446 | IF( jpfld > 0 ) THEN |
---|
447 | ALLOCATE( slf_i(jpfld) ) |
---|
448 | IF( jp_usd > 0 ) slf_i(jp_usd) = sn_usd |
---|
449 | IF( jp_vsd > 0 ) slf_i(jp_vsd) = sn_vsd |
---|
450 | IF( jp_hsw > 0 ) slf_i(jp_hsw) = sn_hsw |
---|
451 | IF( jp_wmp > 0 ) slf_i(jp_wmp) = sn_wmp |
---|
452 | IF( jp_wfr > 0 ) slf_i(jp_wfr) = sn_wfr |
---|
453 | |
---|
454 | ALLOCATE( sf_sd(jpfld), STAT=ierror ) !* allocate and fill sf_sd with stokes drift |
---|
455 | IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave_init: unable to allocate sf_wave structure' ) |
---|
456 | ! |
---|
457 | DO ifpr= 1, jpfld |
---|
458 | ALLOCATE( sf_sd(ifpr)%fnow(jpi,jpj,1) ) |
---|
459 | IF( slf_i(ifpr)%ln_tint ) ALLOCATE( sf_sd(ifpr)%fdta(jpi,jpj,1,2) ) |
---|
460 | END DO |
---|
461 | ! |
---|
462 | CALL fld_fill( sf_sd, slf_i, cn_dir, 'sbc_wave_init', 'Wave module ', 'namsbc_wave' ) |
---|
463 | ENDIF |
---|
464 | ALLOCATE( usd (jpi,jpj,jpk), vsd (jpi,jpj,jpk), wsd(jpi,jpj,jpk) ) |
---|
465 | ALLOCATE( hsw (jpi,jpj) , wmp (jpi,jpj) ) |
---|
466 | ALLOCATE( wfreq(jpi,jpj) ) |
---|
467 | ALLOCATE( ut0sd(jpi,jpj) , vt0sd(jpi,jpj) ) |
---|
468 | ALLOCATE( div_sd(jpi,jpj) ) |
---|
469 | ALLOCATE( tsd2d (jpi,jpj) ) |
---|
470 | |
---|
471 | ut0sd(:,:) = 0._wp |
---|
472 | vt0sd(:,:) = 0._wp |
---|
473 | hsw(:,:) = 0._wp |
---|
474 | wmp(:,:) = 0._wp |
---|
475 | |
---|
476 | usd(:,:,:) = 0._wp |
---|
477 | vsd(:,:,:) = 0._wp |
---|
478 | wsd(:,:,:) = 0._wp |
---|
479 | ! Wave number needed only if ln_zdfswm=T |
---|
480 | IF( .NOT. cpl_wnum ) THEN |
---|
481 | ALLOCATE( sf_wn(1), STAT=ierror ) !* allocate and fill sf_wave with sn_wnum |
---|
482 | IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave_init: unable toallocate sf_wave structure' ) |
---|
483 | ALLOCATE( sf_wn(1)%fnow(jpi,jpj,1) ) |
---|
484 | IF( sn_wnum%ln_tint ) ALLOCATE( sf_wn(1)%fdta(jpi,jpj,1,2) ) |
---|
485 | CALL fld_fill( sf_wn, (/ sn_wnum /), cn_dir, 'sbc_wave', 'Wave module', 'namsbc_wave' ) |
---|
486 | ENDIF |
---|
487 | ALLOCATE( wnum(jpi,jpj) ) |
---|
488 | ENDIF |
---|
489 | ! |
---|
490 | END SUBROUTINE sbc_wave_init |
---|
491 | |
---|
492 | !!====================================================================== |
---|
493 | END MODULE sbcwave |
---|