OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
modis_grib_read.h File Reference

Go to the source code of this file.

Classes

struct  grib_date_t
 
struct  grib_record_t
 

Macros

#define INT2(a, b)
 
#define BDS_LEN(bds)   ((int) ((bds[0]<<16)+(bds[1]<<8)+bds[2]))
 
#define BDS_MoreFlags(bds)   ((bds[3] & 16) != 0)
 
#define BDS_UnusedBits(bds)   ((int) (bds[3] & 15))
 
#define BDS_BinScale(bds)   INT2(bds[4],bds[5])
 
#define BDS_RefValue(bds)   (ibm2flt(bds+6))
 
#define BDS_NumBits(bds)   ((int) bds[10])
 
#define BDS_DataStart(bds)   ((int) (11 + BDS_MoreFlags(bds)*3))
 
#define BDS_NValues(bds)
 
#define UNDEFINED   9.999e20
 
#define BMS_LEN(bms)
 
#define BMS_UnusedBits(bms)   ((bms) == NULL ? 0 : bms[3])
 
#define BMS_StdMap(bms)   ((bms) == NULL ? 0 : ((bms[4]<<8) + bms[5]))
 
#define BMS_bitmap(bms)   ((bms) == NULL ? NULL : (bms)+6)
 
#define BMS_nxny(bms)
 
#define INT3(a, b, c)
 
#define GDS_LEN(gds)   ((int) ((gds[0]<<16)+(gds[1]<<8)+gds[2]))
 
#define GDS_NV(gds)   (gds[3])
 
#define GDS_DataType(gds)   (gds[5])
 
#define GDS_LatLon(gds)   (gds[5] == 0)
 
#define GDS_Gaussian(gds)   (gds[5] == 4)
 
#define GDS_LatLon_nx(gds)   ((int) ((gds[6] << 8) + gds[7]))
 
#define GDS_LatLon_ny(gds)   ((int) ((gds[8] << 8) + gds[9]))
 
#define GDS_PL(gds)
 
#define TRUE   (0==0)
 
#define FALSE   (1==0)
 
#define PDS_Len1(pds)   (pds[0])
 
#define PDS_Len2(pds)   (pds[1])
 
#define PDS_Len3(pds)   (pds[2])
 
#define PDS_LEN(pds)   ((int) ((pds[0]<<16)+(pds[1]<<8)+pds[2]))
 
#define PDS_Vsn(pds)   (pds[3])
 
#define PDS_Center(pds)   (pds[4])
 
#define PDS_Model(pds)   (pds[5])
 
#define PDS_Grid(pds)   (pds[6])
 
#define PDS_HAS_GDS(pds)   ((pds[7] & 128) != 0)
 
#define PDS_HAS_BMS(pds)   ((pds[7] & 64) != 0)
 
#define PDS_PARAM(pds)   (pds[8])
 
#define PDS_L_TYPE(pds)   (pds[9])
 
#define PDS_LEVEL1(pds)   (pds[10])
 
#define PDS_LEVEL2(pds)   (pds[11])
 
#define PDS_KPDS5(pds)   (pds[8])
 
#define PDS_KPDS6(pds)   (pds[9])
 
#define PDS_KPDS7(pds)   ((int) ((pds[10]<<8) + pds[11]))
 
#define PDS_Field(pds)   ((pds[8]<<24)+(pds[9]<<16)+(pds[10]<<8)+pds[11])
 
#define PDS_Year(pds)   (pds[12])
 
#define PDS_Month(pds)   (pds[13])
 
#define PDS_Day(pds)   (pds[14])
 
#define PDS_Hour(pds)   (pds[15])
 
#define PDS_Minute(pds)   (pds[16])
 
#define PDS_ForecastTimeUnit(pds)   (pds[17])
 
#define PDS_P1(pds)   (pds[18])
 
#define PDS_P2(pds)   (pds[19])
 
#define PDS_TimeRange(pds)   (pds[20])
 
#define PDS_NumAve(pds)   ((int) ((pds[21]<<8)+pds[22]))
 
#define PDS_NumMissing(pds)   (pds[23])
 
