1
1
! > Inline harmonic analysis (conventional)
2
2
module MOM_harmonic_analysis
3
3
4
- use MOM_time_manager, only : time_type, real_to_time, time_type_to_real, &
5
- set_date, get_date, increment_date, &
6
- operator (+ ), operator (- ), operator (<), operator (>), operator (>= )
4
+ use MOM_time_manager, only : time_type, real_to_time, time_type_to_real
5
+ use MOM_time_manager, only : set_date, get_date, increment_date
6
+ use MOM_time_manager, only : operator (+ ), operator (- ), operator (<), operator (>), operator (>= )
7
7
use MOM_grid, only : ocean_grid_type
8
8
use MOM_unit_scaling, only : unit_scale_type
9
9
use MOM_file_parser, only : param_file_type, get_param
10
- use MOM_io, only : file_exists, open_ASCII_file, READONLY_FILE, close_file, &
11
- MOM_infra_file, vardesc, MOM_field, &
12
- var_desc, create_MOM_file, SINGLE_FILE, MOM_write_field
10
+ use MOM_io, only : file_exists, open_ASCII_file, READONLY_FILE, close_file
11
+ use MOM_io, only : MOM_infra_file, vardesc, MOM_field
12
+ use MOM_io, only : var_desc, create_MOM_file, SINGLE_FILE, MOM_write_field
13
13
use MOM_error_handler, only : MOM_mesg, MOM_error, NOTE
14
14
use MOM_tidal_forcing, only : astro_longitudes, astro_longitudes_init, eq_phase, nodal_fu, tidal_frequency
15
15
@@ -54,7 +54,6 @@ module MOM_harmonic_analysis
54
54
integer :: length ! < Number of fields of which harmonic analysis is to be performed
55
55
character (len= 4 ), allocatable , dimension (:) :: const_name ! < The name of each constituent
56
56
character (len= 255 ) :: path ! < Path to directory where output will be written
57
- type (ocean_grid_type) :: G ! < The ocean's grid structure
58
57
type (unit_scale_type) :: US ! < A dimensional unit scaling type
59
58
type (HA_node), pointer :: list = > NULL () ! < A linked list for storing the HA info of different fields
60
59
end type harmonic_analysis_CS
@@ -63,9 +62,8 @@ module MOM_harmonic_analysis
63
62
64
63
! > This subroutine sets static variables used by this module and initializes CS%list.
65
64
! ! THIS MUST BE CALLED AT THE END OF tidal_forcing_init.
66
- subroutine HA_init (Time , G , US , param_file , nc , CS )
65
+ subroutine HA_init (Time , US , param_file , nc , CS )
67
66
type (time_type), intent (in ) :: Time ! < The current model time
68
- type (ocean_grid_type), intent (in ) :: G ! < The ocean's grid structure
69
67
type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
70
68
type (param_file_type), intent (in ) :: param_file ! < A structure to parse for run-time parameters
71
69
integer , intent (in ) :: nc ! < The number of tidal constituents in use
@@ -164,7 +162,28 @@ subroutine HA_init(Time, G, US, param_file, nc, CS)
164
162
CS% freq(c), " Frequency of the " // trim (CS% const_name(c))// &
165
163
" constituent. This is used if USE_HA is true and " // trim (CS% const_name(c))// &
166
164
" is in HA_CONSTITUENTS." , units= " rad s-1" , scale= US% T_to_s, default= 0.0 )
167
- if (CS% freq(c)<= 0.0 ) CS% freq(c) = tidal_frequency(trim (CS% const_name(c)))
165
+ if (CS% freq(c)<= 0.0 ) then
166
+ select case (trim (CS% const_name(c)))
167
+ case (' M4' )
168
+ CS% freq(c) = tidal_frequency(' M2' ) * 2
169
+ case (' M6' )
170
+ CS% freq(c) = tidal_frequency(' M2' ) * 3
171
+ case (' M8' )
172
+ CS% freq(c) = tidal_frequency(' M2' ) * 4
173
+ case (' S4' )
174
+ CS% freq(c) = tidal_frequency(' S2' ) * 2
175
+ case (' S6' )
176
+ CS% freq(c) = tidal_frequency(' S2' ) * 3
177
+ case (' MK3' )
178
+ CS% freq(c) = tidal_frequency(' M2' ) + tidal_frequency(' K1' )
179
+ case (' MS4' )
180
+ CS% freq(c) = tidal_frequency(' M2' ) + tidal_frequency(' S2' )
181
+ case (' MN4' )
182
+ CS% freq(c) = tidal_frequency(' M2' ) + tidal_frequency(' N2' )
183
+ case default
184
+ CS% freq(c) = tidal_frequency(trim (CS% const_name(c)))
185
+ end select
186
+ endif
168
187
169
188
call get_param(param_file, mdl, " HA_" // trim (CS% const_name(c))// " _PHASE_T0" , CS% phase0(c), &
170
189
" Phase of the " // trim (CS% const_name(c))// " tidal constituent at time 0. " // &
@@ -236,7 +255,6 @@ subroutine HA_init(Time, G, US, param_file, nc, CS)
236
255
! Populate some parameters of the control structure
237
256
CS% nc = nc
238
257
CS% length = 0
239
- CS% G = G
240
258
CS% US = US
241
259
242
260
! Initialize CS%list
@@ -283,10 +301,11 @@ end subroutine HA_register
283
301
! ! harmonic constants and write results. The tidal constituents are those used in MOM_tidal_forcing, plus the
284
302
! ! mean (of zero frequency). For FtF, only the main diagonal and entries below it are calculated, which are needed
285
303
! ! for Cholesky decomposition.
286
- subroutine HA_accum (key , data , Time , CS )
304
+ subroutine HA_accum (key , data , Time , G , CS )
287
305
character (len=* ), intent (in ) :: key ! < Name of the current field
288
306
real , dimension (:,:), intent (in ) :: data ! < Input data of which harmonic analysis is to be performed [A]
289
307
type (time_type), intent (in ) :: Time ! < The current model time
308
+ type (ocean_grid_type), intent (in ) :: G ! < The ocean's grid structure
290
309
type (harmonic_analysis_CS), intent (inout ) :: CS ! < Control structure of the MOM_harmonic_analysis module
291
310
292
311
! Local variables
@@ -389,7 +408,7 @@ subroutine HA_accum(key, data, Time, CS)
389
408
! !! Compute harmonic constants and write output as Time approaches CS%time_end !!!
390
409
! This guarantees that HA_write will be called before Time becomes larger than CS%time_end
391
410
if (time_type_to_real(CS% time_end - Time) <= dt) then
392
- call HA_write(ha1, Time, CS)
411
+ call HA_write(ha1, Time, G, CS)
393
412
394
413
write (mesg,* ) " MOM_harmonic_analysis: harmonic analysis done, key = " , trim (ha1% key)
395
414
call MOM_error(NOTE, trim (mesg))
@@ -403,9 +422,10 @@ subroutine HA_accum(key, data, Time, CS)
403
422
end subroutine HA_accum
404
423
405
424
! > This subroutine computes the harmonic constants and write output for the current field
406
- subroutine HA_write (ha1 , Time , CS )
425
+ subroutine HA_write (ha1 , Time , G , CS )
407
426
type (HA_type), pointer , intent (in ) :: ha1 ! < Control structure for the current field
408
427
type (time_type), intent (in ) :: Time ! < The current model time
428
+ type (ocean_grid_type), intent (in ) :: G ! < The ocean's grid structure
409
429
type (harmonic_analysis_CS), intent (in ) :: CS ! < Control structure of the MOM_harmonic_analysis module
410
430
411
431
! Local variables
@@ -442,18 +462,18 @@ subroutine HA_write(ha1, Time, CS)
442
462
443
463
! Create output file
444
464
call create_MOM_file(cdf, trim (filename), cdf_vars, &
445
- 2 * nc+1 , cdf_fields, SINGLE_FILE, 86400.0 , G= CS % G)
465
+ 2 * nc+1 , cdf_fields, SINGLE_FILE, 86400.0 , G= G)
446
466
447
467
! Add the initial field back to the mean state
448
468
do j= js,je ; do i= is,ie
449
469
FtSSHw(i,j,1 ) = FtSSHw(i,j,1 ) + ha1% ref(i,j)
450
470
enddo ; enddo
451
471
452
472
! Write data
453
- call MOM_write_field(cdf, cdf_fields(1 ), CS % G% domain, FtSSHw(:,:,1 ), 0.0 )
473
+ call MOM_write_field(cdf, cdf_fields(1 ), G% domain, FtSSHw(:,:,1 ), 0.0 )
454
474
do k= 1 ,nc
455
- call MOM_write_field(cdf, cdf_fields(2 * k ), CS % G% domain, FtSSHw(:,:,2 * k ), 0.0 )
456
- call MOM_write_field(cdf, cdf_fields(2 * k+1 ), CS % G% domain, FtSSHw(:,:,2 * k+1 ), 0.0 )
475
+ call MOM_write_field(cdf, cdf_fields(2 * k ), G% domain, FtSSHw(:,:,2 * k ), 0.0 )
476
+ call MOM_write_field(cdf, cdf_fields(2 * k+1 ), G% domain, FtSSHw(:,:,2 * k+1 ), 0.0 )
457
477
enddo
458
478
459
479
call cdf% flush()
0 commit comments