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, get_date, increment_date, &
4
+ use MOM_time_manager, only : time_type, real_to_time, time_type_to_real, &
5
+ set_date, get_date, increment_date, &
5
6
operator (+ ), operator (- ), operator (<), operator (>), operator (>= )
6
7
use MOM_grid, only : ocean_grid_type
7
8
use MOM_unit_scaling, only : unit_scale_type
@@ -52,7 +53,7 @@ module MOM_harmonic_analysis
52
53
tide_un ! < Phase modulation of tides by nodal cycle [rad].
53
54
integer :: nc ! < The number of tidal constituents in use
54
55
integer :: length ! < Number of fields of which harmonic analysis is to be performed
55
- character (len= 16 ) :: const_name(MAX_CONSTITUENTS) ! < The name of each constituent
56
+ character (len= 2 ), allocatable , dimension (:) :: const_name ! < The name of each constituent
56
57
character (len= 255 ) :: path ! < Path to directory where output will be written
57
58
type (unit_scale_type) :: US ! < A dimensional unit scaling type
58
59
type (HA_node), pointer :: list = > NULL () ! < A linked list for storing the HA info of different fields
@@ -62,20 +63,26 @@ module MOM_harmonic_analysis
62
63
63
64
! > This subroutine sets static variables used by this module and initializes CS%list.
64
65
! ! THIS MUST BE CALLED AT THE END OF tidal_forcing_init.
65
- subroutine HA_init (Time , US , param_file , time_ref , nc , freq , phase0 , const_name , tide_fn , tide_un , CS )
66
+ subroutine HA_init (Time , US , param_file , nc , freq , phase0 , tide_fn , tide_un , CS )
66
67
type (time_type), intent (in ) :: Time ! < The current model time
67
- type (time_type), intent (in ) :: time_ref ! < Reference time (t = 0) used to calculate tidal forcing
68
68
type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
69
69
type (param_file_type), intent (in ) :: param_file ! < A structure to parse for run-time parameters
70
70
real , intent (in ) :: freq(MAX_CONSTITUENTS) ! < The frequency of a tidal constituent [T-1 ~> s-1]
71
71
real , intent (in ) :: phase0(MAX_CONSTITUENTS) ! < The phase of a tidal constituent at time 0 [rad]
72
72
real , intent (in ) :: tide_fn(MAX_CONSTITUENTS) ! < Amplitude modulation of tides by nodal cycle [nondim].
73
73
real , intent (in ) :: tide_un(MAX_CONSTITUENTS) ! < Phase modulation of tides by nodal cycle [rad].
74
74
integer , intent (in ) :: nc ! < The number of tidal constituents in use
75
- character (len= 16 ), intent (in ) :: const_name(MAX_CONSTITUENTS) ! < The name of each constituent
76
75
type (harmonic_analysis_CS), intent (out ) :: CS ! < Control structure of the MOM_harmonic_analysis module
77
76
78
77
! Local variables
78
+ logical :: tides ! < True if tidal forcing module is enabled
79
+ logical :: use_eq_phase ! < If true, tidal forcing is phase-shifted to match
80
+ ! ! equilibrium tide. Set to false if providing tidal phases
81
+ ! ! that have already been shifted by the
82
+ ! ! astronomical/equilibrium argument.
83
+ integer , dimension (3 ) :: tide_ref_date ! < Reference date (t = 0) for tidal forcing (year, month, day).
84
+ character (len= 2 ) :: const_name(MAX_CONSTITUENTS) ! < The name of each constituent
85
+
79
86
type (HA_type) :: ha1 ! < A temporary, null field used for initializing CS%list
80
87
real :: HA_start_time ! < Start time of harmonic analysis [T ~> s]
81
88
real :: HA_end_time ! < End time of harmonic analysis [T ~> s]
@@ -84,6 +91,37 @@ subroutine HA_init(Time, US, param_file, time_ref, nc, freq, phase0, const_name,
84
91
character (len= 255 ) :: mesg
85
92
integer :: year, month, day, hour, minute, second
86
93
94
+ call get_param(param_file, mdl, " TIDES" , tides, &
95
+ " If true, apply tidal momentum forcing." , default= .false. , do_not_log= .true. )
96
+
97
+ call get_param(param_file, mdl, " TIDE_REF_DATE" , tide_ref_date, &
98
+ " Reference date to use for tidal calculations and equilibrium phase." , &
99
+ old_name= " OBC_TIDE_REF_DATE" , defaults= (/ 0 , 0 , 0 / ), do_not_log= tides)
100
+
101
+ call get_param(param_file, mdl, " TIDE_USE_EQ_PHASE" , use_eq_phase, &
102
+ " If true, add the equilibrium phase argument to the specified tidal phases." , &
103
+ old_name= " OBC_TIDE_ADD_EQ_PHASE" , default= .false. , do_not_log= tides)
104
+
105
+ call get_param(param_file, mdl, " HA_CONSTITUENTS" , const_name, &
106
+ " Names of tidal constituents to be harmonically analyzed. " // &
107
+ " They don't have to be the same as those used in MOM_tidal_forcing." , &
108
+ fail_if_missing= .true. )
109
+
110
+ if (sum (tide_ref_date) == 0 ) then ! tide_ref_date defaults to 0.
111
+ CS% time_ref = set_date(1 , 1 , 1 , 0 , 0 , 0 )
112
+ else
113
+ if (.not. use_eq_phase) then
114
+ ! Using a reference date but not using phase relative to equilibrium.
115
+ ! This makes sense as long as either phases are overridden, or
116
+ ! correctly simulating tidal phases is not desired.
117
+ call MOM_mesg(' Tidal phases will *not* be corrected with equilibrium arguments.' )
118
+ endif
119
+ CS% time_ref = set_date(tide_ref_date(1 ), tide_ref_date(2 ), tide_ref_date(3 ), 0 , 0 , 0 )
120
+ endif
121
+
122
+ allocate (CS% const_name(nc))
123
+ read (const_name, * ) CS% const_name
124
+
87
125
! Determine CS%time_start and CS%time_end
88
126
call get_param(param_file, mdl, " HA_START_TIME" , HA_start_time, &
89
127
" Start time of harmonic analysis, in units of days after " // &
@@ -137,13 +175,11 @@ subroutine HA_init(Time, US, param_file, time_ref, nc, freq, phase0, const_name,
137
175
" Path to output files for runtime harmonic analysis." , default= " ./" )
138
176
139
177
! Populate some parameters of the control structure
140
- CS% time_ref = time_ref
141
178
CS% freq = freq
142
179
CS% phase0 = phase0
143
180
CS% tide_fn = tide_fn
144
181
CS% tide_un = tide_un
145
182
CS% nc = nc
146
- CS% const_name = const_name
147
183
CS% length = 0
148
184
CS% US = US
149
185
0 commit comments