MISR Toolkit  1.5.1
MtkHdfToMtkDataTypeConvert.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkHdfToMtkDataTypeConvert =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2005, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrUtil.h"
18 #include <mfhdf.h>
19 
27 
28  if (datatype == NULL)
29  return MTK_NULLPTR;
30 
31  switch (hdf_datatype) {
32  case DFNT_CHAR8: *datatype = MTKe_char8;
33  break;
34  case DFNT_UCHAR8: *datatype = MTKe_uchar8;
35  break;
36  case DFNT_INT8: *datatype = MTKe_int8;
37  break;
38  case DFNT_UINT8: *datatype = MTKe_uint8;
39  break;
40  case DFNT_INT16: *datatype = MTKe_int16;
41  break;
42  case DFNT_UINT16: *datatype = MTKe_uint16;
43  break;
44  case DFNT_INT32: *datatype = MTKe_int32;
45  break;
46  case DFNT_UINT32: *datatype = MTKe_uint32;
47  break;
48  case DFNT_INT64: *datatype = MTKe_int64;
49  break;
50  case DFNT_UINT64: *datatype = MTKe_uint64;
51  break;
52  case DFNT_FLOAT32: *datatype = MTKe_float;
53  break;
54  case DFNT_FLOAT64: *datatype = MTKe_double;
55  break;
56  default:
57  return MTK_FAILURE;
58  }
59 
60  return MTK_SUCCESS;
61 }
62 
65 
66  if (datatype == NULL)
67  return MTK_NULLPTR;
68 
69  switch (nc_datatype) {
70  case NC_CHAR: *datatype = MTKe_char8;
71  break;
72  case NC_UBYTE: *datatype = MTKe_uint8;
73  break;
74  case NC_BYTE: *datatype = MTKe_int8;
75  break;
76  case NC_SHORT: *datatype = MTKe_int16;
77  break;
78  case NC_USHORT: *datatype = MTKe_uint16;
79  break;
80  case NC_INT: *datatype = MTKe_int32;
81  break;
82  case NC_UINT: *datatype = MTKe_uint32;
83  break;
84  case NC_INT64: *datatype = MTKe_int64;
85  break;
86  case NC_UINT64: *datatype = MTKe_uint64;
87  break;
88  case NC_FLOAT: *datatype = MTKe_float;
89  break;
90  case NC_DOUBLE: *datatype = MTKe_double;
91  break;
92  default:
93  return MTK_FAILURE;
94  }
95 
96  return MTK_SUCCESS;
97 }
nc_type
Definition: netcdf.h:253
HDFFCLIBAPI _fcd _fcd intf intf * datatype
#define DFNT_UINT16
Definition: hntdefs.h:46
MTKt_DataType
Definition: MisrUtil.h:36
#define DFNT_UINT8
Definition: hntdefs.h:43
#define DFNT_UINT64
Definition: hntdefs.h:50
#define NC_BYTE
Definition: netcdf.h:35
#define DFNT_UCHAR8
Definition: hntdefs.h:54
#define NC_DOUBLE
Definition: netcdf.h:41
MTKt_status MtkNcToMtkDataTypeConvert(nc_type nc_datatype, MTKt_DataType *datatype)
#define NC_FLOAT
Definition: netcdf.h:40
#define NC_UINT
Definition: netcdf.h:44
#define NC_UINT64
Definition: netcdf.h:46
#define NC_INT64
Definition: netcdf.h:45
#define DFNT_INT64
Definition: hntdefs.h:49
#define NC_SHORT
Definition: netcdf.h:37
#define NC_CHAR
Definition: netcdf.h:36
#define DFNT_INT32
Definition: hntdefs.h:47
#define NC_USHORT
Definition: netcdf.h:43
#define DFNT_FLOAT32
Definition: hntdefs.h:36
#define DFNT_CHAR8
Definition: hntdefs.h:56
#define DFNT_UINT32
Definition: hntdefs.h:48
#define NC_INT
Definition: netcdf.h:38
MTKt_status
Definition: MisrError.h:11
#define DFNT_FLOAT64
Definition: hntdefs.h:38
#define DFNT_INT16
Definition: hntdefs.h:45
#define DFNT_INT8
Definition: hntdefs.h:42
#define NC_UBYTE
Definition: netcdf.h:42
MTKt_status MtkHdfToMtkDataTypeConvert(int32 hdf_datatype, MTKt_DataType *datatype)
Convert HDF data type to MISR Toolkit data type.

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51