NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
restd.c
Go to the documentation of this file.
1 
6 #include "bufrlib.h"
7 
55 void restd( f77int *lun, f77int *tddesc, f77int *nctddesc, f77int ctddesc[] )
56 {
57  f77int i0 = 0;
58 
59  f77int desc, ncdesc, cdesc[MAXNC];
60  f77int i, j, inum, itbd, ictbd;
61  f77int iscl, iref, ibit;
62 
63  char tab, nemo[9], adn[7], cunit[25];
64 
65 /*
66 ** How many child descriptors does *tddesc have?
67 */
68  numtbd( lun, tddesc, nemo, &tab, &itbd, 9, 1 );
69  uptdd( &itbd, lun, &i0, &inum );
70 
71  *nctddesc = 0;
72 /*
73 ** Examine each child descriptor one at a time.
74 */
75  for ( i = 1; i <= inum; i++ ) {
76  uptdd( &itbd, lun, &i, &desc );
77  if (! istdesc( &desc ) ) {
78 /*
79 ** desc is a local descriptor.
80 */
81  numtbd( lun, &desc, nemo, &tab, &ictbd, 9, 1 );
82  if ( tab == 'D' ) {
83 /*
84 ** desc is itself a local Table D descriptor, so resolve
85 ** it now via a recursive call to this same routine.
86 */
87  restd( lun, &desc, &ncdesc, cdesc );
88 
89  if ( ( *nctddesc > 0 ) &&
90  ( ctddesc[(*nctddesc)-1] > ifxy( "101000", 6 ) ) &&
91  ( ctddesc[(*nctddesc)-1] <= ifxy( "101255", 6 ) ) ) {
92 /*
93 ** desc is replicated using fixed replication, so write
94 ** the number of child descriptors into the X value of
95 ** the replication descriptor ctddesc[(*nctddesc)-1]
96 */
97  cadn30( &ctddesc[(*nctddesc)-1], adn, 7 );
98  sprintf( adn, "%c%02ld%c%c%c",
99  adn[0], (long) ncdesc, adn[3], adn[4], adn[5] );
100  ctddesc[(*nctddesc)-1] = ifxy( adn, 7 );
101  }
102  else if ( ( *nctddesc > 1 ) &&
103  ( ctddesc[(*nctddesc)-2] == ifxy( "101000", 6 ) ) ) {
104 /*
105 ** desc is replicated using delayed replication, so write
106 ** the number of child descriptors into the X value of
107 ** the replication descriptor ctddesc[(*nctddesc)-2]
108 */
109  cadn30( &ctddesc[(*nctddesc)-2], adn, 7 );
110  sprintf( adn, "%c%02ld%c%c%c",
111  adn[0], (long) ncdesc, adn[3], adn[4], adn[5] );
112  ctddesc[(*nctddesc)-2] = ifxy( adn, 7 );
113  }
114 /*
115 ** Add the child descriptors to the output list.
116 */
117  for ( j = 0; j < ncdesc; j++ ) {
118  wrdesc( cdesc[j], ctddesc, nctddesc );
119  }
120 
121  }
122  else if ( tab == 'B' ) {
123 /*
124 ** desc is a local Table B descriptor, so precede it with
125 ** a 206YYY operator in the output list.
126 */
127  nemtbb( lun, &ictbd, cunit, &iscl, &iref, &ibit, 25 );
128  sprintf( adn, "%c%c%c%03ld", '2', '0', '6', (long) ibit );
129  wrdesc( ifxy( adn, 7 ), ctddesc, nctddesc );
130  wrdesc( desc, ctddesc, nctddesc );
131  }
132  }
133  else {
134 /*
135 ** desc is a standard Table B, Table D, operator or replicator
136 ** descriptor, so append it "as is" to the output list.
137 */
138  wrdesc( desc, ctddesc, nctddesc );
139  }
140  }
141 
142  return;
143 }
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[])
C C SUBPROGRAM: RESTD C PRGMMR: ATOR ORG: NP12 DATE: 2004-08-18 C C ABSTRACT: GIVEN THE BIT-WISE REPR...
Definition: restd.c:55
function istdesc(IDN)
GIVEN THE BIT-WISE REPRESENTATION OF THE FXY VALUE FOR A DESCRIPTOR, THIS FUNCTION DETERMINES WHETHER...
Definition: istdesc.f:27
subroutine nemtbb(LUN, ITAB, UNIT, ISCL, IREF, IBIT)
THIS SUBROUTINE CHECKS ALL OF THE PROPERTIES (E.G.
Definition: nemtbb.f:49
subroutine numtbd(LUN, IDN, NEMO, TAB, IRET)
THIS SUBROUTINE SEARCHES FOR AN INTEGER IDN, CONTAINING THE BIT-WISE REPRESENTATION OF A DESCRIPTOR (...
Definition: numtbd.f:54
function ifxy(ADSC)
THIS FUNCTION RETURNS THE INTEGER CORRESPONDING TO THE BIT-WISE REPRESENTATION OF AN INPUT CHARACTER ...
Definition: ifxy.f:49
subroutine cadn30(IDN, ADN)
GIVEN THE BIT-WISE REPRESENTATION OF THE FXY VALUE FOR A DESCRIPTOR, THIS ROUTINE CALLS FUNCTION ADN3...
Definition: cadn30.f:29
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