|
RCube
Rcube Rest Server calculates sail routes based on Grib files and sailing boat polar files
|
#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <stdbool.h>#include <string.h>#include <math.h>#include <sys/stat.h>#include "../csources/glibwrapper.h"#include "../csources/r3types.h"#include "../csources/r3util.h"#include "../csources/inline.h"
Go to the source code of this file.
Data Structures | |
| struct | BitReader |
| struct | Sec1Info |
| struct | Sec3Grid |
| struct | Sec4Info |
| struct | Sec5Info |
| struct | Sec6Info |
| struct | MsgParse |
Macros | |
| #define | GRIB_DEBUG 0 /* set to 0 to disable diagnostics */ |
| GRIB2 reader without ecCodes/GLib Supports: | |
Functions | |
| char * | gribReaderVersion (char *str, size_t maxLen) |
| return type of reader | |
| static uint8_t | rdU8 (const uint8_t *p) |
| static uint16_t | rdU16BE (const uint8_t *p) |
| static uint32_t | rdU32BE (const uint8_t *p) |
| static int32_t | rdI32BE (const uint8_t *p) |
| static uint64_t | rdU64BE (const uint8_t *p) |
| static int16_t | readS16beFlexible (const uint8_t *p) |
| static float | rdIEEE32BE (const uint8_t *p) |
| static void | bitInit (BitReader *br, const uint8_t *buf, size_t len) |
| static uint32_t | bitGet (BitReader *br, int nbits) |
| static void | strCopySafe (char *dst, size_t cap, const char *src) |
| static size_t | updateLongUnique (long value, size_t n, size_t maxN, long arr[]) |
| static void | sortLongAsc (long *a, size_t n) |
| static const uint8_t * | findNextGrib (const uint8_t *p, const uint8_t *end) |
| static bool | isCurrentTriplet (int disc, int cat, int par, bool *isU) |
| static const char * | shortNameFor (int disc, int cat, int par) |
| static int | unitToHours (uint8_t unit, int32_t val) |
| static int | scoreHours (int h) |
| static int | pdtLeadHours (int pdtn, const uint8_t *pdt, uint32_t pdtLen) |
| static bool | parseSec1 (const uint8_t *s, uint32_t bodyLen, Sec1Info *out) |
| static bool | parseSec3LatLon (const uint8_t *s, uint32_t bodyLen, Sec3Grid *out) |
| static bool | scanIPlus (int scan) |
| static bool | scanJPlus (int scan) |
| static bool | scanAdjI (int scan) |
| static bool | scanBoustro (int scan) |
| static bool | parseSec4 (const uint8_t *s, uint32_t bodyLen, int discipline, Sec4Info *out) |
| static bool | parseSec5 (const uint8_t *s, uint32_t bodyLen, Sec5Info *out) |
| static int | bmBitAt (const uint8_t *bm, size_t bmBytes, size_t k) |
| static int | parseGrib2Message (const uint8_t *buf, size_t len, int wantData, MsgParse *out, float **outValues) |
| static long | indLat (double lat, const Zone *zone) |
| static long | indLonWrap (double lon, const Zone *zone) |
| static long | idxTij (int iT, int iLon, int iLat, const Zone *zone) |
| static int | findTimeIndex (long timeStep, const Zone *zone) |
| bool | readGribLists (const char *fileName, Zone *zone) |
| Read lists zone.timeStamp, shortName, zone.dataDate, dataTime before full grib reading. | |
| bool | readGribParameters (const char *fileName, Zone *zone) |
| Read grib parameters in zone before full grib reading. | |
| bool | readGribAll (const char *fileName, Zone *zone, int iFlow) |
| read grib file using eccodes C API return true if OK | |
Variables | |
| FlowP * | tGribData [2] = {NULL, NULL} |
| grib data description | |
| #define GRIB_DEBUG 0 /* set to 0 to disable diagnostics */ |
GRIB2 reader without ecCodes/GLib Supports:
Build example: gcc -O2 -Wall -Wextra -c readgriballwithouteccodes.c
Definition at line 37 of file readgriballwithouteccodes.c.
|
static |
Definition at line 84 of file readgriballwithouteccodes.c.
References BitReader::bitpos, BitReader::buf, and BitReader::len.
Referenced by parseGrib2Message().

