# Dynamically determine dataset type within a group and build a mpi struct correspondly

**URL:** <https://forum.hdfgroup.org/t/dynamically-determine-dataset-type-within-a-group-and-build-a-mpi-struct-correspondly/3045>\
**Category:** Hdf-forum archives\
**Created:** [November 6, 2013, 7:00pm UTC](https://forum.hdfgroup.org/t/dynamically-determine-dataset-type-within-a-group-and-build-a-mpi-struct-correspondly/3045 "2013-11-06T19:00:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goon83](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/g/ea666f/32.png) [@goon83](https://forum.hdfgroup.org/u/goon83)\
**Post date:** [November 6, 2013, 7:00pm UTC](https://forum.hdfgroup.org/t/dynamically-determine-dataset-type-within-a-group-and-build-a-mpi-struct-correspondly/3045/1 "2013-11-06T19:00:56Z")

</div>

Hi everyone,  
There is a HDF5 file, which contains several groups. Each group has multiple datasets. The dataset might be different types. A simple examples looks like:  
HDF5 "ptf.h5" {  
GROUP "/" {  
&nbsp;&nbsp;&nbsp;GROUP "g" {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATASET "a" {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATATYPE H5T\_IEEE\_F32LE  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATASET "b" {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATATYPE H5T\_STD\_I64LE  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATASET "c" {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATATYPE H5T\_STD\_I8LE  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATASET "d" {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATATYPE H5T\_STD\_I16LE  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
}}

One job of my is to sort the whole group based on one dataset within MPI environment. One basic step of the sorting codes is to package each line of these four variables into one and exchange among MPI process. Right now, I define some static struct like below and use MPI\_Type\_create\_struct/MPI\_Type\_commit to register this type. After registration, this compound type can be used for MPI\_Sendrecv.

struct community\_type{  
float a;  
double b;  
char c;  
short d;  
}

In order to make the codes more general, one possible way is to dynamically determine the type of each dataset , then find its corresponding type in MPI, and finally call MPI\_Type\_create\_struct/MPI\_Type\_commit to register this type.

Does anyone know any place I can find related information about this idea?

Thanks a lot,  
Bin

> **···**
>
> --
