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