20 implicit none ;
private
22 #include <MOM_memory.h>
24 public dyed_channel_set_obc_tracer_data, dyed_channel_obc_end
25 public register_dyed_channel_obc, dyed_channel_update_flow
29 real :: zonal_flow = 8.57
30 real :: tidal_amp = 0.0
31 real :: frequency = 0.0
40 function register_dyed_channel_obc(param_file, CS, OBC_Reg)
45 logical :: register_dyed_channel_obc
46 character(len=32) :: casename =
"dyed channel"
47 character(len=40) :: mdl =
"register_dyed_channel_OBC"
49 if (
associated(cs))
then
50 call mom_error(warning,
"register_dyed_channel_OBC called with an "// &
51 "associated control structure.")
56 call get_param(param_file, mdl,
"CHANNEL_MEAN_FLOW", cs%zonal_flow, &
57 "Mean zonal flow imposed at upstream open boundary.", &
58 units=
"m/s", default=8.57)
59 call get_param(param_file, mdl,
"CHANNEL_TIDAL_AMP", cs%tidal_amp, &
60 "Sloshing amplitude imposed at upstream open boundary.", &
61 units=
"m/s", default=0.0)
62 call get_param(param_file, mdl,
"CHANNEL_FLOW_FREQUENCY", cs%frequency, &
63 "Frequency of oscillating zonal flow.", &
64 units=
"s-1", default=0.0)
67 call register_obc(casename, param_file, obc_reg)
68 register_dyed_channel_obc = .true.
70 end function register_dyed_channel_obc
73 subroutine dyed_channel_obc_end(CS)
76 if (
associated(cs))
then
79 end subroutine dyed_channel_obc_end
82 subroutine dyed_channel_set_obc_tracer_data(OBC, G, GV, param_file, tr_Reg)
92 character(len=40) :: mdl =
"dyed_channel_set_OBC_tracer_data"
93 character(len=80) :: name, longname
94 integer :: i, j, k, l, itt, isd, ied, jsd, jed, m, n
95 integer :: isdb, iedb, jsdb, jedb
100 if (.not.
associated(obc))
call mom_error(fatal,
'dyed_channel_initialization.F90: '// &
101 'dyed_channel_set_OBC_data() was called but OBC type was not initialized!')
103 call get_param(param_file, mdl,
"NUM_DYE_TRACERS", ntr, &
104 "The number of dye tracers in this run. Each tracer "//&
105 "should have a separate boundary segment.", default=0, &
108 if (obc%number_of_segments < ntr)
then
109 call mom_error(warning,
"Error in dyed_obc segment setup")
116 write(name,
'("dye_",I2.2)') m
117 write(longname,
'("Concentration of dyed_obc Tracer ",I2.2, " on segment ",I2.2)') m, m
118 call tracer_name_lookup(tr_reg, tr_ptr, name)
120 do n=1,obc%number_of_segments
126 call register_segment_tracer(tr_ptr, param_file, gv, &
127 obc%segment(n), obc_scalar=dye)
131 end subroutine dyed_channel_set_obc_tracer_data
134 subroutine dyed_channel_update_flow(OBC, CS, G, Time)
140 type(time_type),
intent(in) :: time
142 character(len=40) :: mdl =
"dyed_channel_update_flow"
143 character(len=80) :: name
144 real :: flow, time_sec, pi
145 integer :: i, j, k, l, itt, isd, ied, jsd, jed, m, n
146 integer :: isdb, iedb, jsdb, jedb
149 if (.not.
associated(obc))
call mom_error(fatal,
'dyed_channel_initialization.F90: '// &
150 'dyed_channel_update_flow() was called but OBC type was not initialized!')
152 time_sec = time_type_to_real(time)
155 do l=1, obc%number_of_segments
156 segment => obc%segment(l)
157 if (.not. segment%on_pe) cycle
158 if (segment%gradient) cycle
159 if (segment%oblique .and. .not. segment%nudged .and. .not. segment%Flather) cycle
161 if (segment%is_E_or_W)
then
162 jsd = segment%HI%jsd ; jed = segment%HI%jed
163 isdb = segment%HI%IsdB ; iedb = segment%HI%IedB
164 if (cs%frequency == 0.0)
then
167 flow = cs%zonal_flow + cs%tidal_amp * cos(2 * pi * cs%frequency * time_sec)
170 do j=jsd,jed ;
do i=isdb,iedb
171 if (segment%specified .or. segment%nudged)
then
172 segment%normal_vel(i,j,k) = flow
174 if (segment%specified)
then
175 segment%normal_trans(i,j,k) = flow * g%dyCu(i,j)
179 do j=jsd,jed ;
do i=isdb,iedb
180 segment%normal_vel_bt(i,j) = flow
183 isd = segment%HI%isd ; ied = segment%HI%ied
184 jsdb = segment%HI%JsdB ; jedb = segment%HI%JedB
185 do j=jsdb,jedb ;
do i=isd,ied
186 segment%normal_vel_bt(i,j) = 0.0
191 end subroutine dyed_channel_update_flow