I've been trying to solve the issue, and the problem seems to be in the 
library itself.

The error is still occurring in the H5G.getObjectNameByIndex() call.

I thought it might be an issue with the recursion keeping to many handles 
open, so I moved the H5F.open() and H5G.open() for the group inside the 
function and close them before I recurse down. 

So the flow for the program is now


For all files
    getGroups()
    saveCSV()
End

getGroups()
public void getGroups(StreamWriter sw)
{
            //open the HDF5 library
            int x = H5.Open();

            //open the file 
            H5FileId gh5file = H5F.open(fname, H5F.OpenMode.ACC_RDONLY);

            //read in the root group
            H5GroupId rootGroup = H5G.open(gh5file, "/");

            //find out how many objects are under the root group
            long count = H5G.getNumObjects(rootGroup);

            //store the names at this level
            ObjectInfo info = H5G.getObjectInfo(rootGroup, "/DYNAMIC DATA"
, false);
            groups.Add(new Group("/DYNAMIC DATA", info.objectType));

            H5G.close(rootGroup);
            H5F.close(gh5file);
            //find all children of roots children recursively
            for (int i = 0; i < groups.Count; i++)
            {
                findChildren(groups[i], fname, sw);
            }

            H5.Close();
}

public static void findChildren(Group s, string fname, StreamWriter sw)
{
            try
            {
                //Get the number of children that belong to current group
                H5FileId gh5file = H5F.open(fname, H5F.OpenMode
.ACC_RDONLY);
                H5GroupId curr_group = H5G.open(gh5file, s.name);
                long count = H5G.getNumObjects(curr_group);

                //for each of the children add them to the parent list
                for (ulong j = 0; j < (ulong)count; j++)
                {
                    //read it by index
                    string obj_name = H5G.getObjectNameByIndex(curr_group, 
j);
                    ObjectInfo info = H5G.getObjectInfo(curr_group, 
obj_name, false);
                    s.children.Add(new Group(s.name + "/" + obj_name, 
info.objectType));
                }
                H5G.close(curr_group);
                H5F.close(gh5file);
 
            }
            catch (Exception ex)
            {
                sw.WriteLine("FindChildren Error: {0}", ex.Message);
                sw.WriteLine("CurrGroup: {0}", s.name);
                throw ex;
            }
 
            //For each child we are going to recurse down 
            for (int i = 0; i < s.children.Count; i++)
            {
                //in the GH5 file format there is nothing below dataset
                //if it is not a dataset, recurse on its children
                if (s.children[i].type != H5GType.DATASET)
                {
                    findChildren(s.children[i], fname, sw);
                }
                else //it is a dataset so log the enformation
                {
                    H5FileId gh5file2 = H5F.open(fname, H5F.OpenMode
.ACC_RDONLY);
                    s.children[i].dsetID = H5D.open(gh5file2, 
s.children[i].name);
                    H5DataTypeId dID = H5D.getType(s.children[i].dsetID);
                    s.children[i].dtypeID = dID;
                    s.children[i].dtype = H5T.getClass(dID);
                    s.children[i].dtype_size = H5T.getSize(dID);
                    s.children[i].numPoints = H5S.getSimpleExtentNPoints(
H5D.getSpace(s.children[i].dsetID));
                    s.children[i].order = H5T.get_order(dID);
                    s.children[i].unit = Helpers
.ReadAttributeString(s.children[i].dsetID, s.children[i].name, "UNITS");
 
                    H5D.close(s.children[i].dsetID);
                    H5F.close(gh5file2);
                }
            }
            //H5G.close(curr_group);
}


So these changes should reduce any handles that are open at any one time. 
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Reply via email to