NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
restd.c
Go to the documentation of this file.
1 
5 #include "bufrlib.h"
6 
43 void restd( f77int *lun, f77int *tddesc, f77int *nctddesc, f77int ctddesc[] )
44 {
45  f77int i0 = 0;
46 
47  f77int desc, ncdesc, cdesc[MAXNC];
48  f77int i, j, inum, itbd, ictbd;
49  f77int iscl, iref, ibit;
50 
51  char tab, nemo[9], adn[7], cunit[25], cwork[31];
52 
53 /*
54 ** How many child descriptors does *tddesc have?
55 */
56  numtbd( lun, tddesc, nemo, &tab, &itbd, 9, 1 );
57  uptdd( &itbd, lun, &i0, &inum );
58 
59  *nctddesc = 0;
60 /*
61 ** Examine each child descriptor one at a time.
62 */
63  for ( i = 1; i <= inum; i++ ) {
64  uptdd( &itbd, lun, &i, &desc );
65  if (! istdesc( &desc ) ) {
66 /*
67 ** desc is a local descriptor.
68 */
69  numtbd( lun, &desc, nemo, &tab, &ictbd, 9, 1 );
70  if ( tab == 'D' ) {
71 /*
72 ** desc is itself a local Table D descriptor, so resolve
73 ** it now via a recursive call to this same routine.
74 */
75  restd( lun, &desc, &ncdesc, cdesc );
76 
77  if ( ( *nctddesc > 0 ) &&
78  ( ctddesc[(*nctddesc)-1] > ifxy( "101000", 6 ) ) &&
79  ( ctddesc[(*nctddesc)-1] <= ifxy( "101255", 6 ) ) ) {
80 /*
81 ** desc is replicated using fixed replication, so write
82 ** the number of child descriptors into the X value of
83 ** the replication descriptor ctddesc[(*nctddesc)-1]
84 */
85  cadn30( &ctddesc[(*nctddesc)-1], adn, 7 );
86  sprintf( cwork, "%c%02ld%c%c%c",
87  adn[0], (long) ncdesc, adn[3], adn[4], adn[5] );
88  strncpy( adn, cwork, 6 ); adn[6] = '\0';
89  ctddesc[(*nctddesc)-1] = ifxy( adn, 7 );
90  }
91  else if ( ( *nctddesc > 1 ) &&
92  ( ctddesc[(*nctddesc)-2] == ifxy( "101000", 6 ) ) ) {
93 /*
94 ** desc is replicated using delayed replication, so write
95 ** the number of child descriptors into the X value of
96 ** the replication descriptor ctddesc[(*nctddesc)-2]
97 */
98  cadn30( &ctddesc[(*nctddesc)-2], adn, 7 );
99  sprintf( cwork, "%c%02ld%c%c%c",
100  adn[0], (long) ncdesc, adn[3], adn[4], adn[5] );
101  strncpy( adn, cwork, 6 ); adn[6] = '\0';
102  ctddesc[(*nctddesc)-2] = ifxy( adn, 7 );
103  }
104 /*
105 ** Add the child descriptors to the output list.
106 */
107  for ( j = 0; j < ncdesc; j++ ) {
108  wrdesc( cdesc[j], ctddesc, nctddesc );
109  }
110 
111  }
112  else if ( tab == 'B' ) {
113 /*
114 ** desc is a local Table B descriptor, so precede it with
115 ** a 206YYY operator in the output list.
116 */
117  nemtbb( lun, &ictbd, cunit, &iscl, &iref, &ibit, 25 );
118  sprintf( cwork, "%c%c%c%03ld", '2', '0', '6', (long) ibit );
119  strncpy( adn, cwork, 6 ); adn[6] = '\0';
120  wrdesc( ifxy( adn, 7 ), ctddesc, nctddesc );
121  wrdesc( desc, ctddesc, nctddesc );
122  }
123  }
124  else {
125 /*
126 ** desc is a standard Table B, Table D, operator or replicator
127 ** descriptor, so append it "as is" to the output list.
128 */
129  wrdesc( desc, ctddesc, nctddesc );
130  }
131  }
132 
133  return;
134 }
Define signatures to enable a number of BUFRLIB subprograms to be called directly from C application ...
void restd(f77int *lun, f77int *tddesc, f77int *nctddesc, f77int ctddesc[])
Given the bit-wise (integer) representation of a local (not WMO-standard) Table D descriptor...
Definition: restd.c:43
function istdesc(IDN)
Given the bit-wise (integer) representation of a descriptor, this function determines whether the des...
Definition: istdesc.f:25
subroutine nemtbb(LUN, ITAB, UNIT, ISCL, IREF, IBIT)
This subroutine returns information about a Table B descriptor from the internal DX BUFR tables...
Definition: nemtbb.f:31
subroutine numtbd(LUN, IDN, NEMO, TAB, IRET)
This subroutine searches for a descriptor within Table B and Table D of the internal DX BUFR tables...
Definition: numtbd.f:35
function ifxy(ADSC)
This function converts an FXY value from its 6 character representation to its bit-wise (integer) rep...
Definition: ifxy.f:42
subroutine cadn30(IDN, ADN)
This subroutine converts an FXY value from its bit-wise (integer) representation to its 6 character r...
Definition: cadn30.f:23
void wrdesc(f77int desc, f77int descary[], f77int *ndescary)
C C SUBPROGRAM: WRDESC C PRGMMR: ATOR ORG: NP12 DATE: 2004-08-18 C C ABSTRACT: GIVEN THE BIT-WISE REP...
Definition: wrdesc.c:46
subroutine uptdd(ID, LUN, IENT, IRET)
THIS SUBROUTINE RETURNS THE BIT-WISE REPRESENTATION OF THE FXY VALUE CORRESPONDING TO...
Definition: uptdd.f:60