Cannot read compound data from HDF file

Dear all,

I cannot read compound data from HDF file. I created the data and wrote it to a HDF file with a FORTRAN subroutine and now trying to read it within another FORTRAN program. Attached are my script, HDF file and its h5dump output. My script halts with an error like:

HDF5-DIAG: Error detected in HDF5 (1.8.8) thread 0:
   #000: H5Tarray.c line 142 in H5Tarray_create2(): not an valid base datatype
     major: Invalid arguments to routine
     minor: Inappropriate type
....
HDF5-DIAG: Error detected in HDF5 (1.8.8) thread 0:
   #000: H5S.c line 365 in H5Sclose(): not a dataspace
     major: Invalid arguments to routine
     minor: Inappropriate type

I would be glad if you can help me on the issue. Thank you all for your concerns.

Best regards,

cc_res.h5 (2.25 KB)

cc_res.txt (685 Bytes)

read_complexcompound.f95 (1.73 KB)

···

--
*Ekin Akoglu*

Research Assistant

Institute of Marine Sciences
Middle East Technical University
P.O. Box 28, 33731
Erdemli, Mersin
Turkey

Web: www.ims.metu.edu.tr
Email: ekin@ims.metu.edu.tr <mailto:ekin@ims.metu.edu.tr>
Phone: +90 324 521 34 34
GSM: +90 506 554 03 90
Fax: +90 324 521 23 27

You need to initialize the Fortran interface:

CALL h5open_f(hdferr)

···

On 2012-03-26 06:22, Ekin Akoglu wrote:

Dear all,

I cannot read compound data from HDF file. I created the data and
wrote it to a HDF file with a FORTRAN subroutine and now trying to
read it within another FORTRAN program. Attached are my script, HDF
file and its h5dump output. My script halts with an error like:

HDF5-DIAG: Error detected in HDF5 (1.8.8) thread 0:
#000: H5Tarray.c line 142 in H5Tarray_create2(): not an valid base
datatype
major: Invalid arguments to routine
minor: Inappropriate type
....
HDF5-DIAG: Error detected in HDF5 (1.8.8) thread 0:
#000: H5S.c line 365 in H5Sclose(): not a dataspace
major: Invalid arguments to routine
minor: Inappropriate type

I would be glad if you can help me on the issue. Thank you all for
your concerns.

Best regards,

--
EKIN AKOGLU

Research Assistant

Institute of Marine Sciences
Middle East Technical University
P.O. Box 28, 33731
Erdemli, Mersin
Turkey

Web: www.ims.metu.edu.tr [1]
Email: ekin@ims.metu.edu.tr [2]
Phone: +90 324 521 34 34
GSM: +90 506 554 03 90
Fax: +90 324 521 23 27

Links:
------
[1] http://webmail.hdfgroup.org/www.ims.metu.edu.tr
[2] mailto:ekin@ims.metu.edu.tr

Thank you for your help. Now it works. In the meantime, I managed to read the data with the attached script without initializing the FORTRAN interface and without defining the compound data type. This seems a shorter approach but I wonder whether this approach might lead to some erroneous results or not while reading data. Is the other one preferable over this one?

Regards,

Ekin

read_complexcompound.f95 (1.4 KB)

···

On 03/26/2012 06:09 PM, brtnfld@hdfgroup.org wrote:

CALL h5open_f(hdferr)

Ekin,

Thank you for your help. Now it works. In the meantime, I managed to read the data with the attached script without initializing the FORTRAN interface and without defining the compound data type.

Your program still has h5open_f call (the call is required! :slight_smile:

This seems a shorter approach but I wonder whether this approach might lead to some erroneous results or not while reading data. Is the other one preferable over this one?

The program works because you are reading data on the same machine it was written. In general, HDF5 file datatype (returned by h5dget_type_f) cannot be used to describe memory buffer (memory datatype) in the h5dread_f call; this is not portable and may not work if the program runs on another system.

The original program is correct (except the missing h5open_f call) and portable.

Elena

···

On Mar 26, 2012, at 2:48 PM, Ekin Akoglu wrote:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Regards,

Ekin

On 03/26/2012 06:09 PM, brtnfld@hdfgroup.org wrote:

CALL h5open_f(hdferr)

<read_complexcompound.f95>_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Dear Elena,

Thank you for your explanation on the issue. It has crucial importance for me to opt for portable code. I have one more question. Is it possible to specify the exact number of digits to be stored in an HDF5 file after the decimal point?

Thank you in advance.

Best regards,

Ekin

···

On 03/29/2012 01:00 AM, Elena Pourmal wrote:

Ekin,

On Mar 26, 2012, at 2:48 PM, Ekin Akoglu wrote:

Thank you for your help. Now it works. In the meantime, I managed to read the data with the attached script without initializing the FORTRAN interface and without defining the compound data type.

Your program still has h5open_f call (the call is required! :slight_smile:

This seems a shorter approach but I wonder whether this approach might lead to some erroneous results or not while reading data. Is the other one preferable over this one?

The program works because you are reading data on the same machine it was written. In general, HDF5 file datatype (returned by h5dget_type_f) cannot be used to describe memory buffer (memory datatype) in the h5dread_f call; this is not portable and may not work if the program runs on another system.

The original program is correct (except the missing h5open_f call) and portable.

Elena
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Regards,

Ekin

On 03/26/2012 06:09 PM, brtnfld@hdfgroup.org >> <mailto:brtnfld@hdfgroup.org> wrote:

CALL h5open_f(hdferr)

<read_complexcompound.f95>_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org <mailto:Hdf-forum@hdfgroup.org>
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
   
--
*Ekin Akoglu*

Research Assistant

Institute of Marine Sciences
Middle East Technical University
P.O. Box 28, 33731
Erdemli, Mersin
Turkey

Web: www.ims.metu.edu.tr
Email: ekin@ims.metu.edu.tr <mailto:ekin@ims.metu.edu.tr>
Phone: +90 324 521 34 34
GSM: +90 506 554 03 90
Fax: +90 324 521 23 27