diff -r fd367312095a src/ls-hdf5.cc
--- a/src/ls-hdf5.cc	Tue Apr 05 11:15:50 2011 +0200
+++ b/src/ls-hdf5.cc	Thu Apr 28 18:11:54 2011 +0200
@@ -251,7 +251,6 @@
   hid_t type_id = -1, type_class_id = -1, data_id = -1, subgroup_id = -1,
     space_id = -1;
 
-  H5G_stat_t info;
   herr_t retval = 0;
   bool ident_valid = valid_identifier (name);
 
@@ -269,9 +268,10 @@
       ident_valid = valid_identifier (vname);
     }
 
-  H5Gget_objinfo (group_id, name, 1, &info);
+  H5O_info_t info;
+  H5Oget_info_by_name (group_id, name, &info, H5P_DEFAULT);
 
-  if (info.type == H5G_GROUP && ident_valid)
+  if (info.type == H5O_TYPE_GROUP && ident_valid)
     {
 #if HAVE_HDF5_18
       subgroup_id = H5Gopen (group_id, name, H5P_DEFAULT);
@@ -358,7 +358,7 @@
         }
 
     }
-  else if (info.type == H5G_DATASET && ident_valid)
+  else if (info.type == H5O_TYPE_DATASET && ident_valid)
     {
       // For backwards compatiability.
 #if HAVE_HDF5_18
@@ -521,6 +521,8 @@
 
           H5Tclose (complex_type);
         }
+      else if (type_class_id == H5T_REFERENCE)
+        d->tc = octave_value_typeinfo::lookup_type ("cell");
       else
         {
           warning ("load: can't read `%s' (unknown datatype)", name);
diff -r fd367312095a src/ov-cell.cc
--- a/src/ov-cell.cc	Tue Apr 05 11:15:50 2011 +0200
+++ b/src/ov-cell.cc	Thu Apr 28 18:11:54 2011 +0200
@@ -1152,99 +1152,214 @@
 
   bool retval = false;
 
-  dim_vector dv;
-  int empty = load_hdf5_empty (loc_id, name, dv);
-  if (empty > 0)
-    matrix.resize(dv);
-  if (empty)
-    return (empty > 0);
+  H5O_info_t info;
+  H5Oget_info_by_name (loc_id, name, &info, H5P_DEFAULT);
+
+  if (info.type == H5O_TYPE_GROUP)
+    { 
+
+      dim_vector dv;
+      int empty = load_hdf5_empty (loc_id, name, dv);
+      if (empty > 0)
+        matrix.resize(dv);
+      if (empty)
+        return (empty > 0);
 
 #if HAVE_HDF5_18
-  hid_t group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
+      hid_t group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
 #else
-  hid_t group_id = H5Gopen (loc_id, name);
+      hid_t group_id = H5Gopen (loc_id, name);
 #endif
 
-  if (group_id < 0)
-    return false;
+      if (group_id < 0)
+        return false;
 
 #if HAVE_HDF5_18
-  hid_t data_hid = H5Dopen (group_id, "dims", H5P_DEFAULT);
+      hid_t data_hid = H5Dopen (group_id, "dims", H5P_DEFAULT);
 #else
-  hid_t data_hid = H5Dopen (group_id, "dims");
+      hid_t data_hid = H5Dopen (group_id, "dims");
 #endif
-  hid_t space_hid = H5Dget_space (data_hid);
-  hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
-  if (rank != 1)
-    {
+      hid_t space_hid = H5Dget_space (data_hid);
+      hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
+      if (rank != 1)
+        {
+          H5Dclose (data_hid);
+          H5Gclose (group_id);
+          return false;
+        }
+
+      OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
+      OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
+
+      H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
+
+      // Octave uses column-major, while HDF5 uses row-major ordering.
+
+      dv.resize (hdims[0]);
+
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, hdims[0]);
+
+      if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
+                   H5P_DEFAULT, tmp) < 0)
+        {
+          H5Dclose (data_hid);
+          H5Gclose (group_id);
+          return false;
+        }
+
       H5Dclose (data_hid);
       H5Gclose (group_id);
-      return false;
+
+      for (hsize_t i = 0, j = hdims[0] - 1; i < hdims[0]; i++, j--)
+        dv(j) = tmp[i];
+
+      hdf5_callback_data dsub;
+
+      herr_t retval2 = -1;
+
+      Cell m (dv);
+
+      int current_item = 0;
+
+      hsize_t num_obj = 0;
+#if HAVE_HDF5_18
+      group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
+#else
+      group_id = H5Gopen (loc_id, name);
+#endif
+      H5Gget_num_objs (group_id, &num_obj);
+      H5Gclose (group_id);
+
+      for (octave_idx_type i = 0; i < dv.numel (); i++)
+        {
+
+          if (current_item >= static_cast<int> (num_obj))
+            retval2 = -1;
+          else
+            retval2 = H5Giterate (loc_id, name, &current_item,
+                                  hdf5_read_next_data, &dsub);
+
+          if (retval2 <= 0)
+            break;
+
+          octave_value ov = dsub.tc;
+          m.elem (i) = ov;
+
+        }
+
+      if (retval2 >= 0)
+        {
+          matrix = m;
+          retval = true;
+        }
+
     }
