48void crbmg(
char *bmg, f77int *mxmb, f77int *nmb, f77int *iret )
50 f77int i1 = 1, i2 = 2, i3 = 3, i4 = 4, i24 = 24;
52 f77int iben, isbyt, iwid;
56 unsigned short i, nsecs;
61 if (
pbf[0] == NULL ) {
62 sprintf( errstr,
"BUFRLIB: CRBMG - NO FILE IS OPEN FOR READING" );
63 bort( errstr, ( f77int ) strlen( errstr ) );
72 strncpy( bmg,
" ", 4);
76 while (
ichkstr(
"BUFR", bmg, &i4, 4, 4 ) != 0 ) {
77 memmove( bmg, &bmg[1], 3 );
78 if ( ( *iret =
rbytes( bmg, mxmb, 3, 1 ) ) != 0 )
return;
84 if ( ( *iret =
rbytes( bmg, mxmb, 4, 4 ) ) != 0 )
return;
85 memcpy( wkint, bmg, 8 );
86 iben =
iupbs01( wkint,
"BEN", 3 );
92 *nmb =
iupbs01( wkint,
"LENM", 4 );
96 if ( ( *iret =
rbytes( bmg, mxmb, 8, *nmb-8 ) ) != 0 )
return;
109 gets1loc(
"LEN1", &iben, &isbyt, &iwid, &wkint[0], 4 );
110 *nmb = lsec +
iupm( &bmg[lsec+isbyt-1], &iwid, 3 );
114 if ( ( *iret =
rbytes( bmg, mxmb, 8, *nmb-8 ) ) != 0 )
return;
118 gets1loc(
"ISC2", &iben, &isbyt, &iwid, &wkint[0], 4 );
119 nsecs =
iupm( &bmg[lsec+isbyt-1], &iwid, 1 ) + 2;
123 for ( i = 1; i <= nsecs; i++ ) {
124 if ( ( *iret =
rbytes( bmg, mxmb, *nmb, 3 ) ) != 0 )
return;
125 lsec =
iupm( &bmg[*nmb], &i24, 3 );
126 if ( ( *iret =
rbytes( bmg, mxmb, *nmb+3, lsec-3 ) ) != 0 )
return;
132 if ( ( *iret =
rbytes( bmg, mxmb, *nmb, 4 ) ) != 0 )
return;
138 if ( *nmb + 4 > *mxmb ) {
142 memmove( &bmg[8], &bmg[4], *nmb-4 );
144 ipkm( &bmg[4], &i3, nmb, 3 );
145 ipkm( &bmg[7], &i1, &i2, 1 );
150 *iret = ( (
ichkstr(
"7777", &bmg[*nmb-4], &i4, 4, 4 ) == 0 ) ? 0 : 2 );
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Define signatures to enable a number of BUFRLIB subprograms to be called directly from C application ...
Define signatures and declare variables for reading or writing BUFR messages via a C language interfa...
f77int rbytes(char *, f77int *, f77int, f77int)
This function reads a specified number of bytes from the system file that was opened via the most rec...
FILE * pbf[2]
File pointers.
void crbmg(char *bmg, f77int *mxmb, f77int *nmb, f77int *iret)
This subroutine reads the next BUFR message from the system file that was opened via the most recent ...
subroutine gets1loc(S1MNEM, IBEN, ISBYT, IWID, IRET)
THIS SUBROUTINE RETURNS THE LOCATION (I.E.
function ichkstr(STR, CHR, N)
THIS FUNCTION COMPARES A SPECIFIED NUMBER OF CHARACTERS FROM AN INPUT CHARACTER ARRAY AGAINST THE SAM...
subroutine ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string,...
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message.
function iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...