OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
fmt_check.h
Go to the documentation of this file.
1 #include "l1io.h"
2 #include <mfhdf.h>
3 
4 /*******************************************************************
5 
6  fmt_check.h
7 
8  purpose: include file to set up some of the structures used
9  in the format checker program
10 
11  Modification history:
12  Programmer Date Description of change
13  ---------- ---- ---------------------
14  W. Robinson 17-Feb-1995 Original development
15  L. Kumar 19-Dec-1995 Modified dims of some char variables
16  of u_data
17  W. Robinson 13-Jun-1996 add prototypes for routines
18  W. Robinson 17-Sep-1996 add capability to do 66k bytes
19  of data instead of 3000 in u_data
20  W. Robinson 30-Sep-1996 Upgrade to include min / max
21  check ranges for the sds values
22  W. Robinson 31-Oct-1996 Upgrade to recognize float64
23  W. Robinson 15-Mar-2001 make changes for linux usage
24  W. Robinson, SAIC 29 Mar 2005 update to fully table driven model
25  and call I/O for sections from here
26  W. Robinson, SAIC 3 Feb 2010 add multipliers for float uncertainty
27  in checking of attributes to a constant
28 
29  *******************************************************************/
30 
31 /*
32  * The FMT_8BLEN variable is defined only for the linux so fmt_check
33  * gets built with smaller arrays
34  */
35 #ifdef FCK_8LEN
36 #define FMT_8BLEN FCK_8LEN
37 #else
38 #define FMT_8BLEN 8251
39 #endif
40 
41 /*
42  * define some codes for use
43  *
44  * attribute value read keywords
45  */
49 };
50 
51 /*
52  * u_data allows the placing of short amounts of attribute data
53  * into the correctly formatted storage
54  */
55 
56 typedef union u_data_d {
57  char chr[FMT_8BLEN * 8];
58  int32 i32[FMT_8BLEN * 2];
59  float32 f32[FMT_8BLEN * 2];
61  char i8[FMT_8BLEN * 8];
62  unsigned char ui8[FMT_8BLEN * 8];
63  float64 f64[FMT_8BLEN];
64 } u_data;
65 
66 /*
67  * With the size of the u_data now, and the need for a similar
68  * structure for the SDS value range, introduce a shorter version
69  * for the sds 2-value range.
70  */
71 typedef union s_data_d {
72  int32 i32[2];
73  float32 f32[2];
74  int16 i16[4];
75  char i8[8];
76  unsigned char ui8[8];
77  float64 f64[20];
78 } s_data;
79 
80 /*
81  * attr_str has all the information about an attribute and its value
82  * if it is fixed
83  */
84 
85 typedef struct attr_str_d {
86  int32 dim_index; /* index into dimension definitions, -1 if */
87  /* no connection made */
88  char obj_nm[100]; /* Name of the science dataset or 'gbl'
89  if refering to a global attribute */
90  char access_nm[200]; /* This is the name used to access the value */
91  char int_nm[200]; /* This is the expected name of the variable */
92  int32 type; /* This is the type of the value returned */
93  int32 count; /* This is the expected count of the variable,
94  if <0, do not check the count */
95  int32 read; /* This is the value read switch,
96  ATT_RD_NOREAD - do not read value,
97  ATT_RD_READ_NOCK - read value but do not check,
98  ATT_RD_READ_ONE_VAL - read the value and check
99  it with what is read into data below
100  ATT_RD_READ_INCLUSIVE - make sure the value(s) are
101  within the range described below */
102  u_data data; /* this is the expected value or range of the attribute */
103 } attr_str;
104 
105 /*
106  * sds_info_str will describe the science dataset and point to
107  * the attribute descriptions for the included attributes
108  */
109 
110 typedef struct sds_info_str_d {
111  char name[100]; /* Name of the science dataset */
112  int32 rank; /* # dimensions in this dataset */
113  int32 type; /* type of the sds data */
114  int32 e_ranges[3]; /* expected range of dimension >0 - check
115  with this value, 0 - do not check, -(value)
116  check vs the dimension size in the location:
117  'value' in the dimension id structure array */
118  int32 n_attr; /* # of attributes in this (I have a max
119  of 50 now) */
120  int32 attr_ind[50]; /* place for index to attribute descriptions */
121  int32 byt_per_val; /* # bytes in a value of this type */
122  int32 flg_rng; /* flag for min / max range checking: 0 - don't
123  check, 1 - do the check */
124  s_data sds_rng; /* minimum and maximum (inclusive)for sds
125  value checking */
126 } sds_info_str;
127 
128 /*
129  * dim_id_str is the structure to hold all the dimension description
130  * information.
131  */
132 typedef struct dim_id_d {
133  char att_nm[200]; /* attrinute name */
134  char att_short[100]; /* short name for attr without spaces */
135  int dim_size; /* the actual dimension size for this case */
136 } dim_id_str;
137 
138 /*
139  * ras_str is the structure containing the raster definition(s)
140  */
141 typedef struct ras_str_d {
142  char lbl_ras[200]; /* raster label, *NONE* or no label */
143  char lbl_pal[200]; /* palette label */
144  int npix_indx; /* index into dimension struct array of the raster # pixels */
145  int nlin_indx; /* index into dimension struct array of the raster # lines */
146 } ras_str;
147 
148 /*
149  * vg_info_str describes the Vgroup products
150  * The 3 Vgroups for bin description are there as well as the
151  * variable product descriptions
152  */
153 typedef struct vg_info_str_d {
154  int32 n_fields; /* # Vdata fields in this Vdata */
155  int32 num_typs[7]; /* list of # types of each field */
156  int32 nrec; /* # Vdata records or -1 to use the nbin
157  value passed in and only check that
158  there are >= nbin # records in the Vdata */
159  char name[VSNAMELENMAX]; /* name of this Vdata */
160  char class[VSNAMELENMAX]; /* class of this Vdata */
161  char field_list[200]; /* names of all the fields comma seperated */
162 } vg_info_str;
163 
164 /*
165  * structure for the entire format
166  */
167 typedef struct fmt_str_d {
168  int n_attr; /* # attribute descriptions */
169  attr_str *att; /* attribute definitions */
170  int n_sds; /* # SDS descriptions */
171  sds_info_str *sds_info; /* SDS definitions */
172  int n_dim_defs; /* # of dimension definitions */
173  dim_id_str *dim_id; /* dimension definitions */
174  int n_raster; /* # raster definitions (either 0 or 1 if a
175  raster exists */
176  ras_str *ras; /* raster definitions */
177  int n_vgroup; /* # v group definitions (either 0 or 1 if a
178  l3 set of v groups exist */
179  int resolve; /* the resolve value about the bin size in km */
180  int vg_nbin_indx; /* index of the '# of bins' in the dimension
181  struct array designating the # of bins to be cross checked. */
182  vg_info_str *vg_info; /* Vgroup information (for L3 prods) */
183 } fmt_str;
184 
185 /*
186  * This structure is here to carry the l3 bin organization info
187  * # rows, bin size, etc
188  */
189 typedef struct l3_org_str_d {
190  int32 numrows; /* # bin rows */
191  int32 bins_eq; /* # nins at the equator */
192  float64 vsize; /* degree vertical size of bin */
193  float64 *hsize; /* degree horizontal size of bin */
194  int32 *start_bin; /* start bin number for each row */
195  int32 *max_bin; /* maximun # bins that can be in a row */
196 } l3_org_str;
197 /*
198  * add multipliers for float uncertainty in checking of attributes to
199  * a constant
200  */
201 #define ERR_FRAC_F32 0.0001
202 #define ERR_FRAC_F64 0.000001
203 /*
204  * Do some prototype definitions
205  */
206 char *s_parse(char*, int);
207 int fmt_rd_attr(char *, FILE *, fmt_str *);
208 int fmt_read(char *, fmt_str *);
209 char *get_line(char*, int, FILE *, int);
210 int var_decode(char *, int32, void *, int32, int32);
211 int get_attr(int32, attr_str, u_data *, int *);
212 void attr_disp(attr_str, u_data, int);
213 void chk_str(attr_str, char *, int32);
214 int fmt_rd_dim(char *, FILE *, fmt_str *);
215 int fmt_rd_sds(char *, FILE *, fmt_str *);
216 int fmt_rd_l3vg(char *, FILE *, fmt_str *);
217 int chk_sds(int32, fmt_str *, int);
218 int fmt_rd_ras(char *, FILE *, fmt_str *);
219 int hdf_ras_chk(char *, char *, char *, int, int);
220 void fmt_exit(int);
221 void ck_v_l3(int32, fmt_str *);
222 int32 group_fnd(int32, int32, int32, int32, vg_info_str *);
223 void chk_sea_grid(int32);
224 void chk_bin_index(int32, int32 *, int32 *);
225 void chk_bin_list(int32, int32, int32 *, int32 *);
226 void chk_l3_prod(int32, int32, char *, char *);
227 void l3_get_org(int, l3_org_str *);
228 
229 #ifndef DBL_DIG
230 #define DBL_DIG 15
231 #endif
232 
233 #ifndef FLT_DIG
234 #define FLT_DIG 6
235 #endif
char * get_line(char *, int, FILE *, int)
Definition: get_line.c:4
int n_sds
Definition: fmt_check.h:170
integer, parameter int16
Definition: cubeio.f90:3
void attr_disp(attr_str, u_data, int)
Definition: attr_disp.c:5
int n_attr
Definition: fmt_check.h:168
dim_id_str * dim_id
Definition: fmt_check.h:173
att_rd_code
Definition: fmt_check.h:46
@ ATT_RD_NOREAD
Definition: fmt_check.h:47
sds_info_str * sds_info
Definition: fmt_check.h:171
vg_info_str * vg_info
Definition: fmt_check.h:182
int fmt_rd_ras(char *, FILE *, fmt_str *)
Definition: fmt_rd_ras.c:7
float64 f64[FMT_8BLEN]
Definition: fmt_check.h:63
void chk_sea_grid(int32)
Definition: ck_v_l3.c:325
int fmt_read(char *, fmt_str *)
Definition: fmt_read.c:7
float32 f32[FMT_8BLEN *2]
Definition: fmt_check.h:59
s_data sds_rng
Definition: fmt_check.h:124
int32 numrows
Definition: fmt_check.h:190
attr_str * att
Definition: fmt_check.h:169
int chk_sds(int32, fmt_str *, int)
Definition: chk_sds.c:11
int hdf_ras_chk(char *, char *, char *, int, int)
Definition: hdf_ras_chk.c:6
@ ATT_RD_READ_ONE_VAL
Definition: fmt_check.h:47
char att_short[100]
Definition: fmt_check.h:134
u_data data
Definition: fmt_check.h:102
unsigned char ui8[8]
Definition: fmt_check.h:76
int32 * max_bin
Definition: fmt_check.h:195
char int_nm[200]
Definition: fmt_check.h:91
char i8[8]
Definition: fmt_check.h:75
int n_raster
Definition: fmt_check.h:174
int32 e_ranges[3]
Definition: fmt_check.h:114
int32 dim_index
Definition: fmt_check.h:86
int n_dim_defs
Definition: fmt_check.h:172
int var_decode(char *, int32, void *, int32, int32)
Definition: var_decode.c:8
void chk_bin_list(int32, int32, int32 *, int32 *)
Definition: ck_v_l3.c:602
char access_nm[200]
Definition: fmt_check.h:90
float64 f64[20]
Definition: fmt_check.h:77
char * s_parse(char *, int)
Definition: s_parse.c:4
char name[100]
Definition: fmt_check.h:111
char name[VSNAMELENMAX]
Definition: fmt_check.h:159
float64 vsize
Definition: fmt_check.h:192
char field_list[200]
Definition: fmt_check.h:161
int32 i32[2]
Definition: fmt_check.h:72
int fmt_rd_dim(char *, FILE *, fmt_str *)
Definition: fmt_rd_dim.c:7
char chr[FMT_8BLEN *8]
Definition: fmt_check.h:57
int vg_nbin_indx
Definition: fmt_check.h:180
int fmt_rd_l3vg(char *, FILE *, fmt_str *)
Definition: fmt_rd_l3vg.c:7
int32 num_typs[7]
Definition: fmt_check.h:155
void ck_v_l3(int32, fmt_str *)
Definition: ck_v_l3.c:9
char att_nm[200]
Definition: fmt_check.h:133
int32 byt_per_val
Definition: fmt_check.h:121
void chk_str(attr_str, char *, int32)
Definition: chk_str.c:4
@ ATT_RD_READ_NOCK
Definition: fmt_check.h:47
int npix_indx
Definition: fmt_check.h:144
float32 f32[2]
Definition: fmt_check.h:73
unsigned char ui8[FMT_8BLEN *8]
Definition: fmt_check.h:62
int32 bins_eq
Definition: fmt_check.h:191
int32 i32[FMT_8BLEN *2]
Definition: fmt_check.h:58
int32 n_fields
Definition: fmt_check.h:154
int16 i16[FMT_8BLEN *4]
Definition: fmt_check.h:60
int fmt_rd_attr(char *, FILE *, fmt_str *)
Definition: fmt_rd_attr.c:10
#define FMT_8BLEN
Definition: fmt_check.h:38
int fmt_rd_sds(char *, FILE *, fmt_str *)
Definition: fmt_rd_sds.c:7
@ ATT_RD_READ_INCLUSIVE
Definition: fmt_check.h:48
int32 * start_bin
Definition: fmt_check.h:194
int32 type
Definition: fmt_check.h:92
int32 count
Definition: fmt_check.h:93
int nlin_indx
Definition: fmt_check.h:145
void l3_get_org(int, l3_org_str *)
Definition: l3_get_org.c:9
int32 attr_ind[50]
Definition: fmt_check.h:120
int dim_size
Definition: fmt_check.h:135
char lbl_ras[200]
Definition: fmt_check.h:142
int n_vgroup
Definition: fmt_check.h:177
int get_attr(int32, attr_str, u_data *, int *)
Definition: get_attr.c:10
void chk_l3_prod(int32, int32, char *, char *)
Definition: ck_v_l3.c:722
void fmt_exit(int)
Definition: fmt_check.c:224
char obj_nm[100]
Definition: fmt_check.h:88
char lbl_pal[200]
Definition: fmt_check.h:143
char i8[FMT_8BLEN *8]
Definition: fmt_check.h:61
int32 read
Definition: fmt_check.h:95
int16 i16[4]
Definition: fmt_check.h:74
int resolve
Definition: fmt_check.h:179
void chk_bin_index(int32, int32 *, int32 *)
Definition: ck_v_l3.c:468
ras_str * ras
Definition: fmt_check.h:176
float64 * hsize
Definition: fmt_check.h:193
int32 group_fnd(int32, int32, int32, int32, vg_info_str *)
Definition: ck_v_l3.c:92