-
-  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
-  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
-
-  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
-
-  // Octave uses column-major, while HDF5 uses row-major ordering.
-
-  dv.resize (hdims[0]);
-
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, hdims[0]);
-
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-               H5P_DEFAULT, tmp) < 0)
-    {
-      H5Dclose (data_hid);
-      H5Gclose (group_id);
-      return false;
-    }
-
-  H5Dclose (data_hid);
-  H5Gclose (group_id);
-
-  for (hsize_t i = 0, j = hdims[0] - 1; i < hdims[0]; i++, j--)
-    dv(j) = tmp[i];
-
-  hdf5_callback_data dsub;
-
-  herr_t retval2 = -1;
-
-  Cell m (dv);
-
-  int current_item = 0;
-
-  hsize_t num_obj = 0;
-#if HAVE_HDF5_18
-  group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
-#else
-  group_id = H5Gopen (loc_id, name);
-#endif
-  H5Gget_num_objs (group_id, &num_obj);
-  H5Gclose (group_id);
-
-  for (octave_idx_type i = 0; i < dv.numel (); i++)
+  else if (info.type == H5O_TYPE_DATASET)
     {
 
-      if (current_item >= static_cast<int> (num_obj))
-        retval2 = -1;
-      else
-        retval2 = H5Giterate (loc_id, name, &current_item,
-                              hdf5_read_next_data, &dsub);
+#if HAVE_HDF5_18
+      hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
+#else
+      hid_t data_hid = H5Dopen (loc_id, name);
+#endif
+      if (data_hid < 0)
+        return false;
 
-      if (retval2 <= 0)
-        break;
+      hid_t space_hid = H5Dget_space (data_hid);
+      hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
+      if (rank < 1)
+        {
+          H5Sclose (space_hid);
+          H5Dclose (data_hid);
+          return false;
+        }
 
-      octave_value ov = dsub.tc;
-      m.elem (i) = ov;
+      OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
+      OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
 
-    }
+      H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
 
-  if (retval2 >= 0)
-    {
-      matrix = m;
-      retval = true;
+      // Octave uses column-major, while HDF5 uses row-major ordering.
+
+      dim_vector dv, dvr;
+      dv.resize(rank);
+      dvr.resize(rank);
+
+      for (hsize_t i = 0; i < rank; i++)
+        {
+          dv(rank - 1 - i) = hdims[i];
+          dvr(i) = hdims[i];
+        }
+
+      herr_t retval2 = -1;
+
+      Cell m (dv);
+
+      OCTAVE_LOCAL_BUFFER (hsize_t, dims1, rank);
+      for (hsize_t i = 0; i < rank; i++)
+        dims1[i] = 1;
+
+      OCTAVE_LOCAL_BUFFER (hsize_t, offset, rank);
+      for (hsize_t i = 0; i < rank; i++)
+        offset[i] = 0;
+
+      hid_t space2_hid = H5Screate_simple(rank, dims1, NULL);
+      retval2 = H5Sselect_hyperslab (space2_hid, H5S_SELECT_SET,
+                                     offset, NULL, dims1, NULL);
+
+      for (octave_idx_type i = 0; i < m.numel (); i++)
+        {
+          hsize_t index = i;
+          for (hsize_t j = 0; j < rank; j++)
+            {
+              hsize_t n = dvr.numel(j + 1);
+              offset[j] = index / n;
+              index = index % n;
+            }
+
+          retval2 = H5Sselect_hyperslab (space_hid, H5S_SELECT_SET,
+                                         offset, NULL, dims1, NULL);
+          if (retval2 < 0)
+            break;
+
+          hobj_ref_t wdata[1];
+          retval2 = H5Dread (data_hid, H5T_STD_REF_OBJ,
+                             space2_hid, space_hid, H5P_DEFAULT, wdata);
+          if (retval2 < 0)
+            break;
+
+          retval2 = H5Sselect_none (space_hid);
+          if (retval2 < 0)
+            break;
+
+          hid_t referenced_hid;
+          referenced_hid = H5Rdereference (data_hid, H5R_OBJECT, wdata);
+          if (referenced_hid < 0) {
+            retval2 = -1;
+            break;
+          }
+
+          hdf5_callback_data dsub;
+
+          retval2 = hdf5_read_next_data (referenced_hid, ".", &dsub);
+          H5Oclose (referenced_hid);
+          if (retval2 < 0)
+            break;
+
+          octave_value ov = dsub.tc;
+          m.elem (i) = ov;
+
+        }
+
+      if (retval2 >= 0)
+        {
+          matrix = m;
+          retval = true;
+        }
+
+      H5Sclose (space2_hid);
+      H5Sclose (space_hid);
+      H5Dclose (data_hid);
     }
 
   return retval;
