h5dread_f problem

Hello All,

I am no fortran expert and my question may be a very silly one. But could
someone help me in understanding this:

I use this API for reading a dataset on Franklin(NERSC) and it works ok.

      CALL h5dread_f(pdsetid,type_id,pdataarray,dims2,error,
     & file_space_id = pdspaceid,mem_space_id = pmemspace,
     & xfer_prp = pcrp_list)

But when I use the same on Bassi(NERSC), it does not read proper data and gives
some garbage value. The source code is exactly the same. The only change being
that I changed the extension from .f to .f90 on bassi as I was getting some file
suffix errors for the .f extension. Apart from that all is the same.

Can anyone guide me on this ?

Regards,
Nikhil

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.

Nikhil,

One thing will be to check memory datatype type_id. BASSI is a big-endian machine and Franklin is a little-endian one, right?

Elena

···

On Nov 25, 2008, at 5:15 PM, Nikhil Laghave wrote:

Hello All,

I am no fortran expert and my question may be a very silly one. But could
someone help me in understanding this:

I use this API for reading a dataset on Franklin(NERSC) and it works ok.

     CALL h5dread_f(pdsetid,type_id,pdataarray,dims2,error,
    & file_space_id = pdspaceid,mem_space_id = pmemspace,
    & xfer_prp = pcrp_list)

But when I use the same on Bassi(NERSC), it does not read proper data and gives
some garbage value. The source code is exactly the same. The only change being
that I changed the extension from .f to .f90 on bassi as I was getting some file
suffix errors for the .f extension. Apart from that all is the same.

Can anyone guide me on this ?

Regards,
Nikhil

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.

----------------------------------------------------------------------
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.

Hi Elena,

Thanks a lot for your help. The endianness was indeed the problem, that I have
fixed now.

Regards,
Nikhil

···

On Tue, Nov 25, 2008 at 9:53 PM, Elena Pourmal <epourmal@hdfgroup.org> wrote:

    Nikhil,

    One thing will be to check memory datatype type_id. BASSI is a big-endian
machine and Franklin is a little-endian one, right?

    Elena

    On Nov 25, 2008, at 5:15 PM, Nikhil Laghave wrote:

        Hello All,

        I am no fortran expert and my question may be a very silly one. But could
        someone help me in understanding this:

        I use this API for reading a dataset on Franklin(NERSC) and it works ok.

            CALL h5dread_f(pdsetid,type_id,pdataarray,dims2,error,
           & file_space_id = pdspaceid,mem_space_id = pmemspace,
           & xfer_prp = pcrp_list)

        But when I use the same on Bassi(NERSC), it does not read proper data
and gives
        some garbage value. The source code is exactly the same. The only change
being
        that I changed the extension from .f to .f90 on bassi as I was getting
some file
        suffix errors for the .f extension. Apart from that all is the same.

        Can anyone guide me on this ?

        Regards,
        Nikhil

        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.

    ----------------------------------------------------------------------
    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.

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.

Hi Nikhil,

I am glad that you found the problem. Actually I failed to tell you how to fix it :wink:

Parameter "type_id" should describe type of the buffer you are reading in (in HDF5 lingo "memory type").

One possible solution will be to use H5T_NATIVE_...... types. For example, if you pass integer buffer to h5dread_f call, then you use H5T_NATIVE_INTEGER for type_id. For C users it will be H5T_NATIVE_INT.
Please note that the code will be portable, since HDF5 knows what H5T_NATIVE_INTEGER represents (little-endian integer on a little-endian machine, and big-endian integer on a big-endian machine along with the sizes 4 or 8 bytes).

Aside: HDF5 provides H5Tget_native_type C function (and undocumented h5tget_native_type_f Fortran function) to get an appropriate memory type using the type of data in the file. Unfortunately with the current Fortran implementation it will not help much since you can only use one of four types of the buffers: integer, real, character and double precision (obsolete). This will change when we introduce Fortran 2003 features in HDF5.

Elena

···

On Nov 26, 2008, at 3:35 PM, Nikhil Laghave wrote:

Hi Elena,

Thanks a lot for your help. The endianness was indeed the problem, that I have
fixed now.

Regards,
Nikhil

On Tue, Nov 25, 2008 at 9:53 PM, Elena Pourmal > <epourmal@hdfgroup.org> wrote:

   Nikhil,

   One thing will be to check memory datatype type_id. BASSI is a big-endian
machine and Franklin is a little-endian one, right?

   Elena

   On Nov 25, 2008, at 5:15 PM, Nikhil Laghave wrote:

       Hello All,

       I am no fortran expert and my question may be a very silly one. But could
       someone help me in understanding this:

       I use this API for reading a dataset on Franklin(NERSC) and it works ok.

           CALL h5dread_f(pdsetid,type_id,pdataarray,dims2,error,
          & file_space_id = pdspaceid,mem_space_id = pmemspace,
          & xfer_prp = pcrp_list)

       But when I use the same on Bassi(NERSC), it does not read proper data
and gives
       some garbage value. The source code is exactly the same. The only change
being
       that I changed the extension from .f to .f90 on bassi as I was getting
some file
       suffix errors for the .f extension. Apart from that all is the same.

       Can anyone guide me on this ?

       Regards,
       Nikhil

       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.

   ----------------------------------------------------------------------
   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.

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.

----------------------------------------------------------------------
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.