{-# LANGUAGE DeriveDataTypeable #-}
module Data.NetCDF.Types where
import Control.Exception
import Data.Typeable
import System.IO (IOMode (..))
data NcType = NcByte
| NcChar
| NcShort
| NcInt
| NcFloat
| NcDouble
| NcString
deriving (Eq, Show)
instance Enum NcType where
fromEnum NcByte = 1
fromEnum NcChar = 2
fromEnum NcShort = 3
fromEnum NcInt = 4
fromEnum NcFloat = 5
fromEnum NcDouble = 6
fromEnum NcString = 12
toEnum n = case n of
1 -> NcByte
2 -> NcChar
3 -> NcShort
4 -> NcInt
5 -> NcFloat
6 -> NcDouble
12 -> NcString
_ -> throw (NcInvalidType n)
type NcId = Int
data NcError = NcError String Int String FilePath
| NcInvalidArgs String
| NcInvalidType Int
deriving (Show, Typeable)
instance Exception NcError
ncIOMode :: IOMode -> Int
ncIOMode ReadMode = 0
ncIOMode WriteMode = 1
ncIOMode _ = throw (NcInvalidArgs "IO mode")
ncGlobal :: Int
ncGlobal = -1
ncUnlimitedLength :: Int
ncUnlimitedLength = 0
ncInvalidId :: NcId
ncInvalidId = -1
ncClobber, ncNoClobber, nc64bitOffset, ncNetCDF4, ncClassicModel :: Int
ncClobber = 0
ncNoClobber = 0x0004
nc64bitOffset = 0x0200
ncNetCDF4 = 0x1000
ncClassicModel = 0x0100