Re: HDF5 question about endianness...

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.

Hi Ed,

Here is a small example that I hope will give you an idea how to use H5Tget_order to get information you need:

#include "hdf5.h"

int main() {

   H5T_order_t order;
   hid_t type;

   order = H5Tget_order(H5T_NATIVE_INT);
   printf("order is %d \n", order);

   type = H5Tcopy(H5T_STD_I32LE);
   order = H5Tget_order(type);
   printf("order is %d \n", order);

   H5Tclose(type);
}
If you run it on AIX system (big-endian) you will get

order is 1
order is 0

where 1 stands for big-endian, and 0 stands for little-endian

H5Tget_native_type is used to construct memory type from the file type avoiding building the memory type from scratch (finding class, size, precision, etc). It is a short cut. In general user still has to know the size and the type of the buffer to read data in.

Elena
At 05:49 AM 9/28/2006 -0600, Ed Hartnett wrote:
Howdy all!

I have a HDF5 question.

I see that the function H5Tget_order can tell me if a type is big or
little endian.

But is there a way to tell if a type is native endian for that
machine?

What is H5Tget_native_type all about? Is this it's purpose? To tell me
if a type is native?

They I could use H5Tget_order to find if something is big or little
endian, and then somehow get_native_type to tell whether this is the
native endianness for the machine?

Is that it?

Thanks!

Ed

--
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

==============================================================================
To unsubscribe netcdf-hdf, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================

-----------------------------------------------------------------------------------------------
Elena Pourmal
The HDF Group
1901 S. First St.
Champaign, IL 61820

epourmal@xxxxxxxxxxxx
(217)333-0238 (office)
(217)333-9049 (fax)
----------------------------------------------------------------------------------------------


==============================================================================
To unsubscribe netcdf-hdf, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: