how to get datatype in fortran

Hello Everybody,

I am trying to write a common function call which will write data to the
concerned dataset. So I pass the datasetname, datasetid, dataspace id etc. to
the call...

But the problem is that the datatype is not common for all calls, so I need to
get the datatype from the datasetname provided. i.e. for first call the dataset
is of the type N5T_NATIVE_REAL and for the next call, its for H5T_NATIVE_INTEGER.

Now how can i get the type of the dataset in this subroutine ? Is there any
library function which does this. In C i think there is H5Tget_native_type, but
its not there for Fortran. So can anyone suggest how to make a universal
function which can write all datatypes ?

Thanks a lot.

Regards,
Nikhil

···

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Before I realised native_type existed in C, I was checking the dataset class (e.g. H5_FLOAT) and element size (e.g. 4 for single and 8 for double precision). I could not capture e.g. signed/unsigned types though.
-- DOminik

Nikhil Laghave wrote:

···

Hello Everybody,

I am trying to write a common function call which will write data to the
concerned dataset. So I pass the datasetname, datasetid, dataspace id etc. to
the call...

But the problem is that the datatype is not common for all calls, so I need to
get the datatype from the datasetname provided. i.e. for first call the dataset
is of the type N5T_NATIVE_REAL and for the next call, its for H5T_NATIVE_INTEGER.

Now how can i get the type of the dataset in this subroutine ? Is there any
library function which does this. In C i think there is H5Tget_native_type, but
its not there for Fortran. So can anyone suggest how to make a universal
function which can write all datatypes ?

Thanks a lot.

Regards,
Nikhil

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Biomedical Simulation Group
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Before I realised native_type existed in C, I was checking the dataset class (e.g. H5_FLOAT) and element size (e.g. 4 for single and 8 for double precision). I could not capture e.g. signed/unsigned types though.

  You can capture signed/unsigned information with the H5Tget_sign() routine. :slight_smile:

    Quincey

···

On Jun 17, 2008, at 1:15 AM, Dominik Szczerba wrote:

-- DOminik

Nikhil Laghave wrote:

Hello Everybody,
I am trying to write a common function call which will write data to the
concerned dataset. So I pass the datasetname, datasetid, dataspace id etc. to
the call...
But the problem is that the datatype is not common for all calls, so I need to
get the datatype from the datasetname provided. i.e. for first call the dataset
is of the type N5T_NATIVE_REAL and for the next call, its for H5T_NATIVE_INTEGER.
Now how can i get the type of the dataset in this subroutine ? Is there any
library function which does this. In C i think there is H5Tget_native_type, but
its not there for Fortran. So can anyone suggest how to make a universal
function which can write all datatypes ?
Thanks a lot.
Regards,
Nikhil
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Biomedical Simulation Group
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

That is a useful hint, thanks! But native type is more convenient I find. I wonder why it is not there in Fortran? -- Dominik

Quincey Koziol wrote:

···

On Jun 17, 2008, at 1:15 AM, Dominik Szczerba wrote:

Before I realised native_type existed in C, I was checking the dataset class (e.g. H5_FLOAT) and element size (e.g. 4 for single and 8 for double precision). I could not capture e.g. signed/unsigned types though.

    You can capture signed/unsigned information with the H5Tget_sign() routine. :slight_smile:

        Quincey

-- DOminik

Nikhil Laghave wrote:

Hello Everybody,
I am trying to write a common function call which will write data to the
concerned dataset. So I pass the datasetname, datasetid, dataspace id etc. to
the call...
But the problem is that the datatype is not common for all calls, so I need to
get the datatype from the datasetname provided. i.e. for first call the dataset
is of the type N5T_NATIVE_REAL and for the next call, its for H5T_NATIVE_INTEGER.
Now how can i get the type of the dataset in this subroutine ? Is there any
library function which does this. In C i think there is H5Tget_native_type, but
its not there for Fortran. So can anyone suggest how to make a universal
function which can write all datatypes ?
Thanks a lot.
Regards,
Nikhil
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Biomedical Simulation Group
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Biomedical Simulation Group
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

All,

About h5tget_native_type_f function.... I simply missed that function and didn't implement it in Fortran. Will do for the next release. Thanks for catching the error.

Currently you will need to construct a memory type using datatype query routines to find the appropriate class and size of the dataset's datatype (NOTE: since FORTRAN doesn't support unsigned integers, care should be taken to avoid data loss when reading unsigned integers. One has to read them in a bigger type). And you will need to overload your function to accommodate different buffers types and shapes.

  We are coming with the new FORTRAN APIs based on the 2003 standard. When we have it in place, one can avoid overloading, but functions like h5tget_native_type_f will still be needed to bypass memory type construction.

Elena

···

On Jun 17, 2008, at 6:41 AM, Dominik Szczerba wrote:

That is a useful hint, thanks! But native type is more convenient I find. I wonder why it is not there in Fortran? -- Dominik

Quincey Koziol wrote:

On Jun 17, 2008, at 1:15 AM, Dominik Szczerba wrote:

Before I realised native_type existed in C, I was checking the dataset class (e.g. H5_FLOAT) and element size (e.g. 4 for single and 8 for double precision). I could not capture e.g. signed/unsigned types though.

   You can capture signed/unsigned information with the H5Tget_sign() routine. :slight_smile:
       Quincey

-- DOminik

Nikhil Laghave wrote:

Hello Everybody,
I am trying to write a common function call which will write data to the
concerned dataset. So I pass the datasetname, datasetid, dataspace id etc. to
the call...
But the problem is that the datatype is not common for all calls, so I need to
get the datatype from the datasetname provided. i.e. for first call the dataset
is of the type N5T_NATIVE_REAL and for the next call, its for H5T_NATIVE_INTEGER.
Now how can i get the type of the dataset in this subroutine ? Is there any
library function which does this. In C i think there is H5Tget_native_type, but
its not there for Fortran. So can anyone suggest how to make a universal
function which can write all datatypes ?
Thanks a lot.
Regards,
Nikhil
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Biomedical Simulation Group
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Biomedical Simulation Group
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.