NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
sntbfe.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Store a master Code/Flag table entry into internal memory
3 
4 C> This subroutine stores the first line of an entry that was
5 C> previously read from an ASCII master Code/Flag table file into an
6 C> internal memory structure. It then reads and stores all remaining
7 C> lines of that same entry into the same internal memory structure.
8 C>
9 C> @author J. Ator
10 C> @date 2017-11-02
11 C>
12 C> @param[in] LUNT -- integer: Fortran logical unit number for
13 C> ASCII file containing Code/Flag table
14 C> information
15 C> @param[in] IFXYN -- integer: Bit-wise representation of FXY number
16 C> @param[in] LINE -- character*(*): First line of Code/Flag table
17 C> entry
18 C>
19 C> <b>Program history log:</b>
20 C> | Date | Programmer | Comments |
21 C> | -----|------------|----------|
22 C> | 2017-11-02 | J. Ator | Original author |
23 C> | 2021-09-30 | J. Ator | Replace jstchr with Fortran intrinsic adjustl |
24 C>
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 
35 C-----------------------------------------------------------------------
36 C-----------------------------------------------------------------------
37 
38 C We already have the FXY number. Now we need to read and parse
39 C all of the remaining lines from the table entry for this FXY
40 C number. The information for each individual code figure or bit
41 C number will then be stored as a separate entry within the
42 C 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 
63 C 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 
71 C 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 
86 C 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 
101 C This line contains a value (code figure or bit number)
102 C and corresponding meaning.
103 
104  ipt = index( tags(2), ' >' )
105  IF ( ipt .EQ. 0 ) THEN
106 
107 C 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 
117 C 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 
130 C Store the information for this value within the internal
131 C 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
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:22
subroutine strnum(STR, NUM)
This subroutine decodes an integer from a character string.
Definition: strnum.f:23
function igetfxy(STR, CFXY)
THIS FUNCTION LOOKS FOR AND RETURNS A VALID FXY NUMBER FROM WITHIN THE GIVEN INPUT STRING...
Definition: igetfxy.f:30
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
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:28
function ifxy(ADSC)
This function converts an FXY value from its 6 character representation to its bit-wise (integer) rep...
Definition: ifxy.f:42
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:28
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:25