|
static |
Definition at line 81 of file readgriballwithouteccodes.c.
References BitReader::bitpos, BitReader::buf, and BitReader::len.
Referenced by parseGrib2Message().

|
static |
Definition at line 414 of file readgriballwithouteccodes.c.
Referenced by parseGrib2Message().

|
static |
Definition at line 132 of file readgriballwithouteccodes.c.
Referenced by readGribAll(), and readGribLists().

|
static |
Definition at line 575 of file readgriballwithouteccodes.c.
References Zone::nTimeStamp, Zone::timeStamp, and zone.
Referenced by readGribAll().

| char * gribReaderVersion | ( | char * | str, |
| size_t | maxLen | ||
| ) |
return type of reader
return version of ECCODE API
Definition at line 41 of file readgriballwithouteccodes.c.
Referenced by testToJson().

|
inlinestatic |
Definition at line 569 of file readgriballwithouteccodes.c.
References Zone::nbLat, Zone::nbLon, and zone.
Referenced by readGribAll().

|
inlinestatic |
Definition at line 551 of file readgriballwithouteccodes.c.
References Zone::latMin, Zone::latStep, and zone.
Referenced by readGribAll().

|
inlinestatic |
Definition at line 556 of file readgriballwithouteccodes.c.
References Zone::lonLeft, Zone::lonStep, Zone::nbLon, and zone.
Referenced by readGribAll().

|
static |
Definition at line 140 of file readgriballwithouteccodes.c.
References par.
Referenced by readGribAll(), readGribLists(), and shortNameFor().

|
static |
Definition at line 422 of file readgriballwithouteccodes.c.
References bitGet(), bitInit(), Sec6Info::bitmap, Sec6Info::bitmapLen, bmBitAt(), Sec5Info::bScale, Sec4Info::category, Sec3Grid::di, Sec3Grid::dj, Sec5Info::drt, Sec5Info::dScale, MsgParse::haveS1, MsgParse::haveS3, MsgParse::haveS4, MsgParse::haveS5, MsgParse::haveS6, MsgParse::haveS7, Sec6Info::indicator, Sec3Grid::lat1, Sec3Grid::lon1, Sec5Info::nBits, Sec3Grid::Ni, Sec3Grid::Nj, Sec4Info::parameter, parseSec1(), parseSec3LatLon(), parseSec4(), parseSec5(), rdIEEE32BE(), rdU32BE(), rdU64BE(), rdU8(), Sec5Info::refV, MsgParse::s1, MsgParse::s3, MsgParse::s4, MsgParse::s5, MsgParse::s6, Sec3Grid::scanFlags, MsgParse::sec7, MsgParse::sec7Len, and shortNameFor().
Referenced by readGribAll().


|
static |
Definition at line 246 of file readgriballwithouteccodes.c.
References Sec1Info::centerId, rdU16BE(), rdU8(), Sec1Info::refDay, Sec1Info::refHour, Sec1Info::refMinute, Sec1Info::refMonth, Sec1Info::refSecond, Sec1Info::refYear, Sec1Info::subcenterId, and Sec1Info::tableVersion.
Referenced by parseGrib2Message(), readGribLists(), and readGribParameters().


|
static |
Definition at line 271 of file readgriballwithouteccodes.c.
References Sec3Grid::di, Sec3Grid::dj, Sec3Grid::lat1, Sec3Grid::lon1, Sec3Grid::Ni, Sec3Grid::Nj, rdU16BE(), rdU32BE(), rdU8(), and Sec3Grid::scanFlags.
Referenced by parseGrib2Message(), and readGribParameters().


