You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everything works fine if I modify the structs to obtain a 1D array, but when I try to write a 2D array I obtain:
:: data: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
:: file [test.h5] created (id=16777216)
HDF5-DIAG: Error detected in HDF5 (1.8.4-patch1) thread 0:
#000: ../../../src/H5D.c line 171 in H5Dcreate2(): unable to create dataset
major: Dataset
minor: Unable to initialize object #1: ../../../src/H5Dint.c line 428 in H5D_create_named(): unable to create and link to dataset
major: Dataset
minor: Unable to initialize object #2: ../../../src/H5L.c line 1639 in H5L_link_object(): unable to create new link to object
major: Links
minor: Unable to initialize object #3: ../../../src/H5L.c line 1862 in H5L_create_real(): can't insert link
major: Symbol table
minor: Unable to insert object #4: ../../../src/H5Gtraverse.c line 877 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found #5: ../../../src/H5Gtraverse.c line 703 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed #6: ../../../src/H5L.c line 1685 in H5L_link_cb(): unable to create object
major: Object header
minor: Unable to initialize object #7: ../../../src/H5O.c line 2677 in H5O_obj_create(): unable to open object
major: Object header
minor: Can't open object #8: ../../../src/H5Doh.c line 296 in H5O_dset_create(): unable to create dataset
major: Dataset
minor: Unable to initialize object #9: ../../../src/H5Dint.c line 1030 in H5D_create(): unable to construct layout information
major: Dataset
minor: Unable to initialize object #10: ../../../src/H5Dcontig.c line 410 in H5D_contig_construct(): unable to retrieve number of elements in dataspace
major: Dataset
minor: Can't get value
panic: hdf5 error code=-1
goroutine 2 [syscall]:
created by runtime.main
/home/brunetto/Code/gop/go/src/pkg/runtime/proc.c:221
exit status 2
The modified source is:
package main
import (
"fmt"
"github.com/sbinet/go-hdf5/pkg/hdf5"
)
const (
FNAME string = "test.h5"
DATASET string = "ArrayOfFloat64"
LENGTHX int = 10
LENGHTY int = 2
CAPACITY int = LENGTHX*LENGHTY
RANK int = 2
)
func main() {
// Initialize array and slice
s1 := [CAPACITY] float64{}
j := float64(0)
for i:=0; i<CAPACITY; i++ {
s1[i] = j
j++
}
fmt.Printf(":: data: %v\n", s1)
// create the file
f,err := hdf5.CreateFile(FNAME, hdf5.F_ACC_TRUNC)
if err != nil {
panic(err)
}
defer f.Close()
fmt.Printf(":: file [%s] created (id=%d)\n", FNAME, f.Id())
// create data space
dims := []int{LENGTHX, LENGHTY}
space,err := hdf5.CreateSimpleDataSpace(dims, nil)
if err != nil {
panic(err)
}
fmt.Printf("Created space ", space)
// create the memory data type
var dtype *hdf5.DataType = hdf5.T_IEEE_F64LE// h5 type for float64 little-endian
if dtype == nil {
panic("could not create a dtype")
}
// create the dataset
dset,err := f.CreateDataSet(DATASET, dtype, space, hdf5.P_DEFAULT)
if err != nil {
panic(err)
}
fmt.Printf(":: dset (id=%d)\n", dset.Id())
// write data to the dataset
fmt.Printf(":: dset.Write...\n")
err = dset.Write(&s1, dtype)
if err != nil {
panic(err)
}
fmt.Printf(":: dset.Write... [ok]\n")
// release resources
dset.Close()
f.Close()
// open the file and the dataset
f, err = hdf5.OpenFile(FNAME, hdf5.F_ACC_RDONLY)
if err != nil {
panic(err)
}
dset,err = f.OpenDataSet(DATASET)
if err != nil {
panic(err)
}
// read it back into a new slice
s2 := make([]float64, CAPACITY)
dset.Read(s2, dtype)
// display the fields
fmt.Printf(":: data: %v\n", s2)
// release resources
dset.Close()
f.Close()
}
I've tried to read the sources of the libraries but I can't find why it breaks or where I've done the mistake.
Also I can't fine more docs or example more than the sources or at http://go.pkgdoc.org/github.com/sbinet/go-hdf5/pkg/hdf5
to understan better how to use these libs.
Do you have any suggestion?
Thank you very much,
brunetto
The text was updated successfully, but these errors were encountered:
Hi againg!
I'm trying to modify your example
https://github.com/sbinet/go-hdf5/blob/master/cmd/test-go-cpxcmpd/test-go-cpxcmpd.go
to be able to save 2D arrays of float, something like
https://bitbucket.org/brunetto/c-utilities/src/cbe96e73d987/data_io.c
Everything works fine if I modify the structs to obtain a 1D array, but when I try to write a 2D array I obtain:
:: data: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
:: file [test.h5] created (id=16777216)
HDF5-DIAG: Error detected in HDF5 (1.8.4-patch1) thread 0:
#000: ../../../src/H5D.c line 171 in H5Dcreate2(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#1: ../../../src/H5Dint.c line 428 in H5D_create_named(): unable to create and link to dataset
major: Dataset
minor: Unable to initialize object
#2: ../../../src/H5L.c line 1639 in H5L_link_object(): unable to create new link to object
major: Links
minor: Unable to initialize object
#3: ../../../src/H5L.c line 1862 in H5L_create_real(): can't insert link
major: Symbol table
minor: Unable to insert object
#4: ../../../src/H5Gtraverse.c line 877 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found
#5: ../../../src/H5Gtraverse.c line 703 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed
#6: ../../../src/H5L.c line 1685 in H5L_link_cb(): unable to create object
major: Object header
minor: Unable to initialize object
#7: ../../../src/H5O.c line 2677 in H5O_obj_create(): unable to open object
major: Object header
minor: Can't open object
#8: ../../../src/H5Doh.c line 296 in H5O_dset_create(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#9: ../../../src/H5Dint.c line 1030 in H5D_create(): unable to construct layout information
major: Dataset
minor: Unable to initialize object
#10: ../../../src/H5Dcontig.c line 410 in H5D_contig_construct(): unable to retrieve number of elements in dataspace
major: Dataset
minor: Can't get value
panic: hdf5 error code=-1
goroutine 1 [running]:
main.main()
/home/brunetto/Code/gop/me/src/master_pj/test.go:53 +0x49c
goroutine 2 [syscall]:
created by runtime.main
/home/brunetto/Code/gop/go/src/pkg/runtime/proc.c:221
exit status 2
The modified source is:
package main
import (
"fmt"
"github.com/sbinet/go-hdf5/pkg/hdf5"
)
const (
FNAME string = "test.h5"
DATASET string = "ArrayOfFloat64"
LENGTHX int = 10
LENGHTY int = 2
CAPACITY int = LENGTHX*LENGHTY
RANK int = 2
)
func main() {
// Initialize array and slice
s1 := [CAPACITY] float64{}
j := float64(0)
for i:=0; i<CAPACITY; i++ {
s1[i] = j
j++
}
fmt.Printf(":: data: %v\n", s1)
}
I've tried to read the sources of the libraries but I can't find why it breaks or where I've done the mistake.
Also I can't fine more docs or example more than the sources or at http://go.pkgdoc.org/github.com/sbinet/go-hdf5/pkg/hdf5
to understan better how to use these libs.
Do you have any suggestion?
Thank you very much,
brunetto
The text was updated successfully, but these errors were encountered: