title: How to write chunks with HDF5 in julia when ndims can vary at runtime?
body: <p>If I had 1000 slices of a 64x64 image, I could write in 64x64x1 chunks like this:</p>
  
  <pre><code>using HDF5
  
  filename = "test.h5"
  # open file
  fmode ="w"
  # get a file object
  fid = h5open(filename, fmode)
  # matrix to write in chunks
  B = rand(64,64,1000)
  # figure out its dimensions
  sizeTuple = size(B)
  ndims = length(sizeTuple)
  # set up to write in chunks of sizeArray
  sizeArray = ones(Int, ndims)
  [sizeArray[i] = sizeTuple[i] for i in 1:(ndims-1)] # last value of size  array is :...:,1
  # create a dataset models within root
  dset = d_create(fid, "models", datatype(Float64), dataspace(size(B)), "chunk", sizeArray)
  [dset[:,:,i] = slicedim(B, ndims, i) for i in 1:size(B, ndims)]
  close(fid)
  </code></pre>
  
  <p>And this works just fine, but the assignment syntax in dset[:,:,i] is specific to ndims = 3. How can I change that if I had 1000 slices of an arbitrary hyperrectangle specified at runtime? E.g., for B = rand(64,64,3,1000) or rand(64,64,64,3,1000)?</p>
  
  <p>Thanks</p>