|
static |
Definition at line 348 of file readgriballwithouteccodes.c.
References Sec4Info::category, Sec4Info::discipline, Sec4Info::parameter, Sec4Info::pdt, Sec4Info::pdtLen, Sec4Info::pdtn, rdU16BE(), and rdU8().
Referenced by parseGrib2Message(), and readGribLists().


|
static |
Definition at line 371 of file readgriballwithouteccodes.c.
References Sec5Info::bScale, Sec5Info::drt, Sec5Info::dScale, Sec5Info::nBits, rdIEEE32BE(), rdU16BE(), rdU8(), readS16beFlexible(), and Sec5Info::refV.
Referenced by parseGrib2Message().


|
static |
Definition at line 205 of file readgriballwithouteccodes.c.
References scoreHours(), and unitToHours().
Referenced by readGribAll(), and readGribLists().


|
inlinestatic |
Definition at line 50 of file readgriballwithouteccodes.c.
References rdU32BE().

|
inlinestatic |
Definition at line 68 of file readgriballwithouteccodes.c.
References rdU32BE().
Referenced by parseGrib2Message(), and parseSec5().


|
inlinestatic |
Definition at line 48 of file readgriballwithouteccodes.c.
Referenced by parseSec1(), parseSec3LatLon(), parseSec4(), parseSec5(), and readS16beFlexible().

|
inlinestatic |
Definition at line 49 of file readgriballwithouteccodes.c.
Referenced by parseGrib2Message(), parseSec3LatLon(), rdI32BE(), rdIEEE32BE(), rdU64BE(), readGribLists(), and readGribParameters().

|
inlinestatic |
Definition at line 51 of file readgriballwithouteccodes.c.
References rdU32BE().
Referenced by parseGrib2Message(), readGribAll(), readGribLists(), and readGribParameters().


|
inlinestatic |
Definition at line 47 of file readgriballwithouteccodes.c.
Referenced by parseGrib2Message(), parseSec1(), parseSec3LatLon(), parseSec4(), parseSec5(), readGribAll(), readGribLists(), and readGribParameters().

| bool readGribAll | ( | const char * | fileName, |
| Zone * | zone, | ||
| int | iFlow | ||
| ) |
read grib file using eccodes C API return true if OK
Definition at line 789 of file readgriballwithouteccodes.c.
References Zone::allTimeStepOK, Zone::anteMeridian, Sec4Info::category, Sec3Grid::di, Sec3Grid::dj, findNextGrib(), findTimeIndex(), FlowP::g, GUST_GFS, idxTij(), indexOf(), indLat(), indLonWrap(), Zone::intervalBegin, Zone::intervalEnd, isCurrentTriplet(), FlowP::lat, Sec3Grid::lat1, Zone::latMax, Zone::latMin, Zone::latStep, FlowP::lon, Sec3Grid::lon1, lonCanonize(), Zone::lonLeft, Zone::lonStep, MAX_SIZE_SHORT_NAME, MISSING, Zone::nbLat, Zone::nbLon, Zone::nDataDate, Sec3Grid::Ni, Sec3Grid::Nj, Zone::nMessage, Zone::nTimeStamp, Sec4Info::parameter, parseGrib2Message(), Sec4Info::pdt, pdtLeadHours(), Sec4Info::pdtLen, Sec4Info::pdtn, rdU64BE(), rdU8(), readGribLists(), readGribParameters(), MsgParse::s3, MsgParse::s4, scanAdjI(), scanBoustro(), Sec3Grid::scanFlags, shortNameFor(), tGribData, Zone::timeStamp, FlowP::u, FlowP::v, FlowP::w, Zone::wellDefined, and zone.
Referenced by initContext(), optionManage(), updateCurrentGrib(), and updateWindGrib().


