# Status

- only a Lon-Lat coordinate is supported
- only simple pakking is supported
- variable list is not complete for NCEP and ECMWF

if ! 'a'.respond_to?(:ord)

    class String
      def ord
        self[0]
      end
    end

end if ! 'a'.respond_to?(:getbyte)

    class String
      def getbyte(i)
        self[i]
      end
    end

end

    def str2uint1(str)
      return nil if str.length==0
      return str.ord
    end
    def str2uint2(str)
      return nil if str.length==0
      return (str.ord<<8)+str.getbyte(1)
    end
    def str2uint3(str)
      return nil if str.length==0
      return (str.ord<<16)+(str.getbyte(1)<<8)+str.getbyte(2)
    end

    index[1].each{|j|
      jj = j-index[1].first
      sb = j*nlon+index[0].first
      sb = sb-map[true,0..jj-1].count_false if jj>0
      sb = sb*nbits_pack
      eb = sb+mask[true,j].count_true*nbits_pack
      if sb!=eb
        var[mask[true,j].where,jj] = get_value(@sgm.file,@pos+8,sb,eb,nbits_pack,nstep)
      end
    }

    sb = index[1].first*nlon*nbits_pack
    eb = (index[1].end+1)*nlon*nbits_pack
    var = get_value(@sgm.file,@pos+8,sb,eb,nbits_pack,nstep)
    var.reshape!(nlon, var.length/nlon)
    var = var[index[0],true]

    eb = nlen*nbits_pack
    var = get_value(@sgm.file,@pos+8,0,eb,nbits_pack,nstep)
    var.reshape!(nlon,nlat)

# NumRu::Grib -- a class for Grib datasets

## Class Methods

#### `Grib.new(filename, mode="r")`

  make a new Grib object.

  ARGUMENTS

  - filename (String): name of the file to open
  - mode (String): IO mode. "r" (read only) or "w" (write only).

#### `Grib.open(filename)`

  open a Grib file.

#### `Grib.create(filename)`

  create a Grib file.

#### `Grib.is_aGrib?(filename)`

  return true when file is a Grib dataset

## Methods

#### `close`

#### `parse`

#### `path`

#### `var_names`

#### `var( name )`

#### `def_var( name )`

#### `enddef`

#### `write`

# NumRu::GribDim

## Class Methods

#### `new( vat, name, length )`

## Methods

#### `var`

#### `length`

#### `name`

#### `typecode`

#### `get`

#### `[indices]`

#### `put_att(key,val)`

#### `set_att(key,val)`

#### `att(key)`

#### `att_names`

#### `inspect`

# NumRu::GribVar

## Class Methods

#### `new( file, name, obj, dims )`

## Methods

#### `file`

#### `name`

#### `rank`

#### `total`

#### `set_var`

#### `set_miss`

#### `dim_names`

#### `dim( index )`

#### `ndims`

#### `def_dim(name,index)`

#### `put_att( key, value )`

#### `set_att( key, value )`

#### `att( key )`

#### `att_names`

#### `shape`

#### `typecode`

#### `get( indics )`

#### `[ indics ]`

#### `inspect`

    if pds1.time_range!=pds2.time_range
      warn("time range is not same: #{pds1.time_range} != #{pds2.time_range}")
      return true
    end