Get array dimensions in a compound datatype

Dear all,
I am struggling a bit to get the dimensions of the array inside a compound datatype. I am extracting the data from the hdf and I am successful in extracting the all atomic but arrays. This is due to the fact that I am unable to extract the dimension of the array. I am using HDF.PInvoke in C#.

The biggest issue I have is to extract parameter ‘dims’ in the below code from the hdf file. I know dims can be defined for example ulong[2]={Dim1, Dim2}, but that is not what I wan’t to do since Dim2 is not the same in every hdf file. Is there a way to extract dims parameter required for HDF5get_array_dims from hdf file?.

int arrDim = H5T.get_array_dims(mem_type_ID,dims);

mem_type_ID is obtained by looping through all data types, k is the loop index.

herr_t nmembers = H5T.get_nmembers(typeID);
hid_t mem_type = H5T.copy(typeID);   

for (uint k = 0; k <= nmembers - 1; k++)
{
...
hid_t mem_type_ID = H5T.get_member_type(mem_type, k);
...
}

Also, Is there a way to know the datatype of the elements inside the array?

Thanks in advance
BR,
Raghu

Raghu, how are you? I’m not sure I understand the first part of your question. H5T.get_array_dims gives you the extent of the individual dimensions. Is your question, how many dimensions (rank) there are in the first place? If that’s the case, H5T.get_array_ndims is what you want.
On your second question (how to determine the element type of an array type): Let’s say array_type_id is a handle of your array type. Then elt_type_id = H5T.get_super(array_type_id) is the type from which the array type was derived, in this case, the array element type.
Does that answer your question(s)?

Best, G.

Hello gheber,
Thanks for the quick reply. The main issue I have in handling the H5T.get_array_dims is to do with second parameter dims, How do I obtain this from the from the h5 file?. I know that the rank of the array is 1 from H5T.get_array_ndims but I do not know how many elements are there in the array. In that case I need to obtain that information from h5 file, the question is how do I know the number of elements in the array?.

BR,
Raghu

Thanks for the information. I found an alternative solution. Having known the size of the object and the size of the element of the array, I was able to derive the number of elements.