| bool readGribLists | ( | const char * | fileName, |
| Zone * | zone | ||
| ) |
Read lists zone.timeStamp, shortName, zone.dataDate, dataTime before full grib reading.
Definition at line 583 of file readgriballwithouteccodes.c.
References Sec4Info::category, Sec1Info::centerId, Zone::centreId, Zone::dataDate, Zone::dataTime, Sec4Info::discipline, Zone::editionNumber, findNextGrib(), g_strlcpy, Zone::intervalBegin, Zone::intervalEnd, Zone::intervalLimit, isCurrentTriplet(), MAX_N_DATA_DATE, MAX_N_DATA_TIME, MAX_N_SHORT_NAME, MAX_N_TIME_STAMPS, MAX_SIZE_SHORT_NAME, Zone::nDataDate, Zone::nDataTime, Zone::nShortName, Zone::nTimeStamp, Sec4Info::parameter, parseSec1(), parseSec4(), Sec4Info::pdt, pdtLeadHours(), Sec4Info::pdtLen, Sec4Info::pdtn, rdU32BE(), rdU64BE(), rdU8(), Sec1Info::refDay, Sec1Info::refHour, Sec1Info::refMinute, Sec1Info::refMonth, Sec1Info::refYear, Zone::shortName, shortNameFor(), sortLongAsc(), Zone::stepUnits, strCopySafe(), Zone::timeStamp, updateLong(), updateLongUnique(), and zone.
Referenced by gribToStrJson(), and readGribAll().


| bool readGribParameters | ( | const char * | fileName, |
| Zone * | zone | ||
| ) |
Read grib parameters in zone before full grib reading.
Definition at line 706 of file readgriballwithouteccodes.c.
References Zone::anteMeridian, Sec1Info::centerId, Zone::centreId, Sec3Grid::di, Sec3Grid::dj, Zone::editionNumber, Sec3Grid::lat1, Zone::latMax, Zone::latMin, Zone::latStep, Sec3Grid::lon1, lonCanonize(), Zone::lonLeft, Zone::lonRight, Zone::lonStep, Zone::nbLat, Zone::nbLon, Sec3Grid::Ni, Sec3Grid::Nj, Zone::numberOfValues, parseSec1(), parseSec3LatLon(), rdU32BE(), rdU64BE(), rdU8(), Zone::stepUnits, and zone.
Referenced by gribToStrJson(), and readGribAll().


|
static |
Definition at line 56 of file readgriballwithouteccodes.c.
References rdU16BE().
Referenced by parseSec5().


|
inlinestatic |
Definition at line 337 of file readgriballwithouteccodes.c.
Referenced by readGribAll().

|
inlinestatic |
Definition at line 338 of file readgriballwithouteccodes.c.
Referenced by readGribAll().

|
inlinestatic |
Definition at line 335 of file readgriballwithouteccodes.c.
|
inlinestatic |
Definition at line 336 of file readgriballwithouteccodes.c.
|
static |
Definition at line 187 of file readgriballwithouteccodes.c.
Referenced by pdtLeadHours().

|
static |
Definition at line 159 of file readgriballwithouteccodes.c.
References isCurrentTriplet(), and par.
Referenced by parseGrib2Message(), readGribAll(), and readGribLists().


|
static |
Definition at line 124 of file readgriballwithouteccodes.c.
Referenced by readGribLists().

|
static |
Definition at line 111 of file readgriballwithouteccodes.c.
Referenced by readGribLists().

|
static |
Definition at line 172 of file readgriballwithouteccodes.c.
Referenced by pdtLeadHours().

|
static |
Definition at line 118 of file readgriballwithouteccodes.c.
Referenced by readGribLists().

| FlowP* tGribData[2] = {NULL, NULL} |
grib data description
Definition at line 14 of file readgriballwithouteccodes.c.
Referenced by checkGrib(), consistentGrib(), findCurrentGrib(), findWindGrib(), launchAction(), main(), optionManage(), and readGribAll().