26uint8_t
bitf[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
27uint8_t
biti[8] = {0xFF,0x7f,0x3f,0x1F,0x0F,0x07,0x03,0x01};
28uint8_t
bitk[8] = {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
53 for ( j = 0; j < nc ; j++ )
60 c = source + ( *bit0_offset + d ) / 8;
61 i = ( *bit0_offset + d ) % 8;
63 * ( target + j ) += ( 1U << ( r - 1 ) );
72 * ( target + nc ) =
'\0';
100 i = ( *bit0_offset ) % 8;
103 for ( j = 0; j < nc ; j++ )
105 c = source + ( *bit0_offset ) / 8;
106 * ( target + j ) = ( *c &
biti[i] );
109 * ( target + j ) <<= i;
110 * ( target + j ) |= ( ( * ( c + 1 ) &
bitk[i - 1] ) >> k );
112 if ( * ( target + j ) != -1 )
117 * ( target + nc ) =
'\0';
143 if ( bit_length > 32 || bit_length == 0 )
153 c = source + ( *bit0_offset + d ) / 8;
154 i = ( *bit0_offset + d ) % 8;
156 *target += ( 1U << ( r - 1 ) );
163 *bit0_offset += bit_length;
190 if ( bit_length > 32 || bit_length == 0 )
193 if ( bit_length < 8 )
198 c = source + ( *bit0_offset ) / 8;
199 i = ( *bit0_offset ) % 8;
200 x = ( ( uint64_t ) ( *c &
biti[i] ) << 32 ) + ( ( uint64_t ) ( * ( c + 1 ) ) << 24 ) + ( ( uint64_t ) ( * ( c + 2 ) ) << 16 ) +
201 ( ( uint64_t ) ( * ( c + 3 ) ) << 8 ) + ( uint64_t ) ( * ( c + 4 ) );
202 x >>= ( 40 - i - bit_length );
203 *target = ( uint32_t ) x;
204 if ( ( 1UL << bit_length ) != ( x + 1UL ) )
207 *bit0_offset += bit_length;
228 if ( bits > 32 || bits == 0 )
232 mask = ( ( uint32_t ) 1 << ( bits - 1 ) );
237 *target = - ( int32_t ) ( source - mask );
240 *target = ( int32_t ) ( source );
255 return ( ( uint32_t ) source[1] + ( uint32_t ) source[0] * 256 );
268 return ( ( uint32_t ) source[2] + ( uint32_t ) source[1] * 256 + ( uint32_t ) source[0] * 65536 );
283 d->
x = (
id % 100000 ) / 1000;
285 sprintf ( d->
c,
"%06u",
id );
302 d->
x = source[0] & 0x3f;
303 d->
f = ( source[0] >> 6 ) & 0x03;
304 sprintf ( d->
c,
"%u%02u%03u", d->
f, d->
x, d->
y );
321 memcpy ( s , buf, size );
340 while ( l && s[--l] ==
' ' )
355 if ( ( d->
f == 0 ) &&
357 ( d->
y == 1 || d->
y == 2 || d->
y == 11 || d->
y == 12 ) )
373 if ( ( d->
f == 0 ) &&
392 if ( ( d->
f == 0 ) &&
417 sprintf ( aux,
"%%17.%dlf " , escale );
418 snprintf ( fmt, dim, aux, val );
421 snprintf ( fmt, dim,
"%17.0lf " , val );
443 sprintf ( aux,
"%%.%dlf" , escale );
444 snprintf ( fmt, dim, aux, val );
447 snprintf ( fmt, dim,
"%.0lf" , val );
496 for ( j = 0; j < bm->
nb ; j++ )
507 for (k = 0; k < bm->
nq; k++)
522 for (k = 0; k < bm->
ns1; k++)
531 for (k = 0; k < bm->
nds; k++)
561 wrote = fwrite( &(off->
nr), sizeof (
buf_t ), 1, f);
564 wrote = fwrite( &(off->
ofs[0]), sizeof (
buf_t ), off->
nr, f);
583 readed = fread( &(off->
nr), sizeof (
buf_t ), 1, f);
586 readed = fread( &(off->
ofs[0]), sizeof (
buf_t ), off->
nr, f);
Include header file for bufrdeco library.
uint32_t buf_t
Type to set offsets and dimension of arrays or counters used in bufrdeco.
#define bufrdeco_assert_with_return_val(__my_expr__, __returnval__)
Check a expression and returns a given value if it fails.
#define BUFR_MAX_BITMAP_PRESENT_DATA
Max number of data present in a bitmap definition.
buf_t get_bits_as_char_array(char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
uint32_t two_bytes_to_uint32(const uint8_t *source)
returns the uint32_t value from an array of two bytes, most significant first
uint32_t three_bytes_to_uint32(const uint8_t *source)
returns the uint32_t value from an array of three bytes, most significant first
int get_table_b_reference_from_uint32_t(int32_t *target, uint8_t bits, uint32_t source)
Get an int32_t from bits according with bufr criteria to change the reference of a descritor....
int uint32_t_to_descriptor(struct bufr_descriptor *d, uint32_t id)
parse an integer with a descriptor fom bufr ECWMF libary
int is_a_local_descriptor(struct bufr_descriptor *d)
check if a descriptor is a local descriptor
int bufrdeco_add_to_bitmap(struct bufrdeco_bitmap *bm, buf_t index_to, buf_t index_by)
Push a bitmap element in a bufrdeco_bitmap.
int bufr_write_subset_offset_bits(FILE *f, struct bufrdeco_subset_bit_offsets *off)
Write offset bit array for subsets in a non-compressed bufr.
char * bufr_charray_to_string(char *s, char *buf, size_t size)
get a null termitated c-string from an array of unsigned chars
char * get_formatted_value_from_escale2(char *fmt, size_t dim, int32_t escale, double val)
gets a string with formatted value depending of scale
buf_t get_bits_as_char_array2(char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
int bufr_read_subset_offset_bits(FILE *f, struct bufrdeco_subset_bit_offsets *off)
Write offset bit array for subsets in a non-compressed bufr.
char * get_formatted_value_from_escale(char *fmt, size_t dim, int32_t escale, double val)
gets a string with formatted value depending of scale
uint32_t get_bits_as_uint32_t(uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
int is_a_delayed_descriptor(struct bufr_descriptor *d)
check if a descriptor is a delayed descriptor
uint32_t get_bits_as_uint32_t2(uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
Read bits from an array of uint8_t and set them as an uint32_t.
char * bufr_adjust_string(char *s)
Supress trailing blanks of a string.
int two_bytes_to_descriptor(struct bufr_descriptor *d, const uint8_t *source)
set a struct bufr_descriptor from two consecutive bytes in bufr file
int is_a_short_delayed_descriptor(struct bufr_descriptor *d)
check if a descriptor is a short delayed descriptor
int get_bitmaped_info(struct bufrdeco_bitmap_related_vars *brv, uint32_t target, struct bufrdeco *b)
Get bitmap info searching into bitmaps.
struct bufrdeco_bitmap * bmap[BUFR_MAX_BITMAPS]
Stores all needed data for a bufr bitmap.
buf_t bitmaped_by[BUFR_MAX_BITMAP_PRESENT_DATA]
buf_t dstat[BUFR_MAX_QUALITY_DATA]
buf_t stat1[BUFR_MAX_QUALITY_DATA]
buf_t quality[BUFR_MAX_QUALITY_DATA]
buf_t bitmap_to[BUFR_MAX_BITMAP_PRESENT_DATA]
Array of offset in bits for every subset in a non-compressed bufr. Offset is counted in bits from the...
buf_t ofs[BUFR_MAX_SUBSETS]
This struct contains all needed data to parse and decode a BUFR file.
struct bufrdeco_bitmap_array bitmap