/// <summary>
        ///
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="a"></param>
        protected override void WriteData(int[] origin, Array a)
        {
            if (origin == null)
            {
                origin = new int[Rank];
            }

            int[] shape = new int[origin.Length];
            for (int i = 0; i < shape.Length; i++)
            {
                shape[i] = a.GetLength(i);
            }

            int res;

            switch (Type.GetTypeCode(TypeOfData))
            {
            case TypeCode.Boolean:
                byte[] bldata = FromMultidimArrayBool(a);
                res = NetCDF.nc_put_vara_ubyte(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), bldata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.DateTime:
                double[] dtData = FromMultidimArrayDateTime(a);
                res = NetCDF.nc_put_vara_double(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), dtData);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.Double:
                double[] data = FromMultidimArray <double>(a);
                res = NetCDF.nc_put_vara_double(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), data);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.Single:
                float[] fdata = FromMultidimArray <float>(a);
                res = NetCDF.nc_put_vara_float(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), fdata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.Int64:
                long[] ldata = FromMultidimArray <long>(a);
                res = NetCDF.nc_put_vara_longlong(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), ldata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.UInt64:
                ulong[] uldata = FromMultidimArray <ulong>(a);
                res = NetCDF.nc_put_vara_ulonglong(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), uldata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.Int32:
                int[] idata = FromMultidimArray <int>(a);
                res = NetCDF.nc_put_vara_int(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), idata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.UInt32:
                uint[] uidata = FromMultidimArray <uint>(a);
                res = NetCDF.nc_put_vara_uint(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), uidata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.Int16:
                short[] sdata = FromMultidimArray <short>(a);
                res = NetCDF.nc_put_vara_short(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), sdata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.UInt16:
                ushort[] usdata = FromMultidimArray <ushort>(a);
                res = NetCDF.nc_put_vara_ushort(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), usdata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.Byte:
                byte[] bdata = FromMultidimArray <byte>(a);
                if (isNcChar)
                {
                    res = NetCDF.nc_put_vara_text(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), bdata);
                }
                else
                {
                    res = NetCDF.nc_put_vara_ubyte(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), bdata);
                }
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.SByte:
                sbyte[] sbdata = FromMultidimArray <sbyte>(a);
                res = NetCDF.nc_put_vara_schar(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), sbdata);
                NetCDFDataSet.HandleResult(res);
                return;

            case TypeCode.String:
                string[] strdata = FromMultidimArrayString(a);
                res = NetCDF.nc_put_vara_string(NcId, varid, ConvertToIntPtr(origin), ConvertToIntPtr(shape), strdata);
                NetCDFDataSet.HandleResult(res);
                return;

            default:
                throw new NotSupportedException("Unsupported type of data.");
            }
        }