61 auto dims = file.get_var_dims(name);
62 m_count = std::vector<size_t>( get_dims_shape( dims));
63 m_start = std::vector<size_t>( dims.size(), 0);
73 template<
class ContainerType, std::enable_if_t< dg::is_vector_v<
74 ContainerType, dg::SharedVectorTag>,
bool> =
true>
86 template<
class Topology, std::enable_if_t<
87 !dg::is_vector_v<Topology>,
bool> =
true>
90 auto ss = grid.start();
91 auto cc = grid.count();
92 m_start = std::vector<size_t>( ss.begin(), ss.end());
93 m_count = std::vector<size_t>( cc.begin(), cc.end());
116 m_start.insert( m_start.begin(), start0);
117 m_count.insert( m_count.begin(), count0);
121 unsigned ndim()
const {
return m_start.size();}
124 const std::vector<size_t>&
start()
const {
return m_start;}
126 const std::vector<size_t>&
count()
const {
return m_count;}
128 std::vector<size_t>&
start() {
return m_start;}
130 std::vector<size_t>&
count() {
return m_count;}
132 const size_t*
startp()
const {
return &m_start[0];}
134 const size_t*
countp()
const {
return &m_count[0];}
136 std::vector<size_t> m_start, m_count;
161 : m_slab( local_start, local_count), m_comm(comm)
174 std::vector<size_t> local_count, MPI_Comm comm)
175 : m_slab( local_start, local_count), m_comm(comm)
191 template<
class ContainerType, std::enable_if_t< dg::is_vector_v<
192 ContainerType, dg::MPIVectorTag>,
bool> =
true>
196 int count = data.size();
197 MPI_Comm comm = data.communicator();
199 MPI_Comm_rank( comm, &rank);
200 MPI_Comm_size( comm, &size);
201 std::vector<int> counts ( size);
202 MPI_Allgather( &
count, 1, MPI_INT, &counts[0], 1, MPI_INT, comm);
204 for(
int r=0; r<rank; r++)
219 template<
class MPITopology, std::enable_if_t<!dg::is_vector_v<MPITopology>,
248 m_slab.
start().insert( m_slab.
start().begin(), start0);
249 m_slab.
count().insert( m_slab.
count().begin(), count0);
256 const std::vector<size_t>&
start()
const {
return m_slab.
start();}
258 const std::vector<size_t>&
count()
const {
return m_slab.
count();}
296inline int mpi_comm_global2local_rank( MPI_Comm comm,
int global_rank = 0, MPI_Comm global_comm = MPI_COMM_WORLD )
298 MPI_Group local_group, global_group;
299 MPI_Comm_group(comm, &local_group);
300 MPI_Comm_group(MPI_COMM_WORLD, &global_group);
302 MPI_Group_translate_ranks(global_group, 1, &global_rank, local_group, &local_root_rank);
303 return local_root_rank;
Definition easy_atts.h:15
A NetCDF Hyperslab for MPINcFile.
Definition nc_hyperslab.h:151
const size_t * countp() const
Definition nc_hyperslab.h:268
MPINcHyperslab(const MPITopology &grid)
grid.start(), grid.count(), grid.communicator()
Definition nc_hyperslab.h:221
MPINcHyperslab(size_t start0, const T ¶m)
Same as MPINcHyperslab{ start0, 1, grid}
Definition nc_hyperslab.h:228
const size_t * startp() const
Definition nc_hyperslab.h:266
MPINcHyperslab(const ContainerType &data)
{local_start(data) , local_size(data), data.communicator()}
Definition nc_hyperslab.h:193
MPI_Comm communicator() const
Definition nc_hyperslab.h:264
MPINcHyperslab(size_t start0, size_t count0, const T ¶m)
{start0, MPINcHyperslab( param).start()}, {count0, MPINcHyperslab(param).count(), MPINcHyperslab....
Definition nc_hyperslab.h:245
std::vector< size_t > & count()
Definition nc_hyperslab.h:262
MPINcHyperslab(size_t local_start, size_t local_count, MPI_Comm comm)
{local_start}, {local_count}
Definition nc_hyperslab.h:160
const std::vector< size_t > & count() const
Definition nc_hyperslab.h:258
const std::vector< size_t > & start() const
Definition nc_hyperslab.h:256
unsigned ndim() const
Definition nc_hyperslab.h:253
MPINcHyperslab(std::vector< size_t > local_start, std::vector< size_t > local_count, MPI_Comm comm)
local_start, local_count, comm
Definition nc_hyperslab.h:173
std::vector< size_t > & start()
Definition nc_hyperslab.h:260
A NetCDF Hyperslab for SerialNcFile.
Definition nc_hyperslab.h:27
const size_t * countp() const
Definition nc_hyperslab.h:134
std::vector< size_t > & count()
Definition nc_hyperslab.h:130
NcHyperslab(std::vector< size_t > start, std::vector< size_t > count)
start, count
Definition nc_hyperslab.h:45
std::vector< size_t > & start()
Definition nc_hyperslab.h:128
const std::vector< size_t > & count() const
Definition nc_hyperslab.h:126
const size_t * startp() const
Definition nc_hyperslab.h:132
const std::vector< size_t > & start() const
Definition nc_hyperslab.h:124
unsigned ndim() const
Definition nc_hyperslab.h:121
NcHyperslab(const Topology &grid)
grid.start(), grid.count()
Definition nc_hyperslab.h:88
NcHyperslab(size_t start0, size_t count0, const T ¶m)
{start0, NcHyperslab( param).start()}, {count0, NcHyperslab(param).count()}
Definition nc_hyperslab.h:113
NcHyperslab(const ContainerType &data)
{0 , data.size()}
Definition nc_hyperslab.h:75
NcHyperslab(size_t start0, const T ¶m)
Same as NcHyperslab{ start0, 1, param}
Definition nc_hyperslab.h:98
NcHyperslab(const File &file, std::string name)
Definition nc_hyperslab.h:59
NcHyperslab(size_t start, size_t count=1)
{start}, {count}
Definition nc_hyperslab.h:34