#define PDS_Century(pds)   (pds[24])
 
#define PDS_Subcenter(pds)   (pds[25])
 
#define PDS_DecimalScale(pds)   INT2(pds[26],pds[27])
 
#define PDS_Year4(pds)   (pds[12] + 100*(pds[24] - (pds[12] != 0)))
 
#define GRIB_SUCCESS   0
 
#define GRIB_MISSING_END_SECTION   -1
 
#define GRIB_MISSING_GDS_NUM_DATAPOINTS   1
 
#define GRIB_BAD_SEEK   8
 
#define GRIB_MALLOC_ERROR   11
 
#define GRIB_INPUT_ERROR   12
 
#define GRIB_ERROR_IN_CALLED   13
 
#define GRIB_BAD_NUM_VS_NAME   14
 
#define VERSION   "wgrib v1.5.0b10 (5-07-96) Wesley Ebisuzaki"
 
#define CHECK_GRIB
 
#define MSEEK   1024
 
#define BUFF_ALLOC0   40000
 
#define min(a, b)   ((a) < (b) ? (a) : (b))
 
#define max(a, b)   ((a) < (b) ? (b) : (a))
 

Functions

int modis_grib_setup (char *inlun, char *outlun, grib_record_t *grib_records, int numofrecords, char *errmsg)
 
int modis_grib_read (char *lun, int version, grib_record_t *grib_records, int N_grib_records, char *errmsg)
 
unsigned char * seek_grib (FILE *file, long *pos, long *len_grib, unsigned char *buffer, unsigned int buf_len)
 
int read_grib (FILE *file, long pos, long len_grib, unsigned char *buffer)
 
int Name_Matches_PDS (char *name, char *pds)
 
int parse_grib_message (unsigned char *buffer, unsigned char **pds, unsigned char **gds, unsigned char **bms, unsigned char **bds, int *nx, int *ny, long *nxny, char *errmsg)
 
void BDS_unpack (float *flt, unsigned char *bits, unsigned char *bitmap, int n_bits, int n, double ref, double scale)
 
double ibm2flt (unsigned char *ibm)
 
double int_power (double x, int y)
 
int GDS_grid (unsigned char *gds, int *nx, int *ny, long int *nxny)
 

Macro Definition Documentation

◆ BDS_BinScale

#define BDS_BinScale (   bds)    INT2(bds[4],bds[5])

Definition at line 64 of file modis_grib_read.h.

◆ BDS_DataStart

#define BDS_DataStart (   bds)    ((int) (11 + BDS_MoreFlags(bds)*3))

Definition at line 69 of file modis_grib_read.h.

◆ BDS_LEN

#define BDS_LEN (   bds)    ((int) ((bds[0]<<16)+(bds[1]<<8)+bds[2]))

Definition at line 59 of file modis_grib_read.h.

◆ BDS_MoreFlags

#define BDS_MoreFlags (   bds)    ((bds[3] & 16) != 0)

Definition at line 61 of file modis_grib_read.h.

◆ BDS_NumBits

#define BDS_NumBits (   bds)    ((int) bds[10])

Definition at line 67 of file modis_grib_read.h.

◆ BDS_NValues

