NCEPLIBS-bufr 11.7.1
sntbfe.f
Go to the documentation of this file.
1C> @file
2C> @brief Store a master Code/Flag table entry into internal memory
3
4C> This subroutine stores the first line of an entry that was
5C> previously read from an ASCII master Code/Flag table file into an
6C> internal memory structure. It then reads and stores all remaining
7C> lines of that same entry into the same internal memory structure.
8C>
9C> @author J. Ator
10C> @date 2017-11-02
11C>
12C> @param[in] LUNT -- integer: Fortran logical unit number for
13C> ASCII file containing Code/Flag table
14C> information
15C> @param[in] IFXYN -- integer: Bit-wise representation of FXY number
16C> @param[in] LINE -- character*(*): First line of Code/Flag table
17C> entry
18C>
19C> <b>Program history log:</b>
20C> | Date | Programmer | Comments |
21C> | -----|------------|----------|
22C> | 2017-11-02 | J. Ator | Original author |
23C> | 2021-09-30 | J. Ator | Replace jstchr with Fortran intrinsic adjustl |
24C>
25 SUBROUTINE sntbfe ( LUNT, IFXYN, LINE )
26
27 character*(*) line
28 character*160 cline, tags(4), cdstr(2), adsc(10), cval(25)
29 character*128 bort_str1, bort_str2
30 character*6 adn30, clemon, cdsc
31 dimension idfxy(10), idval(25)
32
33 logical done, lstnblk
34
35C-----------------------------------------------------------------------
36C-----------------------------------------------------------------------
37
38C We already have the FXY number. Now we need to read and parse
39C all of the remaining lines from the table entry for this FXY
40C number. The information for each individual code figure or bit
41C number will then be stored as a separate entry within the
42C internal memory structure.
43
44 done = .false.
45 nidfxy = 0
46 nidval = 0
47
48 DO WHILE ( .NOT. done )
49
50 IF ( igetntbl( lunt, cline ) .NE. 0 ) THEN
51 bort_str2 = ' IS INCOMPLETE'
52 GOTO 900
53 ENDIF
54
55 CALL parstr ( cline, tags, 4, ntag, '|', .false. )
56 IF ( ( ntag .LT. 2 ) .OR. ( ntag .GT. 3 ) ) THEN
57 bort_str2 = ' HAS BAD CARD'
58 GOTO 900
59 ENDIF
60
61 IF ( ntag .EQ. 2 ) THEN
62
63C This line contains a list of dependencies.
64
65 CALL parstr ( tags(2), cdstr, 2, ntag, '=', .false. )
66 IF ( ntag .NE. 2 ) THEN
67 bort_str2 = ' HAS BAD DEPENDENCY CARD'
68 GOTO 900
69 ENDIF
70
71C Parse the list of FXY numbers.
72
73 CALL parstr ( cdstr(1), adsc, 10, nidfxy, ',', .false. )
74 IF ( nidfxy .EQ. 0 ) THEN
75 bort_str2 = ' HAS BAD DEPENDENCY LIST (FXY)'
76 GOTO 900
77 ENDIF
78 DO ii = 1, nidfxy
79 IF ( igetfxy( adsc(ii), cdsc ) .NE. 0 ) THEN
80 bort_str2 = ' HAS BAD DEPENDENCY (FXY)'
81 GOTO 900
82 ENDIF
83 idfxy(ii) = ifxy( cdsc )
84 ENDDO
85
86C Parse the list of values.
87
88 CALL parstr ( cdstr(2), cval, 25, nidval, ',', .false. )
89 IF ( nidval .EQ. 0 ) THEN
90 bort_str2 = ' HAS BAD DEPENDENCY LIST (VAL)'
91 GOTO 900
92 ENDIF
93 DO ii = 1, nidval
94 cval(ii) = adjustl( cval(ii) )
95 CALL strnum ( cval(ii), ival )
96 idval(ii) = ival
97 ENDDO
98
99 ELSE
100
101C This line contains a value (code figure or bit number)
102C and corresponding meaning.
103
104 ipt = index( tags(2), ' >' )
105 IF ( ipt .EQ. 0 ) THEN
106
107C This is the last line for this table entry.
108
109 done = .true.
110 ELSE
111 tags(2)(ipt+1:ipt+1) = ' '
112 ENDIF
113
114 tags(2) = adjustl( tags(2) )
115 CALL strnum ( tags(2), ival )
116
117C Find the last non-blank character in the meaning string.
118
119 tags(3) = adjustl( tags(3) )
120 lt3 = len(tags(3))
121 lstnblk = .false.
122 DO WHILE ( ( lt3 .GT. 0 ) .AND. ( .NOT. lstnblk ) )
123 IF ( tags(3)(lt3:lt3) .NE. ' ' ) THEN
124 lstnblk = .true.
125 ELSE
126 lt3 = lt3 - 1
127 ENDIF
128 ENDDO
129
130C Store the information for this value within the internal
131C memory structure.
132
133 IF ( ( nidfxy .EQ. 0 ) .AND. ( nidval .EQ. 0 ) ) THEN
134 CALL strtbfe ( ifxyn, ival, tags(3), lt3, -1, -1 )
135 ELSE
136 DO ii = 1, nidfxy
137 DO jj = 1, nidval
138 CALL strtbfe ( ifxyn, ival, tags(3), lt3,
139 + idfxy(ii), idval(jj) )
140 ENDDO
141 ENDDO
142 ENDIF
143
144 ENDIF
145
146 ENDDO
147
148 RETURN
149
150 900 clemon = adn30( ifxyn, 6 )
151 WRITE(bort_str1,'("BUFRLIB: SNTBFE - TABLE F ENTRY FOR' //
152 . ' ELEMENT DESCRIPTOR: ",5A)')
153 . clemon(1:1), '-', clemon(2:3), '-', clemon(4:6)
154 CALL bort2(bort_str1,bort_str2)
155 END
character *(*) function adn30(IDN, L30)
This function converts an FXY value from its bit-wise (integer) representation to its 5 or 6 characte...
Definition: adn30.f:29
subroutine bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:23
void strtbfe(f77int *, f77int *, char *, f77int *, f77int *, f77int *)
This subroutine adds a new entry to the internal memory structure for storage of master Code/Flag tab...
Definition: strtbfe.c:33
function ifxy(ADSC)
This function converts an FXY value from its 6 character representation to its bit-wise (integer) rep...
Definition: ifxy.f:43
function igetfxy(STR, CFXY)
THIS FUNCTION LOOKS FOR AND RETURNS A VALID FXY NUMBER FROM WITHIN THE GIVEN INPUT STRING.
Definition: igetfxy.f:31
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: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:38
subroutine sntbfe(LUNT, IFXYN, LINE)
This subroutine stores the first line of an entry that was previously read from an ASCII master Code/...
Definition: sntbfe.f:26
subroutine strnum(STR, NUM)
This subroutine decodes an integer from a character string.
Definition: strnum.f:24