HDF5DotNet vs HDFView (write string dataset)

Hi all,

I am writing a utility program that generates a .h5 file for the
pre/post-processor SMS. The first thing SMS does is check for a scalar
dataset in the .h5 file called 'File Type' that contains the string "Xmdf".
If SMS fails to find this it will report a certain error. I am using the
HDF5DotNet 1.8.9 wrappers and generate the dataset with the following code:

Dim enc As New System.Text.ASCIIEncoding
Dim myType1 As H5DataTypeId = H5T.copy(H5T.H5Type.C_S1)
H5T.setSize(myType1, 5)
Dim mySpaceID As H5DataSpaceId = H5S.create(H5S.H5SClass.SCALAR)
Dim myDataSetId As H5DataSetId = H5D.create(xid, "File Type", myType1,
mySpaceID)
Dim h5str1 As New H5Array(Of System.Byte)(enc.GetBytes("Xmdf"))
H5D.write(myDataSetId, myType1, h5str1)

If I open my generated .h5 file in HDFView everything appears fine: the
scalar dataset is there and contains the string "Xmdf". However SMS will
not load the file and gives the error indicating that it cannot find the
'File Type' dataset. If I manually delete the 'File Type' dataset from
within HDFView and then manually add it back in, the file can be read by SMS
without a problem.

Can anyone explain if there is a difference between how I am writing the
string dataset and how HDFView writes the dataset, or what I can do to
attempt to solve the problem? SMS tech support have simply said "check the
way in which the dataset is being written".

Any thoughts/tips/pointers much appreciated!
Kind regards,
Andy Wiersma

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/HDF5DotNet-vs-HDFView-write-string-dataset-tp4025303.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Andy, very odd indeed.

Does SMS expect a scalar dataset of a fixed or variable-length string type?

Are we sure that it's not finding the dataset or it's finding it and not

happy with the content and still saying it's not finding it?

(You could verify that by creating a scalar integer dataset '/File Type' and
see if you

get the same problem.)

If that's the case, it might be down to a subtlety such as the following:

I'd have to refresh my mind if H5T.setSize(*, 5) creates 4 or 5 usable
characters.

In any event, you are not writing the terminating null character. You are
writing

only 4 bytes (88, 100, 109, 102). Try a 5 byte array with a 0 at the end.

What happens? (HDFView might append that for your automatically.)

G.

···

From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org]
On Behalf Of Andywizma
Sent: Saturday, August 11, 2012 11:34 PM
To: hdf-forum@hdfgroup.org
Subject: [Hdf-forum] HDF5DotNet vs HDFView (write string dataset)

Hi all, I am writing a utility program that generates a .h5 file for the
pre/post-processor SMS. The first thing SMS does is check for a scalar
dataset in the .h5 file called 'File Type' that contains the string "Xmdf".
If SMS fails to find this it will report a certain error. I am using the
HDF5DotNet 1.8.9 wrappers and generate the dataset with the following code:
Dim enc As New System.Text.ASCIIEncoding Dim myType1 As H5DataTypeId =
H5T.copy(H5T.H5Type.C_S1) H5T.setSize(myType1, 5) Dim mySpaceID As
H5DataSpaceId = H5S.create(H5S.H5SClass.SCALAR) Dim myDataSetId As
H5DataSetId = H5D.create(xid, "File Type", myType1, mySpaceID) Dim h5str1 As
New H5Array(Of System.Byte)(enc.GetBytes("Xmdf")) H5D.write(myDataSetId,
myType1, h5str1) If I open my generated .h5 file in HDFView everything
appears fine: the scalar dataset is there and contains the string "Xmdf".
However SMS will not load the file and gives the error indicating that it
cannot find the 'File Type' dataset. If I manually delete the 'File Type'
dataset from within HDFView and then manually add it back in, the file can
be read by SMS without a problem. Can anyone explain if there is a
difference between how I am writing the string dataset and how HDFView
writes the dataset, or what I can do to attempt to solve the problem? SMS
tech support have simply said "check the way in which the dataset is being
written". Any thoughts/tips/pointers much appreciated! Kind regards, Andy
Wiersma

  _____

View this message in context: HDF5DotNet vs HDFView (write string dataset)
<http://hdf-forum.184993.n3.nabble.com/HDF5DotNet-vs-HDFView-write-string-da
taset-tp4025303.html>
Sent from the hdf-forum mailing list archive
<http://hdf-forum.184993.n3.nabble.com/> at Nabble.com.

Hi Gerd,

I am not sure if SMS is expecting a fixed or variable-length string, maybe
the problem is that it is expecting a variable-length string type?

SMS will return the same error message in either of the following cases: it
can't find the 'File Type' dataset OR the content is not correct. So yes
you are right, it could also be that SMS is not happy with the content.
For instance, the same error message is returned if I remove the dataset
'File Type' or if I have the contents as 'Zmdf' not 'Xmdf'.

