// $Id$
//*****************************************************************************/
// Copyright 1998-2022 Stonie R. Cooper, Licensed under the auspices of GPLv3,
// See top-level copyright disclaimer (COPYRIGHT) and license (LICENSE)
//                    Prague, NE
// File:            pdinrs_grib2.h
// Author:          Stonie R. Cooper
// Documentation:   NA
// Revision Record: (as follows)
//         Rewritten: 20050114 by Stonie R. Cooper
//                  Established initial file for pdinrs_grib2.h
// Dependencies: pdinrs.h
//*****************************************************************************/

#ifndef PDINRS_GRIB2_H
#define PDINRS_GRIB2_H

#define VALUECOUNT 12
#define OCTETSIZE  4
#define STRINGSIZE 81
#define STARTARTIFICIAL 512
#define MAXG2TABLESIZE  512

#include <pdinrs.h>

typedef struct
{
  char name[STRINGSIZE];
  char type; // 0 = int; 1 = double
  union
  {
    int ivalue;
    double rvalue;
  } value;
} fieldType;

typedef struct
{
  int gridDef;
  fieldType field[VALUECOUNT];
} grib2Type;

typedef struct
{
  int artificial;
  grib2Type grib2;
} grib2TableType;

int matchGrib2toTable(grib2TableType *table, int *tableSize, grib2Type grib2, int *currentIndex, char *directory);

int readGrib2Tables(char *directory, grib2TableType *table);

int saveGrib2Table(char *fileName, grib2TableType table);

#endif
