NCEPLIBS-bufr  12.0.0
sntbbe.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Store a master Table B entry into Fortran arrays
3 C>
4 C> @author J. Ator @date 2007-01-19
5 
6 C> This subroutine stores an entry that was previously read from an
7 C> ASCII master Table B file into a set of merged Fortran arrays.
8 C>
9 C> @param[in] IFXYN -- integer: Bit-wise representation of FXY number
10 C> @param[in] LINE -- character*(*): Table B entry
11 C> @param[in] MXMTBB -- integer: Dimensioned size (in integers) of
12 C> merged output arrays; used by the subroutine
13 C> to ensure that it doesn't overflow these
14 C> arrays
15 C> @param[out] NMTBB -- integer: Number of entries in merged output
16 C> arrays
17 C> @param[out] IMFXYN -- integer(*): Merged array containing bit-wise
18 C> representations of FXY numbers
19 C> @param[out] CMSCL -- character*4(*): Merged array containing
20 C> scale factors
21 C> @param[out] CMSREF -- character*12(*): Merged array containing
22 C> reference values
23 C> @param[out] CMBW -- character*4(*): Merged array containing
24 C> bit widths
25 C> @param[out] CMUNIT -- character*24(*): Merged array containing units
26 C> @param[out] CMMNEM -- character*8(*): Merged array containing
27 C> mnemonics
28 C> @param[out] CMDSC -- character*4(*): Merged array containing
29 C> descriptor codes
30 C> @param[out] CMELEM -- character*120(*): Merged array containing
31 C> element names
32 C>
33 C> @author J. Ator @date 2007-01-19
34  SUBROUTINE sntbbe ( IFXYN, LINE, MXMTBB,
35  . NMTBB, IMFXYN, CMSCL, CMSREF, CMBW,
36  . CMUNIT, CMMNEM, CMDSC, CMELEM )
37 
38  CHARACTER*(*) LINE
39  CHARACTER*200 TAGS(10), WKTAG
40  CHARACTER*128 BORT_STR1, BORT_STR2
41  CHARACTER*4 CMDSC(*)
42  CHARACTER CMELEM(120,*)
43  CHARACTER CMUNIT(24,*)
44  CHARACTER CMSREF(12,*)
45  CHARACTER CMMNEM(8,*)
46  CHARACTER CMSCL(4,*), CMBW(4,*)
47 
48  INTEGER IMFXYN(*)
49 
50 C-----------------------------------------------------------------------
51 C-----------------------------------------------------------------------
52 
53  IF ( nmtbb .GE. mxmtbb ) GOTO 900
54  nmtbb = nmtbb + 1
55 
56 C Store the FXY number. This is the element descriptor.
57 
58  imfxyn( nmtbb ) = ifxyn
59 
60 C Parse the table entry.
61 
62  CALL parstr ( line, tags, 10, ntag, '|', .false. )
63  IF ( ntag .LT. 4 ) THEN
64  bort_str2 = ' HAS TOO FEW FIELDS'
65  GOTO 901
66  ENDIF
67 
68 C Scale factor.
69 
70  tags(2) = adjustl( tags(2) )
71  IF ( tags(2) .EQ. ' ' ) THEN
72  bort_str2 = ' HAS MISSING SCALE FACTOR'
73  GOTO 901
74  ENDIF
75  tags(2)(1:4) = adjustr( tags(2)(1:4) )
76  DO ii = 1, 4
77  cmscl( ii, nmtbb ) = tags(2)(ii:ii)
78  ENDDO
79 
80 C Reference value.
81 
82  tags(3) = adjustl( tags(3) )
83  IF ( tags(3) .EQ. ' ' ) THEN
84  bort_str2 = ' HAS MISSING REFERENCE VALUE'
85  GOTO 901
86  ENDIF
87  tags(3)(1:12) = adjustr( tags(3)(1:12) )
88  DO ii = 1, 12
89  cmsref( ii, nmtbb ) = tags(3)(ii:ii)
90  ENDDO
91 
92 C Bit width.
93 
94  tags(4) = adjustl( tags(4) )
95  IF ( tags(4) .EQ. ' ' ) THEN
96  bort_str2 = ' HAS MISSING BIT WIDTH'
97  GOTO 901
98  ENDIF
99  tags(4)(1:4) = adjustr( tags(4)(1:4) )
100  DO ii = 1, 4
101  cmbw( ii, nmtbb ) = tags(4)(ii:ii)
102  END DO
103 
104 C Units. Note that this field is allowed to be blank.
105 
106  IF ( ntag .GT. 4 ) THEN
107  tags(5) = adjustl( tags(5) )
108  DO ii = 1, 24
109  cmunit( ii, nmtbb ) = tags(5)(ii:ii)
110  ENDDO
111  ELSE
112  DO ii = 1, 24
113  cmunit( ii, nmtbb ) = ' '
114  ENDDO
115  ENDIF
116 
117 C Comment (additional) fields. Any of these fields may be blank.
118 
119  cmdsc( nmtbb ) = ' '
120  DO ii = 1, 8
121  cmmnem( ii, nmtbb ) = ' '
122  ENDDO
123  DO ii = 1, 120
124  cmelem( ii, nmtbb ) = ' '
125  ENDDO
126  IF ( ntag .GT. 5 ) THEN
127  wktag = tags(6)
128  CALL parstr ( wktag, tags, 10, ntag, ';', .false. )
129  IF ( ntag .GT. 0 ) THEN
130 C The first additional field contains the mnemonic.
131  tags(1) = adjustl( tags(1) )
132 C If there is a mnemonic, then make sure it's legal.
133  IF ( ( tags(1) .NE. ' ' ) .AND.
134  . ( nemock( tags(1) ) .NE. 0 ) ) THEN
135  bort_str2 = ' HAS ILLEGAL MNEMONIC'
136  GOTO 901
137  ENDIF
138  DO ii = 1, 8
139  cmmnem( ii, nmtbb ) = tags(1)(ii:ii)
140  ENDDO
141  ENDIF
142  IF ( ntag .GT. 1 ) THEN
143 C The second additional field contains descriptor codes.
144  tags(2) = adjustl( tags(2) )
145  cmdsc( nmtbb ) = tags(2)(1:4)
146  ENDIF
147  IF ( ntag .GT. 2 ) THEN
148 C The third additional field contains the element name.
149  tags(3) = adjustl( tags(3) )
150  DO ii = 1, 120
151  cmelem( ii, nmtbb ) = tags(3)(ii:ii)
152  ENDDO
153  ENDIF
154  ENDIF
155 
156  RETURN
157  900 CALL bort('BUFRLIB: SNTBBE - OVERFLOW OF MERGED ARRAYS')
158  901 bort_str1 = 'BUFRLIB: SNTBBE - CARD BEGINNING WITH: ' //
159  . line(1:20)
160  CALL bort2(bort_str1,bort_str2)
161  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 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 sntbbe(IFXYN, LINE, MXMTBB, NMTBB, IMFXYN, CMSCL, CMSREF, CMBW, CMUNIT, CMMNEM, CMDSC, CMELEM)
This subroutine stores an entry that was previously read from an ASCII master Table B file into a set...
Definition: sntbbe.f:37