Re: Design

> > I do have some comments. Unfortunately my printer only printed the first 
> > five pages so I appologize if some of these issues are covered after page 5.
> 
>  ...
> 
> > Well enough for now. I've got to go print the rest out.
> 
> The version I got and printed also only had five pages, and seems to end
> rather abruptly.  Is this the whole document, or did it get truncated in
> the process of copying it to the FTP directory on ftp.ncsa.uiuc.edu?
> 
>   -rw-rw-r--  1 russ       127056 May  6 16:52 design.ps
> 

Hmmm, the size looks correct (Russ's is older because of the
time zone difference):

Frw-r--r--   1 chouck   wsstaff   127056 May 06 17:01 design.ps

I just printed directly from the outgoing directory and it came out
fine (I was also able to ftp it to myslef and that copy
printed OK too)....

Page 6 is a postscript picture, do you think that could be the 
problem somehow?  (The doc is supposed to be 9 pages).

Is everyone having this problem?

-Chris

>From owner-netcdf-hdf@xxxxxxxxxxxxxxxx 28 2003 Oct -0700 07:19:17 
Message-ID: <wrx3cdda1i2.fsf@xxxxxxxxxxxxxxxxxxxxxxx>
Date: 28 Oct 2003 07:19:17 -0700
From: Ed Hartnett <ed@xxxxxxxxxxxxxxxx>
To: netcdf-hdf@xxxxxxxxxxxxxxxx
Subject: question about H5Sselect_elements
Received: (from majordo@localhost)
        by unidata.ucar.edu (UCAR/Unidata) id h9SEJIiY024901
        for netcdf-hdf-out; Tue, 28 Oct 2003 07:19:18 -0700 (MST)
Received: from rodney.unidata.ucar.edu (rodney.unidata.ucar.edu 
[128.117.140.88])
        by unidata.ucar.edu (UCAR/Unidata) with ESMTP id h9SEJHOb024893
        for <netcdf-hdf@xxxxxxxxxxxxxxxx>; Tue, 28 Oct 2003 07:19:17 -0700 (MST)
Organization: UCAR/Unidata
Keywords: 200310281419.h9SEJHOb024893
Lines: 16
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: owner-netcdf-hdf@xxxxxxxxxxxxxxxx
Precedence: bulk

Question for the HDF Home Office:

In H5Sselect_elements, is this parameter zero based?

const hssize_t *coord[ ]
    A 2-dimensional array specifying the coordinates of the elements
    being selected. 

I presume, this being C, that the coord array contains 0-bases
references to the elements being selected. This seems to be the case
in the h5_select sample program too.

Thanks,

Ed


>From owner-netcdf-hdf@xxxxxxxxxxxxxxxx 28 2003 Oct -0700 07:35:40 
Message-ID: <wrxy8v58m6b.fsf@xxxxxxxxxxxxxxxxxxxxxxx>
Date: 28 Oct 2003 07:35:40 -0700
From: Ed Hartnett <ed@xxxxxxxxxxxxxxxx>
To: netcdf-hdf@xxxxxxxxxxxxxxxx
Subject: why does this give me a segmetation fault?
Received: (from majordo@localhost)
        by unidata.ucar.edu (UCAR/Unidata) id h9SEZoGL011130
        for netcdf-hdf-out; Tue, 28 Oct 2003 07:35:50 -0700 (MST)
Received: from rodney.unidata.ucar.edu (rodney.unidata.ucar.edu 
[128.117.140.88])
        by unidata.ucar.edu (UCAR/Unidata) with ESMTP id h9SEZhOb011056
        for <netcdf-hdf@xxxxxxxxxxxxxxxx>; Tue, 28 Oct 2003 07:35:43 -0700 (MST)
Organization: UCAR/Unidata
Keywords: 200310281435.h9SEZhOb011056
Lines: 161
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: owner-netcdf-hdf@xxxxxxxxxxxxxxxx
Precedence: bulk


Howdy Quincey!

Do me a favor, compile and run this program.

When I chage this program to use a contiguous dataset, and take out
the H5Dextend call, everything works. But using an extendable dataset,
it give me a seg fault.

Obviously I'm doing something wrong with respect to my setting up or
using the chunked dataset. I'm going to reread the docs and see what
they say again...

Ed


/* 
   Why doesn't this work?
*/

#include <hdf5.h>

int main(void);

#define BAIL(e) do { \
printf("Bailing out in file %s, line %d, error:%d.\n", __FILE__, __LINE__, e); \
goto exit; \
} while (0) 

#define DATASET_NAME "eds_ds"