I have tried writing the null-character as follows:

Dim h5str1 As New H5Array(Of System.Byte)({88, 109, 100, 102, 0})

Again it looks fine in HDFView but won't load in SMS! Very strange, any
other thoughts/ideas/options would be greatly appreciated.
kind regards,
Andy

···

On Tue, Aug 14, 2012 at 7:14 AM, Gerd Heber [via hdf-forum] < ml-node+s184993n4025308h0@n3.nabble.com> wrote:

Andy, very odd indeed.****

Does SMS expect a scalar dataset of a fixed or variable-length string type?
****

Are we sure that it’s not finding the dataset or it’s finding it and not**
**

happy with the content and still saying it’s not finding it?****

(You could verify that by creating a scalar integer dataset ‘/File Type’
and see if you****

get the same problem.)****

If that’s the case, it might be down to a subtlety such as the following:*
***

** **

I’d have to refresh my mind if H5T.setSize(*, 5) creates 4 or 5 usable
characters.****

In any event, you are not writing the terminating null character. You are
writing****

only 4 bytes (88, 100, 109, 102). Try a 5 byte array with a 0 at the end.*
***

What happens? (HDFView might append that for your automatically…)****

** **

G.****

** **

** **

*From:* [hidden email]<http://user/SendEmail.jtp?type=node&node=4025308&i=0>[mailto:[hidden
email] <http://user/SendEmail.jtp?type=node&node=4025308&i=1>] *On Behalf
Of *Andywizma

*Sent:* Saturday, August 11, 2012 11:34 PM
*To:* [hidden email]<http://user/SendEmail.jtp?type=node&node=4025308&i=2>
*Subject:* [Hdf-forum] HDF5DotNet vs HDFView (write string dataset)****

** **

Hi all, I am writing a utility program that generates a .h5 file for the
pre/post-processor SMS. The first thing SMS does is check for a scalar
dataset in the .h5 file called 'File Type' that contains the string "Xmdf".
If SMS fails to find this it will report a certain error. I am using the
HDF5DotNet 1.8.9 wrappers and generate the dataset with the following code:
Dim enc As New System.Text.ASCIIEncoding Dim myType1 As H5DataTypeId =
H5T.copy(H5T.H5Type.C_S1) H5T.setSize(myType1, 5) Dim mySpaceID As
H5DataSpaceId = H5S.create(H5S.H5SClass.SCALAR) Dim myDataSetId As
H5DataSetId = H5D.create(xid, "File Type", myType1, mySpaceID) Dim h5str1
As New H5Array(Of System.Byte)(enc.GetBytes("Xmdf")) H5D.write(myDataSetId,
myType1, h5str1) If I open my generated .h5 file in HDFView everything
appears fine: the scalar dataset is there and contains the string "Xmdf".
However SMS will not load the file and gives the error indicating that it
cannot find the 'File Type' dataset. If I manually delete the 'File Type'
dataset from within HDFView and then manually add it back in, the file can
be read by SMS without a problem. Can anyone explain if there is a
difference between how I am writing the string dataset and how HDFView
writes the dataset, or what I can do to attempt to solve the problem? SMS
tech support have simply said "check the way in which the dataset is being
written". Any thoughts/tips/pointers much appreciated! Kind regards, Andy
Wiersma ****
------------------------------

View this message in context: HDF5DotNet vs HDFView (write string dataset)<http://hdf-forum.184993.n3.nabble.com/HDF5DotNet-vs-HDFView-write-string-dataset-tp4025303.html>
Sent from the hdf-forum mailing list archive<http://hdf-forum.184993.n3.nabble.com/>at Nabble.com.
****

_______________________________________________
Hdf-forum is for HDF software users discussion.
[hidden email] <http://user/SendEmail.jtp?type=node&node=4025308&i=3>
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

------------------------------
If you reply to this email, your message will be added to the discussion
below:

http://hdf-forum.184993.n3.nabble.com/HDF5DotNet-vs-HDFView-write-string-dataset-tp4025303p4025308.html
To unsubscribe from HDF5DotNet vs HDFView (write string dataset), click
here<http://hdf-forum.184993.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025303&code=YW5kcmV3LndpZXJzbWFAZ21haWwuY29tfDQwMjUzMDN8ODU1NTk2OTY0>
.
NAML<http://hdf-forum.184993.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html!nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers!nabble%3Aemail.naml-instant_emails!nabble%3Aemail.naml-send_instant_email!nabble%3Aemail.naml>

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/HDF5DotNet-vs-HDFView-write-string-dataset-tp4025303p4025311.html
Sent from the hdf-forum mailing list archive at Nabble.com.