9 implicit none ;
private 11 #include <MOM_memory.h> 20 real,
allocatable,
dimension(:) :: coordinateresolution
23 real :: adapttimeratio = 1e-1
26 real :: adaptalpha = 1.0
29 real :: adaptzoom = 200.0
32 real :: adaptzoomcoeff = 0.0
35 real :: adaptbuoycoeff = 0.0
38 real :: adaptdrho0 = 0.5
42 logical :: adaptdomin = .false.
52 integer,
intent(in) :: nk
53 real,
dimension(:),
intent(in) :: coordinateResolution
55 if (
associated(cs))
call mom_error(fatal,
"init_coord_adapt: CS already associated")
57 allocate(cs%coordinateResolution(nk))
60 cs%coordinateResolution(:) = coordinateresolution(:)
68 if (.not.
associated(cs))
return 69 deallocate(cs%coordinateResolution)
73 subroutine set_adapt_params(CS, adaptTimeRatio, adaptAlpha, adaptZoom, adaptZoomCoeff, &
74 adaptBuoyCoeff, adaptDrho0, adaptDoMin)
76 real,
optional,
intent(in) :: adaptTimeRatio, adaptAlpha, adaptZoom, adaptZoomCoeff
77 real,
optional,
intent(in) :: adaptBuoyCoeff, adaptDrho0
78 logical,
optional,
intent(in) :: adaptDoMin
80 if (.not.
associated(cs))
call mom_error(fatal,
"set_adapt_params: CS not associated")
82 if (
present(adapttimeratio)) cs%adaptTimeRatio = adapttimeratio
83 if (
present(adaptalpha)) cs%adaptAlpha = adaptalpha
84 if (
present(adaptzoom)) cs%adaptZoom = adaptzoom
85 if (
present(adaptzoomcoeff)) cs%adaptZoomCoeff = adaptzoomcoeff
86 if (
present(adaptbuoycoeff)) cs%adaptBuoyCoeff = adaptbuoycoeff
87 if (
present(adaptdrho0)) cs%adaptDrho0 = adaptdrho0
88 if (
present(adaptdomin)) cs%adaptDoMin = adaptdomin
91 subroutine build_adapt_column(CS, G, GV, tv, i, j, zInt, tInt, sInt, h, zNext)
93 type(ocean_grid_type),
intent(in) :: G
96 integer,
intent(in) :: i, j
97 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(in) :: zInt, tInt, sInt
98 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
99 real,
dimension(SZK_(GV)+1),
intent(inout) :: zNext
103 real :: h_up, b1, b_denom_1, d1, depth, drdz, nominal_z, stretching
104 real,
dimension(SZK_(GV)+1) :: alpha, beta, del2sigma
105 real,
dimension(SZK_(GV)) :: kGrid, c1
111 znext(nz+1) = zint(i,j,nz+1)
114 depth = g%bathyT(i,j) * gv%m_to_H
124 if (g%mask2dT(i,j-1) > 0.)
then 126 0.5 * (tint(i,j,2:nz) + tint(i,j-1,2:nz)), &
127 0.5 * (sint(i,j,2:nz) + sint(i,j-1,2:nz)), &
128 0.5 * (zint(i,j,2:nz) + zint(i,j-1,2:nz)) * gv%H_to_Pa, &
129 alpha, beta, 2, nz - 1, tv%eqn_of_state)
131 del2sigma(2:nz) = del2sigma(2:nz) + &
132 (alpha(2:nz) * (tint(i,j-1,2:nz) - tint(i,j,2:nz)) + &
133 beta(2:nz) * (sint(i,j-1,2:nz) - sint(i,j,2:nz)))
136 if (g%mask2dT(i,j+1) > 0.)
then 138 0.5 * (tint(i,j,2:nz) + tint(i,j+1,2:nz)), &
139 0.5 * (sint(i,j,2:nz) + sint(i,j+1,2:nz)), &
140 0.5 * (zint(i,j,2:nz) + zint(i,j+1,2:nz)) * gv%H_to_Pa, &
141 alpha, beta, 2, nz - 1, tv%eqn_of_state)
143 del2sigma(2:nz) = del2sigma(2:nz) + &
144 (alpha(2:nz) * (tint(i,j+1,2:nz) - tint(i,j,2:nz)) + &
145 beta(2:nz) * (sint(i,j+1,2:nz) - sint(i,j,2:nz)))
148 if (g%mask2dT(i-1,j) > 0.)
then 150 0.5 * (tint(i,j,2:nz) + tint(i-1,j,2:nz)), &
151 0.5 * (sint(i,j,2:nz) + sint(i-1,j,2:nz)), &
152 0.5 * (zint(i,j,2:nz) + zint(i-1,j,2:nz)) * gv%H_to_Pa, &
153 alpha, beta, 2, nz - 1, tv%eqn_of_state)
155 del2sigma(2:nz) = del2sigma(2:nz) + &
156 (alpha(2:nz) * (tint(i-1,j,2:nz) - tint(i,j,2:nz)) + &
157 beta(2:nz) * (sint(i-1,j,2:nz) - sint(i,j,2:nz)))
160 if (g%mask2dT(i+1,j) > 0.)
then 162 0.5 * (tint(i,j,2:nz) + tint(i+1,j,2:nz)), &
163 0.5 * (sint(i,j,2:nz) + sint(i+1,j,2:nz)), &
164 0.5 * (zint(i,j,2:nz) + zint(i+1,j,2:nz)) * gv%H_to_Pa, &
165 alpha, beta, 2, nz - 1, tv%eqn_of_state)
167 del2sigma(2:nz) = del2sigma(2:nz) + &
168 (alpha(2:nz) * (tint(i+1,j,2:nz) - tint(i,j,2:nz)) + &
169 beta(2:nz) * (sint(i+1,j,2:nz) - sint(i,j,2:nz)))
179 alpha, beta, 1, nz + 1, tv%eqn_of_state)
182 del2sigma(k) = del2sigma(k) * (0.5 * (h(i,j,k-1) + h(i,j,k))) / &
183 max(alpha(k) * (tv%T(i,j,k) - tv%T(i,j,k-1)) + &
184 beta(k) * (tv%S(i,j,k) - tv%S(i,j,k-1)), 1e-20)
189 h_up = merge(h(i,j,k), h(i,j,k-1), del2sigma(k) > 0.)
190 del2sigma(k) = 0.5 * cs%adaptAlpha * &
191 sign(min(abs(del2sigma(k)), 0.5 * h_up), del2sigma(k))
194 znext(k) = zint(i,j,k) + del2sigma(k)
205 drdz = 0.5 * (alpha(k) + alpha(k+1)) * (tint(i,j,k+1) - tint(i,j,k)) + &
206 0.5 * (beta(k) + beta(k+1)) * (sint(i,j,k+1) - sint(i,j,k))
208 drdz = drdz / (znext(k) - znext(k+1) + gv%H_subroundoff)
213 kgrid(k) = (cs%adaptTimeRatio * nz**2 * depth) * &
214 (cs%adaptZoomCoeff / (cs%adaptZoom * gv%m_to_H + 0.5*(znext(k) + znext(k+1))) + &
215 (cs%adaptBuoyCoeff * drdz / cs%adaptDrho0) + &
216 max(1.0 - cs%adaptZoomCoeff - cs%adaptBuoyCoeff, 0.0) / depth)
226 b_denom_1 = 1. + d1 * kgrid(k-1)
228 b1 = 1.0 / (b_denom_1 + kgrid(k))
231 c1(k) = kgrid(k) * b1
236 znext(k) = b1 * (znext(k) + kgrid(k-1)*znext(k-1))
240 znext(k) = znext(k) + c1(k)*znext(k+1)
243 if (cs%adaptDoMin)
then 245 stretching = zint(i,j,nz+1) / depth
248 nominal_z = nominal_z + cs%coordinateResolution(k-1) * stretching
250 znext(k) = max(znext(k), nominal_z)
252 znext(k) = min(znext(k), zint(i,j,nz+1))
subroutine, public build_adapt_column(CS, G, GV, tv, i, j, zInt, tInt, sInt, h, zNext)
subroutine, public calculate_density_derivs(T, S, pressure, drho_dT, drho_dS, start, npts, EOS)
Calls the appropriate subroutine to calculate density derivatives for 1-D array inputs.
Provides subroutines for quantities specific to the equation of state.
subroutine, public set_adapt_params(CS, adaptTimeRatio, adaptAlpha, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptDrho0, adaptDoMin)
The thermo_var_ptrs structure contains pointers to an assortment of thermodynamic fields that may be ...
Regrid columns for the adaptive coordinate.
subroutine, public mom_error(level, message, all_print)
subroutine, public end_coord_adapt(CS)
Clean up the coordinate control structure.
subroutine, public init_coord_adapt(CS, nk, coordinateResolution)
Initialise an adapt_CS with parameters.