12 implicit none ;
private 14 #include <MOM_memory.h> 23 real,
allocatable,
dimension(:) :: coordinateresolution
26 real :: adapttimeratio
35 real :: adaptzoomcoeff
38 real :: adaptbuoycoeff
45 logical :: adaptdomin = .false.
48 public init_coord_adapt, set_adapt_params, build_adapt_column, end_coord_adapt
53 subroutine init_coord_adapt(CS, nk, coordinateResolution, m_to_H, kg_m3_to_R)
55 integer,
intent(in) :: nk
56 real,
dimension(:),
intent(in) :: coordinateresolution
58 real,
intent(in) :: m_to_h
59 real,
intent(in) :: kg_m3_to_r
61 if (
associated(cs))
call mom_error(fatal,
"init_coord_adapt: CS already associated")
63 allocate(cs%coordinateResolution(nk))
66 cs%coordinateResolution(:) = coordinateresolution(:)
69 cs%adaptTimeRatio = 1e-1
71 cs%adaptZoom = 200.0 * m_to_h
72 cs%adaptZoomCoeff = 0.0
73 cs%adaptBuoyCoeff = 0.0
74 cs%adaptDrho0 = 0.5 * kg_m3_to_r
76 end subroutine init_coord_adapt
79 subroutine end_coord_adapt(CS)
83 if (.not.
associated(cs))
return 84 deallocate(cs%coordinateResolution)
86 end subroutine end_coord_adapt
89 subroutine set_adapt_params(CS, adaptTimeRatio, adaptAlpha, adaptZoom, adaptZoomCoeff, &
90 adaptBuoyCoeff, adaptDrho0, adaptDoMin)
92 real,
optional,
intent(in) :: adapttimeratio
93 real,
optional,
intent(in) :: adaptalpha
95 real,
optional,
intent(in) :: adaptzoom
96 real,
optional,
intent(in) :: adaptzoomcoeff
97 real,
optional,
intent(in) :: adaptbuoycoeff
98 real,
optional,
intent(in) :: adaptdrho0
100 logical,
optional,
intent(in) :: adaptdomin
104 if (.not.
associated(cs))
call mom_error(fatal,
"set_adapt_params: CS not associated")
106 if (
present(adapttimeratio)) cs%adaptTimeRatio = adapttimeratio
107 if (
present(adaptalpha)) cs%adaptAlpha = adaptalpha
108 if (
present(adaptzoom)) cs%adaptZoom = adaptzoom
109 if (
present(adaptzoomcoeff)) cs%adaptZoomCoeff = adaptzoomcoeff
110 if (
present(adaptbuoycoeff)) cs%adaptBuoyCoeff = adaptbuoycoeff
111 if (
present(adaptdrho0)) cs%adaptDrho0 = adaptdrho0
112 if (
present(adaptdomin)) cs%adaptDoMin = adaptdomin
113 end subroutine set_adapt_params
115 subroutine build_adapt_column(CS, G, GV, US, tv, i, j, zInt, tInt, sInt, h, zNext)
117 type(ocean_grid_type),
intent(in) :: g
122 integer,
intent(in) :: i
123 integer,
intent(in) :: j
124 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(in) :: zint
125 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(in) :: tint
126 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(in) :: sint
127 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
128 real,
dimension(SZK_(GV)+1),
intent(inout) :: znext
132 real :: h_up, b1, b_denom_1, d1, depth, nominal_z, stretching
134 real,
dimension(SZK_(GV)+1) :: alpha
135 real,
dimension(SZK_(GV)+1) :: beta
136 real,
dimension(SZK_(GV)+1) :: del2sigma
137 real,
dimension(SZK_(GV)+1) :: dh_d2s
138 real,
dimension(SZK_(GV)) :: kgrid, c1
144 znext(nz+1) = zint(i,j,nz+1)
147 depth = g%bathyT(i,j) * gv%Z_to_H
150 del2sigma(:) = 0.0 ; dh_d2s(:) = 0.0
157 if (g%mask2dT(i,j-1) > 0.)
then 159 0.5 * (tint(i,j,2:nz) + tint(i,j-1,2:nz)), &
160 0.5 * (sint(i,j,2:nz) + sint(i,j-1,2:nz)), &
161 0.5 * (zint(i,j,2:nz) + zint(i,j-1,2:nz)) * (gv%H_to_RZ * gv%g_Earth), &
162 alpha, beta, tv%eqn_of_state, (/2,nz/) )
164 del2sigma(2:nz) = del2sigma(2:nz) + &
165 (alpha(2:nz) * (tint(i,j-1,2:nz) - tint(i,j,2:nz)) + &
166 beta(2:nz) * (sint(i,j-1,2:nz) - sint(i,j,2:nz)))
169 if (g%mask2dT(i,j+1) > 0.)
then 171 0.5 * (tint(i,j,2:nz) + tint(i,j+1,2:nz)), &
172 0.5 * (sint(i,j,2:nz) + sint(i,j+1,2:nz)), &
173 0.5 * (zint(i,j,2:nz) + zint(i,j+1,2:nz)) * (gv%H_to_RZ * gv%g_Earth), &
174 alpha, beta, tv%eqn_of_state, (/2,nz/) )
176 del2sigma(2:nz) = del2sigma(2:nz) + &
177 (alpha(2:nz) * (tint(i,j+1,2:nz) - tint(i,j,2:nz)) + &
178 beta(2:nz) * (sint(i,j+1,2:nz) - sint(i,j,2:nz)))
181 if (g%mask2dT(i-1,j) > 0.)
then 183 0.5 * (tint(i,j,2:nz) + tint(i-1,j,2:nz)), &
184 0.5 * (sint(i,j,2:nz) + sint(i-1,j,2:nz)), &
185 0.5 * (zint(i,j,2:nz) + zint(i-1,j,2:nz)) * (gv%H_to_RZ * gv%g_Earth), &
186 alpha, beta, tv%eqn_of_state, (/2,nz/) )
188 del2sigma(2:nz) = del2sigma(2:nz) + &
189 (alpha(2:nz) * (tint(i-1,j,2:nz) - tint(i,j,2:nz)) + &
190 beta(2:nz) * (sint(i-1,j,2:nz) - sint(i,j,2:nz)))
193 if (g%mask2dT(i+1,j) > 0.)
then 195 0.5 * (tint(i,j,2:nz) + tint(i+1,j,2:nz)), &
196 0.5 * (sint(i,j,2:nz) + sint(i+1,j,2:nz)), &
197 0.5 * (zint(i,j,2:nz) + zint(i+1,j,2:nz)) * (gv%H_to_RZ * gv%g_Earth), &
198 alpha, beta, tv%eqn_of_state, (/2,nz/) )
200 del2sigma(2:nz) = del2sigma(2:nz) + &
201 (alpha(2:nz) * (tint(i+1,j,2:nz) - tint(i,j,2:nz)) + &
202 beta(2:nz) * (sint(i+1,j,2:nz) - sint(i,j,2:nz)))
212 alpha, beta, tv%eqn_of_state, (/1,nz+1/) )
215 dh_d2s(k) = del2sigma(k) * (0.5 * (h(i,j,k-1) + h(i,j,k))) / &
216 max(alpha(k) * (tv%T(i,j,k) - tv%T(i,j,k-1)) + &
217 beta(k) * (tv%S(i,j,k) - tv%S(i,j,k-1)), 1e-20*us%kg_m3_to_R)
222 h_up = merge(h(i,j,k), h(i,j,k-1), dh_d2s(k) > 0.)
223 dh_d2s(k) = 0.5 * cs%adaptAlpha * &
224 sign(min(abs(del2sigma(k)), 0.5 * h_up), dh_d2s(k))
227 znext(k) = zint(i,j,k) + dh_d2s(k)
238 drdz = 0.5 * (alpha(k) + alpha(k+1)) * (tint(i,j,k+1) - tint(i,j,k)) + &
239 0.5 * (beta(k) + beta(k+1)) * (sint(i,j,k+1) - sint(i,j,k))
241 drdz = drdz / (znext(k) - znext(k+1) + gv%H_subroundoff)
246 kgrid(k) = (cs%adaptTimeRatio * nz**2 * depth) * &
247 (cs%adaptZoomCoeff / (cs%adaptZoom + 0.5*(znext(k) + znext(k+1))) + &
248 (cs%adaptBuoyCoeff * drdz / cs%adaptDrho0) + &
249 max(1.0 - cs%adaptZoomCoeff - cs%adaptBuoyCoeff, 0.0) / depth)
259 b_denom_1 = 1. + d1 * kgrid(k-1)
261 b1 = 1.0 / (b_denom_1 + kgrid(k))
264 c1(k) = kgrid(k) * b1
269 znext(k) = b1 * (znext(k) + kgrid(k-1)*znext(k-1))
273 znext(k) = znext(k) + c1(k)*znext(k+1)
276 if (cs%adaptDoMin)
then 278 stretching = zint(i,j,nz+1) / depth
281 nominal_z = nominal_z + cs%coordinateResolution(k-1) * stretching
283 znext(k) = max(znext(k), nominal_z)
285 znext(k) = min(znext(k), zint(i,j,nz+1))
288 end subroutine build_adapt_column
Describes various unit conversion factors.
Provides a transparent unit rescaling type to facilitate dimensional consistency testing.
Control structure for adaptive coordinates (coord_adapt).
Routines for error handling and I/O management.
Calculate the derivatives of density with temperature and salinity from T, S, and P...
Provides subroutines for quantities specific to the equation of state.
Describes the vertical ocean grid, including unit conversion factors.
Pointers to an assortment of thermodynamic fields that may be available, including potential temperat...
Provides a transparent vertical ocean grid type and supporting routines.
Provides transparent structures with groups of MOM6 variables and supporting routines.
Regrid columns for the adaptive coordinate.