Skip to content

Commit e8dc900

Browse files
committed
Inline Harmonic Analysis
Update 6: The frequencies of 8 overtides/compound tides (MK3, MN4, M4, MS4, S4, M6, M8) have been added (for harmonic analysis only).
1 parent 032488f commit e8dc900

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

src/diagnostics/MOM_harmonic_analysis.F90

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
!> Inline harmonic analysis (conventional)
22
module MOM_harmonic_analysis
33

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(>=)
77
use MOM_grid, only : ocean_grid_type
88
use MOM_unit_scaling, only : unit_scale_type
99
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
1313
use MOM_error_handler, only : MOM_mesg, MOM_error, NOTE
1414
use MOM_tidal_forcing, only : astro_longitudes, astro_longitudes_init, eq_phase, nodal_fu, tidal_frequency
1515

@@ -54,7 +54,7 @@ module MOM_harmonic_analysis
5454
integer :: length !< Number of fields of which harmonic analysis is to be performed
5555
character(len=4), allocatable, dimension(:) :: const_name !< The name of each constituent
5656
character(len=255) :: path !< Path to directory where output will be written
57-
type(ocean_grid_type) :: G !< The ocean's grid structure
57+
type(ocean_grid_type), pointer :: G !< The ocean's grid structure
5858
type(unit_scale_type) :: US !< A dimensional unit scaling type
5959
type(HA_node), pointer :: list => NULL() !< A linked list for storing the HA info of different fields
6060
end type harmonic_analysis_CS
@@ -65,7 +65,7 @@ module MOM_harmonic_analysis
6565
!! THIS MUST BE CALLED AT THE END OF tidal_forcing_init.
6666
subroutine HA_init(Time, G, US, param_file, nc, CS)
6767
type(time_type), intent(in) :: Time !< The current model time
68-
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
68+
type(ocean_grid_type), target :: G !< The ocean's grid structure
6969
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
7070
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters
7171
integer, intent(in) :: nc !< The number of tidal constituents in use
@@ -164,7 +164,28 @@ subroutine HA_init(Time, G, US, param_file, nc, CS)
164164
CS%freq(c), "Frequency of the "//trim(CS%const_name(c))//&
165165
" constituent. This is used if USE_HA is true and "//trim(CS%const_name(c))//&
166166
" 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)))
167+
if (CS%freq(c)<=0.0) then
168+
select case (trim(CS%const_name(c)))
169+
case ('M4')
170+
CS%freq(c) = tidal_frequency('M2') * 2
171+
case ('M6')
172+
CS%freq(c) = tidal_frequency('M2') * 3
173+
case ('M8')
174+
CS%freq(c) = tidal_frequency('M2') * 4
175+
case ('S4')
176+
CS%freq(c) = tidal_frequency('S2') * 2
177+
case ('S6')
178+
CS%freq(c) = tidal_frequency('S2') * 3
179+
case ('MK3')
180+
CS%freq(c) = tidal_frequency('M2') + tidal_frequency('K1')
181+
case ('MS4')
182+
CS%freq(c) = tidal_frequency('M2') + tidal_frequency('S2')
183+
case ('MN4')
184+
CS%freq(c) = tidal_frequency('M2') + tidal_frequency('N2')
185+
case default
186+
CS%freq(c) = tidal_frequency(trim(CS%const_name(c)))
187+
end select
188+
endif
168189

169190
call get_param(param_file, mdl, "HA_"//trim(CS%const_name(c))//"_PHASE_T0", CS%phase0(c), &
170191
"Phase of the "//trim(CS%const_name(c))//" tidal constituent at time 0. "//&
@@ -236,7 +257,7 @@ subroutine HA_init(Time, G, US, param_file, nc, CS)
236257
! Populate some parameters of the control structure
237258
CS%nc = nc
238259
CS%length = 0
239-
CS%G = G
260+
CS%G => G
240261
CS%US = US
241262

242263
! Initialize CS%list

0 commit comments

Comments
 (0)