12 implicit none ;
private
64 logical :: nonblocking_updates
66 integer :: first_direction
70 real,
allocatable,
dimension(:,:) :: &
71 mask2dt, & !< 0 for land points and 1 for ocean points on the h-grid [nondim].
72 geolatt, & !< The geographic latitude at q points [degrees of latitude] or [m].
73 geolont, & !< The geographic longitude at q points [degrees of longitude] or [m].
74 dxt, & !< dxT is delta x at h points [L ~> m].
75 idxt, & !< 1/dxT [L-1 ~> m-1].
76 dyt, & !< dyT is delta y at h points [L ~> m].
77 idyt, & !< IdyT is 1/dyT [L-1 ~> m-1].
78 areat, & !< The area of an h-cell [L2 ~> m2].
80 real,
allocatable,
dimension(:,:) :: sin_rot
83 real,
allocatable,
dimension(:,:) :: cos_rot
87 real,
allocatable,
dimension(:,:) :: &
88 mask2dcu, & !< 0 for boundary points and 1 for ocean points on the u grid [nondim].
89 geolatcu, & !< The geographic latitude at u points [degrees of latitude] or [m].
90 geoloncu, & !< The geographic longitude at u points [degrees of longitude] or [m].
91 dxcu, & !< dxCu is delta x at u points [L ~> m].
92 idxcu, & !< 1/dxCu [L-1 ~> m-1].
93 dycu, & !< dyCu is delta y at u points [L ~> m].
94 idycu, & !< 1/dyCu [L-1 ~> m-1].
95 dy_cu, & !< The unblocked lengths of the u-faces of the h-cell [L ~> m].
96 iareacu, & !< The masked inverse areas of u-grid cells [L-2 ~> m-2].
99 real,
allocatable,
dimension(:,:) :: &
100 mask2dcv, & !< 0 for boundary points and 1 for ocean points on the v grid [nondim].
101 geolatcv, & !< The geographic latitude at v points [degrees of latitude] or [m].
102 geoloncv, & !< The geographic longitude at v points [degrees of longitude] or [m].
103 dxcv, & !< dxCv is delta x at v points [L ~> m].
104 idxcv, & !< 1/dxCv [L-1 ~> m-1].
105 dycv, & !< dyCv is delta y at v points [L ~> m].
106 idycv, & !< 1/dyCv [L-1 ~> m-1].
107 dx_cv, & !< The unblocked lengths of the v-faces of the h-cell [L ~> m].
108 iareacv, & !< The masked inverse areas of v-grid cells [L-2 ~> m-2].
111 real,
allocatable,
dimension(:,:) :: &
112 mask2dbu, & !< 0 for boundary points and 1 for ocean points on the q grid [nondim].
113 geolatbu, & !< The geographic latitude at q points [degrees of latitude] or [m].
114 geolonbu, & !< The geographic longitude at q points [degrees of longitude] or [m].
115 dxbu, & !< dxBu is delta x at q points [L ~> m].
116 idxbu, & !< 1/dxBu [L-1 ~> m-1].
117 dybu, & !< dyBu is delta y at q points [L ~> m].
118 idybu, & !< 1/dyBu [L-1 ~> m-1].
119 areabu, & !< areaBu is the area of a q-cell [L ~> m]
122 real,
pointer,
dimension(:) :: gridlatt => null()
125 real,
pointer,
dimension(:) :: gridlatb => null()
128 real,
pointer,
dimension(:) :: gridlont => null()
131 real,
pointer,
dimension(:) :: gridlonb => null()
134 character(len=40) :: &
135 x_axis_units, & !< The units that are used in labeling the x coordinate axes.
139 real,
allocatable,
dimension(:,:) :: &
142 logical :: bathymetry_at_vel
145 real,
allocatable,
dimension(:,:) :: &
146 dblock_u, & !< Topographic depths at u-points at which the flow is blocked [Z ~> m].
148 real,
allocatable,
dimension(:,:) :: &
149 dblock_v, & !< Topographic depths at v-points at which the flow is blocked [Z ~> m].
151 real,
allocatable,
dimension(:,:) :: &
153 real,
allocatable,
dimension(:,:) :: &
154 df_dx, & !< Derivative d/dx f (Coriolis parameter) at h-points [T-1 L-1 ~> s-1 m-1].
159 real :: iareat_global
167 real :: rad_earth = 6.378e6
178 logical,
optional,
intent(in) :: bathymetry_at_vel
182 integer :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb, isg, ieg, jsg, jeg
187 if (
associated(g))
then
188 call mom_error(warning,
"create_dyn_horgrid called with an associated horgrid_type.")
195 g%isc = hi%isc ; g%iec = hi%iec ; g%jsc = hi%jsc ; g%jec = hi%jec
196 g%isd = hi%isd ; g%ied = hi%ied ; g%jsd = hi%jsd ; g%jed = hi%jed
197 g%isg = hi%isg ; g%ieg = hi%ieg ; g%jsg = hi%jsg ; g%jeg = hi%jeg
199 g%IscB = hi%IscB ; g%IecB = hi%IecB ; g%JscB = hi%JscB ; g%JecB = hi%JecB
200 g%IsdB = hi%IsdB ; g%IedB = hi%IedB ; g%JsdB = hi%JsdB ; g%JedB = hi%JedB
201 g%IsgB = hi%IsgB ; g%IegB = hi%IegB ; g%JsgB = hi%JsgB ; g%JegB = hi%JegB
203 g%idg_offset = hi%idg_offset ; g%jdg_offset = hi%jdg_offset
204 g%isd_global = g%isd + hi%idg_offset ; g%jsd_global = g%jsd + hi%jdg_offset
205 g%symmetric = hi%symmetric
207 g%bathymetry_at_vel = .false.
208 if (
present(bathymetry_at_vel)) g%bathymetry_at_vel = bathymetry_at_vel
210 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
211 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
212 isg = g%isg ; ieg = g%ieg ; jsg = g%jsg ; jeg = g%jeg
214 allocate(g%dxT(isd:ied,jsd:jed)) ; g%dxT(:,:) = 0.0
215 allocate(g%dxCu(isdb:iedb,jsd:jed)) ; g%dxCu(:,:) = 0.0
216 allocate(g%dxCv(isd:ied,jsdb:jedb)) ; g%dxCv(:,:) = 0.0
217 allocate(g%dxBu(isdb:iedb,jsdb:jedb)) ; g%dxBu(:,:) = 0.0
218 allocate(g%IdxT(isd:ied,jsd:jed)) ; g%IdxT(:,:) = 0.0
219 allocate(g%IdxCu(isdb:iedb,jsd:jed)) ; g%IdxCu(:,:) = 0.0
220 allocate(g%IdxCv(isd:ied,jsdb:jedb)) ; g%IdxCv(:,:) = 0.0
221 allocate(g%IdxBu(isdb:iedb,jsdb:jedb)) ; g%IdxBu(:,:) = 0.0
223 allocate(g%dyT(isd:ied,jsd:jed)) ; g%dyT(:,:) = 0.0
224 allocate(g%dyCu(isdb:iedb,jsd:jed)) ; g%dyCu(:,:) = 0.0
225 allocate(g%dyCv(isd:ied,jsdb:jedb)) ; g%dyCv(:,:) = 0.0
226 allocate(g%dyBu(isdb:iedb,jsdb:jedb)) ; g%dyBu(:,:) = 0.0
227 allocate(g%IdyT(isd:ied,jsd:jed)) ; g%IdyT(:,:) = 0.0
228 allocate(g%IdyCu(isdb:iedb,jsd:jed)) ; g%IdyCu(:,:) = 0.0
229 allocate(g%IdyCv(isd:ied,jsdb:jedb)) ; g%IdyCv(:,:) = 0.0
230 allocate(g%IdyBu(isdb:iedb,jsdb:jedb)) ; g%IdyBu(:,:) = 0.0
232 allocate(g%areaT(isd:ied,jsd:jed)) ; g%areaT(:,:) = 0.0
233 allocate(g%IareaT(isd:ied,jsd:jed)) ; g%IareaT(:,:) = 0.0
234 allocate(g%areaBu(isdb:iedb,jsdb:jedb)) ; g%areaBu(:,:) = 0.0
235 allocate(g%IareaBu(isdb:iedb,jsdb:jedb)) ; g%IareaBu(:,:) = 0.0
237 allocate(g%mask2dT(isd:ied,jsd:jed)) ; g%mask2dT(:,:) = 0.0
238 allocate(g%mask2dCu(isdb:iedb,jsd:jed)) ; g%mask2dCu(:,:) = 0.0
239 allocate(g%mask2dCv(isd:ied,jsdb:jedb)) ; g%mask2dCv(:,:) = 0.0
240 allocate(g%mask2dBu(isdb:iedb,jsdb:jedb)) ; g%mask2dBu(:,:) = 0.0
241 allocate(g%geoLatT(isd:ied,jsd:jed)) ; g%geoLatT(:,:) = 0.0
242 allocate(g%geoLatCu(isdb:iedb,jsd:jed)) ; g%geoLatCu(:,:) = 0.0
243 allocate(g%geoLatCv(isd:ied,jsdb:jedb)) ; g%geoLatCv(:,:) = 0.0
244 allocate(g%geoLatBu(isdb:iedb,jsdb:jedb)) ; g%geoLatBu(:,:) = 0.0
245 allocate(g%geoLonT(isd:ied,jsd:jed)) ; g%geoLonT(:,:) = 0.0
246 allocate(g%geoLonCu(isdb:iedb,jsd:jed)) ; g%geoLonCu(:,:) = 0.0
247 allocate(g%geoLonCv(isd:ied,jsdb:jedb)) ; g%geoLonCv(:,:) = 0.0
248 allocate(g%geoLonBu(isdb:iedb,jsdb:jedb)) ; g%geoLonBu(:,:) = 0.0
250 allocate(g%dx_Cv(isd:ied,jsdb:jedb)) ; g%dx_Cv(:,:) = 0.0
251 allocate(g%dy_Cu(isdb:iedb,jsd:jed)) ; g%dy_Cu(:,:) = 0.0
253 allocate(g%areaCu(isdb:iedb,jsd:jed)) ; g%areaCu(:,:) = 0.0
254 allocate(g%areaCv(isd:ied,jsdb:jedb)) ; g%areaCv(:,:) = 0.0
255 allocate(g%IareaCu(isdb:iedb,jsd:jed)) ; g%IareaCu(:,:) = 0.0
256 allocate(g%IareaCv(isd:ied,jsdb:jedb)) ; g%IareaCv(:,:) = 0.0
258 allocate(g%bathyT(isd:ied, jsd:jed)) ; g%bathyT(:,:) = 0.0
259 allocate(g%CoriolisBu(isdb:iedb, jsdb:jedb)) ; g%CoriolisBu(:,:) = 0.0
260 allocate(g%dF_dx(isd:ied, jsd:jed)) ; g%dF_dx(:,:) = 0.0
261 allocate(g%dF_dy(isd:ied, jsd:jed)) ; g%dF_dy(:,:) = 0.0
263 allocate(g%sin_rot(isd:ied,jsd:jed)) ; g%sin_rot(:,:) = 0.0
264 allocate(g%cos_rot(isd:ied,jsd:jed)) ; g%cos_rot(:,:) = 1.0
266 if (g%bathymetry_at_vel)
then
267 allocate(g%Dblock_u(isdb:iedb, jsd:jed)) ; g%Dblock_u(:,:) = 0.0
268 allocate(g%Dopen_u(isdb:iedb, jsd:jed)) ; g%Dopen_u(:,:) = 0.0
269 allocate(g%Dblock_v(isd:ied, jsdb:jedb)) ; g%Dblock_v(:,:) = 0.0
270 allocate(g%Dopen_v(isd:ied, jsdb:jedb)) ; g%Dopen_v(:,:) = 0.0
275 allocate(g%gridLonT(isg:ieg)) ; g%gridLonT(:) = 0.0
276 allocate(g%gridLonB(isg-1:ieg)) ; g%gridLonB(:) = 0.0
277 allocate(g%gridLatT(jsg:jeg)) ; g%gridLatT(:) = 0.0
278 allocate(g%gridLatB(jsg-1:jeg)) ; g%gridLatB(:) = 0.0
286 real,
intent(in) :: m_in_new_units
290 integer :: i, j, isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
292 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
293 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
295 if (m_in_new_units == 1.0)
return
296 if (m_in_new_units < 0.0) &
297 call mom_error(fatal,
"rescale_grid_bathymetry: Negative depth units are not permitted.")
298 if (m_in_new_units == 0.0) &
299 call mom_error(fatal,
"rescale_grid_bathymetry: Zero depth units are not permitted.")
301 rescale = 1.0 / m_in_new_units
302 do j=jsd,jed ;
do i=isd,ied
303 g%bathyT(i,j) = rescale*g%bathyT(i,j)
305 if (g%bathymetry_at_vel)
then ;
do j=jsd,jed ;
do i=isdb,iedb
306 g%Dblock_u(i,j) = rescale*g%Dblock_u(i,j) ; g%Dopen_u(i,j) = rescale*g%Dopen_u(i,j)
307 enddo ;
enddo ;
endif
308 if (g%bathymetry_at_vel)
then ;
do j=jsdb,jedb ;
do i=isd,ied
309 g%Dblock_v(i,j) = rescale*g%Dblock_v(i,j) ; g%Dopen_v(i,j) = rescale*g%Dopen_v(i,j)
310 enddo ;
enddo ;
endif
311 g%max_depth = rescale*g%max_depth
323 integer :: i, j, isd, ied, jsd, jed
324 integer :: isdb, iedb, jsdb, jedb
325 m_to_l = 1.0 ;
if (
present(us)) m_to_l = us%m_to_L
326 l_to_m = 1.0 ;
if (
present(us)) l_to_m = us%L_to_m
328 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
329 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
331 do j=jsd,jed ;
do i=isd,ied
332 if (g%dxT(i,j) < 0.0) g%dxT(i,j) = 0.0
333 if (g%dyT(i,j) < 0.0) g%dyT(i,j) = 0.0
339 do j=jsd,jed ;
do i=isdb,iedb
340 if (g%dxCu(i,j) < 0.0) g%dxCu(i,j) = 0.0
341 if (g%dyCu(i,j) < 0.0) g%dyCu(i,j) = 0.0
346 do j=jsdb,jedb ;
do i=isd,ied
347 if (g%dxCv(i,j) < 0.0) g%dxCv(i,j) = 0.0
348 if (g%dyCv(i,j) < 0.0) g%dyCv(i,j) = 0.0
353 do j=jsdb,jedb ;
do i=isdb,iedb
354 if (g%dxBu(i,j) < 0.0) g%dxBu(i,j) = 0.0
355 if (g%dyBu(i,j) < 0.0) g%dyBu(i,j) = 0.0
360 if (g%areaBu(i,j) <= 0.0) g%areaBu(i,j) = g%dxBu(i,j) * g%dyBu(i,j)
368 real,
intent(in) :: val
371 i_val = 0.0 ;
if (val /= 0.0) i_val = 1.0/val
379 if (.not.
associated(g))
then
380 call mom_error(fatal,
"destroy_dyn_horgrid called with an unassociated horgrid_type.")
383 deallocate(g%dxT) ;
deallocate(g%dxCu) ;
deallocate(g%dxCv) ;
deallocate(g%dxBu)
384 deallocate(g%IdxT) ;
deallocate(g%IdxCu) ;
deallocate(g%IdxCv) ;
deallocate(g%IdxBu)
386 deallocate(g%dyT) ;
deallocate(g%dyCu) ;
deallocate(g%dyCv) ;
deallocate(g%dyBu)
387 deallocate(g%IdyT) ;
deallocate(g%IdyCu) ;
deallocate(g%IdyCv) ;
deallocate(g%IdyBu)
389 deallocate(g%areaT) ;
deallocate(g%IareaT)
390 deallocate(g%areaBu) ;
deallocate(g%IareaBu)
391 deallocate(g%areaCu) ;
deallocate(g%IareaCu)
392 deallocate(g%areaCv) ;
deallocate(g%IareaCv)
394 deallocate(g%mask2dT) ;
deallocate(g%mask2dCu)
395 deallocate(g%mask2dCv) ;
deallocate(g%mask2dBu)
397 deallocate(g%geoLatT) ;
deallocate(g%geoLatCu)
398 deallocate(g%geoLatCv) ;
deallocate(g%geoLatBu)
399 deallocate(g%geoLonT) ;
deallocate(g%geoLonCu)
400 deallocate(g%geoLonCv) ;
deallocate(g%geoLonBu)
402 deallocate(g%dx_Cv) ;
deallocate(g%dy_Cu)
404 deallocate(g%bathyT) ;
deallocate(g%CoriolisBu)
405 deallocate(g%dF_dx) ;
deallocate(g%dF_dy)
406 deallocate(g%sin_rot) ;
deallocate(g%cos_rot)
408 if (
allocated(g%Dblock_u))
deallocate(g%Dblock_u)
409 if (
allocated(g%Dopen_u))
deallocate(g%Dopen_u)
410 if (
allocated(g%Dblock_v))
deallocate(g%Dblock_v)
411 if (
allocated(g%Dopen_v))
deallocate(g%Dopen_v)
413 deallocate(g%gridLonT) ;
deallocate(g%gridLatT)
414 deallocate(g%gridLonB) ;
deallocate(g%gridLatB)
416 deallocate(g%Domain%mpp_domain)