A Monday 03 December 2007, Francesc Altet escrigué:
> Ups, I've ended with a similar program and send it to the
> [EMAIL PROTECTED] list past Saturday.  I'm attaching my own
> version (which is pretty similar to yours).  Sorry for not sending
> you a copy of my previous message, because it could saved you some
> work :-/

Well, as Ivan pointed out, a couple of glitches slipped in my program.  
I'm attaching the correct version, but the result is the same, i.e. 
when N=600. I'm getting a segfault both under HDF5 1.6.5 and 1.8.0 
beta5.

Cheers,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"
#include "hdf5.h"

#define H5FILE_NAME "write-bug.h5"
#define DATASETNAME "DoubleArray"
/* define N      600 */  /* Try this for seg fault */
#define N      600
#define M      5
#define RANK   6

int
main (void)
{
    hid_t       file, dataset;         /* file and dataset handles */
    hid_t       datatype, dataspace;   /* handles */
    hid_t       mem_space, plist;
    hsize_t     dimsf[] = {2,2,N,N,M,M};
    hsize_t     dimsc[] = {1,1,1,6,M,M};
    hsize_t     start[] = {0,0,0,0,0,0};
    hsize_t     step[]  = {1,1,1,1,1,1};
    hsize_t     count[] = {2,2,N,N,1,1};
    herr_t      status;
    double      data[2][2][N][N][1][1];          /* data to write */
    int         i, j;

    /*
     * Create a new file using H5F_ACC_TRUNC access,
     * default file creation properties, and default file
     * access properties.
     */
    file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

    /*
     * Describe the size of the array and create the data space for fixed
     * size dataset.
     */
    dataspace = H5Screate_simple(RANK, dimsf, NULL);

    /* Set the chunkshape */
    plist = H5Pcreate(H5P_DATASET_CREATE);
    H5Pset_chunk(plist, RANK, dimsc);

    /*
     * Define datatype for the data in the file.
     * We will store little endian DOUBLE numbers.
     */
    datatype = H5Tcopy(H5T_NATIVE_DOUBLE);
    status = H5Tset_order(datatype, H5T_ORDER_LE);

    /*
     * Create a new dataset within the file using defined dataspace and
     * datatype and default dataset creation properties.
     */
    dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace,	plist);

    /* Create a simple memory data space */
    mem_space = H5Screate_simple(RANK, count, NULL);

    /* Fill the dataset starting with trailing dimensions first */
    for (j = 0; j < M; j++) {
      start[4] = j;
      for (i = 0; i < M; i++) {
	start[5] = i;

	/* Define a hyperslab in the dataset */
	H5Sselect_hyperslab(dataspace, H5S_SELECT_SET,
			    start, step, count, NULL);

	/* Write the data to the dataset using default transfer properties */
	status = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, mem_space, dataspace,
			  H5P_DEFAULT, data);
      }
    }

    /*
     * Close/release resources.
     */
    H5Sclose(mem_space);
    H5Sclose(dataspace);
    H5Tclose(datatype);
    H5Dclose(dataset);
    H5Fclose(file);

    return 0;
}
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to