Example “RUBY/EX26/hdf_dataset_iteration.rb” illustrates the raw reading of Nastran HDF file content. First, the library must be loaded:
Post.loadHdf5Library("C:/NewProgs/HDF5/HDF5-1.8.20-win32/bin/hdf5.dll")
Then, HDF5 file is attached and different methods are called to obtain information on the content of the file. In particular, the different Datasets contained in the file are identified, and their characteristics (Compound members, and number of items).
db.attachHdf(h5Path)
dsets=db.getHdfAttachmentDataSets(h5Path)
dsets.each do |dsPath|
members=db.getHdfAttachmentCompoundMemberNames(h5Path,dsPath)
nbrLines=db.getHdfAttachmentDataSetNbrItems(h5Path,dsPath)
printf("%s (%d*%d)\n",dsPath,nbrLines,members.size)
members.each do |str|
printf("%20s\n",str)
end
end
In the end, iteration on content uses instructions as
db.each_hdfAttachmentNasSetItem(h5Path,dsets[2],iMin,iMax) do |x|
puts x
$stdout.printf("\n\n")
end
The raw reading of Dataset content in an Array is shown in example “TESTSAT/RUBY/EX26/hdf_dataset_array.rb”.