legacy/src/main/java/ucar/nc2/FileWriter.java
public int[] computeChunkShape(long maxChunkElems) {
      int[] chunkShape = new int[rank];

      for (int iDim = 0; iDim < rank; ++iDim) {
        int size = (int) (maxChunkElems / stride[iDim]);
        size = (size == 0) ? 1 : size;
        size = Math.min(size, shape[iDim] - current[iDim]);
        chunkShape[iDim] = size;
      }

      return chunkShape;
    }
public int[] computeChunkShape(long maxChunkElems) {
      int[] chunkShape = new int[rank];

      for (int iDim = 0; iDim < rank; ++iDim) {
        int size = (int) (maxChunkElems / stride[iDim]);
        size = (size == 0) ? 1 : size;
        size = Math.min(size, shape[iDim] - current[iDim]);
        chunkShape[iDim] = size;
      }

      return chunkShape;
    }
Computes the shape of the largest possible <b>contiguous</b> chunk, starting at {@link #getCurrentCounter()}
and with {@code numElems <= maxChunkElems}.

@param maxChunkElems the maximum number of elements in the chunk shape. The actual element count of the shape
returned is likely to be different, and can be found with {@link Index#computeSize}.
@return the shape of the largest possible contiguous chunk.