Yet Another eXchange Tool 0.11.4
Loading...
Searching...
No Matches
xt_xmap_dist_dir_bucket_gen2f.f90
Go to the documentation of this file.
1
13
14!
15! Keywords:
16! Maintainer: Jörg Behrens <behrens@dkrz.de>
17! Moritz Hanke <hanke@dkrz.de>
18! Thomas Jahns <jahns@dkrz.de>
19! URL: https://dkrz-sw.gitlab-pages.dkrz.de/yaxt/
20!
21! Redistribution and use in source and binary forms, with or without
22! modification, are permitted provided that the following conditions are
23! met:
24!
25! Redistributions of source code must retain the above copyright notice,
26! this list of conditions and the following disclaimer.
27!
28! Redistributions in binary form must reproduce the above copyright
29! notice, this list of conditions and the following disclaimer in the
30! documentation and/or other materials provided with the distribution.
31!
32! Neither the name of the DKRZ GmbH nor the names of its contributors
33! may be used to endorse or promote products derived from this software
34! without specific prior written permission.
35!
36! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
37! IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
38! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
39! PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
40! OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
42! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
43! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
44! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47!
48#include "fc_feature_defs.inc"
49MODULE xt_xmap_dist_dir_bucket_gen2
50 USE iso_c_binding, ONLY: c_int, c_ptr, c_size_t
51 USE xt_core, ONLY: xt_mpi_fint_kind
52 USE xt_config_f, ONLY: xt_config
53 USE xt_xmap_intersection, ONLY: xt_com_list
54 USE xt_idxlist_abstract, ONLY: xt_idxlist
55 USE xt_xmap_dist_dir_bucket_gen, ONLY: xt_xmdd_bucket_gen
56 IMPLICIT NONE
57 PRIVATE
58
59 INTEGER(c_int), PUBLIC, PARAMETER :: &
60 xt_dist_dir_bucket_gen_type_send = 1, &
61 xt_dist_dir_bucket_gen_type_recv = 2, &
62 xt_dist_dir_bucket_gen_type_sendrecv = 3
63
64 TYPE, BIND(c), PUBLIC :: xt_xmdd_bucket_gen_comms
65 INTEGER(xt_mpi_fint_kind) :: intra_comm, inter_comm, &
66 tag_offset_intra, tag_offset_inter
68
69 ! Interface of bucket generator
70 !
71 ! Essentially, the generator needs to be able to enumerate all
72 ! buckets used to form intersections. This means the generator only
73 ! needs to produce buckets that actually can intersect and,
74 ! consequently, buckets that won't intersect the requested type of
75 ! list can be skipped.
78 SUBROUTINE xt_xmdd_bucket_gen_define_interface_f(gen, init, destroy, &
79 get_intersect_max_num, next, gen_state_size, init_params)
80 IMPORT :: xt_xmdd_bucket_gen, xt_config, xt_idxlist, c_int, &
81 c_ptr, c_size_t, xt_mpi_fint_kind, xt_com_list, &
83 TYPE(xt_xmdd_bucket_gen), INTENT(inout) :: gen
84 INTERFACE
85 ! The init function sets up the generator state.
86 FUNCTION init(gen_state, src_idxlist, &
87 dst_idxlist, config, comms, init_params) BIND(c) RESULT(stripify)
88 IMPORT :: c_int, c_ptr, xt_idxlist, xt_config, &
90 INTEGER(c_int) :: stripify
91 TYPE(c_ptr), VALUE :: gen_state
92 TYPE(xt_idxlist), VALUE, INTENT(in) :: src_idxlist,dst_idxlist
93 TYPE(xt_config), VALUE, INTENT(in) :: config
94 TYPE(xt_xmdd_bucket_gen_comms), intent(in) :: comms
95 TYPE(c_ptr), VALUE, INTENT(in) :: init_params
96 END FUNCTION init
97
98 ! The destroy function clean up the generator state. Can be zero
99 ! if no cleaning is needed.
100 SUBROUTINE destroy(gen_state) BIND(c)
101 IMPORT :: c_ptr
102 TYPE(c_ptr), VALUE, INTENT(in) :: gen_state
103 END SUBROUTINE destroy
104
105 FUNCTION get_intersect_max_num(gen_state, &
106 bucket_type) BIND(C) RESULT(max_num)
107 IMPORT :: c_ptr, c_int
108 TYPE(c_ptr), VALUE :: gen_state
109 INTEGER(c_int), VALUE :: bucket_type
110 INTEGER(c_int) :: max_num
111 END FUNCTION get_intersect_max_num
112
113 ! The next function returns the next bucket and corresponding rank
114 ! (ranks can be skipped when the intersection will be empty
115 ! anyway).
116 ! Any previously returned buckets become invalid.
117 FUNCTION next(gen_state, bucket_type) &
118 BIND(C) result(bucket)
119 IMPORT :: c_ptr, c_int, xt_com_list
120 TYPE(c_ptr), VALUE :: gen_state
121 INTEGER(c_int), VALUE :: bucket_type
122 TYPE(xt_com_list) :: bucket
123 END FUNCTION next
124 END INTERFACE
125 ! INTERFACE
126 ! SUBROUTINE xt_xmdd_bucket_gen_def_if_f2c(gen, init, destroy, &
127 ! get_intersect_max_num, next, gen_state_size) &
128 ! BIND(c, name='xt_xmdd_bucket_gen_def_if_f2c')
129 ! IMPORT :: c_funptr, c_size_t, c_ptr
130 ! IMPLICIT NONE
131 ! TYPE(c_ptr), VALUE :: gen
132 ! TYPE(c_funptr), VALUE :: init, destroy, get_intersect_max_num, next
133 ! INTEGER(c_size_t), VALUE :: gen_state_size
134 ! TYPE(c_ptr), VALUE :: gen
135 ! END SUBROUTINE xt_xmdd_bucket_gen_def_if_f2c
136 ! END INTERFACE
137 ! gen_state_size is the size of the generator state
138 !
139 ! The distributed directory will provide memory aligned to
140 ! TYPE(c_ptr) variables of this size.
141 INTEGER(c_size_t) :: gen_state_size
142 TYPE(c_ptr), VALUE :: init_params
143 END SUBROUTINE xt_xmdd_bucket_gen_define_interface_f
145END MODULE xt_xmap_dist_dir_bucket_gen2
146!
147! Local Variables:
148! f90-continuation-indent: 5
149! coding: utf-8
150! indent-tabs-mode: nil
151! show-trailing-whitespace: t
152! require-trailing-newline: t
153! End:
154!
void xt_xmdd_bucket_gen_define_interface(Xt_xmdd_bucket_gen gen, Xt_xmdd_bucket_gen_init_state init, Xt_xmdd_bucket_gen_destroy_state destroy, Xt_xmdd_bucket_gen_get_intersect_max_num get_intersect_max_num, Xt_xmdd_bucket_gen_next next, size_t gen_state_size, void *init_params)