int
main()
{
   hid_t hdfid = 0, datasetid = 0, plistid = 0, type = 0;
   hid_t mem_space = 0, file_space = 0;
   float data = 99.9;
   hssize_t ndata;
   hssize_t coord[1][1];
   int retval = 0;

   /* Create a file. */
   if ((hdfid = H5Fcreate("aaa_test.h5", H5F_ACC_TRUNC, H5P_DEFAULT, 
H5P_DEFAULT)) < 0)
      BAIL(-1);

   /* Store floats. */
   if ((type = H5Tcopy(H5T_NATIVE_FLOAT)) < 0)
      BAIL(-2);
   
   /* Reading and writing to memory always happens one element at a
      time. */
   {
      hsize_t dimsize1[] = {1};
      if ((mem_space = H5Screate_simple(1, dimsize1, NULL)) < 0) 
         BAIL(-3);
   }
   
   /* Crate an extendable dataset, of rank 1, with 1 datum in it. */
   {
      hsize_t maxdim = H5S_UNLIMITED, start_ndata = 1, chunk_size = 1;
      if ((file_space = H5Screate_simple(1, &start_ndata, &maxdim)) < 0) 
         BAIL(-4);
      if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
         BAIL(-4);
      if (H5Pset_chunk(plistid, 1,  &chunk_size) < 0)
         BAIL(-4);
      if ((datasetid = H5Dcreate(hdfid, DATASET_NAME, 
                                 type, file_space, plistid)) < 0)
         BAIL(-4);
   }

   /* Write one value. */
   if ((file_space = H5Dget_space(datasetid)) < 0)
      BAIL(-4);
   ndata = H5Sget_simple_extent_npoints(file_space);
   printf("number of data in dataset: %d\n", (int)ndata);
   coord[0][0] = 0;
   if (H5Sselect_elements(file_space, H5S_SELECT_SET, 1, 
                          (const hssize_t **)coord) < 0)
      BAIL(-4);
   if (H5Dwrite(datasetid, type, mem_space, file_space, 
                H5P_DEFAULT, &data) < 0)
      BAIL(-4);
   H5Dclose(datasetid);
   datasetid = 0;

   /* Read the value just written. */
   {
      float thefloat;

      if ((datasetid = H5Dopen(hdfid, DATASET_NAME)) < 0)
         BAIL(-3);
      if ((file_space = H5Dget_space(datasetid)) < 0)
         BAIL(-3);
      ndata = H5Sget_simple_extent_npoints(file_space);
      printf("number of data in dataset: %d\n", (int)ndata);
      coord[0][0] = 0;
      if (H5Sselect_elements(file_space, H5S_SELECT_SET, 1, 
                             (const hssize_t **)coord) < 0)
         BAIL(-4);
      if (H5Dread(datasetid, type, mem_space, file_space, 
                  H5P_DEFAULT, &thefloat) < 0)
         BAIL(-3);
      printf("the float: %f\n", thefloat);
      H5Dclose(datasetid);
      datasetid = 0;
   }

   /* Add another datum. */
   {
      hsize_t extend_size = 2;
      float secfloat = 88.8;
      if ((datasetid = H5Dopen(hdfid, DATASET_NAME)) < 0)
         BAIL(-3);
      if (H5Dextend(datasetid, &extend_size) < 0)
         BAIL(-10);
      if ((file_space = H5Dget_space(datasetid)) < 0)
         BAIL(-4);
      ndata = H5Sget_simple_extent_npoints(file_space);
      printf("number of data in dataset: %d\n", (int)ndata);
      coord[0][0] = 1;
      if (H5Sselect_elements(file_space, H5S_SELECT_SET, 1, 
                             (const hssize_t **)coord) < 0)
         BAIL(-4);
      if (H5Dwrite(datasetid, type, mem_space, file_space, 
                   H5P_DEFAULT, &secfloat) < 0)
         BAIL(-4);
      H5Dclose(datasetid);
      datasetid = 0;
   }

   /* Read the value just written. */
   {
      float thefloat;

      if ((datasetid = H5Dopen(hdfid, DATASET_NAME)) < 0)
         BAIL(-3);
      if ((file_space = H5Dget_space(datasetid)) < 0)
         BAIL(-3);
      ndata = H5Sget_simple_extent_npoints(file_space);
      printf("number of data in dataset: %d\n", (int)ndata);
      coord[0][0] = 1;
      if (H5Sselect_elements(file_space, H5S_SELECT_SET, 1, 
                             (const hssize_t **)coord) < 0)
         BAIL(-4);
      if (H5Dread(datasetid, type, mem_space, file_space, 
                  H5P_DEFAULT, &thefloat) < 0)
         BAIL(-3);
      printf("the float: %f\n", thefloat);
      H5Dclose(datasetid);
      datasetid = 0;
   }

 exit:
   if (datasetid > 0) H5Dclose(datasetid);
   if (type > 0) H5Tclose(type);
   if (mem_space > 0) H5Sclose(mem_space);
   if (file_space > 0) H5Sclose(file_space);
   if (plistid > 0) H5Pclose(plistid);
   return retval;
}