title: How can I get a list of netCDF variables with particular dimensions?
body: <pre><code>{
  dimensions:
      grp = 50 ;
      time = UNLIMITED ; // (0 currently)
      depth = 3 ;
      scalar = 1 ;
      spectral_bands = 2 ;
      x1AndTime = 13041 ;
      x2AndTime = 13041 ;
      midTotoAndTime = 13041 ;
  variables:
      double time(time) ;
      double a1(time, hru) ;
      double a2(time, hru) ;
      double a3(x1AndTime, hru) ;
      double a4(x2AndTime, hru) ;
      double a5(hru) ;
  </code></pre>
  
  <p>Open the netCDF file in <code>R</code></p>
  
  <p><code>out &lt;- ncdf4::nc_open('test.nc')</code></p>
  
  <p>Get all the variables</p>
  
  <p><code>ncvars &lt;- names(out[['var']])</code></p>
  
  <p>This gives me a list of <em>all</em> the variables in the netCDF file.</p>
  
  <p>How can I get a list of the variables that have dimensions <code>time</code> and <code>hru</code>, for example?</p>
  
  <p>Intended output:</p>
  
  <p>List with <code>a1, a2</code></p>