1 | MODULE tide_mod |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE tide_mod *** |
---|
4 | !! Compute nodal modulations corrections and pulsations |
---|
5 | !!====================================================================== |
---|
6 | !! History : 1.0 ! 2007 (O. Le Galloudec) Original code |
---|
7 | !!---------------------------------------------------------------------- |
---|
8 | USE oce, ONLY : sshn ! sea-surface height |
---|
9 | USE par_oce ! ocean parameters |
---|
10 | USE phycst, ONLY : rpi ! pi |
---|
11 | USE daymod, ONLY : ndt05 ! half-length of time step |
---|
12 | USE in_out_manager ! I/O units |
---|
13 | USE iom ! xIOs server |
---|
14 | |
---|
15 | IMPLICIT NONE |
---|
16 | PRIVATE |
---|
17 | |
---|
18 | PUBLIC tide_init |
---|
19 | PUBLIC tide_update ! called by stp |
---|
20 | PUBLIC tide_init_harmonics ! called internally and by module diaharm |
---|
21 | PUBLIC upd_tide ! called in dynspg_... modules |
---|
22 | |
---|
23 | INTEGER, PUBLIC, PARAMETER :: jpmax_harmo = 64 !: maximum number of harmonic components |
---|
24 | |
---|
25 | TYPE :: tide |
---|
26 | CHARACTER(LEN=4) :: cname_tide = '' |
---|
27 | REAL(wp) :: equitide |
---|
28 | INTEGER :: nt, ns, nh, np, np1, shift |
---|
29 | INTEGER :: nksi, nnu0, nnu1, nnu2, R |
---|
30 | INTEGER :: nformula |
---|
31 | END TYPE tide |
---|
32 | |
---|
33 | TYPE(tide), DIMENSION(:), POINTER :: tide_components !: Array of selected tidal component parameters |
---|
34 | |
---|
35 | TYPE, PUBLIC :: tide_harmonic !: Oscillation parameters of harmonic tidal components |
---|
36 | CHARACTER(LEN=4) :: cname_tide ! Name of component |
---|
37 | REAL(wp) :: equitide ! Amplitude of equilibrium tide |
---|
38 | REAL(wp) :: f ! Node factor |
---|
39 | REAL(wp) :: omega ! Angular velocity |
---|
40 | REAL(wp) :: v0 ! Initial phase at prime meridian |
---|
41 | REAL(wp) :: u ! Phase correction |
---|
42 | END type tide_harmonic |
---|
43 | |
---|
44 | TYPE(tide_harmonic), PUBLIC, DIMENSION(:), POINTER :: tide_harmonics !: Oscillation parameters of selected tidal components |
---|
45 | |
---|
46 | LOGICAL , PUBLIC :: ln_tide !: |
---|
47 | LOGICAL , PUBLIC :: ln_tide_pot !: |
---|
48 | INTEGER :: nn_tide_var ! Variant of tidal parameter set and tide-potential computation |
---|
49 | LOGICAL :: ln_tide_dia ! Enable tidal diagnostic output |
---|
50 | LOGICAL :: ln_read_load !: |
---|
51 | LOGICAL , PUBLIC :: ln_scal_load !: |
---|
52 | LOGICAL , PUBLIC :: ln_tide_ramp !: |
---|
53 | INTEGER , PUBLIC :: nb_harmo !: Number of active tidal components |
---|
54 | REAL(wp), PUBLIC :: rn_tide_ramp_dt !: |
---|
55 | REAL(wp), PUBLIC :: rn_scal_load !: |
---|
56 | CHARACTER(lc), PUBLIC :: cn_tide_load !: |
---|
57 | REAL(wp) :: rn_tide_gamma ! Tidal tilt factor |
---|
58 | |
---|
59 | REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: pot_astro !: tidal potential |
---|
60 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: pot_astro_comp ! tidal-potential component |
---|
61 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: amp_pot, phi_pot |
---|
62 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: amp_load, phi_load |
---|
63 | |
---|
64 | REAL(wp) :: rn_tide_ramp_t ! Elapsed time in seconds |
---|
65 | |
---|
66 | REAL(wp) :: sh_T, sh_s, sh_h, sh_p, sh_p1 ! astronomic angles |
---|
67 | REAL(wp) :: sh_xi, sh_nu, sh_nuprim, sh_nusec, sh_R ! |
---|
68 | REAL(wp) :: sh_I, sh_x1ra, sh_N ! |
---|
69 | |
---|
70 | !!---------------------------------------------------------------------- |
---|
71 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
72 | !! $Id$ |
---|
73 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
74 | !!---------------------------------------------------------------------- |
---|
75 | CONTAINS |
---|
76 | |
---|
77 | SUBROUTINE tide_init |
---|
78 | !!---------------------------------------------------------------------- |
---|
79 | !! *** ROUTINE tide_init *** |
---|
80 | !!---------------------------------------------------------------------- |
---|
81 | INTEGER :: ji, jk |
---|
82 | CHARACTER(LEN=4), DIMENSION(jpmax_harmo) :: sn_tide_cnames ! Names of selected tidal components |
---|
83 | INTEGER :: ios ! Local integer output status for namelist read |
---|
84 | ! |
---|
85 | NAMELIST/nam_tide/ln_tide, nn_tide_var, ln_tide_dia, ln_tide_pot, rn_tide_gamma, & |
---|
86 | & ln_scal_load, ln_read_load, cn_tide_load, & |
---|
87 | & ln_tide_ramp, rn_scal_load, rn_tide_ramp_dt, & |
---|
88 | & sn_tide_cnames |
---|
89 | !!---------------------------------------------------------------------- |
---|
90 | ! |
---|
91 | ! Initialise all array elements of sn_tide_cnames, as some of them |
---|
92 | ! typically do not appear in namelist_ref or namelist_cfg |
---|
93 | sn_tide_cnames(:) = '' |
---|
94 | ! Read Namelist nam_tide |
---|
95 | REWIND( numnam_ref ) ! Namelist nam_tide in reference namelist : Tides |
---|
96 | READ ( numnam_ref, nam_tide, IOSTAT = ios, ERR = 901) |
---|
97 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_tide in reference namelist', lwp ) |
---|
98 | ! |
---|
99 | REWIND( numnam_cfg ) ! Namelist nam_tide in configuration namelist : Tides |
---|
100 | READ ( numnam_cfg, nam_tide, IOSTAT = ios, ERR = 902 ) |
---|
101 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'nam_tide in configuration namelist', lwp ) |
---|
102 | IF(lwm) WRITE ( numond, nam_tide ) |
---|
103 | ! |
---|
104 | IF( ln_tide ) THEN |
---|
105 | IF (lwp) THEN |
---|
106 | WRITE(numout,*) |
---|
107 | WRITE(numout,*) 'tide_init : Initialization of the tidal components' |
---|
108 | WRITE(numout,*) '~~~~~~~~~ ' |
---|
109 | WRITE(numout,*) ' Namelist nam_tide' |
---|
110 | WRITE(numout,*) ' Use tidal components ln_tide = ', ln_tide |
---|
111 | WRITE(numout,*) ' Variant (1: default; 0: legacy option) nn_tide_var = ', nn_tide_var |
---|
112 | WRITE(numout,*) ' Tidal diagnostic output ln_tide_dia = ', ln_tide_dia |
---|
113 | WRITE(numout,*) ' Apply astronomical potential ln_tide_pot = ', ln_tide_pot |
---|
114 | WRITE(numout,*) ' Tidal tilt factor rn_tide_gamma = ', rn_tide_gamma |
---|
115 | WRITE(numout,*) ' Use scalar approx. for load potential ln_scal_load = ', ln_scal_load |
---|
116 | WRITE(numout,*) ' Read load potential from file ln_read_load = ', ln_read_load |
---|
117 | WRITE(numout,*) ' Apply ramp on tides at startup ln_tide_ramp = ', ln_tide_ramp |
---|
118 | WRITE(numout,*) ' Fraction of SSH used in scal. approx. rn_scal_load = ', rn_scal_load |
---|
119 | WRITE(numout,*) ' Duration (days) of ramp rn_tide_ramp_dt = ', rn_tide_ramp_dt |
---|
120 | ENDIF |
---|
121 | ELSE |
---|
122 | rn_scal_load = 0._wp |
---|
123 | |
---|
124 | IF(lwp) WRITE(numout,*) |
---|
125 | IF(lwp) WRITE(numout,*) 'tide_init : tidal components not used (ln_tide = F)' |
---|
126 | IF(lwp) WRITE(numout,*) '~~~~~~~~~ ' |
---|
127 | RETURN |
---|
128 | ENDIF |
---|
129 | ! |
---|
130 | IF( ln_read_load.AND.(.NOT.ln_tide_pot) ) & |
---|
131 | & CALL ctl_stop('ln_read_load requires ln_tide_pot') |
---|
132 | IF( ln_scal_load.AND.(.NOT.ln_tide_pot) ) & |
---|
133 | & CALL ctl_stop('ln_scal_load requires ln_tide_pot') |
---|
134 | IF( ln_scal_load.AND.ln_read_load ) & |
---|
135 | & CALL ctl_stop('Choose between ln_scal_load and ln_read_load') |
---|
136 | IF( ln_tide_ramp.AND.((nitend-nit000+1)*rdt/rday < rn_tide_ramp_dt) ) & |
---|
137 | & CALL ctl_stop('rn_tide_ramp_dt must be lower than run duration') |
---|
138 | IF( ln_tide_ramp.AND.(rn_tide_ramp_dt<0.) ) & |
---|
139 | & CALL ctl_stop('rn_tide_ramp_dt must be positive') |
---|
140 | ! |
---|
141 | ! Initialise array used to store tidal oscillation parameters (frequency, |
---|
142 | ! amplitude, phase); also retrieve and store array of information about |
---|
143 | ! selected tidal components |
---|
144 | CALL tide_init_harmonics(sn_tide_cnames, tide_harmonics, tide_components) |
---|
145 | ! |
---|
146 | ! Number of active tidal components |
---|
147 | nb_harmo = size(tide_components) |
---|
148 | ! |
---|
149 | ! Ensure that tidal components have been set in namelist_cfg |
---|
150 | IF( nb_harmo == 0 ) CALL ctl_stop( 'tide_init : No tidal components set in nam_tide' ) |
---|
151 | ! |
---|
152 | IF (.NOT.ln_scal_load ) rn_scal_load = 0._wp |
---|
153 | ! |
---|
154 | ALLOCATE( amp_pot(jpi,jpj,nb_harmo), & |
---|
155 | & phi_pot(jpi,jpj,nb_harmo), pot_astro(jpi,jpj) ) |
---|
156 | IF( ln_tide_dia ) ALLOCATE( pot_astro_comp(jpi,jpj) ) |
---|
157 | IF( ln_read_load ) THEN |
---|
158 | ALLOCATE( amp_load(jpi,jpj,nb_harmo), phi_load(jpi,jpj,nb_harmo) ) |
---|
159 | CALL tide_init_load |
---|
160 | amp_pot(:,:,:) = amp_load(:,:,:) |
---|
161 | phi_pot(:,:,:) = phi_load(:,:,:) |
---|
162 | ELSE |
---|
163 | amp_pot(:,:,:) = 0._wp |
---|
164 | phi_pot(:,:,:) = 0._wp |
---|
165 | ENDIF |
---|
166 | ! |
---|
167 | END SUBROUTINE tide_init |
---|
168 | |
---|
169 | |
---|
170 | SUBROUTINE tide_init_components(pcnames, ptide_comp) |
---|
171 | !!---------------------------------------------------------------------- |
---|
172 | !! *** ROUTINE tide_init_components *** |
---|
173 | !! |
---|
174 | !! Returns pointer to array of variables of type 'tide' that contain |
---|
175 | !! information about the selected tidal components |
---|
176 | !! ---------------------------------------------------------------------- |
---|
177 | CHARACTER(LEN=4), DIMENSION(jpmax_harmo), INTENT(in) :: pcnames ! Names of selected components |
---|
178 | TYPE(tide), POINTER, DIMENSION(:), INTENT(out) :: ptide_comp ! Selected components |
---|
179 | INTEGER, ALLOCATABLE, DIMENSION(:) :: kcomppos ! Indices of selected components |
---|
180 | INTEGER :: kcomp, jk, ji ! Miscellaneous integers |
---|
181 | TYPE(tide), POINTER, DIMENSION(:) :: tide_components ! All available components |
---|
182 | |
---|
183 | ! Populate local array with information about all available tidal |
---|
184 | ! components |
---|
185 | ! |
---|
186 | ! Note, here 'tide_components' locally overrides the global module |
---|
187 | ! variable of the same name to enable the use of the global name in the |
---|
188 | ! include file that contains the initialisation of elements of array |
---|
189 | ! 'tide_components' |
---|
190 | ALLOCATE(tide_components(jpmax_harmo), kcomppos(jpmax_harmo)) |
---|
191 | ! Initialise array of indices of the selected componenents |
---|
192 | kcomppos(:) = 0 |
---|
193 | ! Include tidal component parameters for all available components |
---|
194 | IF (nn_tide_var < 1) THEN |
---|
195 | #define TIDE_VAR_0 |
---|
196 | #include "tide.h90" |
---|
197 | #undef TIDE_VAR_0 |
---|
198 | ELSE |
---|
199 | #include "tide.h90" |
---|
200 | END IF |
---|
201 | ! Identify the selected components that are availble |
---|
202 | kcomp = 0 |
---|
203 | DO jk = 1, jpmax_harmo |
---|
204 | IF (TRIM(pcnames(jk)) /= '') THEN |
---|
205 | DO ji = 1, jpmax_harmo |
---|
206 | IF (TRIM(pcnames(jk)) == tide_components(ji)%cname_tide) THEN |
---|
207 | kcomp = kcomp + 1 |
---|
208 | IF (lwp) WRITE(numout, '(10X,"Tidal component #",I2.2,36X,"= ",A4)') kcomp, pcnames(jk) |
---|
209 | kcomppos(kcomp) = ji |
---|
210 | EXIT |
---|
211 | END IF |
---|
212 | END DO |
---|
213 | END IF |
---|
214 | END DO |
---|
215 | |
---|
216 | ! Allocate and populate reduced list of components |
---|
217 | ALLOCATE(ptide_comp(kcomp)) |
---|
218 | DO jk = 1, kcomp |
---|
219 | ptide_comp(jk) = tide_components(kcomppos(jk)) |
---|
220 | END DO |
---|
221 | |
---|
222 | ! Release local array of available components and list of selected |
---|
223 | ! components |
---|
224 | DEALLOCATE(tide_components, kcomppos) |
---|
225 | |
---|
226 | END SUBROUTINE tide_init_components |
---|
227 | |
---|
228 | |
---|
229 | SUBROUTINE tide_init_harmonics(pcnames, ptide_harmo, ptide_comp) |
---|
230 | !!---------------------------------------------------------------------- |
---|
231 | !! *** ROUTINE tide_init_harmonics *** |
---|
232 | !! |
---|
233 | !! Returns pointer to array of variables of type 'tide_harmonics' that |
---|
234 | !! contain oscillation parameters of the selected harmonic tidal |
---|
235 | !! components |
---|
236 | !! ---------------------------------------------------------------------- |
---|
237 | CHARACTER(LEN=4), DIMENSION(jpmax_harmo), INTENT(in) :: pcnames ! Names of selected components |
---|
238 | TYPE(tide_harmonic), POINTER, DIMENSION(:) :: ptide_harmo ! Oscillation parameters of tidal components |
---|
239 | TYPE(tide), POINTER, DIMENSION(:), OPTIONAL :: ptide_comp ! Selected components |
---|
240 | TYPE(tide), POINTER, DIMENSION(:) :: ztcomp ! Selected components |
---|
241 | |
---|
242 | ! Retrieve information about selected tidal components |
---|
243 | ! If requested, prepare tidal component array for returning |
---|
244 | IF (PRESENT(ptide_comp)) THEN |
---|
245 | CALL tide_init_components(pcnames, ptide_comp) |
---|
246 | ztcomp => ptide_comp |
---|
247 | ELSE |
---|
248 | CALL tide_init_components(pcnames, ztcomp) |
---|
249 | END IF |
---|
250 | |
---|
251 | ! Allocate and populate array of oscillation parameters |
---|
252 | ALLOCATE(ptide_harmo(size(ztcomp))) |
---|
253 | ptide_harmo(:)%cname_tide = ztcomp(:)%cname_tide |
---|
254 | ptide_harmo(:)%equitide = ztcomp(:)%equitide |
---|
255 | CALL tide_harmo(ztcomp, ptide_harmo) |
---|
256 | |
---|
257 | END SUBROUTINE tide_init_harmonics |
---|
258 | |
---|
259 | |
---|
260 | SUBROUTINE tide_init_potential |
---|
261 | !!---------------------------------------------------------------------- |
---|
262 | !! *** ROUTINE tide_init_potential *** |
---|
263 | !! |
---|
264 | !! *** Reference: |
---|
265 | !! CT71) Cartwright, D. E. and Tayler, R. J. (1971): New computations of |
---|
266 | !! the Tide-generating Potential. Geophys. J. R. astr. Soc. 23, |
---|
267 | !! pp. 45-74. DOI: 10.1111/j.1365-246X.1971.tb01803.x |
---|
268 | !! |
---|
269 | !!---------------------------------------------------------------------- |
---|
270 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
271 | REAL(wp) :: zcons, ztmp1, ztmp2, zlat, zlon, ztmp, zamp, zcs ! local scalar |
---|
272 | !!---------------------------------------------------------------------- |
---|
273 | |
---|
274 | IF( ln_read_load ) THEN |
---|
275 | amp_pot(:,:,:) = amp_load(:,:,:) |
---|
276 | phi_pot(:,:,:) = phi_load(:,:,:) |
---|
277 | ELSE |
---|
278 | amp_pot(:,:,:) = 0._wp |
---|
279 | phi_pot(:,:,:) = 0._wp |
---|
280 | ENDIF |
---|
281 | DO jk = 1, nb_harmo |
---|
282 | zcons = rn_tide_gamma * tide_components(jk)%equitide * tide_harmonics(jk)%f |
---|
283 | DO ji = 1, jpi |
---|
284 | DO jj = 1, jpj |
---|
285 | ztmp1 = tide_harmonics(jk)%f * amp_pot(ji,jj,jk) * COS( phi_pot(ji,jj,jk) & |
---|
286 | & + tide_harmonics(jk)%v0 + tide_harmonics(jk)%u ) |
---|
287 | ztmp2 = -tide_harmonics(jk)%f * amp_pot(ji,jj,jk) * SIN( phi_pot(ji,jj,jk) & |
---|
288 | & + tide_harmonics(jk)%v0 + tide_harmonics(jk)%u ) |
---|
289 | zlat = gphit(ji,jj)*rad !! latitude en radian |
---|
290 | zlon = glamt(ji,jj)*rad !! longitude en radian |
---|
291 | ztmp = tide_harmonics(jk)%v0 + tide_harmonics(jk)%u + tide_components(jk)%nt * zlon |
---|
292 | ! le potentiel est composé des effets des astres: |
---|
293 | SELECT CASE( tide_components(jk)%nt ) |
---|
294 | CASE( 0 ) ! long-periodic tidal constituents (included unless |
---|
295 | zcs = zcons * ( 0.5_wp - 1.5_wp * SIN( zlat )**2 ) ! compatibility with original formulation is requested) |
---|
296 | IF ( nn_tide_var < 1 ) zcs = 0.0_wp |
---|
297 | CASE( 1 ) ! diurnal tidal constituents |
---|
298 | zcs = zcons * SIN( 2.0_wp*zlat ) |
---|
299 | CASE( 2 ) ! semi-diurnal tidal constituents |
---|
300 | zcs = zcons * COS( zlat )**2 |
---|
301 | CASE( 3 ) ! Terdiurnal tidal constituents; the colatitude-dependent |
---|
302 | zcs = zcons * COS( zlat )**3 ! factor is sin(theta)^3 (Table 2 of CT71) |
---|
303 | CASE DEFAULT ! constituents of higher frequency are not included |
---|
304 | zcs = 0.0_wp |
---|
305 | END SELECT |
---|
306 | ztmp1 = ztmp1 + zcs * COS( ztmp ) |
---|
307 | ztmp2 = ztmp2 - zcs * SIN( ztmp ) |
---|
308 | zamp = SQRT( ztmp1*ztmp1 + ztmp2*ztmp2 ) |
---|
309 | amp_pot(ji,jj,jk) = zamp |
---|
310 | phi_pot(ji,jj,jk) = ATAN2( -ztmp2 / MAX( 1.e-10_wp , zamp ) , & |
---|
311 | & ztmp1 / MAX( 1.e-10_wp, zamp ) ) |
---|
312 | END DO |
---|
313 | END DO |
---|
314 | END DO |
---|
315 | ! |
---|
316 | END SUBROUTINE tide_init_potential |
---|
317 | |
---|
318 | |
---|
319 | SUBROUTINE tide_init_load |
---|
320 | !!---------------------------------------------------------------------- |
---|
321 | !! *** ROUTINE tide_init_load *** |
---|
322 | !!---------------------------------------------------------------------- |
---|
323 | INTEGER :: inum ! Logical unit of input file |
---|
324 | INTEGER :: ji, jj, itide ! dummy loop indices |
---|
325 | REAL(wp), DIMENSION(jpi,jpj) :: ztr, zti !: workspace to read in tidal harmonics data |
---|
326 | !!---------------------------------------------------------------------- |
---|
327 | IF(lwp) THEN |
---|
328 | WRITE(numout,*) |
---|
329 | WRITE(numout,*) 'tide_init_load : Initialization of load potential from file' |
---|
330 | WRITE(numout,*) '~~~~~~~~~~~~~~ ' |
---|
331 | ENDIF |
---|
332 | ! |
---|
333 | CALL iom_open ( cn_tide_load , inum ) |
---|
334 | ! |
---|
335 | DO itide = 1, nb_harmo |
---|
336 | CALL iom_get ( inum, jpdom_data,TRIM(tide_components(itide)%cname_tide)//'_z1', ztr(:,:) ) |
---|
337 | CALL iom_get ( inum, jpdom_data,TRIM(tide_components(itide)%cname_tide)//'_z2', zti(:,:) ) |
---|
338 | ! |
---|
339 | DO ji=1,jpi |
---|
340 | DO jj=1,jpj |
---|
341 | amp_load(ji,jj,itide) = SQRT( ztr(ji,jj)**2. + zti(ji,jj)**2. ) |
---|
342 | phi_load(ji,jj,itide) = ATAN2(-zti(ji,jj), ztr(ji,jj) ) |
---|
343 | END DO |
---|
344 | END DO |
---|
345 | ! |
---|
346 | END DO |
---|
347 | CALL iom_close( inum ) |
---|
348 | ! |
---|
349 | END SUBROUTINE tide_init_load |
---|
350 | |
---|
351 | |
---|
352 | SUBROUTINE tide_update( kt ) |
---|
353 | !!---------------------------------------------------------------------- |
---|
354 | !! *** ROUTINE tide_update *** |
---|
355 | !!---------------------------------------------------------------------- |
---|
356 | INTEGER, INTENT( in ) :: kt ! ocean time-step |
---|
357 | INTEGER :: jk ! dummy loop index |
---|
358 | !!---------------------------------------------------------------------- |
---|
359 | |
---|
360 | IF( nsec_day == NINT(0.5_wp * rdt) .OR. kt == nit000 ) THEN ! start a new day |
---|
361 | ! |
---|
362 | CALL tide_harmo(tide_components, tide_harmonics, ndt05) ! Update oscillation parameters of tidal components for start of current day |
---|
363 | ! |
---|
364 | ! |
---|
365 | IF(lwp) THEN |
---|
366 | WRITE(numout,*) |
---|
367 | WRITE(numout,*) 'tide_update : Update of the components and (re)Init. the potential at kt=', kt |
---|
368 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
369 | DO jk = 1, nb_harmo |
---|
370 | WRITE(numout,*) tide_harmonics(jk)%cname_tide, tide_harmonics(jk)%u, & |
---|
371 | & tide_harmonics(jk)%f,tide_harmonics(jk)%v0, tide_harmonics(jk)%omega |
---|
372 | END DO |
---|
373 | ENDIF |
---|
374 | ! |
---|
375 | IF( ln_tide_pot ) CALL tide_init_potential |
---|
376 | ! |
---|
377 | rn_tide_ramp_t = (kt - nit000)*rdt ! Elapsed time in seconds |
---|
378 | ENDIF |
---|
379 | ! |
---|
380 | END SUBROUTINE tide_update |
---|
381 | |
---|
382 | |
---|
383 | SUBROUTINE tide_harmo( ptide_comp, ptide_harmo, psec_day ) |
---|
384 | ! |
---|
385 | TYPE(tide), DIMENSION(:), POINTER :: ptide_comp ! Array of selected tidal component parameters |
---|
386 | TYPE(tide_harmonic), DIMENSION(:), POINTER :: ptide_harmo ! Oscillation parameters of selected tidal components |
---|
387 | INTEGER, OPTIONAL :: psec_day ! Number of seconds since the start of the current day |
---|
388 | ! |
---|
389 | IF (PRESENT(psec_day)) THEN |
---|
390 | CALL astronomic_angle(psec_day) |
---|
391 | ELSE |
---|
392 | CALL astronomic_angle(nsec_day) |
---|
393 | END IF |
---|
394 | CALL tide_pulse( ptide_comp, ptide_harmo ) |
---|
395 | CALL tide_vuf( ptide_comp, ptide_harmo ) |
---|
396 | ! |
---|
397 | END SUBROUTINE tide_harmo |
---|
398 | |
---|
399 | |
---|
400 | SUBROUTINE astronomic_angle(psec_day) |
---|
401 | !!---------------------------------------------------------------------- |
---|
402 | !! tj is time elapsed since 1st January 1900, 0 hour, counted in julian |
---|
403 | !! century (e.g. time in days divide by 36525) |
---|
404 | !!---------------------------------------------------------------------- |
---|
405 | INTEGER :: psec_day ! Number of seconds from midnight |
---|
406 | REAL(wp) :: cosI, p, q, t2, t4, sin2I, s2, tgI2, P1, sh_tgn2, at1, at2 |
---|
407 | REAL(wp) :: zqy , zsy, zday, zdj, zhfrac |
---|
408 | !!---------------------------------------------------------------------- |
---|
409 | ! |
---|
410 | zqy = AINT( (nyear-1901.)/4. ) |
---|
411 | zsy = nyear - 1900. |
---|
412 | ! |
---|
413 | zdj = dayjul( nyear, nmonth, nday ) |
---|
414 | zday = zdj + zqy - 1. |
---|
415 | ! |
---|
416 | zhfrac = psec_day / 3600. |
---|
417 | ! |
---|
418 | !---------------------------------------------------------------------- |
---|
419 | ! Sh_n Longitude of ascending lunar node |
---|
420 | !---------------------------------------------------------------------- |
---|
421 | sh_N=(259.1560564-19.328185764*zsy-.0529539336*zday-.0022064139*zhfrac)*rad |
---|
422 | !---------------------------------------------------------------------- |
---|
423 | ! T mean solar angle (Greenwhich time) |
---|
424 | !---------------------------------------------------------------------- |
---|
425 | sh_T=(180.+zhfrac*(360./24.))*rad |
---|
426 | !---------------------------------------------------------------------- |
---|
427 | ! h mean solar Longitude |
---|
428 | !---------------------------------------------------------------------- |
---|
429 | sh_h=(280.1895014-.238724988*zsy+.9856473288*zday+.0410686387*zhfrac)*rad |
---|
430 | !---------------------------------------------------------------------- |
---|
431 | ! s mean lunar Longitude |
---|
432 | !---------------------------------------------------------------------- |
---|
433 | sh_s=(277.0256206+129.38482032*zsy+13.176396768*zday+.549016532*zhfrac)*rad |
---|
434 | !---------------------------------------------------------------------- |
---|
435 | ! p1 Longitude of solar perigee |
---|
436 | !---------------------------------------------------------------------- |
---|
437 | sh_p1=(281.2208569+.01717836*zsy+.000047064*zday+.000001961*zhfrac)*rad |
---|
438 | !---------------------------------------------------------------------- |
---|
439 | ! p Longitude of lunar perigee |
---|
440 | !---------------------------------------------------------------------- |
---|
441 | sh_p=(334.3837214+40.66246584*zsy+.111404016*zday+.004641834*zhfrac)*rad |
---|
442 | |
---|
443 | sh_N = MOD( sh_N ,2*rpi ) |
---|
444 | sh_s = MOD( sh_s ,2*rpi ) |
---|
445 | sh_h = MOD( sh_h, 2*rpi ) |
---|
446 | sh_p = MOD( sh_p, 2*rpi ) |
---|
447 | sh_p1= MOD( sh_p1,2*rpi ) |
---|
448 | |
---|
449 | cosI = 0.913694997 -0.035692561 *cos(sh_N) |
---|
450 | |
---|
451 | sh_I = ACOS( cosI ) |
---|
452 | |
---|
453 | sin2I = sin(sh_I) |
---|
454 | sh_tgn2 = tan(sh_N/2.0) |
---|
455 | |
---|
456 | at1=atan(1.01883*sh_tgn2) |
---|
457 | at2=atan(0.64412*sh_tgn2) |
---|
458 | |
---|
459 | sh_xi=-at1-at2+sh_N |
---|
460 | |
---|
461 | IF( sh_N > rpi ) sh_xi=sh_xi-2.0*rpi |
---|
462 | |
---|
463 | sh_nu = at1 - at2 |
---|
464 | |
---|
465 | !---------------------------------------------------------------------- |
---|
466 | ! For constituents l2 k1 k2 |
---|
467 | !---------------------------------------------------------------------- |
---|
468 | |
---|
469 | tgI2 = tan(sh_I/2.0) |
---|
470 | P1 = sh_p-sh_xi |
---|
471 | |
---|
472 | t2 = tgI2*tgI2 |
---|
473 | t4 = t2*t2 |
---|
474 | sh_x1ra = sqrt( 1.0-12.0*t2*cos(2.0*P1)+36.0*t4 ) |
---|
475 | |
---|
476 | p = sin(2.0*P1) |
---|
477 | q = 1.0/(6.0*t2)-cos(2.0*P1) |
---|
478 | sh_R = atan(p/q) |
---|
479 | |
---|
480 | p = sin(2.0*sh_I)*sin(sh_nu) |
---|
481 | q = sin(2.0*sh_I)*cos(sh_nu)+0.3347 |
---|
482 | sh_nuprim = atan(p/q) |
---|
483 | |
---|
484 | s2 = sin(sh_I)*sin(sh_I) |
---|
485 | p = s2*sin(2.0*sh_nu) |
---|
486 | q = s2*cos(2.0*sh_nu)+0.0727 |
---|
487 | sh_nusec = 0.5*atan(p/q) |
---|
488 | ! |
---|
489 | END SUBROUTINE astronomic_angle |
---|
490 | |
---|
491 | |
---|
492 | SUBROUTINE tide_pulse( ptide_comp, ptide_harmo ) |
---|
493 | !!---------------------------------------------------------------------- |
---|
494 | !! *** ROUTINE tide_pulse *** |
---|
495 | !! |
---|
496 | !! ** Purpose : Compute tidal frequencies |
---|
497 | !!---------------------------------------------------------------------- |
---|
498 | TYPE(tide), DIMENSION(:), POINTER :: ptide_comp ! Array of selected tidal component parameters |
---|
499 | TYPE(tide_harmonic), DIMENSION(:), POINTER :: ptide_harmo ! Oscillation parameters of selected tidal components |
---|
500 | ! |
---|
501 | INTEGER :: jh |
---|
502 | REAL(wp) :: zscale |
---|
503 | REAL(wp) :: zomega_T = 13149000.0_wp |
---|
504 | REAL(wp) :: zomega_s = 481267.892_wp |
---|
505 | REAL(wp) :: zomega_h = 36000.76892_wp |
---|
506 | REAL(wp) :: zomega_p = 4069.0322056_wp |
---|
507 | REAL(wp) :: zomega_n = 1934.1423972_wp |
---|
508 | REAL(wp) :: zomega_p1= 1.719175_wp |
---|
509 | !!---------------------------------------------------------------------- |
---|
510 | ! |
---|
511 | zscale = rad / ( 36525._wp * 86400._wp ) |
---|
512 | ! |
---|
513 | DO jh = 1, size(ptide_harmo) |
---|
514 | ptide_harmo(jh)%omega = ( zomega_T * ptide_comp( jh )%nT & |
---|
515 | & + zomega_s * ptide_comp( jh )%ns & |
---|
516 | & + zomega_h * ptide_comp( jh )%nh & |
---|
517 | & + zomega_p * ptide_comp( jh )%np & |
---|
518 | & + zomega_p1* ptide_comp( jh )%np1 ) * zscale |
---|
519 | END DO |
---|
520 | ! |
---|
521 | END SUBROUTINE tide_pulse |
---|
522 | |
---|
523 | |
---|
524 | SUBROUTINE tide_vuf( ptide_comp, ptide_harmo ) |
---|
525 | !!---------------------------------------------------------------------- |
---|
526 | !! *** ROUTINE tide_vuf *** |
---|
527 | !! |
---|
528 | !! ** Purpose : Compute nodal modulation corrections |
---|
529 | !! |
---|
530 | !! ** Outputs : vt: Phase of tidal potential relative to Greenwich (radians) |
---|
531 | !! ut: Phase correction u due to nodal motion (radians) |
---|
532 | !! ft: Nodal correction factor |
---|
533 | !!---------------------------------------------------------------------- |
---|
534 | TYPE(tide), DIMENSION(:), POINTER :: ptide_comp ! Array of selected tidal component parameters |
---|
535 | TYPE(tide_harmonic), DIMENSION(:), POINTER :: ptide_harmo ! Oscillation parameters of selected tidal components |
---|
536 | ! |
---|
537 | INTEGER :: jh ! dummy loop index |
---|
538 | !!---------------------------------------------------------------------- |
---|
539 | ! |
---|
540 | DO jh = 1, size(ptide_harmo) |
---|
541 | ! Phase of the tidal potential relative to the Greenwhich |
---|
542 | ! meridian (e.g. the position of the fictuous celestial body). Units are radian: |
---|
543 | ptide_harmo(jh)%v0 = sh_T * ptide_comp( jh )%nT & |
---|
544 | & + sh_s * ptide_comp( jh )%ns & |
---|
545 | & + sh_h * ptide_comp( jh )%nh & |
---|
546 | & + sh_p * ptide_comp( jh )%np & |
---|
547 | & + sh_p1* ptide_comp( jh )%np1 & |
---|
548 | & + ptide_comp( jh )%shift * rad |
---|
549 | ! |
---|
550 | ! Phase correction u due to nodal motion. Units are radian: |
---|
551 | ptide_harmo(jh)%u = sh_xi * ptide_comp( jh )%nksi & |
---|
552 | & + sh_nu * ptide_comp( jh )%nnu0 & |
---|
553 | & + sh_nuprim * ptide_comp( jh )%nnu1 & |
---|
554 | & + sh_nusec * ptide_comp( jh )%nnu2 & |
---|
555 | & + sh_R * ptide_comp( jh )%R |
---|
556 | |
---|
557 | ! Nodal correction factor: |
---|
558 | ptide_harmo(jh)%f = nodal_factort( ptide_comp( jh )%nformula ) |
---|
559 | END DO |
---|
560 | ! |
---|
561 | END SUBROUTINE tide_vuf |
---|
562 | |
---|
563 | |
---|
564 | RECURSIVE FUNCTION nodal_factort( kformula ) RESULT( zf ) |
---|
565 | !!---------------------------------------------------------------------- |
---|
566 | !!---------------------------------------------------------------------- |
---|
567 | INTEGER, INTENT(in) :: kformula |
---|
568 | ! |
---|
569 | REAL(wp) :: zf |
---|
570 | REAL(wp) :: zs, zf1, zf2 |
---|
571 | CHARACTER(LEN=3) :: clformula |
---|
572 | !!---------------------------------------------------------------------- |
---|
573 | ! |
---|
574 | SELECT CASE( kformula ) |
---|
575 | ! |
---|
576 | CASE( 0 ) !== formule 0, solar waves |
---|
577 | zf = 1.0 |
---|
578 | ! |
---|
579 | CASE( 1 ) !== formule 1, compound waves (78 x 78) |
---|
580 | zf=nodal_factort(78) |
---|
581 | zf = zf * zf |
---|
582 | ! |
---|
583 | CASE ( 4 ) !== formule 4, compound waves (78 x 235) |
---|
584 | zf1 = nodal_factort( 78) |
---|
585 | zf = nodal_factort(235) |
---|
586 | zf = zf1 * zf |
---|
587 | ! |
---|
588 | CASE( 18 ) !== formule 18, compound waves (78 x 78 x 78 ) |
---|
589 | zf1 = nodal_factort(78) |
---|
590 | zf = zf1 * zf1 * zf1 |
---|
591 | ! |
---|
592 | CASE( 20 ) !== formula 20, compound waves ( 78 x 78 x 78 x 78 ) |
---|
593 | zf1 = nodal_factort(78) |
---|
594 | zf = zf1 * zf1 * zf1 * zf1 |
---|
595 | ! |
---|
596 | CASE( 73 ) !== formule 73 |
---|
597 | zs = sin(sh_I) |
---|
598 | zf = (2./3.-zs*zs)/0.5021 |
---|
599 | ! |
---|
600 | CASE( 74 ) !== formule 74 |
---|
601 | zs = sin(sh_I) |
---|
602 | zf = zs * zs / 0.1578 |
---|
603 | ! |
---|
604 | CASE( 75 ) !== formule 75 |
---|
605 | zs = cos(sh_I/2) |
---|
606 | zf = sin(sh_I) * zs * zs / 0.3800 |
---|
607 | ! |
---|
608 | CASE( 76 ) !== formule 76 |
---|
609 | zf = sin(2*sh_I) / 0.7214 |
---|
610 | ! |
---|
611 | CASE( 78 ) !== formule 78 |
---|
612 | zs = cos(sh_I/2) |
---|
613 | zf = zs * zs * zs * zs / 0.9154 |
---|
614 | ! |
---|
615 | CASE( 149 ) !== formule 149 |
---|
616 | zs = cos(sh_I/2) |
---|
617 | zf = zs*zs*zs*zs*zs*zs / 0.8758 |
---|
618 | ! |
---|
619 | CASE( 215 ) !== formule 215 |
---|
620 | zs = cos(sh_I/2) |
---|
621 | zf = zs*zs*zs*zs / 0.9154 * sh_x1ra |
---|
622 | ! |
---|
623 | CASE( 227 ) !== formule 227 |
---|
624 | zs = sin(2*sh_I) |
---|
625 | zf = sqrt( 0.8965*zs*zs+0.6001*zs*cos (sh_nu)+0.1006 ) |
---|
626 | ! |
---|
627 | CASE ( 235 ) !== formule 235 |
---|
628 | zs = sin(sh_I) |
---|
629 | zf = sqrt( 19.0444*zs*zs*zs*zs + 2.7702*zs*zs*cos(2*sh_nu) + .0981 ) |
---|
630 | ! |
---|
631 | CASE DEFAULT |
---|
632 | WRITE( clformula, '(I3)' ) kformula |
---|
633 | CALL ctl_stop('nodal_factort: formula ' // clformula // ' is not available') |
---|
634 | END SELECT |
---|
635 | ! |
---|
636 | END FUNCTION nodal_factort |
---|
637 | |
---|
638 | |
---|
639 | FUNCTION dayjul( kyr, kmonth, kday ) |
---|
640 | !!---------------------------------------------------------------------- |
---|
641 | !! *** THIS ROUTINE COMPUTES THE JULIAN DAY (AS A REAL VARIABLE) |
---|
642 | !!---------------------------------------------------------------------- |
---|
643 | INTEGER,INTENT(in) :: kyr, kmonth, kday |
---|
644 | ! |
---|
645 | INTEGER,DIMENSION(12) :: idayt, idays |
---|
646 | INTEGER :: inc, ji |
---|
647 | REAL(wp) :: dayjul, zyq |
---|
648 | ! |
---|
649 | DATA idayt/0.,31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334./ |
---|
650 | !!---------------------------------------------------------------------- |
---|
651 | ! |
---|
652 | idays(1) = 0. |
---|
653 | idays(2) = 31. |
---|
654 | inc = 0. |
---|
655 | zyq = MOD( kyr-1900. , 4. ) |
---|
656 | IF( zyq == 0.) inc = 1. |
---|
657 | DO ji = 3, 12 |
---|
658 | idays(ji)=idayt(ji)+inc |
---|
659 | END DO |
---|
660 | dayjul = idays(kmonth) + kday |
---|
661 | ! |
---|
662 | END FUNCTION dayjul |
---|
663 | |
---|
664 | |
---|
665 | SUBROUTINE upd_tide(pdelta) |
---|
666 | !!---------------------------------------------------------------------- |
---|
667 | !! *** ROUTINE upd_tide *** |
---|
668 | !! |
---|
669 | !! ** Purpose : provide at each time step the astronomical potential |
---|
670 | !! |
---|
671 | !! ** Method : computed from pulsation and amplitude of all tide components |
---|
672 | !! |
---|
673 | !! ** Action : pot_astro actronomical potential |
---|
674 | !!---------------------------------------------------------------------- |
---|
675 | REAL, INTENT(in) :: pdelta ! Temporal offset in seconds |
---|
676 | INTEGER :: jk ! Dummy loop index |
---|
677 | REAL(wp) :: zt, zramp ! Local scalars |
---|
678 | REAL(wp), DIMENSION(nb_harmo) :: zwt ! Temporary array |
---|
679 | !!---------------------------------------------------------------------- |
---|
680 | ! |
---|
681 | zwt(:) = tide_harmonics(:)%omega * pdelta |
---|
682 | ! |
---|
683 | IF( ln_tide_ramp ) THEN ! linear increase if asked |
---|
684 | zt = rn_tide_ramp_t + pdelta |
---|
685 | zramp = MIN( MAX( zt / (rn_tide_ramp_dt*rday) , 0._wp ) , 1._wp ) |
---|
686 | ENDIF |
---|
687 | ! |
---|
688 | pot_astro(:,:) = 0._wp ! update tidal potential (sum of all harmonics) |
---|
689 | DO jk = 1, nb_harmo |
---|
690 | IF ( .NOT. ln_tide_dia ) THEN |
---|
691 | pot_astro(:,:) = pot_astro(:,:) + amp_pot(:,:,jk) * COS( zwt(jk) + phi_pot(:,:,jk) ) |
---|
692 | ELSE |
---|
693 | pot_astro_comp(:,:) = amp_pot(:,:,jk) * COS( zwt(jk) + phi_pot(:,:,jk) ) |
---|
694 | pot_astro(:,:) = pot_astro(:,:) + pot_astro_comp(:,:) |
---|
695 | IF ( iom_use( "tide_pot_" // TRIM( tide_harmonics(jk)%cname_tide ) ) ) THEN ! Output tidal potential (incl. load potential) |
---|
696 | IF ( ln_tide_ramp ) pot_astro_comp(:,:) = zramp * pot_astro_comp(:,:) |
---|
697 | CALL iom_put( "tide_pot_" // TRIM( tide_harmonics(jk)%cname_tide ), pot_astro_comp(:,:) ) |
---|
698 | END IF |
---|
699 | END IF |
---|
700 | END DO |
---|
701 | ! |
---|
702 | IF ( ln_tide_ramp ) pot_astro(:,:) = zramp * pot_astro(:,:) |
---|
703 | ! |
---|
704 | IF( ln_tide_dia ) THEN ! Output total tidal potential (incl. load potential) |
---|
705 | IF ( iom_use( "tide_pot" ) ) CALL iom_put( "tide_pot", pot_astro(:,:) + rn_scal_load * sshn(:,:) ) |
---|
706 | END IF |
---|
707 | ! |
---|
708 | END SUBROUTINE upd_tide |
---|
709 | |
---|
710 | !!====================================================================== |
---|
711 | END MODULE tide_mod |
---|