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

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 "/" {
   GROUP "g" {
      DATASET "a" {
      DATASET "b" {
      DATASET "c" {
      DATASET "d" {

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,