Re: question about vlens and the size of their base type...

> Hi Ed,
> 
> Welcome to 64-bit world :-)
> 
> I believe that the sizes of size_t and integer pointer are 8 on your new 
> machine

    Yup. :-)

        Quincey

> 
> Elena
> 
> At 04:26 PM 8/29/2005, Ed Hartnett wrote:
> 
> >Howdy HDF5 Folk!
> >
> >I have a HDF5 question.
> >
> >I just switched to a new, faster, computer, and when I compile my
> >usual set of HDF5 "tests," I get some new behavior.
> >
> >(I have tests in quotes because I'm not really trying to test HDF5,
> >just exercising it in a way similar to that which netCDF-4 does -
> >more of a sanity check than a set of tests).
> >
> >Anyway, the program is appended below. What happens is that I create a
> >VLEN of base type NC_INT. Then I check the size of the VLEN type, and
> >it has been, until today, 8. (Is this 4 bytes each for the two fields
> >in hvl_t?)
> >
> >Now, when I run this program, I get a size of 16 instead of 8.
> >
> >What's up with that, I wonder?
> >
> >Here's my new system name info, in case it helps:
> >Linux shecky.unidata.ucar.edu 2.6.12-1.1398_FC4smp #1 SMP Fri Jul 15
> >01:05:24 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux
> >
> >It does seem to imply some 64-bit stuff going on...
> >
> >Any thoughts or suggestions would be most welcome.
> >
> >Ed
> >
> >int
> >main()
> >{
> >    hid_t fileid, grpid, spaceid, typeid, attid;
> >    hsize_t dims[1] = {DIM1_LEN};
> >    hvl_t data[DIM1_LEN];
> >    int *phoney;
> >    int i, j;
> >    size_t size;
> >
> >    /* Create some phoney data, an array of struct s1, which holds a
> >     * pointer to a variable length array of int. */
> >    for (i=0; i<DIM1_LEN; i++)
> >    {
> >       if (!(phoney = malloc(sizeof(int) * i+1)))
> >         return NC_ENOMEM;
> >       for (j=0; j<i+1; j++)
> >         phoney[j] = -99;
> >       data[i].p = phoney;
> >       data[i].len = i+1;
> >    }
> >
> >    printf("*** Checking simple HDF5 variable length types...");
> >
> >    /* Open file. */
> >    if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
> >                            H5P_DEFAULT)) < 0) ERR;
> >    if ((grpid = H5Gcreate(fileid, "grp1", 0)) < 0) ERR;
> >
> >    /* Create VLEN type. */
> >    if ((typeid =  H5Tvlen_create(H5T_NATIVE_INT)) < 0) ERR;
> >
> >    /* Although it's a vlen of ints, the size is rouned up to 8. */
> >    if (!(size = H5Tget_size(typeid))) ERR;
> >    if (size != 8) ERR;
> >
> >    /* Write an attribute of this vlen type. */
> >    if ((spaceid = H5Screate_simple(1, dims, NULL)) < 0) ERR;
> >    if ((attid = H5Acreate(grpid, ATT_NAME, typeid, spaceid,
> >                           H5P_DEFAULT)) < 0) ERR;
> >    if (H5Awrite(attid, typeid, data) < 0) ERR;
> >    if (H5Aclose(attid) < 0) ERR;
> >    if (H5Tclose(typeid) < 0) ERR;
> >    if (H5Gclose(grpid) < 0) ERR;
> >    if (H5Fclose(fileid) < 0) ERR;
> >
> >    SUMMARIZE_ERR;
> >
> >    /* Print out our number of errors, if any, and exit badly. */
> >    if (total_err)
> >    {
> >       printf("%d errors detected! Sorry!\n", total_err);
> >       return 2;
> >    }
> >
> >    printf("*** Tests successful!\n");
> >    return 0;
> >}
> >
> >
> >--
> >Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx
> 
> -----------------------------------------------------------------------------------------------
> Elena Pourmal, HDF QA, Maintenance and Support Team Leader
> NCSA University of Illinois at Urbana-Champaign
> 605 E. Springfield Ave.
> Champaign, IL 61820
> 
> epourmal@xxxxxxxxxxxxx
> (217)333-0238 (office)
> (217)244-1987 (fax)
> ----------------------------------------------------------------------------------------------
> 
>