#define BDS_NValues (   bds)
Value:
(((BDS_LEN(bds) - BDS_DataStart(bds))*8 - \

Definition at line 72 of file modis_grib_read.h.

◆ BDS_RefValue

#define BDS_RefValue (   bds)    (ibm2flt(bds+6))

Definition at line 66 of file modis_grib_read.h.

◆ BDS_UnusedBits

#define BDS_UnusedBits (   bds)    ((int) (bds[3] & 15))

Definition at line 62 of file modis_grib_read.h.

◆ BMS_bitmap

#define BMS_bitmap (   bms)    ((bms) == NULL ? NULL : (bms)+6)

Definition at line 84 of file modis_grib_read.h.

◆ BMS_LEN

#define BMS_LEN (   bms)
Value:
((bms) == NULL ? 0 : \
(bms[0]<<16)+(bms[1]<<8)+bms[2])

Definition at line 80 of file modis_grib_read.h.

◆ BMS_nxny

#define BMS_nxny (   bms)
Value:
((((bms) == NULL) || BMS_StdMap(bms)) \
? 0 : (BMS_LEN(bms)*8 - 48 - BMS_UnusedBits(bms)))

Definition at line 85 of file modis_grib_read.h.

◆ BMS_StdMap

#define BMS_StdMap (   bms)    ((bms) == NULL ? 0 : ((bms[4]<<8) + bms[5]))

Definition at line 83 of file modis_grib_read.h.

◆ BMS_UnusedBits

#define BMS_UnusedBits (   bms)    ((bms) == NULL ? 0 : bms[3])

Definition at line 82 of file modis_grib_read.h.

◆ BUFF_ALLOC0

#define BUFF_ALLOC0   40000

Definition at line 213 of file modis_grib_read.h.

◆ CHECK_GRIB

#define CHECK_GRIB

Definition at line 206 of file modis_grib_read.h.

◆ FALSE

#define FALSE   (1==0)

Definition at line 150 of file modis_grib_read.h.

◆ GDS_DataType

#define GDS_DataType (   gds)    (gds[5])

Definition at line 102 of file modis_grib_read.h.

◆ GDS_Gaussian

#define GDS_Gaussian (   gds)    (gds[5] == 4)

Definition at line 105 of file modis_grib_read.h.

◆ GDS_LatLon

#define GDS_LatLon (   gds)    (gds[5] == 0)

Definition at line 104 of file modis_grib_read.h.

◆ GDS_LatLon_nx

#define GDS_LatLon_nx (   gds)    ((int) ((gds[6] << 8) + gds[7]))

Definition at line 107 of file modis_grib_read.h.

◆ GDS_LatLon_ny

#define GDS_LatLon_ny (   gds)    ((int) ((gds[8] << 8) + gds[9]))

Definition at line 108 of file modis_grib_read.h.

◆ GDS_LEN

#define GDS_LEN (   gds)    ((int) ((gds[0]<<16)+(gds[1]<<8)+gds[2]))

Definition at line 99 of file modis_grib_read.h.

◆ GDS_NV

#define GDS_NV (   gds)    (gds[3])

Definition at line 101 of file modis_grib_read.h.

◆ GDS_PL

#define GDS_PL (   gds)
Value:
((gds[4] == 255) ? -1 : \
(int) gds[3] * 4 + (int) gds[4] - 1)

Definition at line 111 of file modis_grib_read.h.

◆ GRIB_BAD_NUM_VS_NAME

#define GRIB_BAD_NUM_VS_NAME   14

Definition at line 202 of file modis_grib_read.h.

◆ GRIB_BAD_SEEK

#define GRIB_BAD_SEEK   8

Definition at line 198 of file modis_grib_read.h.

◆ GRIB_ERROR_IN_CALLED

#define GRIB_ERROR_IN_CALLED   13

Definition at line 201 of file modis_grib_read.h.

◆ GRIB_INPUT_ERROR

#define GRIB_INPUT_ERROR   12

Definition at line 200 of file modis_grib_read.h.

◆ GRIB_MALLOC_ERROR

#define GRIB_MALLOC_ERROR   11

Definition at line 199 of file modis_grib_read.h.

◆ GRIB_MISSING_END_SECTION

#define GRIB_MISSING_END_SECTION   -1

Definition at line 196 of file modis_grib_read.h.

◆ GRIB_MISSING_GDS_NUM_DATAPOINTS

#define GRIB_MISSING_GDS_NUM_DATAPOINTS   1

Definition at line 197 of file modis_grib_read.h.

◆ GRIB_SUCCESS

#define GRIB_SUCCESS   0

Definition at line 195 of file modis_grib_read.h.

◆ INT2

#define INT2 (   a,
  b 
)
Value:
((1-(int) ((unsigned) (a & 0x80) >> 6)) \
* (int) (((a & 0x7f) << 8) + b))

Definition at line 55 of file modis_grib_read.h.

◆ INT3

#define INT3 (   a,
  b,
  c 
)
Value:
((1-(int) ((unsigned) (a & 0x80) >> 6)) \
* (int) (((a & 127) << 16)+(b<<8)+c))

