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/2019/dev_r11879_ENHANCE-05_SimonM-Harmonic_Analysis/src/OCE/SBC – NEMO

source: NEMO/branches/2019/dev_r11879_ENHANCE-05_SimonM-Harmonic_Analysis/src/OCE/SBC/tide_mod.F90 @ 12097

Last change on this file since 12097 was 12097, checked in by smueller, 4 years ago

Addition of AGRIF directives to enable compilation with key_agrif (ticket #2175)

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