14 use mom_time_manager,
only : time_type,
operator(+),
operator(/), time_type_to_real
18 implicit none ;
private
20 #include <MOM_memory.h>
22 public scm_cvmix_tests_ts_init
23 public scm_cvmix_tests_surface_forcing_init
24 public scm_cvmix_tests_wind_forcing
25 public scm_cvmix_tests_buoyancy_forcing
35 logical :: usewindstress
36 logical :: useheatflux
37 logical :: useevaporation
38 logical :: usediurnalsw
48 #include "version_variable.h"
50 character(len=40) :: mdl =
"SCM_CVMix_tests"
55 subroutine scm_cvmix_tests_ts_init(T, S, h, G, GV, US, param_file, just_read_params)
56 real,
dimension(NIMEM_,NJMEM_, NKMEM_),
intent(out) :: t
57 real,
dimension(NIMEM_,NJMEM_, NKMEM_),
intent(out) :: s
58 real,
dimension(NIMEM_,NJMEM_, NKMEM_),
intent(in) :: h
63 logical,
optional,
intent(in) :: just_read_params
66 real :: upperlayertempmld
67 real :: upperlayersaltmld
68 real :: upperlayertemp
69 real :: upperlayersalt
70 real :: lowerlayertemp
71 real :: lowerlayersalt
72 real :: lowerlayerdtdz
73 real :: lowerlayerdsdz
74 real :: lowerlayermintemp
75 real :: zc, dz, top, bottom
77 integer :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz
79 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
80 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
83 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
85 if (.not.just_read)
call log_version(param_file, mdl, version)
86 call get_param(param_file, mdl,
"SCM_TEMP_MLD", upperlayertempmld, &
87 'Initial temp mixed layer depth', &
88 units=
'm', default=0.0, scale=us%m_to_Z, do_not_log=just_read)
89 call get_param(param_file, mdl,
"SCM_SALT_MLD", upperlayersaltmld, &
90 'Initial salt mixed layer depth', &
91 units=
'm', default=0.0, scale=us%m_to_Z, do_not_log=just_read)
92 call get_param(param_file, mdl,
"SCM_L1_SALT", upperlayersalt, &
93 'Layer 2 surface salinity', units=
'1e-3', default=35.0, do_not_log=just_read)
94 call get_param(param_file, mdl,
"SCM_L1_TEMP", upperlayertemp, &
95 'Layer 1 surface temperature', units=
'C', default=20.0, do_not_log=just_read)
96 call get_param(param_file, mdl,
"SCM_L2_SALT", lowerlayersalt, &
97 'Layer 2 surface salinity', units=
'1e-3', default=35.0, do_not_log=just_read)
98 call get_param(param_file, mdl,
"SCM_L2_TEMP", lowerlayertemp, &
99 'Layer 2 surface temperature', units=
'C', default=20.0, do_not_log=just_read)
100 call get_param(param_file, mdl,
"SCM_L2_DTDZ", lowerlayerdtdz, &
101 'Initial temperature stratification in layer 2', &
102 units=
'C/m', default=0.0, scale=us%Z_to_m, do_not_log=just_read)
103 call get_param(param_file, mdl,
"SCM_L2_DSDZ", lowerlayerdsdz, &
104 'Initial salinity stratification in layer 2', &
105 units=
'PPT/m', default=0.0, scale=us%Z_to_m, do_not_log=just_read)
106 call get_param(param_file, mdl,
"SCM_L2_MINTEMP",lowerlayermintemp, &
107 'Layer 2 minimum temperature', units=
'C', default=4.0, do_not_log=just_read)
109 if (just_read)
return
111 do j=js,je ;
do i=is,ie
115 bottom = bottom - h(i,j,k)*gv%H_to_Z
116 zc = 0.5*( top + bottom )
117 dz = min(0., zc + upperlayertempmld)
118 t(i,j,k) = max(lowerlayermintemp,lowerlayertemp + lowerlayerdtdz * dz)
119 dz = min(0., zc + upperlayersaltmld)
120 s(i,j,k) = lowerlayersalt + lowerlayerdsdz * dz
125 end subroutine scm_cvmix_tests_ts_init
128 subroutine scm_cvmix_tests_surface_forcing_init(Time, G, param_file, CS)
129 type(time_type),
intent(in) :: time
135 #include "version_variable.h"
137 if (
associated(cs))
then
138 call mom_error(fatal,
"SCM_CVMix_tests_surface_forcing_init called with an associated "// &
139 "control structure.")
146 call get_param(param_file, mdl,
"SCM_USE_WIND_STRESS", &
147 cs%UseWindStress,
"Wind Stress switch "// &
148 "used in the SCM CVMix surface forcing.", &
149 units=
'', default=.false.)
150 call get_param(param_file, mdl,
"SCM_USE_HEAT_FLUX", &
151 cs%UseHeatFlux,
"Heat flux switch "// &
152 "used in the SCM CVMix test surface forcing.", &
153 units=
'', default=.false.)
154 call get_param(param_file, mdl,
"SCM_USE_EVAPORATION", &
155 cs%UseEvaporation,
"Evaporation switch "// &
156 "used in the SCM CVMix test surface forcing.", &
157 units=
'', default=.false.)
158 call get_param(param_file, mdl,
"SCM_USE_DIURNAL_SW", &
159 cs%UseDiurnalSW,
"Diurnal sw radation switch "// &
160 "used in the SCM CVMix test surface forcing.", &
161 units=
'', default=.false.)
162 if (cs%UseWindStress)
then
163 call get_param(param_file, mdl,
"SCM_TAU_X", &
164 cs%tau_x,
"Constant X-dir wind stress "// &
165 "used in the SCM CVMix test surface forcing.", &
166 units=
'N/m2', fail_if_missing=.true.)
167 call get_param(param_file, mdl,
"SCM_TAU_Y", &
168 cs%tau_y,
"Constant y-dir wind stress "// &
169 "used in the SCM CVMix test surface forcing.", &
170 units=
'N/m2', fail_if_missing=.true.)
172 if (cs%UseHeatFlux)
then
173 call get_param(param_file, mdl,
"SCM_HEAT_FLUX", &
174 cs%surf_HF,
"Constant surface heat flux "// &
175 "used in the SCM CVMix test surface forcing.", &
176 units=
'm K/s', fail_if_missing=.true.)
178 if (cs%UseEvaporation)
then
179 call get_param(param_file, mdl,
"SCM_EVAPORATION", &
180 cs%surf_evap,
"Constant surface evaporation "// &
181 "used in the SCM CVMix test surface forcing.", &
182 units=
'm/s', fail_if_missing=.true.)
184 if (cs%UseDiurnalSW)
then
185 call get_param(param_file, mdl,
"SCM_DIURNAL_SW_MAX", &
186 cs%Max_sw,
"Maximum diurnal sw radiation "// &
187 "used in the SCM CVMix test surface forcing.", &
188 units=
'm K/s', fail_if_missing=.true.)
191 end subroutine scm_cvmix_tests_surface_forcing_init
193 subroutine scm_cvmix_tests_wind_forcing(state, forces, day, G, US, CS)
196 type(time_type),
intent(in) :: day
201 integer :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
202 integer :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
205 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
206 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
207 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
208 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
210 do j=js,je ;
do i=isq,ieq
211 forces%taux(i,j) = cs%tau_x
213 do j=jsq,jeq ;
do i=is,ie
214 forces%tauy(i,j) = cs%tau_y
216 call pass_vector(forces%taux, forces%tauy, g%Domain, to_all)
219 mag_tau = sqrt(cs%tau_x*cs%tau_x + cs%tau_y*cs%tau_y)
220 if (
associated(forces%ustar))
then ;
do j=js,je ;
do i=is,ie
221 forces%ustar(i,j) = us%m_to_Z*us%T_to_s * sqrt( mag_tau / cs%Rho0 )
222 enddo ;
enddo ;
endif
224 end subroutine scm_cvmix_tests_wind_forcing
227 subroutine scm_cvmix_tests_buoyancy_forcing(state, fluxes, day, G, CS)
229 type(
forcing),
intent(inout) :: fluxes
230 type(time_type),
intent(in) :: day
235 integer :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
236 integer :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
242 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
243 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
244 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
245 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
247 if (cs%UseHeatFlux)
then
251 do j=jsq,jeq ;
do i=is,ie
252 fluxes%sens(i,j) = cs%surf_HF * cs%Rho0 * fluxes%C_p
256 if (cs%UseEvaporation)
then
257 do j=jsq,jeq ;
do i=is,ie
261 fluxes%evap(i,j) = cs%surf_evap * cs%Rho0
265 if (cs%UseDiurnalSW)
then
266 do j=jsq,jeq ;
do i=is,ie
271 fluxes%sw(i,j) = cs%Max_sw * max(0.0,cos(2*pi* &
272 (time_type_to_real(day)/86400.-0.5))) * cs%RHO0 * fluxes%C_p
276 end subroutine scm_cvmix_tests_buoyancy_forcing