102 PROGRAM unstruct_halo_exchang
110 #if defined __PGI && ( __PGIC__ == 15 || __PGIC__ == 14 )
116 INTEGER :: comm_rank, comm_size
117 INTEGER :: i, j, rank, ierror
119 INTEGER(xi) :: local_indices(12, 0:2), idx
120 INTEGER(xi) :: halo_indices(5, 0:2)
121 INTEGER(xi) :: src_indices(12, 0:2), tgt_indices(5, 0:2)
122 INTEGER :: src_offsets(12)
123 INTEGER :: tgt_offsets(5)
125 TYPE(xt_idxlist) :: src_idxlist, tgt_idxlist
126 TYPE(xt_xmap) :: xmap
127 TYPE(xt_redist) :: redist
128 DOUBLE PRECISION :: src_data(12), tgt_data(12)
132 CALL mpi_init(ierror)
133 IF (ierror /= mpi_success) stop 1
135 CALL mpi_comm_rank(mpi_comm_world, comm_rank, ierror)
136 IF (ierror /= mpi_success) stop 1
137 CALL mpi_comm_size (mpi_comm_world, comm_size, ierror)
138 IF (ierror /= mpi_success) stop 1
140 IF (comm_size /= 3) stop 3
143 local_indices(:,0) = (/ 1_xi, 4_xi, 8_xi, &
144 & 0_xi, 3_xi, 7_xi, 12_xi, &
145 & 2_xi, 6_xi, 11_xi, &
147 local_indices(:,1) = (/ 4_xi, 8_xi, 13_xi, &
148 & 3_xi, 7_xi, 12_xi, 17_xi, &
149 & 6_xi, 11_xi, 16_xi, &
151 local_indices(:,2) = (/ 3_xi, 7_xi, 12_xi, &
152 & 2_xi, 6_xi, 11_xi, 16_xi, &
153 & 5_xi, 10_xi, 15_xi, &
157 halo_indices(:,0) = (/ 8_xi, 12_xi, 11_xi, 10_xi, 5_xi /)
158 halo_indices(:,1) = (/ 4_xi, 3_xi, 6_xi, 10_xi, 15_xi /)
159 halo_indices(:,2) = (/ 3_xi, 7_xi, 12_xi, 2_xi, 16_xi /)
161 DO rank = 0, comm_size - 1
162 DO i = 1,
SIZE(local_indices, 1)
163 idx = local_indices(i, rank)
164 src_indices(i, rank) = merge(-1_xi, idx, any(halo_indices(:, rank) == idx))
166 tgt_indices(:, rank) = halo_indices(:, rank)
170 src_idxlist =
xt_idxvec_new(src_indices(:,comm_rank),
SIZE(src_indices, 1))
171 tgt_idxlist =
xt_idxvec_new(tgt_indices(:,comm_rank),
SIZE(tgt_indices, 1))
177 src_offsets = (/(i, i = 0,
SIZE(src_indices, 1) - 1)/)
178 DO i = 1,
SIZE(halo_indices, 1)
179 DO j = 1,
SIZE(local_indices, 1)
180 IF (halo_indices(i, comm_rank) == local_indices(j, comm_rank)) &
181 tgt_offsets(i) = j - 1
185 & mpi_double_precision)
188 src_data(:) = dble(src_indices(:,comm_rank))
189 tgt_data(:) = dble(src_indices(:,comm_rank))
191 fmt =
'(I1, " ", A, " exchange: ", xx(I3))'
192 WRITE(fmt(29:30),
'(I2)')
SIZE(src_data, 1)
193 print fmt, comm_rank,
'before', int(src_data(:))
198 print fmt, comm_rank,
'after ', int(tgt_data(:))
208 CALL mpi_finalize(ierror)
209 IF (ierror /= mpi_success) stop 1
210 END PROGRAM unstruct_halo_exchang
void xt_initialize(MPI_Comm default_comm)
void xt_idxlist_delete(Xt_idxlist idxlist)
Xt_idxlist xt_idxvec_new(const Xt_int *idxlist, int num_indices)
void xt_redist_delete(Xt_redist redist)
void xt_redist_s_exchange(Xt_redist redist, int num_arrays, const void **src_data, void **dst_data)
Xt_redist xt_redist_p2p_off_new(Xt_xmap xmap, const int *src_offsets, const int *dst_offsets, MPI_Datatype datatype)
void xt_xmap_delete(Xt_xmap xmap)
Xt_xmap xt_xmap_all2all_new(Xt_idxlist src_idxlist, Xt_idxlist dst_idxlist, MPI_Comm comm)