30 MODULE fms_diag_bbox_mod
101 integer,
intent(in) :: subregion_start
102 integer,
intent(in) :: subregion_end
104 integer,
intent(in) :: dim
106 integer :: block_start
112 block_start = bounds%imin
113 block_end = bounds%imax
115 block_start = bounds%jmin
116 block_end = bounds%jmax
118 block_start = bounds%kmin
119 block_end = bounds%kmax
122 if (block_start < subregion_start .and. block_end < subregion_start)
then
127 if (block_start > subregion_end .and. block_end > subregion_end)
then
179 subroutine update_index(this, starting_index, ending_index, dim, ignore_halos)
181 integer,
intent(in) :: starting_index
182 integer,
intent(in) :: ending_index
183 integer,
intent(in) :: dim
184 logical,
intent(in) :: ignore_halos
193 if (ignore_halos)
then
202 this%imin = starting_index + nhalox
203 this%imax = ending_index + nhalox
205 this%jmin = starting_index + nhaloy
206 this%jmax = ending_index + nhaloy
208 this%kmin = starting_index
209 this%kmax = ending_index
215 pure integer function get_hi (this)
result(rslt)
222 pure integer function get_hj (this)
result(rslt)
229 pure integer function get_fis (this)
result(rslt)
236 pure integer function get_fie (this)
result(rslt)
243 pure integer function get_fjs (this)
result(rslt)
250 pure integer function get_fje (this)
result(rslt)
258 integer,
intent(in) :: lower_val
259 integer,
intent(in) :: upper_val
260 this%imin = lower_val
261 this%jmin = lower_val
262 this%kmin = lower_val
263 this%imax = upper_val
264 this%jmax = upper_val
265 this%kmax = upper_val
271 SUBROUTINE update_bounds(this, lower_i, upper_i, lower_j, upper_j, lower_k, upper_k)
273 INTEGER,
INTENT(in) :: lower_i
274 INTEGER,
INTENT(in) :: upper_i
275 INTEGER,
INTENT(in) :: lower_j
276 INTEGER,
INTENT(in) :: upper_j
277 INTEGER,
INTENT(in) :: lower_k
278 INTEGER,
INTENT(in) :: upper_k
279 this%imin = min(this%imin, lower_i)
280 this%imax = max(this%imax, upper_i)
281 this%jmin = min(this%jmin, lower_j)
282 this%jmax = max(this%jmax, upper_j)
283 this%kmin = min(this%kmin, lower_k)
284 this%kmax = max(this%kmax, upper_k)
289 function set_bounds(this, field_data, lower_i, upper_i, lower_j, upper_j, lower_k, upper_k, has_halos) &
292 class(*),
intent(in) :: field_data(:,:,:,:)
293 INTEGER,
INTENT(in) :: lower_i
294 INTEGER,
INTENT(in) :: upper_i
295 INTEGER,
INTENT(in) :: lower_j
296 INTEGER,
INTENT(in) :: upper_j
297 INTEGER,
INTENT(in) :: lower_k
298 INTEGER,
INTENT(in) :: upper_k
299 LOGICAL,
INTENT(in) :: has_halos
301 character(len=150) :: error_msg
310 this%has_halos = has_halos
316 nhalos_2 = ubound(field_data,1)-(upper_i-lower_i+1)
317 if (mod(nhalos_2, 2) .ne. 0)
then
318 error_msg =
"There are non-symmetric halos in the first dimension"
322 this%nhalo_I = nhalox
324 nhalos_2 = ubound(field_data,2)-(upper_j-lower_j + 1)
325 if (mod(nhalos_2, 2) .ne. 0)
then
326 error_msg =
"There are non-symmetric halos in the second dimension"
330 this%nhalo_J = nhaloy
332 this%imin = 1 + nhalox
333 this%imax = ubound(field_data,1) - nhalox
334 this%jmin = 1 + nhaloy
335 this%jmax = ubound(field_data,2) - nhaloy
348 class(*),
INTENT( in),
DIMENSION(:,:,:,:) :: array
349 this%imin = lbound(array,1)
350 this%imax = ubound(array,1)
351 this%jmin = lbound(array,2)
352 this%jmax = ubound(array,2)
353 this%kmin = lbound(array,3)
354 this%kmax = ubound(array,3)
356 this%has_halos = .false.
365 CLASS(*),
INTENT( in),
DIMENSION(:,:,:,:,:) :: array
366 this%imin = lbound(array,1)
367 this%imax = ubound(array,1)
368 this%jmin = lbound(array,2)
369 this%jmax = ubound(array,2)
370 this%kmin = lbound(array,3)
371 this%kmax = ubound(array,3)
379 ie_in, je_in, ke_in, err_msg)
result(ierr)
382 class(*),
intent(in) :: field(:,:,:,:)
383 integer,
intent(in),
optional :: is_in, js_in, ks_in, ie_in, je_in, ke_in
384 character(len=*),
intent(out),
optional :: err_msg
387 integer :: is, js, ks, ie, je, ke
390 integer :: twohi, twohj
391 integer :: fis, fie, fjs, fje
392 integer :: n1, n2, n3
395 if (
present(err_msg)) err_msg =
''
402 IF (
PRESENT(is_in) ) is = is_in
403 IF (
PRESENT(js_in) ) js = js_in
404 IF (
PRESENT(ks_in) ) ks = ks_in
414 IF (
PRESENT(ie_in) ) ie = ie_in
415 IF (
PRESENT(je_in) ) je = je_in
416 IF (
PRESENT(ke_in) ) ke = ke_in
418 twohi = n1 - (ie - is + 1)
419 IF ( mod(twohi, 2) /= 0 )
THEN
420 ierr = fms_error_handler(
'diag_util_mod:recondition_indices', &
421 'non-symmetric halos in first dimension', err_msg)
425 twohj = n2 - (je - js + 1)
426 IF ( mod(twohj, 2) /= 0 )
THEN
427 ierr = fms_error_handler(
'diag_util_mod:recondition_indices', &
428 'non-symmetric halos in second dimension', err_msg)
437 IF (
PRESENT(ie_in) .AND.
PRESENT(je_in) )
THEN
451 indices%bounds3D%imin = is
452 indices%bounds3D%imax = ie
453 indices%bounds3D%jmin = js
454 indices%bounds3D%jmax = je
455 indices%bounds3D%kmin = ks
456 indices%bounds3D%kmax = ke
469 integer,
intent(in) :: starting
470 integer,
intent(in) :: ending
471 integer,
intent(in) :: dim
483 bounds_out%imin = max(starting, bounds_out%imin)-starting+1
484 bounds_out%imax = min(bounds_out%imax, bounds_out%imin + ending-starting)
486 bounds_out%jmin = max(starting, bounds_out%jmin)-starting+1
487 bounds_out%jmax = min(bounds_out%jmax, bounds_out%jmin + ending-starting)
489 bounds_out%kmin =max(starting, bounds_out%kmin)-starting+1
490 bounds_out%kmax = min(bounds_out%kmax, bounds_out%kmin + ending-starting)
500 integer,
intent(in) :: starting
501 integer,
intent(in) :: ending
502 integer,
intent(in) :: dim
513 bounds_in%imin = min(abs(starting-bounds%imin+1), starting)
514 bounds_in%imax = min(bounds_in%imax, (bounds_in%imin + ending-starting))
516 bounds_in%jmin = min(abs(starting-bounds%jmin+1), starting)
517 bounds_in%jmax = min(bounds_in%jmax, (bounds_in%jmin + ending-starting))
519 bounds_in%kmin = min(abs(starting-bounds%kmin+1), starting)
520 bounds_in%kmax = min(bounds_in%kmax, (bounds_in%kmin + ending-starting))
524 END MODULE fms_diag_bbox_mod
subroutine rebase_input(bounds_in, bounds, starting, ending, dim)
Rebase the input bounds for a given dimension based on the starting and ending indices of a subregion...
logical function, public recondition_indices(indices, field, is_in, js_in, ks_in, ie_in, je_in, ke_in, err_msg)
Updates indices based on presence/absence of input indices is, js, ks, ie, je, and ke.
subroutine update_bounds(this, lower_i, upper_i, lower_j, upper_j, lower_k, upper_k)
Update the first three (normally x, y, and z) min and max boundaries (array indices) of the instance ...
integer, parameter ydimension
Parameter defining the y dimension.
pure integer function get_imin(this)
Gets imin of fmsDiagIbounds_type.
subroutine reset_bounds_from_array_4d(this, array)
Reset the instance bounding box with the bounds determined from the first three dimensions of the 5D ...
pure integer function get_fjs(this)
Gets the updated index ‘fjs’ of fmsDiagBoundsHalos_type in the I dimension.
integer, parameter xdimension
Parameter defining the x dimension.
subroutine rebase_output(bounds_out, starting, ending, dim)
Rebase the ouput bounds for a given dimension based on the starting and ending indices of a subregion...
pure integer function get_hi(this)
Gets the halo size of fmsDiagBoundsHalos_type in the I dimension.
pure integer function get_imax(this)
Gets imax of fmsDiagIbounds_type.
pure integer function get_fje(this)
Gets the updated index ‘fje’ of fmsDiagBoundsHalos_type in the I dimension.
pure integer function get_kmax(this)
Gets kmax of fmsDiagIbounds_type.
pure integer function get_fie(this)
Gets the updated index ‘fie’ of fmsDiagBoundsHalos_type in the I dimension.
logical pure function, public determine_if_block_is_in_region(subregion_start, subregion_end, bounds, dim)
The PEs grid points are divided further into "blocks". This function determines if a block.
pure integer function get_hj(this)
Gets the halo size of fmsDiagBoundsHalos_type in the J dimension.
subroutine reset_bounds(this, lower_val, upper_val)
Reset the instance bounding lower and upper bounds to lower_val and upper_val, respectively.
subroutine update_index(this, starting_index, ending_index, dim, ignore_halos)
Updates the starting and ending index of a given dimension.
subroutine reset_bounds_from_array_5d(this, array)
Reset the instance bounding box with the bounds determined from the first three dimensions of the 5D ...
pure integer function get_fis(this)
Gets the updated index ‘fis’ of fmsDiagBoundsHalos_type in the I dimension.
pure integer function get_jmin(this)
Gets jmin of fmsDiagIbounds_type.
pure integer function get_jmax(this)
Gets jmax of fmsDiagIbounds_type.
pure integer function get_kmin(this)
Gets kmin of fmsDiagIbounds_type.
integer, parameter zdimension
Parameter defininf the z dimension.
character(len=150) function set_bounds(this, field_data, lower_i, upper_i, lower_j, upper_j, lower_k, upper_k, has_halos)
Sets the bounds of a bounding region.
Data structure holding starting and ending indices in the I, J, and K dimensions. It also has extra m...
logical function, public fms_error_handler(routine, message, err_msg)
Facilitates the control of fatal error conditions.
subroutine, public error_mesg(routine, message, level)
Print notes, warnings and error messages; terminates program for warning and error messages....
Data structure holding a 3D bounding box. It is commonlyused to represent the interval bounds or limi...