If a NetCDF4 or HDF5 file contains groups, we can access those groups via the method below. getfilegrpnames, filegrpdef Example 1

A NetCDF4 file named "myfile.h5" contains groups: "grp1", "group2", and "g3".

"ncdump myfile.nc" produces the following output:

netcdf myfile {

group: grp1 {
  dimensions:
        lev = 2 ;
        lat = 2 ;
        lon = 3 ;
  variables:
        float lev(lev) ;
        float lat(lat) ;
        float lon(lon) ;
        float PS(lat, lon) ;
                PS:_FillValue = 9.96921e+36f ;
        float T(lev, lat, lon) ;
                T:_FillValue = 9.96921e+36f ;
        float Q(lev, lat, lon) ;
                Q:_FillValue = 9.96921e+36f ;
  data:

   lev = 1, 2 ;

   lat = 3, 4 ;

   lon = 5, 6, 7 ;

   PS =
  1000, 1000, 1000,
  1000, 1000, 1000 ;

   T =
  273.15, 273.15, 273.15,
  273.15, 273.15, 273.15,
  273.15, 273.15, 273.15,
  273.15, 273.15, 273.15 ;

   Q =
  0.015, 0.015, 0.015,
  0.015, 0.015, 0.015,
  0.015, 0.015, 0.015,
  0.015, 0.015, 0.015 ;
  } // group grp1

group: group2 {
  } // group group2

group: g3 {
  } // group g3
}
Users can access group "grp1", and read variables in group "grp1" with code:
 f = addfile("myfile.nc","c")

 g = f=>grp1

;read variable T

 tg = g->T

;Or directly from file

 tf = f->/grp1/T

;and read Q as below:

 vn = "/grp1/Q"

 q = f->$vn$