Definition at line 91 of file modis_grib_read.h.

◆ max

#define max (   a,
  b 
)    ((a) < (b) ? (b) : (a))

Definition at line 217 of file modis_grib_read.h.

◆ min

#define min (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 216 of file modis_grib_read.h.

◆ MSEEK

#define MSEEK   1024

Definition at line 212 of file modis_grib_read.h.

◆ PDS_Center

#define PDS_Center (   pds)    (pds[4])

Definition at line 160 of file modis_grib_read.h.

◆ PDS_Century

#define PDS_Century (   pds)    (pds[24])

Definition at line 188 of file modis_grib_read.h.

◆ PDS_Day

#define PDS_Day (   pds)    (pds[14])

Definition at line 179 of file modis_grib_read.h.

◆ PDS_DecimalScale

#define PDS_DecimalScale (   pds)    INT2(pds[26],pds[27])

Definition at line 190 of file modis_grib_read.h.

◆ PDS_Field

#define PDS_Field (   pds)    ((pds[8]<<24)+(pds[9]<<16)+(pds[10]<<8)+pds[11])

Definition at line 175 of file modis_grib_read.h.

◆ PDS_ForecastTimeUnit

#define PDS_ForecastTimeUnit (   pds)    (pds[17])

Definition at line 182 of file modis_grib_read.h.

◆ PDS_Grid

#define PDS_Grid (   pds)    (pds[6])

Definition at line 162 of file modis_grib_read.h.

◆ PDS_HAS_BMS

#define PDS_HAS_BMS (   pds)    ((pds[7] & 64) != 0)

Definition at line 164 of file modis_grib_read.h.

◆ PDS_HAS_GDS

#define PDS_HAS_GDS (   pds)    ((pds[7] & 128) != 0)

Definition at line 163 of file modis_grib_read.h.

◆ PDS_Hour

#define PDS_Hour (   pds)    (pds[15])

Definition at line 180 of file modis_grib_read.h.

◆ PDS_KPDS5

#define PDS_KPDS5 (   pds)    (pds[8])

Definition at line 170 of file modis_grib_read.h.

◆ PDS_KPDS6

#define PDS_KPDS6 (   pds)    (pds[9])

Definition at line 171 of file modis_grib_read.h.

◆ PDS_KPDS7

#define PDS_KPDS7 (   pds)    ((int) ((pds[10]<<8) + pds[11]))

Definition at line 172 of file modis_grib_read.h.

◆ PDS_L_TYPE

#define PDS_L_TYPE (   pds)    (pds[9])

Definition at line 166 of file modis_grib_read.h.

◆ PDS_LEN

#define PDS_LEN (   pds)    ((int) ((pds[0]<<16)+(pds[1]<<8)+pds[2]))

Definition at line 158 of file modis_grib_read.h.

◆ PDS_Len1

#define PDS_Len1 (   pds)    (pds[0])

Definition at line 155 of file modis_grib_read.h.

◆ PDS_Len2

#define PDS_Len2 (   pds)    (pds[1])

Definition at line 156 of file modis_grib_read.h.

◆ PDS_Len3

#define PDS_Len3 (   pds)    (pds[2])

Definition at line 157 of file modis_grib_read.h.

◆ PDS_LEVEL1

#define PDS_LEVEL1 (   pds)    (pds[10])

Definition at line 167 of file modis_grib_read.h.

◆ PDS_LEVEL2

#define PDS_LEVEL2 (   pds)    (pds[11])

Definition at line 168 of file modis_grib_read.h.

◆ PDS_Minute

#define PDS_Minute (   pds)    (pds[16])

Definition at line 181 of file modis_grib_read.h.

◆ PDS_Model

#define PDS_Model (   pds)    (pds[5])

Definition at line 161 of file modis_grib_read.h.

◆ PDS_Month

#define PDS_Month (   pds)    (pds[13])

Definition at line 178 of file modis_grib_read.h.

◆ PDS_NumAve

#define PDS_NumAve (   pds)    ((int) ((pds[21]<<8)+pds[22]))

Definition at line 186 of file modis_grib_read.h.

