New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
tide_mod.F90 in NEMO/branches/UKMO/r14075_India_uncoupled/src/OCE/SBC – NEMO

source: NEMO/branches/UKMO/r14075_India_uncoupled/src/OCE/SBC/tide_mod.F90 @ 15422

Last change on this file since 15422 was 15422, checked in by jcastill, 3 years ago

Changes tested so that they can merged with the CO9 Met Office branch - jpmax_harmo should be 34 with FES14 tides, but the last components are not used anyway

File size: 15.9 KB
Line 
1MODULE 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 dom_oce        ! ocean space and time domain
9   USE phycst         ! physical constant
10   USE daymod         ! calendar
11
12   IMPLICIT NONE
13   PRIVATE
14
15   PUBLIC   tide_harmo       ! called by tideini and diaharm modules
16   PUBLIC   tide_init_Wave   ! called by tideini and diaharm modules
17
18   INTEGER, PUBLIC, PARAMETER ::   jpmax_harmo = 31   !: maximum number of harmonic
19
20   TYPE, PUBLIC ::    tide
21      CHARACTER(LEN=4) ::   cname_tide
22      REAL(wp)         ::   equitide
23      INTEGER          ::   nutide
24      INTEGER          ::   nt, ns, nh, np, np1, shift
25      INTEGER          ::   nksi, nnu0, nnu1, nnu2, R
26      INTEGER          ::   nformula
27   END TYPE tide
28
29   TYPE(tide), PUBLIC, DIMENSION(jpmax_harmo) ::   Wave   !:
30
31   REAL(wp) ::   sh_T, sh_s, sh_h, sh_p, sh_p1             ! astronomic angles
32   REAL(wp) ::   sh_xi, sh_nu, sh_nuprim, sh_nusec, sh_R   !
33   REAL(wp) ::   sh_I, sh_x1ra, sh_N                       !
34
35   !!----------------------------------------------------------------------
36   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
37   !! $Id$
38   !! Software governed by the CeCILL license (see ./LICENSE)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE tide_init_Wave
43# if defined key_FES14_tides 
44#     include "tide_FES14.h90" 
45# else
46#     include "tide.h90"
47# endif
48   END SUBROUTINE tide_init_Wave
49
50
51   SUBROUTINE tide_harmo( pomega, pvt, put , pcor, ktide ,kc)
52      !!----------------------------------------------------------------------
53      !!----------------------------------------------------------------------
54      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide            ! Indice of tidal constituents
55      INTEGER                , INTENT(in ) ::   kc               ! Total number of tidal constituents
56      REAL(wp), DIMENSION(kc), INTENT(out) ::   pomega           ! pulsation in radians/s
57      REAL(wp), DIMENSION(kc), INTENT(out) ::   pvt, put, pcor   !
58      !!----------------------------------------------------------------------
59      !
60      CALL astronomic_angle
61      CALL tide_pulse( pomega, ktide ,kc )
62      CALL tide_vuf  ( pvt, put, pcor, ktide ,kc )
63      !
64   END SUBROUTINE tide_harmo
65
66
67   SUBROUTINE astronomic_angle
68      !!----------------------------------------------------------------------
69      !!  tj is time elapsed since 1st January 1900, 0 hour, counted in julian
70      !!  century (e.g. time in days divide by 36525)
71      !!----------------------------------------------------------------------
72      REAL(wp) ::   cosI, p, q, t2, t4, sin2I, s2, tgI2, P1, sh_tgn2, at1, at2
73      REAL(wp) ::   zqy , zsy, zday, zdj, zhfrac
74      !!----------------------------------------------------------------------
75      !
76      zqy = AINT( (nyear-1901.)/4. )
77      zsy = nyear - 1900.
78      !
79      zdj  = dayjul( nyear, nmonth, nday )
80      zday = zdj + zqy - 1.
81      !
82      zhfrac = nsec_day / 3600.
83      !
84      !----------------------------------------------------------------------
85      !  Sh_n Longitude of ascending lunar node
86      !----------------------------------------------------------------------
87      sh_N=(259.1560564-19.328185764*zsy-.0529539336*zday-.0022064139*zhfrac)*rad
88      !----------------------------------------------------------------------
89      ! T mean solar angle (Greenwhich time)
90      !----------------------------------------------------------------------
91      sh_T=(180.+zhfrac*(360./24.))*rad
92      !----------------------------------------------------------------------
93      ! h mean solar Longitude
94      !----------------------------------------------------------------------
95      sh_h=(280.1895014-.238724988*zsy+.9856473288*zday+.0410686387*zhfrac)*rad
96      !----------------------------------------------------------------------
97      ! s mean lunar Longitude
98      !----------------------------------------------------------------------
99      sh_s=(277.0256206+129.38482032*zsy+13.176396768*zday+.549016532*zhfrac)*rad
100      !----------------------------------------------------------------------
101      ! p1 Longitude of solar perigee
102      !----------------------------------------------------------------------
103      sh_p1=(281.2208569+.01717836*zsy+.000047064*zday+.000001961*zhfrac)*rad
104      !----------------------------------------------------------------------
105      ! p Longitude of lunar perigee
106      !----------------------------------------------------------------------
107      sh_p=(334.3837214+40.66246584*zsy+.111404016*zday+.004641834*zhfrac)*rad
108
109      sh_N = MOD( sh_N ,2*rpi )
110      sh_s = MOD( sh_s ,2*rpi )
111      sh_h = MOD( sh_h, 2*rpi )
112      sh_p = MOD( sh_p, 2*rpi )
113      sh_p1= MOD( sh_p1,2*rpi )
114
115      cosI = 0.913694997 -0.035692561 *cos(sh_N)
116
117      sh_I = ACOS( cosI )
118
119      sin2I   = sin(sh_I)
120      sh_tgn2 = tan(sh_N/2.0)
121
122      at1=atan(1.01883*sh_tgn2)
123      at2=atan(0.64412*sh_tgn2)
124
125      sh_xi=-at1-at2+sh_N
126
127      IF( sh_N > rpi )   sh_xi=sh_xi-2.0*rpi
128
129      sh_nu = at1 - at2
130
131      !----------------------------------------------------------------------
132      ! For constituents l2 k1 k2
133      !----------------------------------------------------------------------
134
135      tgI2 = tan(sh_I/2.0)
136      P1   = sh_p-sh_xi
137
138      t2 = tgI2*tgI2
139      t4 = t2*t2
140      sh_x1ra = sqrt( 1.0-12.0*t2*cos(2.0*P1)+36.0*t4 )
141
142      p = sin(2.0*P1)
143      q = 1.0/(6.0*t2)-cos(2.0*P1)
144      sh_R = atan(p/q)
145
146      p = sin(2.0*sh_I)*sin(sh_nu)
147      q = sin(2.0*sh_I)*cos(sh_nu)+0.3347
148      sh_nuprim = atan(p/q)
149
150      s2 = sin(sh_I)*sin(sh_I)
151      p  = s2*sin(2.0*sh_nu)
152      q  = s2*cos(2.0*sh_nu)+0.0727
153      sh_nusec = 0.5*atan(p/q)
154      !
155   END SUBROUTINE astronomic_angle
156
157
158   SUBROUTINE tide_pulse( pomega, ktide ,kc )
159      !!----------------------------------------------------------------------
160      !!                     ***  ROUTINE tide_pulse  ***
161      !!                     
162      !! ** Purpose : Compute tidal frequencies
163      !!----------------------------------------------------------------------
164      INTEGER                , INTENT(in ) ::   kc       ! Total number of tidal constituents
165      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide    ! Indice of tidal constituents
166      REAL(wp), DIMENSION(kc), INTENT(out) ::   pomega   ! pulsation in radians/s
167      !
168      INTEGER  ::   jh
169      REAL(wp) ::   zscale
170      REAL(wp) ::   zomega_T =  13149000.0_wp
171      REAL(wp) ::   zomega_s =    481267.892_wp
172      REAL(wp) ::   zomega_h =     36000.76892_wp
173      REAL(wp) ::   zomega_p =      4069.0322056_wp
174      REAL(wp) ::   zomega_n =      1934.1423972_wp
175      REAL(wp) ::   zomega_p1=         1.719175_wp
176      !!----------------------------------------------------------------------
177      !
178      zscale =  rad / ( 36525._wp * 86400._wp ) 
179      !
180      DO jh = 1, kc
181         pomega(jh) = (  zomega_T * Wave( ktide(jh) )%nT   &
182            &          + zomega_s * Wave( ktide(jh) )%ns   &
183            &          + zomega_h * Wave( ktide(jh) )%nh   &
184            &          + zomega_p * Wave( ktide(jh) )%np   &
185            &          + zomega_p1* Wave( ktide(jh) )%np1  ) * zscale
186      END DO
187      !
188   END SUBROUTINE tide_pulse
189
190
191   SUBROUTINE tide_vuf( pvt, put, pcor, ktide ,kc )
192      !!----------------------------------------------------------------------
193      !!                     ***  ROUTINE tide_vuf  ***
194      !!                     
195      !! ** Purpose : Compute nodal modulation corrections
196      !!
197      !! ** Outputs : vt: Phase of tidal potential relative to Greenwich (radians)
198      !!              ut: Phase correction u due to nodal motion (radians)
199      !!              ft: Nodal correction factor
200      !!----------------------------------------------------------------------
201      INTEGER                , INTENT(in ) ::   kc               ! Total number of tidal constituents
202      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide            ! Indice of tidal constituents
203      REAL(wp), DIMENSION(kc), INTENT(out) ::   pvt, put, pcor   !
204      !
205      INTEGER ::   jh   ! dummy loop index
206      !!----------------------------------------------------------------------
207      !
208      DO jh = 1, kc
209         !  Phase of the tidal potential relative to the Greenwhich
210         !  meridian (e.g. the position of the fictuous celestial body). Units are radian:
211         pvt(jh) = sh_T * Wave( ktide(jh) )%nT    &
212            &    + sh_s * Wave( ktide(jh) )%ns    &
213            &    + sh_h * Wave( ktide(jh) )%nh    &
214            &    + sh_p * Wave( ktide(jh) )%np    &
215            &    + sh_p1* Wave( ktide(jh) )%np1   &
216            &    +        Wave( ktide(jh) )%shift * rad
217         !
218         !  Phase correction u due to nodal motion. Units are radian:
219         put(jh) = sh_xi     * Wave( ktide(jh) )%nksi   &
220            &    + sh_nu     * Wave( ktide(jh) )%nnu0   &
221            &    + sh_nuprim * Wave( ktide(jh) )%nnu1   &
222            &    + sh_nusec  * Wave( ktide(jh) )%nnu2   &
223            &    + sh_R      * Wave( ktide(jh) )%R
224
225         !  Nodal correction factor:
226         pcor(jh) = nodal_factort( Wave( ktide(jh) )%nformula )
227      END DO
228      !
229   END SUBROUTINE tide_vuf
230
231
232   RECURSIVE FUNCTION nodal_factort( kformula ) RESULT( zf )
233      !!----------------------------------------------------------------------
234      !!----------------------------------------------------------------------
235      INTEGER, INTENT(in) :: kformula
236      !
237      REAL(wp) :: zf
238      REAL(wp) :: zs, zf1, zf2
239      !!----------------------------------------------------------------------
240      !
241      SELECT CASE( kformula )
242      !
243      CASE( 0 )                  !==  formule 0, solar waves
244         zf = 1.0
245         !
246      CASE( 1 )                  !==  formule 1, compound waves (78 x 78)
247         zf=nodal_factort(78)
248         zf = zf * zf
249         !
250      CASE ( 2 )                 !==  formule 2, compound waves (78 x 0)  ===  (78)
251       zf1= nodal_factort(78)
252       zf = nodal_factort( 0)
253       zf = zf1 * zf
254       !
255      CASE ( 4 )                 !==  formule 4,  compound waves (78 x 235)
256         zf1 = nodal_factort( 78)
257         zf  = nodal_factort(235)
258         zf  = zf1 * zf
259         !
260      CASE ( 5 )                 !==  formule 5,  compound waves (78 *78 x 235)
261         zf1 = nodal_factort( 78)
262         zf  = nodal_factort(235)
263         zf  = zf * zf1 * zf1
264         !
265      CASE ( 6 )                 !==  formule 6,  compound waves (78 *78 x 0)
266         zf1 = nodal_factort(78)
267         zf  = nodal_factort( 0)
268         zf  = zf * zf1 * zf1 
269         !
270      CASE( 7 )                  !==  formule 7, compound waves (75 x 75)
271         zf = nodal_factort(75)
272         zf = zf * zf
273         !
274      CASE( 8 )                  !==  formule 8,  compound waves (78 x 0 x 235)
275         zf  = nodal_factort( 78)
276         zf1 = nodal_factort(  0)
277         zf2 = nodal_factort(235)
278         zf  = zf * zf1 * zf2
279         !
280      CASE( 9 )                  !==  formule 9,  compound waves (78 x 0 x 227)
281         zf  = nodal_factort( 78)
282         zf1 = nodal_factort(  0)
283         zf2 = nodal_factort(227)
284         zf  = zf * zf1 * zf2
285         !
286      CASE( 10 )                 !==  formule 10,  compound waves (78 x 227)
287         zf  = nodal_factort( 78)
288         zf1 = nodal_factort(227)
289         zf  = zf * zf1
290         !
291      CASE( 11 )                 !==  formule 11,  compound waves (75 x 0)
292!!gm bug???? zf 2 fois !
293         zf = nodal_factort(75)
294         zf1 = nodal_factort( 0)
295         zf = zf * zf1
296         !
297      CASE( 12 )                 !==  formule 12,  compound waves (78 x 78 x 78 x 0)
298         zf1 = nodal_factort(78)
299         zf  = nodal_factort( 0)
300         zf  = zf * zf1 * zf1 * zf1
301         !
302      CASE( 13 )                 !==  formule 13, compound waves (78 x 75)
303         zf1 = nodal_factort(78)
304         zf  = nodal_factort(75)
305         zf  = zf * zf1
306         !
307      CASE( 14 )                 !==  formule 14, compound waves (235 x 0)  ===  (235)
308         zf  = nodal_factort(235)
309         zf1 = nodal_factort(  0)
310         zf  = zf * zf1
311         !
312      CASE( 15 )                 !==  formule 15, compound waves (235 x 75)
313         zf  = nodal_factort(235)
314         zf1 = nodal_factort( 75)
315         zf  = zf * zf1
316         !
317      CASE( 16 )                 !==  formule 16, compound waves (78 x 0 x 0)  ===  (78)
318         zf  = nodal_factort(78)
319         zf1 = nodal_factort( 0)
320         zf  = zf * zf1 * zf1
321         !
322      CASE( 17 )                 !==  formule 17,  compound waves (227 x 0)
323         zf1 = nodal_factort(227)
324         zf  = nodal_factort(  0)
325         zf  = zf * zf1
326         !
327      CASE( 18 )                 !==  formule 18,  compound waves (78 x 78 x 78 )
328         zf1 = nodal_factort(78)
329         zf  = zf1 * zf1 * zf1
330         !
331      CASE( 19 )                 !==  formule 19, compound waves (78 x 0 x 0 x 0)  ===  (78)
332!!gm bug2 ==>>>   here identical to formule 16,  a third multiplication by zf1 is missing
333         zf  = nodal_factort(78)
334         zf1 = nodal_factort( 0)
335         zf = zf * zf1 * zf1
336         !
337      CASE( 20 )                 !==  formule 20,  compound waves ( 78 x 78 x 78 x 78 ) 
338         zf1 = nodal_factort(78) 
339         zf  = zf1 * zf1 * zf1 * zf1 
340         !
341      CASE( 73 )                 !==  formule 73
342         zs = sin(sh_I)
343         zf = (2./3.-zs*zs)/0.5021
344         !
345      CASE( 74 )                 !==  formule 74
346         zs = sin(sh_I)
347         zf = zs * zs / 0.1578
348         !
349      CASE( 75 )                 !==  formule 75
350         zs = cos(sh_I/2)
351         zf = sin(sh_I) * zs * zs / 0.3800
352         !
353      CASE( 76 )                 !==  formule 76
354         zf = sin(2*sh_I) / 0.7214
355         !
356      CASE( 77 )                 !==  formule 77
357         zs = sin(sh_I/2)
358         zf = sin(sh_I) * zs * zs / 0.0164
359         !
360      CASE( 78 )                 !==  formule 78
361         zs = cos(sh_I/2)
362         zf = zs * zs * zs * zs / 0.9154
363         !
364      CASE( 79 )                 !==  formule 79
365         zs = sin(sh_I)
366         zf = zs * zs / 0.1565
367         !
368      CASE( 144 )                !==  formule 144
369         zs = sin(sh_I/2)
370         zf = ( 1-10*zs*zs+15*zs*zs*zs*zs ) * cos(sh_I/2) / 0.5873
371         !
372      CASE( 149 )                !==  formule 149
373         zs = cos(sh_I/2)
374         zf = zs*zs*zs*zs*zs*zs / 0.8758
375         !
376      CASE( 215 )                !==  formule 215
377         zs = cos(sh_I/2)
378         zf = zs*zs*zs*zs / 0.9154 * sh_x1ra
379         !
380      CASE( 227 )                !==  formule 227
381         zs = sin(2*sh_I)
382         zf = sqrt( 0.8965*zs*zs+0.6001*zs*cos (sh_nu)+0.1006 )
383         !
384      CASE ( 235 )               !==  formule 235
385         zs = sin(sh_I)
386         zf = sqrt( 19.0444*zs*zs*zs*zs + 2.7702*zs*zs*cos(2*sh_nu) + .0981 )
387         !
388      END SELECT
389      !
390   END FUNCTION nodal_factort
391
392
393   FUNCTION dayjul( kyr, kmonth, kday )
394      !!----------------------------------------------------------------------
395      !!  *** THIS ROUTINE COMPUTES THE JULIAN DAY (AS A REAL VARIABLE)
396      !!----------------------------------------------------------------------
397      INTEGER,INTENT(in) ::   kyr, kmonth, kday
398      !
399      INTEGER,DIMENSION(12) ::  idayt, idays
400      INTEGER  ::   inc, ji
401      REAL(wp) ::   dayjul, zyq
402      !
403      DATA idayt/0.,31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334./
404      !!----------------------------------------------------------------------
405      !
406      idays(1) = 0.
407      idays(2) = 31.
408      inc = 0.
409      zyq = MOD( kyr-1900. , 4. )
410      IF( zyq == 0.)   inc = 1.
411      DO ji = 3, 12
412         idays(ji)=idayt(ji)+inc
413      END DO
414      dayjul = idays(kmonth) + kday
415      !
416   END FUNCTION dayjul
417
418   !!======================================================================
419END MODULE tide_mod
Note: See TracBrowser for help on using the repository browser.