ocssw  1.0
/disk01/web/ocssw/build/src/auto_qc/fmt_check/fmt_check.h (r8102/r3749)
Go to the documentation of this file.
00001 #include "l1io.h" 
00002 /*******************************************************************
00003 
00004    fmt_check.h
00005 
00006    purpose: include file to set up some of the structures used
00007             in the format checker program
00008 
00009    Modification history:
00010       Programmer        Date            Description of change
00011       ----------        ----            ---------------------
00012       W. Robinson       17-Feb-1995     Original development
00013       L. Kumar      19-Dec-1995     Modified dims of some char variables
00014                     of u_data
00015       W. Robinson       13-Jun-1996     add prototypes for routines
00016       W. Robinson       17-Sep-1996     add capability to do 66k bytes
00017                                         of data instead of 3000 in u_data
00018       W. Robinson       30-Sep-1996     Upgrade to include min / max
00019                                         check ranges for the sds values
00020       W. Robinson       31-Oct-1996     Upgrade to recognize float64
00021       W. Robinson       15-Mar-2001     make changes for linux usage
00022       W. Robinson, SAIC 29 Mar 2005     update to fully table driven model
00023                                         and call I/O for sections from here
00024       W. Robinson, SAIC 3 Feb 2010      add multipliers for float uncertainty 
00025                                         in checking of attributes to a constant
00026 
00027 *******************************************************************/
00028 
00029 /*
00030  *  The FMT_8BLEN variable is defined only for the linux so fmt_check
00031  *  gets built with smaller arrays
00032  */
00033 #ifdef FCK_8LEN
00034   #define FMT_8BLEN FCK_8LEN
00035 #else
00036   #define FMT_8BLEN 8251
00037 #endif
00038 
00039 /*
00040  *  define some codes for use
00041  *
00042  *  attribute value read keywords
00043  */
00044 enum att_rd_code { ATT_RD_NOREAD, ATT_RD_READ_NOCK, ATT_RD_READ_ONE_VAL,
00045     ATT_RD_READ_INCLUSIVE };
00046 static char *att_rd_str[] = { "NOREAD", "READ_NOCK", "READ_ONE_VAL", 
00047     "READ_INCLUSIVE" };
00048 
00049 /*
00050  *  u_data allows the placing of short amounts of attribute data
00051  *  into the correctly formatted storage
00052  */
00053 
00054 typedef union u_data_d 
00055    {
00056    char chr[FMT_8BLEN * 8];
00057    int32 i32[FMT_8BLEN * 2];
00058    float32 f32[FMT_8BLEN * 2];
00059    int16 i16[FMT_8BLEN * 4];
00060    char i8[FMT_8BLEN * 8];
00061    unsigned char ui8[FMT_8BLEN * 8];
00062    float64 f64[FMT_8BLEN];
00063    } u_data;
00064 
00065 /*
00066  *  With the size of the u_data now, and the need for a similar
00067  *  structure for the SDS value range, introduce a shorter version
00068  *  for the sds 2-value range.
00069  */
00070 typedef union s_data_d
00071    {
00072    int32 i32[2];
00073    float32 f32[2];
00074    int16 i16[4];
00075    char i8[8];
00076    unsigned char ui8[8];
00077    float64 f64[20];
00078    } s_data;
00079 
00080 /*
00081  * attr_str has all the information about an attribute and its value
00082  * if it is fixed
00083  */
00084 
00085 typedef struct attr_str_d
00086    {
00087    int32 dim_index;       /* index into dimension definitions, -1 if */
00088                           /* no connection made  */
00089    char obj_nm[100];      /* Name of the science dataset or 'gbl'
00090                              if refering to a global attribute  */
00091    char access_nm[200];   /* This is the name used to access the value */
00092    char int_nm[200];      /* This is the expected name of the variable */
00093    int32 type;            /* This is the type of the value returned */
00094    int32 count;           /* This is the expected count of the variable, 
00095                              if <0, do not check the count */
00096    int32 read;            /* This is the value read switch,
00097                              ATT_RD_NOREAD - do not read value,
00098                              ATT_RD_READ_NOCK - read value but do not check,
00099                              ATT_RD_READ_ONE_VAL - read the value and check 
00100                                  it with what is read into data below 
00101                              ATT_RD_READ_INCLUSIVE - make sure the value(s) are
00102                                  within the range described below  */
00103    u_data data;     /* this is the expected value or range of the attribute */
00104    } attr_str; 
00105 
00106 /*
00107  * sds_info_str will describe the science dataset and point to 
00108  * the attribute descriptions for the included attributes
00109  */
00110 
00111 typedef struct sds_info_str_d
00112    {
00113    char name[100];         /* Name of the science dataset */
00114    int32 rank;             /* # dimensions in this dataset */
00115    int32 type;             /* type of the sds data */
00116    int32 e_ranges[3];      /* expected range of dimension >0 - check
00117                               with this value, 0 - do not check, -(value)
00118                               check vs the dimension size in the location:
00119                               'value' in the dimension id structure array */
00120    int32 n_attr;           /* # of attributes in this (I have a max 
00121                               of 50 now) */
00122    int32 attr_ind[50];     /* place for index to attribute descriptions */
00123    int32 byt_per_val;      /* # bytes in a value of this type  */
00124    int32 flg_rng;          /* flag for min / max range checking: 0 - don't
00125                               check,  1 - do the check */
00126    s_data sds_rng;      /* minimum and maximum (inclusive)for sds 
00127                               value checking */
00128    } sds_info_str;
00129 
00130 /*
00131  *  dim_id_str is the structure to hold all the dimension description 
00132  *  information.
00133  */
00134 typedef struct dim_id_d
00135   {
00136   char att_nm[200];     /* attrinute name */
00137   char att_short[100];  /* short name for attr without spaces */
00138   int dim_size;         /* the actual dimension size for this case */
00139   } dim_id_str;
00140 
00141 /*
00142  *  ras_str is the structure containing the raster definition(s)
00143  */
00144 typedef struct ras_str_d
00145   {
00146   char lbl_ras[200];   /* raster label, *NONE* or no label */
00147   char lbl_pal[200];   /* palette label */
00148   int npix_indx;  /* index into dimension struct array of the raster # pixels */
00149   int nlin_indx;  /* index into dimension struct array of the raster # lines */
00150   } ras_str;
00151 
00152 /*
00153  * vg_info_str  describes the Vgroup products
00154  * The 3 Vgroups for bin description are there as well as the 
00155  * variable product descriptions
00156  */
00157 typedef struct vg_info_str_d
00158   {
00159   int32 n_fields;           /*  # Vdata fields in this Vdata */
00160   int32 num_typs[7];        /*  list of # types of each field */
00161   int32 nrec;               /*  # Vdata records or -1 to use the nbin
00162                                  value passed in and only check that
00163                                  there are >= nbin # records in the Vdata  */
00164   char name[VSNAMELENMAX];  /*  name of this Vdata */
00165   char class[VSNAMELENMAX]; /*  class of this Vdata */
00166   char field_list[200];     /*  names of all the fields comma seperated */
00167   } vg_info_str;
00168 
00169 /*
00170  * structure for the entire format
00171  */
00172 typedef struct fmt_str_d
00173   {
00174   int n_attr;  /* # attribute descriptions */
00175   attr_str *att;  /* attribute definitions */
00176   int n_sds;      /* # SDS descriptions */
00177   sds_info_str *sds_info;  /* SDS definitions */
00178   int n_dim_defs;          /* # of dimension definitions */
00179   dim_id_str *dim_id;       /* dimension definitions */
00180   int n_raster;            /* # raster definitions (either 0 or 1 if a 
00181                               raster exists */
00182   ras_str *ras;            /* raster definitions */
00183   int n_vgroup;            /* # v group definitions (either 0 or 1 if a 
00184                               l3 set of v groups exist */
00185   int resolve;            /* the resolve value about the bin size in km */
00186   int vg_nbin_indx;       /* index of the '# of bins' in the dimension 
00187                   struct array designating the # of bins to be cross checked. */
00188   vg_info_str *vg_info;   /* Vgroup information (for L3 prods)  */
00189   } fmt_str;
00190 
00191 /*
00192  *  This structure is here to carry the l3 bin organization info
00193  *  # rows, bin size, etc
00194  */
00195 typedef struct l3_org_str_d
00196   {
00197   int32 numrows;  /*  # bin rows */
00198   int32 bins_eq;  /*  # nins at the equator  */
00199   float64 vsize;  /*  degree vertical size of bin  */
00200   float64 *hsize;  /*  degree horizontal size of bin  */
00201   int32 *start_bin;  /*  start bin number for each row  */
00202   int32 *max_bin;  /*  maximun # bins that can be in a row  */
00203   } l3_org_str;
00204 /*
00205  *  add multipliers for float uncertainty in checking of attributes to
00206  *  a constant
00207  */
00208 #define ERR_FRAC_F32 0.0001
00209 #define ERR_FRAC_F64 0.000001
00210 /*
00211  *  Do some prototype definitions
00212  */
00213 char *s_parse( char*, int );
00214 int fmt_rd_attr( char *, FILE *, fmt_str * );
00215 int fmt_read( char *, fmt_str * );
00216 char *get_line( char*, int, FILE *, int );
00217 int var_decode( char *, int32, void *, int32, int32 );
00218 int get_attr( int32, attr_str, u_data *, int * );
00219 void attr_disp( attr_str, u_data, int );
00220 void chk_str( attr_str, char *, int32 );
00221 int fmt_rd_dim( char *, FILE *, fmt_str * );
00222 int fmt_rd_sds( char *, FILE *, fmt_str * );
00223 int fmt_rd_l3vg( char *, FILE *, fmt_str * );
00224 int chk_sds( int32, fmt_str *, int );
00225 int fmt_rd_ras( char *, FILE *, fmt_str * );
00226 int hdf_ras_chk( char *, char *, char *, int, int );
00227 void fmt_exit( int );
00228 void ck_v_l3( int32, fmt_str * );
00229 int32 group_fnd( int32, int32, int32, int32, vg_info_str * );
00230 void chk_sea_grid( int32 );
00231 void chk_bin_index( int32, int32 *, int32 * );
00232 void chk_bin_list( int32, int32, int32 *, int32 * );
00233 void chk_l3_prod( int32, int32, char *, char * );
00234 int32 rdvdata( int32, char *, char *, int32, int32, unsigned char * );
00235 void l3_get_org( int, l3_org_str * );
00236 
00237 #ifndef DBL_DIG
00238 #define DBL_DIG 15
00239 #endif
00240 
00241 #ifndef FLT_DIG
00242 #define FLT_DIG 6
00243 #endif