46 void crbmg(
char *bmg, f77int *mxmb, f77int *nmb, f77int *iret )
48 f77int i1 = 1, i2 = 2, i3 = 3, i4 = 4, i24 = 24;
50 f77int iben, isbyt, iwid;
54 unsigned short i, nsecs;
59 if (
pbf[0] == NULL ) {
60 sprintf( errstr,
"BUFRLIB: CRBMG - NO FILE IS OPEN FOR READING" );
61 bort( errstr, ( f77int ) strlen( errstr ) );
70 strncpy( bmg,
" ", 4);
74 while (
ichkstr(
"BUFR", bmg, &i4, 4, 4 ) != 0 ) {
75 memmove( bmg, &bmg[1], 3 );
76 if ( ( *iret =
rbytes( bmg, mxmb, 3, 1 ) ) != 0 )
return;
82 if ( ( *iret =
rbytes( bmg, mxmb, 4, 4 ) ) != 0 )
return;
83 memcpy( wkint, bmg, 8 );
84 iben =
iupbs01( wkint,
"BEN", 3 );
90 *nmb =
iupbs01( wkint,
"LENM", 4 );
94 if ( ( *iret =
rbytes( bmg, mxmb, 8, *nmb-8 ) ) != 0 )
return;
107 gets1loc(
"LEN1", &iben, &isbyt, &iwid, &wkint[0], 4 );
108 *nmb = lsec +
iupm( &bmg[lsec+isbyt-1], &iwid, 3 );
112 if ( ( *iret =
rbytes( bmg, mxmb, 8, *nmb-8 ) ) != 0 )
return;
116 gets1loc(
"ISC2", &iben, &isbyt, &iwid, &wkint[0], 4 );
117 nsecs =
iupm( &bmg[lsec+isbyt-1], &iwid, 1 ) + 2;
121 for ( i = 1; i <= nsecs; i++ ) {
122 if ( ( *iret =
rbytes( bmg, mxmb, *nmb, 3 ) ) != 0 )
return;
123 lsec =
iupm( &bmg[*nmb], &i24, 3 );
124 if ( ( *iret =
rbytes( bmg, mxmb, *nmb+3, lsec-3 ) ) != 0 )
return;
130 if ( ( *iret =
rbytes( bmg, mxmb, *nmb, 4 ) ) != 0 )
return;
136 if ( *nmb + 4 > *mxmb ) {
140 memmove( &bmg[8], &bmg[4], *nmb-4 );
142 ipkm( &bmg[4], &i3, nmb, 3 );
143 ipkm( &bmg[7], &i1, &i2, 1 );
148 *iret = ( (
ichkstr(
"7777", &bmg[*nmb-4], &i4, 4, 4 ) == 0 ) ? 0 : 2 );
Define signatures to enable a number of BUFRLIB subprograms to be called directly from C application ...
FILE * pbf[2]
File pointers.
function iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...
function ichkstr(STR, CHR, N)
THIS FUNCTION COMPARES A SPECIFIED NUMBER OF CHARACTERS FROM AN INPUT CHARACTER ARRAY AGAINST THE SAM...
subroutine gets1loc(S1MNEM, IBEN, ISBYT, IWID, IRET)
THIS SUBROUTINE RETURNS THE LOCATION (I.E.
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...
void crbmg(char *, f77int *, f77int *, f77int *)
This subroutine reads the next BUFR message from the system file that was opened via the most recent ...
subroutine ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string...
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message...