◆ PDS_NumMissing

#define PDS_NumMissing (   pds)    (pds[23])

Definition at line 187 of file modis_grib_read.h.

◆ PDS_P1

#define PDS_P1 (   pds)    (pds[18])

Definition at line 183 of file modis_grib_read.h.

◆ PDS_P2

#define PDS_P2 (   pds)    (pds[19])

Definition at line 184 of file modis_grib_read.h.

◆ PDS_PARAM

#define PDS_PARAM (   pds)    (pds[8])

Definition at line 165 of file modis_grib_read.h.

◆ PDS_Subcenter

#define PDS_Subcenter (   pds)    (pds[25])

Definition at line 189 of file modis_grib_read.h.

◆ PDS_TimeRange

#define PDS_TimeRange (   pds)    (pds[20])

Definition at line 185 of file modis_grib_read.h.

◆ PDS_Vsn

#define PDS_Vsn (   pds)    (pds[3])

Definition at line 159 of file modis_grib_read.h.

◆ PDS_Year

#define PDS_Year (   pds)    (pds[12])

Definition at line 177 of file modis_grib_read.h.

◆ PDS_Year4

#define PDS_Year4 (   pds)    (pds[12] + 100*(pds[24] - (pds[12] != 0)))

Definition at line 191 of file modis_grib_read.h.

◆ TRUE

#define TRUE   (0==0)

Definition at line 149 of file modis_grib_read.h.

◆ UNDEFINED

#define UNDEFINED   9.999e20

Definition at line 76 of file modis_grib_read.h.

◆ VERSION

#define VERSION   "wgrib v1.5.0b10 (5-07-96) Wesley Ebisuzaki"

Definition at line 204 of file modis_grib_read.h.

Function Documentation

◆ BDS_unpack()

void BDS_unpack ( float *  flt,
unsigned char *  bits,
unsigned char *  bitmap,
int  n_bits,
int  n,
double  ref,
double  scale 
)

◆ GDS_grid()

int GDS_grid ( unsigned char *  gds,
int *  nx,
int *  ny,
long int *  nxny 
)

◆ ibm2flt()

double ibm2flt ( unsigned char *  ibm)

◆ int_power()

double int_power ( double  x,
int  y 
)

◆ modis_grib_read()

int modis_grib_read ( char *  lun,
int  version,
grib_record_t grib_records,
int  N_grib_records,
char *  errmsg 
)

◆ modis_grib_setup()

int modis_grib_setup ( char *  inlun,
char *  outlun,
grib_record_t grib_records,
int  numofrecords,
char *  errmsg 
)

◆ Name_Matches_PDS()

int Name_Matches_PDS ( char *  name,
char *  pds 
)

◆ parse_grib_message()

int parse_grib_message ( unsigned char *  buffer,
unsigned char **  pds,
unsigned char **  gds,
unsigned char **  bms,
unsigned char **  bds,
int *  nx,
int *  ny,
long *  nxny,
char *  errmsg 
)

◆ read_grib()

int read_grib ( FILE *  file,
long  pos,
long  len_grib,
unsigned char *  buffer 
)

◆ seek_grib()

unsigned char* seek_grib ( FILE *  file,
long *  pos,
long *  len_grib,
unsigned char *  buffer,
unsigned int  buf_len 
)
#define BDS_DataStart(bds)
#define NULL
Definition: decode_rs.h:63
#define BDS_LEN(bds)
#define BDS_NumBits(bds)
#define BMS_LEN(bms)
#define BDS_UnusedBits(bds)
data_t b[NROOTS+1]
Definition: decode_rs.h:77
#define BMS_StdMap(bms)
#define BMS_UnusedBits(bms)
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument validate it against the input L1A and LUT and to use it determine the correct files to retrieve the ephemeris and attitude data from Changed to produce a LocalGranuleID starting with MYD03 if run on Aqua data Added the Scan Type file attribute to the Geolocation copied from the L1A and attitude_angels to radians rather than degrees The accumulation of Cumulated gflags was moved from GEO_validate_earth_location c to GEO_locate_one_scan c
Definition: HISTORY.txt:464
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424