/// <summary>
        /// Note that only char array can be higher dimensional here, it will then
        /// be flattened before written
        /// </summary>
        public void Write(NetCdfVariable ncVariable, int[] origin, int[] shape, Array array)
        {
            var originPtr  = NetCdfFileHelper.ConvertToIntPtr(origin);
            var shapePtr   = NetCdfFileHelper.ConvertToIntPtr(shape);
            var ncDataType = GetNetCdfDataType(array);

            switch (ncDataType)
            {
            case NetCdfDataType.NC_BYTE:
                CheckResult(NetCdfWrapper.nc_put_vara(id, ncVariable, originPtr, shapePtr, (byte[])array));
                break;

            case NetCdfDataType.NC_CHAR:
                var bytes = NetCdfFileHelper.FlattenCharArray(array, shape);
                CheckResult(NetCdfWrapper.nc_put_vara_text(id, ncVariable, originPtr, shapePtr, bytes));
                break;

            case NetCdfDataType.NC_INT:
                CheckResult(NetCdfWrapper.nc_put_vara_int(id, ncVariable, originPtr, shapePtr, (int[])array));
                break;

            case NetCdfDataType.NC_FLOAT:
                CheckResult(NetCdfWrapper.nc_put_vara_float(id, ncVariable, originPtr, shapePtr, (float[])array));
                break;

            case NetCdfDataType.NC_DOUBLE:
                CheckResult(NetCdfWrapper.nc_put_vara_double(id, ncVariable, originPtr, shapePtr, (double[])array));
                break;

            default:
                throw new Exception(
                          String.Format("Unknown type for writing NetCDF variable to file: type {0} to file {1}",
                                        ncDataType, path));
            }
        }