Yet Another eXchange Tool  DO_NOT_EDIT_HERE
test_idxempty_f.f90
1 
12 
13 !
14 ! Keywords:
15 ! Maintainer: Jörg Behrens <behrens@dkrz.de>
16 ! Moritz Hanke <hanke@dkrz.de>
17 ! Thomas Jahns <jahns@dkrz.de>
18 ! URL: https://doc.redmine.dkrz.de/yaxt/html/
19 !
20 ! Redistribution and use in source and binary forms, with or without
21 ! modification, are permitted provided that the following conditions are
22 ! met:
23 !
24 ! Redistributions of source code must retain the above copyright notice,
25 ! this list of conditions and the following disclaimer.
26 !
27 ! Redistributions in binary form must reproduce the above copyright
28 ! notice, this list of conditions and the following disclaimer in the
29 ! documentation and/or other materials provided with the distribution.
30 !
31 ! Neither the name of the DKRZ GmbH nor the names of its contributors
32 ! may be used to endorse or promote products derived from this software
33 ! without specific prior written permission.
34 !
35 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
36 ! IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
37 ! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
38 ! PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
39 ! OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40 ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
41 ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42 ! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43 ! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44 ! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45 ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 !
47 PROGRAM test_idxempty
48  USE mpi
49  USE yaxt, ONLY: xt_initialize, xt_finalize, xt_idxlist, xt_idxempty_new, &
50  xt_int_kind, xt_stripe, xt_idxlist_get_intersection, &
53  USE ftest_common, ONLY: init_mpi, finish_mpi, test_abort
54  USE test_idxlist_utils, ONLY: check_idxlist, test_err_count, &
55  idxlist_pack_unpack_copy
56  IMPLICIT NONE
57 
58  TYPE(xt_idxlist) :: idxempty, idxempty_copy
59  INTEGER(xt_int_kind) :: no_idx(1)
60  TYPE(xt_stripe), ALLOCATABLE :: stripes(:)
61 
62 
63  CALL init_mpi
64  CALL xt_initialize(mpi_comm_world)
65 
67 
68  CALL check_idxlist(idxempty, no_idx(1:0))
69 
70  idxempty_copy = idxlist_pack_unpack_copy(idxempty)
71 
72  ! check the computed intersection, must be identical to original list
73  CALL check_idxlist(idxempty_copy, no_idx(1:0))
74 
75  CALL check_intersection
76 
78 
79  IF (ALLOCATED(stripes)) &
80  CALL test_abort("unexpected non-zero amount of stripes for &
81  &empty index set", &
82  __file__, &
83  __line__)
84 
85  CALL check_bounding_box
86 
89 
90  CALL xt_finalize
91  CALL finish_mpi
92 
93  IF (test_err_count() /= 0) CALL test_abort("non-zero error count", &
94  __file__, &
95  __line__)
96 
97 CONTAINS
98 
99  SUBROUTINE check_intersection
100  TYPE(xt_idxlist) :: intersection
101 
103  CALL check_idxlist(intersection, no_idx(1:0))
104  CALL xt_idxlist_delete(intersection)
105 
106  END SUBROUTINE check_intersection
107 
108  SUBROUTINE check_bounding_box
109  INTEGER, PARAMETER :: ndims = 3
110  INTEGER(xt_int_kind), PARAMETER :: global_start_index = 0
111  INTEGER(xt_int_kind) :: global_size(ndims)
112  TYPE(xt_bounds) :: bounds(ndims)
113 
114  global_size = 10
115  bounds = xt_idxlist_get_bounding_box(idxempty, global_size, &
116  global_start_index)
117  IF (any(bounds%size /= 0)) &
118  CALL test_abort("ERROR: non-zero boundings box for xt_idxempty in &
119  &xt_idxlist_get_bounding_box", &
120  __file__, &
121  __line__)
122  END SUBROUTINE check_bounding_box
123 
124 END PROGRAM test_idxempty
125 !
126 ! Local Variables:
127 ! f90-continuation-indent: 5
128 ! coding: utf-8
129 ! indent-tabs-mode: nil
130 ! show-trailing-whitespace: t
131 ! require-trailing-newline: t
132 ! End:
133 !