1 /*$$$ SUBPROGRAM DOCUMENTATION BLOCK
4 C PRGMMR: ATOR ORG: NP12 DATE: 2009-03-23
6 C ABSTRACT: THIS ROUTINE SEARCHES FOR AN ENTRY CORRESPONDING TO IDN
7 C IN THE BUFR MASTER TABLE (EITHER 'B' OR 'D', DEPENDING ON THE VALUE
8 C OF IDN). THE SEARCH USES BINARY SEARCH LOGIC, SO ALL OF THE ENTRIES
9 C IN THE TABLE MUST BE SORTED IN ASCENDING ORDER (BY FXY NUMBER) IN
10 C ORDER FOR THIS ROUTINE TO WORK PROPERLY.
12 C PROGRAM HISTORY LOG:
13 C 2009-03-23 J. ATOR -- ORIGINAL AUTHOR
15 C USAGE: CALL NUMMTB( IDN, TAB, IPT )
16 C INPUT ARGUMENT LIST:
17 C IDN - INTEGER: BIT-WISE REPRESENTATION OF FXY VALUE TO BE
20 C OUTPUT ARGUMENT LIST:
21 C TAB - CHARACTER: TABLE IN WHICH IDN WAS FOUND ('B' OR 'D')
22 C IPT - INTEGER: INDEX OF ENTRY FOR IDN IN MASTER TABLE TAB
25 C THIS ROUTINE CALLS: BORT CADN30 CMPIA
26 C THIS ROUTINE IS CALLED BY: STSEQ
27 C Normally not called by any application
32 C MACHINE: PORTABLE TO ALL PLATFORMS
39 void nummtb( f77int
*idn
, char *tab
, f77int
*ipt
)
41 f77int
*pifxyn
, *pbs
, nmt
;
43 char adn
[7], errstr
[129];
45 if ( *idn
>= ifxy( "300000", 6 ) ) {
47 pifxyn
= &mstabs
.idfxyn
[0];
52 pifxyn
= &mstabs
.ibfxyn
[0];
56 pbs
= ( f77int
* ) bsearch( idn
, pifxyn
, ( size_t ) nmt
, sizeof( f77int
),
57 ( int (*) ( const void *, const void * ) ) cmpia
);
59 cadn30( idn
, adn
, sizeof( adn
) );
61 sprintf( errstr
, "BUFRLIB: NUMMTB - COULD NOT FIND DESCRIPTOR "
62 "%s IN MASTER TABLE %c", adn
, *tab
);
63 bort( errstr
, ( f77int
) strlen( errstr
) );