NCEPLIBS-bufr  12.0.1
sntbde.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Store a master Table D entry into Fortran arrays
3 C>
4 C> @author J. Ator @date 2007-01-19
5 
6 C> This subroutine stores the first line of an entry that was
7 C> previously read from an ASCII master Table D file into a set of
8 C> merged Fortran arrays. It then reads and stores all remaining
9 C> lines of that same entry into the same merged Fortran arrays.
10 C>
11 C> @param[in] LUNT -- integer: Fortran logical unit number for
12 C> ASCII file containing Table D information
13 C> @param[in] IFXYN -- integer: Bit-wise representation of FXY number
14 C> @param[in] LINE -- character*(*): First line of Table D entry
15 C> @param[in] MXMTBD -- integer: Dimensioned size (in integers) of
16 C> merged output arrays; used by the subroutine
17 C> to ensure that it doesn't overflow these
18 C> arrays
19 C> @param[in] MXELEM -- integer: Maximum number of elements to be
20 C> stored per Table D sequence within merged
21 C> output arrays; used by the subroutine to
22 C> ensure that it doesn't overflow these arrays
23 C> @param[out] NMTBD -- integer: Number of entries in merged output
24 C> arrays
25 C> @param[out] IMFXYN -- integer(*): Merged array containing bit-wise
26 C> representations of FXY numbers
27 C> @param[out] CMMNEM -- character*8(*): Merged array containing
28 C> mnemonics
29 C> @param[out] CMDSC -- character*4(*): Merged array containing
30 C> descriptor codes
31 C> @param[out] CMSEQ -- character*120(*): Merged array containing
32 C> sequence names
33 C> @param[out] NMELEM -- integer(*): Merged array containing number of
34 C> elements stored for each sequence
35 C> @param[out] IEFXYN -- integer(*,*): Merged array containing bit-wise
36 C> representations of element FXY numbers
37 C> @param[out] CEELEM -- character*120(*,*): Merged array containing
38 C> element names
39 C>
40 C> @author J. Ator @date 2007-01-19
41  SUBROUTINE sntbde ( LUNT, IFXYN, LINE, MXMTBD, MXELEM,
42  . NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ,
43  . NMELEM, IEFXYN, CEELEM )
44 
45  CHARACTER*(*) LINE
46  CHARACTER*200 TAGS(10), CLINE
47  CHARACTER*128 BORT_STR1, BORT_STR2
48  CHARACTER*120 CEELEM(MXMTBD,MXELEM)
49  CHARACTER*6 ADN30, ADSC, CLEMON
50  CHARACTER*4 CMDSC(*)
51  CHARACTER CMSEQ(120,*)
52  CHARACTER CMMNEM(8,*)
53 
54  INTEGER IMFXYN(*), NMELEM(*),
55  . IEFXYN(MXMTBD,MXELEM)
56 
57  LOGICAL DONE
58 
59 C-----------------------------------------------------------------------
60 C-----------------------------------------------------------------------
61 
62  IF ( nmtbd .GE. mxmtbd ) GOTO 900
63  nmtbd = nmtbd + 1
64 
65 C Store the FXY number. This is the sequence descriptor.
66 
67  imfxyn( nmtbd ) = ifxyn
68 
69 C Is there any other information within the first line of the
70 C table entry? If so, it follows a "|" separator.
71 
72  DO ii = 1, 8
73  cmmnem( ii, nmtbd ) = ' '
74  ENDDO
75  cmdsc( nmtbd ) = ' '
76  DO ii = 1, 120
77  cmseq( ii, nmtbd ) = ' '
78  ENDDO
79  ipt = index( line, '|' )
80  IF ( ipt .NE. 0 ) THEN
81 
82 C Parse the rest of the line. Any of the fields may be blank.
83 
84  CALL parstr ( line(ipt+1:), tags, 10, ntag, ';', .false. )
85  IF ( ntag .GT. 0 ) THEN
86 C The first additional field contains the mnemonic.
87  tags(1) = adjustl( tags(1) )
88 C If there is a mnemonic, then make sure it's legal.
89  IF ( ( tags(1) .NE. ' ' ) .AND.
90  . ( nemock( tags(1) ) .NE. 0 ) ) THEN
91  bort_str2 = ' HAS ILLEGAL MNEMONIC'
92  GOTO 901
93  ENDIF
94  DO ii = 1, 8
95  cmmnem( ii, nmtbd ) = tags(1)(ii:ii)
96  ENDDO
97  ENDIF
98  IF ( ntag .GT. 1 ) THEN
99 C The second additional field contains descriptor codes.
100  tags(2) = adjustl( tags(2) )
101  cmdsc( nmtbd ) = tags(2)(1:4)
102  ENDIF
103  IF ( ntag .GT. 2 ) THEN
104 C The third additional field contains the sequence name.
105  tags(3) = adjustl( tags(3) )
106  DO ii = 1, 120
107  cmseq( ii, nmtbd ) = tags(3)(ii:ii)
108  ENDDO
109  ENDIF
110  ENDIF
111 
112 C Now, read and parse all remaining lines from this table entry.
113 C Each line should contain an element descriptor for the sequence
114 C represented by the current sequence descriptor.
115 
116  nelem = 0
117  done = .false.
118  DO WHILE ( .NOT. done )
119  IF ( igetntbl( lunt, cline ) .NE. 0 ) THEN
120  bort_str2 = ' IS INCOMPLETE'
121  GOTO 901
122  ENDIF
123  CALL parstr ( cline, tags, 10, ntag, '|', .false. )
124  IF ( ntag .LT. 2 ) THEN
125  bort_str2 = ' HAS BAD ELEMENT CARD'
126  GOTO 901
127  ENDIF
128 
129 C The second field contains the FXY number for this element.
130 
131  IF ( igetfxy( tags(2), adsc ) .NE. 0 ) THEN
132  bort_str2 = ' HAS BAD OR MISSING' //
133  . ' ELEMENT FXY NUMBER'
134  GOTO 901
135  ENDIF
136  IF ( nelem .GE. mxelem ) GOTO 900
137  nelem = nelem + 1
138  iefxyn( nmtbd, nelem ) = ifxy( adsc )
139 
140 C The third field (if it exists) contains the element name.
141 
142  IF ( ntag .GT. 2 ) THEN
143  tags(3) = adjustl( tags(3) )
144  ceelem( nmtbd, nelem ) = tags(3)(1:120)
145  ELSE
146  ceelem( nmtbd, nelem ) = ' '
147  ENDIF
148 
149 C Is this the last line for this table entry?
150 
151  IF ( index( tags(2), ' >' ) .EQ. 0 ) done = .true.
152  ENDDO
153  nmelem( nmtbd ) = nelem
154 
155  RETURN
156 
157  900 CALL bort('BUFRLIB: SNTBDE - OVERFLOW OF MERGED ARRAYS')
158  901 clemon = adn30( ifxyn, 6 )
159  WRITE(bort_str1,'("BUFRLIB: SNTBDE - TABLE D ENTRY FOR' //
160  . ' SEQUENCE DESCRIPTOR: ",5A)')
161  . clemon(1:1), '-', clemon(2:3), '-', clemon(4:6)
162  CALL bort2(bort_str1,bort_str2)
163  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
function ifxy(ADSC)
Convert an FXY value from its 6 character representation to its WMO bit-wise representation.
Definition: ifxy.f:34
function igetfxy(STR, CFXY)
This function looks for and returns a valid FXY number from within the given input string.
Definition: igetfxy.f:20
function igetntbl(LUNT, LINE)
This subroutine reads the next line from an ASCII master table B, table D or Code/Flag table file,...
Definition: igetntbl.f:24
function nemock(NEMO)
This function checks a mnemonic to verify that it has a length of between 1 and 8 characters and that...
Definition: nemock.f:18
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
Parse a string containing one or more substrings into an array of substrings.
Definition: parstr.f:24
subroutine sntbde(LUNT, IFXYN, LINE, MXMTBD, MXELEM, NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ, NMELEM, IEFXYN, CEELEM)
This subroutine stores the first line of an entry that was previously read from an ASCII master Table...
Definition: sntbde.f:44