64 void stseq( f77int *lun, f77int *irepct, f77int *idn,
char nemo[8],
65 char cseq[55], f77int cdesc[], f77int *ncdesc )
67 f77int i, j, nb, nd, ipt, ix, iy, iret, nbits;
68 f77int i0 = 0, imxcd, rpidn, pkint, ilen;
70 char tab, adn[7], adn2[7], nemo2[9], units[10], errstr[129];
71 char rpseq[56], card[80], cblk =
' ';
78 #ifdef DYNAMIC_ALLOCATION
89 static f77int naf, iafpk[MXNAF];
95 numtbd( lun, idn, nemo2, &tab, &iret,
sizeof( nemo2 ),
sizeof( tab ) );
96 if ( ( iret > 0 ) && ( tab ==
'D' ) )
return;
102 nd =
igetntbi( lun, &tab,
sizeof ( tab ) );
103 cadn30( idn, adn,
sizeof( adn ) );
104 stntbi( &nd, lun, adn, nemo, cseq,
sizeof( adn ), 8, 55 );
111 for ( i = 0; i < *ncdesc; i++ ) {
112 cadn30( &cdesc[i], adn,
sizeof( adn ) );
113 if ( adn[0] ==
'3' ) {
119 nummtb( &cdesc[i], &tab, &ipt );
129 sprintf( rpseq,
"REPLICATION SEQUENCE %.3lu",
130 (
unsigned long ) ++(*irepct) );
131 memset( &rpseq[24], (
int) cblk, 31 );
132 sprintf( nemo2,
"RPSEQ%.3lu", (
unsigned long ) *irepct );
134 stseq( lun, irepct, &rpidn, nemo2, rpseq,
135 &MSTABS_BASE(idefxy)[
icvidx(&ipt,&i0,&imxcd)],
136 &MSTABS_BASE(ndelem)[ipt] );
144 stseq( lun, irepct, &cdesc[i], &MSTABS_BASE(cdmnem)[ipt][0],
145 &MSTABS_BASE(cdseq)[ipt][0],
146 &MSTABS_BASE(idefxy)[
icvidx(&ipt,&i0,&imxcd)],
147 &MSTABS_BASE(ndelem)[ipt] );
151 else if ( adn[0] ==
'2' ) {
155 strnum( &adn[1], &ix, 2 );
156 strnum( &adn[3], &iy, 3 );
158 if ( ( ( ix >= 4 ) && ( ix <= 6 ) ) || (
imrkopr( adn, 6 ) ) ) {
164 strncpy( nemo2, adn, 6 );
165 memset( &nemo2[6], (
int) cblk, 2 );
167 if ( ( ix == 4 ) && ( iy == 0 ) ) {
172 sprintf( errstr,
"BUFRLIB: STSEQ - TOO MANY ASSOCIATED"
173 " FIELD CANCELLATION OPERATORS" );
174 bort( errstr, ( f77int ) strlen( errstr ) );
182 nemtab( lun, nemo2, &pkint, &tab, &iret, 8,
sizeof( tab ) );
183 if ( ( iret == 0 ) || ( tab !=
'B' ) ) {
188 nb =
igetntbi( lun, &tab,
sizeof( tab ) );
191 sprintf( rpseq,
"Associated field of %3lu bits",
192 (
unsigned long ) iy );
194 strcpy( units,
"NUMERIC" );
196 else if ( ix == 5 ) {
197 sprintf( rpseq,
"Text string of %3lu bytes",
198 (
unsigned long ) iy );
200 strcpy( units,
"CCITT IA5" );
202 else if ( ix == 6 ) {
203 sprintf( rpseq,
"Local descriptor of %3lu bits",
204 (
unsigned long ) iy );
207 strcpy( units,
"CCITT IA5" );
210 strcpy( units,
"NUMERIC" );
216 sprintf( rpseq,
"Substituted value" );
218 else if ( ix == 24 ) {
219 sprintf( rpseq,
"First-order statistical value" );
221 else if ( ix == 25 ) {
222 sprintf( rpseq,
"Difference statistical value" );
224 else if ( ix == 32 ) {
225 sprintf( rpseq,
"Replaced/retained value" );
229 strcpy( units,
"NUMERIC" );
231 ilen = ( f77int ) strlen( rpseq );
232 memset( &rpseq[ilen], (
int) cblk, 55 - ilen );
238 pkint = (
igettdi( lun ) - 49152 );
239 cadn30( &pkint, adn2,
sizeof( adn2 ) );
241 stntbi( &nb, lun, adn2, nemo2, rpseq,
242 sizeof( adn2 ), 8, 55 );
245 memset( card, (
int) cblk,
sizeof( card ) );
247 strncpy( &card[2], nemo2, 8 );
248 strncpy( &card[16],
"0", 1 );
249 strncpy( &card[30],
"0", 1 );
250 sprintf( &card[33],
"%4lu", (
unsigned long ) nbits );
251 strncpy( &card[40], units, strlen( units ) );
252 elemdx( card, lun,
sizeof( card ) );
258 if ( naf >= MXNAF ) {
259 sprintf( errstr,
"BUFRLIB: STSEQ - TOO MANY ASSOCIATED"
260 " FIELDS ARE IN EFFECT AT THE SAME TIME" );
261 bort( errstr, ( f77int ) strlen( errstr ) );
263 iafpk[naf++] = pkint;
270 if ( ++i >= *ncdesc ) {
271 sprintf( errstr,
"BUFRLIB: STSEQ - COULD NOT FIND LOCAL"
272 " DESCRIPTOR PLACEHOLDER FOR %s", adn );
273 bort( errstr, ( f77int ) strlen( errstr ) );
281 else if ( adn[0] ==
'1' ) {
290 strnum( &adn[3], &iy, 3 );
297 if ( ( i+1 ) >= *ncdesc ) {
298 sprintf( errstr,
"BUFRLIB: STSEQ - COULD NOT FIND DELAYED "
299 "DESCRIPTOR REPLICATION FACTOR FOR %s", adn );
300 bort( errstr, ( f77int ) strlen( errstr ) );
302 else if ( cdesc[i+1] ==
ifxy(
"031002", 6 ) ) {
303 pkint =
ifxy(
"360001", 6 );
305 else if ( cdesc[i+1] ==
ifxy(
"031001", 6 ) ) {
306 pkint =
ifxy(
"360002", 6 );
308 else if ( cdesc[i+1] ==
ifxy(
"031000", 6 ) ) {
309 pkint =
ifxy(
"360004", 6 );
312 sprintf( errstr,
"BUFRLIB: STSEQ - UNKNOWN DELAYED "
313 "DESCRIPTOR REPLICATION FACTOR FOR %s", adn );
314 bort( errstr, ( f77int ) strlen( errstr ) );
319 pkint =
ifxy(
"101000", 6 ) + iy;
326 pktdd( &nd, lun, &pkint, &iret );
328 strncpy( nemo2, nemo, 8 );
330 sprintf( errstr,
"BUFRLIB: STSEQ - BAD RETURN FROM PKTDD WHEN "
331 "STORING REPLICATOR FOR PARENT MNEMONIC %s", nemo2 );
332 bort( errstr, ( f77int ) strlen( errstr ) );
335 strnum( &adn[1], &ix, 2 );
340 if ( ix > ( *ncdesc - i ) ) {
341 sprintf( errstr,
"BUFRLIB: STSEQ - NOT ENOUGH REMAINING CHILD "
342 "DESCRIPTORS TO COMPLETE REPLICATION FOR %s", adn );
343 bort( errstr, ( f77int ) strlen( errstr ) );
345 else if ( ( ix == 1 ) && ( cdesc[i] >=
ifxy (
"300000", 6 ) ) ) {
351 nummtb( &cdesc[i], &tab, &ipt );
352 stseq( lun, irepct, &cdesc[i], &MSTABS_BASE(cdmnem)[ipt][0],
353 &MSTABS_BASE(cdseq)[ipt][0],
354 &MSTABS_BASE(idefxy)[
icvidx(&ipt,&i0,&imxcd)],
355 &MSTABS_BASE(ndelem)[ipt] );
365 #ifdef DYNAMIC_ALLOCATION
366 if ( ( rpdesc = malloc( imxcd *
sizeof(f77int) ) ) == NULL ) {
367 sprintf( errstr,
"BUFRLIB: STSEQ - UNABLE TO ALLOCATE SPACE"
369 bort( errstr, ( f77int ) strlen( errstr ) );
372 for ( j = 0; j < ix; j++ ) {
373 rpdesc[j] = cdesc[i+j];
378 sprintf( rpseq,
"REPLICATION SEQUENCE %.3lu",
379 (
unsigned long ) ++(*irepct) );
380 memset( &rpseq[24], (
int) cblk, 31 );
381 sprintf( nemo2,
"RPSEQ%.3lu", (
unsigned long ) *irepct );
383 stseq( lun, irepct, &rpidn, nemo2, rpseq, rpdesc, &ix );
385 #ifdef DYNAMIC_ALLOCATION
398 numtbd( lun, &cdesc[i], nemo2, &tab, &iret,
sizeof( nemo2 ),
400 if ( ( iret == 0 ) || ( tab !=
'B' ) ) {
404 nummtb( &cdesc[i], &tab, &ipt );
408 nb =
igetntbi( lun, &tab,
sizeof( tab ) );
409 cadn30( &cdesc[i], adn2,
sizeof( adn2 ) );
410 stntbi( &nb, lun, adn2, &MSTABS_BASE(cbmnem)[ipt][0],
411 &MSTABS_BASE(cbelem)[ipt][0],
sizeof( adn2 ), 8, 55 );
414 memset( card, (
int) cblk,
sizeof( card ) );
416 strncpy( &card[2], &MSTABS_BASE(cbmnem)[ipt][0], 8 );
417 strncpy( &card[13], &MSTABS_BASE(cbscl)[ipt][0], 4 );
418 strncpy( &card[19], &MSTABS_BASE(cbsref)[ipt][0], 12 );
419 strncpy( &card[33], &MSTABS_BASE(cbbw)[ipt][0], 4 );
420 strncpy( &card[40], &MSTABS_BASE(cbunit)[ipt][0], 14 );
421 elemdx( card, lun,
sizeof( card ) );
425 if ( strncmp( adn,
"204", 3 ) != 0 ) {
434 if ( ( naf > 0 ) && ( pkint <
ifxy(
"100000", 6 ) ) &&
435 ( ( pkint <
ifxy(
"031000", 6 ) ) ||
436 ( pkint >
ifxy(
"031255", 6 ) ) ) ) {
437 for ( j = 0; j < naf; j++ ) {
438 pktdd( &nd, lun, &iafpk[j], &iret );
440 sprintf( errstr,
"BUFRLIB: STSEQ - BAD RETURN FROM PKTDD "
441 "WHEN STORING ASSOCIATED FIELDS" );
442 bort( errstr, ( f77int ) strlen( errstr ) );
449 pktdd( &nd, lun, &pkint, &iret );
451 strncpy( nemo2, nemo, 8 );
453 sprintf( errstr,
"BUFRLIB: STSEQ - BAD RETURN FROM PKTDD WHEN "
454 "STORING CHILD FOR PARENT MNEMONIC %s", nemo2 );
455 bort( errstr, ( f77int ) strlen( errstr ) );
Define signatures to enable a number of BUFRLIB subprograms to be called directly from C application ...
void stseq(f77int *lun, f77int *irepct, f77int *idn, char nemo[8], char cseq[55], f77int cdesc[], f77int *ncdesc)
C C SUBPROGRAM: STSEQ C PRGMMR: ATOR ORG: NP12 DATE: 2009-03-23 C C ABSTRACT: USING THE BUFR MASTER T...
void nummtb(f77int *idn, char *tab, f77int *ipt)
C C SUBPROGRAM: NUMMTB C PRGMMR: ATOR ORG: NP12 DATE: 2009-03-23 C C ABSTRACT: THIS ROUTINE SEARCHES ...
subroutine strnum(STR, NUM)
THIS SUBROUTINE DECODES AN INTEGER FROM A CHARACTER STRING.
INTEGER function igetprm(CPRMNM)
This function returns the current value of a parameter used for allocating one or more internal array...
function igettdi(IFLAG)
DEPENDING ON THE VALUE OF THE INPUT FLAG, THIS FUNCTION EITHER RETURNS THE NEXT USABLE SCRATCH TABLE ...
subroutine numtbd(LUN, IDN, NEMO, TAB, IRET)
THIS SUBROUTINE SEARCHES FOR AN INTEGER IDN, CONTAINING THE BIT-WISE REPRESENTATION OF A DESCRIPTOR (...
function ifxy(ADSC)
THIS FUNCTION RETURNS THE INTEGER CORRESPONDING TO THE BIT-WISE REPRESENTATION OF AN INPUT CHARACTER ...
subroutine cadn30(IDN, ADN)
GIVEN THE BIT-WISE REPRESENTATION OF THE FXY VALUE FOR A DESCRIPTOR, THIS ROUTINE CALLS FUNCTION ADN3...
function igetntbi(LUN, CTB)
THIS FUNCTION RETURNS THE NEXT AVAILABLE INDEX FOR STORING AN ENTRY WITHIN INTERNAL BUFR TABLE CTB...
subroutine pktdd(ID, LUN, IDN, IRET)
THIS SUBROUTINE STORES INFORMATION ABOUT A "CHILD" MNEMONIC WITHIN THE INTERNAL BUFR TABLE D ENTRY (I...
subroutine stntbi(N, LUN, NUMB, NEMO, CELSQ)
THIS SUBROUTINE STORES A NEW ENTRY WITHIN INTERNAL BUFR TABLE B OR D, DEPENDING ON THE VALUE OF NUMB...
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
THIS SUBROUTINE SEARCHES FOR MNEMONIC NEMO WITHIN THE INTERNAL TABLE B AND D ARRAYS HOLDING THE DICTI...
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
subroutine elemdx(CARD, LUN)
THIS SUBROUTINE DECODES THE SCALE FACTOR, REFERENCE VALUE, BIT WIDTH AND UNITS (I.E., THE "ELEMENTS") FROM A TABLE B MNEMONIC DEFINITION CARD THAT WAS PREVIOUSLY READ FROM A USER-SUPPLIED BUFR DICTIONARY TABLE FILE IN CHARACTER FORMAT BY BUFR ARCHIVE LIBRARY SUBROUTINE RDUSDX.
Define signatures and declare variables for internal storage of master Table B and Table D entries...
INTEGER function imrkopr(NEMO)
This function determines whether a specified mnemonic is a Table C marker operator.
f77int icvidx(f77int *ii, f77int *jj, f77int *numjj)
C C SUBPROGRAM: ICVIDX C PRGMMR: ATOR ORG: NP12 DATE: 2009-03-23 C C ABSTRACT: THIS ROUTINE COMPUTES ...