NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
sntbbe.f
Go to the documentation of this file.
1 C> @file
2 C> @author ATOR @date 2007-01-19
3 
4 C> THIS SUBROUTINE PARSES AN ENTRY THAT WAS PREVIOUSLY READ
5 C> FROM AN ASCII MASTER TABLE B FILE AND THEN STORES THE OUTPUT INTO
6 C> THE MERGED ARRAYS.
7 C>
8 C> PROGRAM HISTORY LOG:
9 C> 2007-01-19 J. ATOR -- ORIGINAL AUTHOR
10 C> 2021-01-08 J. ATOR -- MODIFIED MSTABS ARRAY DECLARATIONS
11 C> FOR GNUv10 PORTABILITY
12 C>
13 C> USAGE: CALL SNTBBE ( IFXYN, LINE, MXMTBB,
14 C> NMTBB, IMFXYN, CMSCL, CMSREF, CMBW,
15 C> CMUNIT, CMMNEM, CMDSC, CMELEM )
16 C> INPUT ARGUMENT LIST:
17 C> IFXYN - INTEGER: BIT-WISE REPRESENTATION OF FXY NUMBER FOR
18 C> TABLE ENTRY; THIS FXY NUMBER IS THE ELEMENT DESCRIPTOR
19 C> LINE - CHARACTER*(*): TABLE ENTRY
20 C> MXMTBB - INTEGER: MAXIMUM NUMBER OF ENTRIES TO BE STORED IN
21 C> MERGED MASTER TABLE B ARRAYS; THIS SHOULD BE THE SAME
22 C> NUMBER AS WAS USED TO DIMENSION THE OUTPUT ARRAYS IN
23 C> THE CALLING PROGRAM, AND IT IS USED BY THIS SUBROUTINE
24 C> TO ENSURE THAT IT DOESN'T OVERFLOW THESE ARRAYS
25 C>
26 C> OUTPUT ARGUMENT LIST:
27 C> NMTBB - INTEGER: NUMBER OF ENTRIES IN MERGED MASTER TABLE B
28 C> ARRAYS
29 C> IMFXYN(*)- INTEGER: MERGED ARRAY CONTAINING BIT-WISE
30 C> REPRESENTATIONS OF FXY NUMBERS (I.E. ELEMENT
31 C> DESCRIPTORS)
32 C> CMSCL(*) - CHARACTER*4: MERGED ARRAY CONTAINING SCALE FACTORS
33 C> CMSREF(*)- CHARACTER*12: MERGED ARRAY CONTAINING REFERENCE VALUES
34 C> CMBW(*) - CHARACTER*4: MERGED ARRAY CONTAINING BIT WIDTHS
35 C> CMUNIT(*)- CHARACTER*14: MERGED ARRAY CONTAINING UNITS
36 C> CMMNEM(*)- CHARACTER*8: MERGED ARRAY CONTAINING MNEMONICS
37 C> CMDSC(*) - CHARACTER*4: MERGED ARRAY CONTAINING DESCRIPTOR CODES
38 C> CMELEM(*)- CHARACTER*120: MERGED ARRAY CONTAINING ELEMENT NAMES
39 C>
40 C> REMARKS:
41 C> THIS ROUTINE CALLS: BORT BORT2 JSTCHR NEMOCK
42 C> PARSTR RJUST
43 C> THIS ROUTINE IS CALLED BY: RDMTBB
44 C> Normally not called by any application
45 C> programs.
46 C>
47  SUBROUTINE sntbbe ( IFXYN, LINE, MXMTBB,
48  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
49  . cmunit, cmmnem, cmdsc, cmelem )
50 
51 
52 
53  character*(*) line
54  character*200 tags(10), wktag
55  character*128 bort_str1, bort_str2
56  character*4 cmdsc(*)
57  character cmelem(120,*)
58  character cmunit(14,*)
59  character cmsref(12,*)
60  character cmmnem(8,*)
61  character cmscl(4,*), cmbw(4,*)
62 
63  integer imfxyn(*)
64 
65 C-----------------------------------------------------------------------
66 C-----------------------------------------------------------------------
67 
68  IF ( nmtbb .GE. mxmtbb ) goto 900
69  nmtbb = nmtbb + 1
70 
71 C Store the FXY number. This is the element descriptor.
72 
73  imfxyn( nmtbb ) = ifxyn
74 
75 C Parse the table entry.
76 
77  CALL parstr( line, tags, 10, ntag, '|', .false. )
78  IF ( ntag .LT. 4 ) THEN
79  bort_str2 = ' HAS TOO FEW FIELDS'
80  goto 901
81  ENDIF
82 
83 C Scale factor.
84 
85  CALL jstchr( tags(2), iret )
86  IF ( iret .NE. 0 ) THEN
87  bort_str2 = ' HAS MISSING SCALE FACTOR'
88  goto 901
89  ENDIF
90  rj = rjust( tags(2)(1:4) )
91  DO ii = 1, 4
92  cmscl( ii, nmtbb ) = tags(2)(ii:ii)
93  ENDDO
94 
95 C Reference value.
96 
97  CALL jstchr( tags(3), iret )
98  IF ( iret .NE. 0 ) THEN
99  bort_str2 = ' HAS MISSING REFERENCE VALUE'
100  goto 901
101  ENDIF
102  rj = rjust( tags(3)(1:12) )
103  DO ii = 1, 12
104  cmsref( ii, nmtbb ) = tags(3)(ii:ii)
105  ENDDO
106 
107 C Bit width.
108 
109  CALL jstchr( tags(4), iret )
110  IF ( iret .NE. 0 ) THEN
111  bort_str2 = ' HAS MISSING BIT WIDTH'
112  goto 901
113  ENDIF
114  rj = rjust( tags(4)(1:4) )
115  DO ii = 1, 4
116  cmbw( ii, nmtbb ) = tags(4)(ii:ii)
117  END DO
118 
119 C Units. Note that this field is allowed to be blank.
120 
121  IF ( ntag .GT. 4 ) THEN
122  CALL jstchr( tags(5), iret )
123  DO ii = 1, 14
124  cmunit( ii, nmtbb ) = tags(5)(ii:ii)
125  ENDDO
126  ELSE
127  DO ii = 1, 14
128  cmunit( ii, nmtbb ) = ' '
129  ENDDO
130  ENDIF
131 
132 C Comment (additional) fields. Any of these fields may be blank.
133 
134  cmdsc( nmtbb ) = ' '
135  DO ii = 1, 8
136  cmmnem( ii, nmtbb ) = ' '
137  ENDDO
138  DO ii = 1, 120
139  cmelem( ii, nmtbb ) = ' '
140  ENDDO
141  IF ( ntag .GT. 5 ) THEN
142  wktag = tags(6)
143  CALL parstr( wktag, tags, 10, ntag, ';', .false. )
144  IF ( ntag .GT. 0 ) THEN
145 C The first additional field contains the mnemonic.
146  CALL jstchr( tags(1), iret )
147 C If there is a mnemonic, then make sure it's legal.
148  IF ( ( iret .EQ. 0 ) .AND.
149  . ( nemock( tags(1) ) .NE. 0 ) ) THEN
150  bort_str2 = ' HAS ILLEGAL MNEMONIC'
151  goto 901
152  ENDIF
153  DO ii = 1, 8
154  cmmnem( ii, nmtbb ) = tags(1)(ii:ii)
155  ENDDO
156  ENDIF
157  IF ( ntag .GT. 1 ) THEN
158 C The second additional field contains descriptor codes.
159  CALL jstchr( tags(2), iret )
160  cmdsc( nmtbb ) = tags(2)(1:4)
161  ENDIF
162  IF ( ntag .GT. 2 ) THEN
163 C The third additional field contains the element name.
164  CALL jstchr( tags(3), iret )
165  DO ii = 1, 120
166  cmelem( ii, nmtbb ) = tags(3)(ii:ii)
167  ENDDO
168  ENDIF
169  ENDIF
170 
171  RETURN
172  900 CALL bort('BUFRLIB: SNTBBE - OVERFLOW OF MERGED ARRAYS')
173  901 bort_str1 = 'BUFRLIB: SNTBBE - CARD BEGINNING WITH: ' //
174  . line(1:20)
175  CALL bort2(bort_str1,bort_str2)
176  END
function rjust(STR)
THIS FUNCTION RIGHT JUSTIFIES A CHARACTER STRING.
Definition: rjust.f:29
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS...
Definition: parstr.f:37
subroutine bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:20
function nemock(NEMO)
THIS FUNCTION CHECKS A MNEMONIC TO VERIFY THAT IT HAS A LENGTH OF BETWEEN ONE AND EIGHT CHARACTERS AN...
Definition: nemock.f:36
subroutine jstchr(STR, IRET)
THIS SUBROUTINE LEFT-JUSTIFIES (I.E.
Definition: jstchr.f:43
subroutine sntbbe(IFXYN, LINE, MXMTBB, NMTBB, IMFXYN, CMSCL, CMSREF, CMBW, CMUNIT, CMMNEM, CMDSC, CMELEM)
THIS SUBROUTINE PARSES AN ENTRY THAT WAS PREVIOUSLY READ FROM AN ASCII MASTER TABLE B FILE AND THEN S...
Definition: sntbbe.f:47
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23