NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
sntbfe.f
Go to the documentation of this file.
1 C> @file
2 C> @author ATOR @date 2017-11-02
3 
4 C> THIS SUBROUTINE READS A COMPLETE ENTRY (CORRESPONDING
5 C> TO THE INPUT FXY NUMBER) FROM AN ASCII MASTER CODE/FLAG TABLE AND
6 C> STORES THE OUTPUT INTO AN INTERNAL MEMORY STRUCTURE.
7 C>
8 C> PROGRAM HISTORY LOG:
9 C> 2017-11-02 J. ATOR -- ORIGINAL AUTHOR
10 C>
11 C> USAGE: CALL SNTBFE ( LUNT, IFXYN, LINE )
12 C> INPUT ARGUMENT LIST:
13 C> LUNT - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
14 C> CONTAINING MASTER CODE/FLAG TABLE INFORMATION
15 C> IFXYN - INTEGER: BIT-WISE REPRESENTATION OF FXY NUMBER
16 C> LINE - CHARACTER*(*): FIRST LINE OF TABLE ENTRY
17 C>
18 C> REMARKS:
19 C> THIS ROUTINE CALLS: ADN30 BORT2 IFXY IGETFXY
20 C> IGETNTBL JSTCHR PARSTR STRNUM
21 C> STRTBFE
22 C> THIS ROUTINE IS CALLED BY: RDMTBF
23 C> Normally not called by any application
24 C> programs.
25 C>
26  SUBROUTINE sntbfe ( LUNT, IFXYN, LINE )
27 
28 
29 
30  character*(*) line
31  character*160 cline, tags(4), cdstr(2), adsc(10), cval(25)
32  character*128 bort_str1, bort_str2
33  character*6 adn30, clemon, cdsc
34  dimension idfxy(10), idval(25)
35 
36  logical done, lstnblk
37 
38 C-----------------------------------------------------------------------
39 C-----------------------------------------------------------------------
40 
41 C We already have the FXY number. Now we need to read and parse
42 C all of the remaining lines from the table entry for this FXY
43 C number. The information for each individual code figure or bit
44 C number will then be stored as a separate entry within the
45 C internal memory structure.
46 
47  done = .false.
48  nidfxy = 0
49  nidval = 0
50 
51  DO WHILE ( .NOT. done )
52 
53  IF ( igetntbl( lunt, cline ) .NE. 0 ) THEN
54  bort_str2 = ' IS INCOMPLETE'
55  goto 900
56  ENDIF
57 
58  CALL parstr( cline, tags, 4, ntag, '|', .false. )
59  IF ( ( ntag .LT. 2 ) .OR. ( ntag .GT. 3 ) ) THEN
60  bort_str2 = ' HAS BAD CARD'
61  goto 900
62  ENDIF
63 
64  IF ( ntag .EQ. 2 ) THEN
65 
66 C This line contains a list of dependencies.
67 
68  CALL parstr( tags(2), cdstr, 2, ntag, '=', .false. )
69  IF ( ntag .NE. 2 ) THEN
70  bort_str2 = ' HAS BAD DEPENDENCY CARD'
71  goto 900
72  ENDIF
73 
74 C Parse the list of FXY numbers.
75 
76  CALL parstr( cdstr(1), adsc, 10, nidfxy, ',', .false. )
77  IF ( nidfxy .EQ. 0 ) THEN
78  bort_str2 = ' HAS BAD DEPENDENCY LIST (FXY)'
79  goto 900
80  ENDIF
81  DO ii = 1, nidfxy
82  IF ( igetfxy( adsc(ii), cdsc ) .NE. 0 ) THEN
83  bort_str2 = ' HAS BAD DEPENDENCY (FXY)'
84  goto 900
85  ENDIF
86  idfxy(ii) = ifxy( cdsc )
87  ENDDO
88 
89 C Parse the list of values.
90 
91  CALL parstr( cdstr(2), cval, 25, nidval, ',', .false. )
92  IF ( nidval .EQ. 0 ) THEN
93  bort_str2 = ' HAS BAD DEPENDENCY LIST (VAL)'
94  goto 900
95  ENDIF
96  DO ii = 1, nidval
97  CALL jstchr( cval(ii), ier )
98  CALL strnum( cval(ii), ival )
99  idval(ii) = ival
100  ENDDO
101 
102  ELSE
103 
104 C This line contains a value (code figure or bit number)
105 C and corresponding meaning.
106 
107  ipt = index( tags(2), ' >' )
108  IF ( ipt .EQ. 0 ) THEN
109 
110 C This is the last line for this table entry.
111 
112  done = .true.
113  ELSE
114  tags(2)(ipt+1:ipt+1) = ' '
115  ENDIF
116 
117  CALL jstchr( tags(2), ier )
118  CALL strnum( tags(2), ival )
119 
120 C Find the last non-blank character in the meaning string.
121 
122  CALL jstchr( tags(3), ier )
123  lt3 = len(tags(3))
124  lstnblk = .false.
125  DO WHILE ( ( lt3 .GT. 0 ) .AND. ( .NOT. lstnblk ) )
126  IF ( tags(3)(lt3:lt3) .NE. ' ' ) THEN
127  lstnblk = .true.
128  ELSE
129  lt3 = lt3 - 1
130  ENDIF
131  ENDDO
132 
133 C Store the information for this value within the internal
134 C memory structure.
135 
136  IF ( ( nidfxy .EQ. 0 ) .AND. ( nidval .EQ. 0 ) ) THEN
137  CALL strtbfe( ifxyn, ival, tags(3), lt3, -1, -1 )
138  ELSE
139  DO ii = 1, nidfxy
140  DO jj = 1, nidval
141  CALL strtbfe( ifxyn, ival, tags(3), lt3,
142  + idfxy(ii), idval(jj) )
143  ENDDO
144  ENDDO
145  ENDIF
146 
147  ENDIF
148 
149  ENDDO
150 
151  RETURN
152 
153  900 clemon = adn30( ifxyn, 6 )
154  WRITE(bort_str1,'("BUFRLIB: SNTBFE - TABLE F ENTRY FOR' //
155  . ' ELEMENT DESCRIPTOR: ",5A)')
156  . clemon(1:1), '-', clemon(2:3), '-', clemon(4:6)
157  CALL bort2(bort_str1,bort_str2)
158  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:20
subroutine strnum(STR, NUM)
THIS SUBROUTINE DECODES AN INTEGER FROM A CHARACTER STRING.
Definition: strnum.f:33
function igetfxy(STR, CFXY)
THIS FUNCTION LOOKS FOR AND RETURNS A VALID FXY NUMBER FROM WITHIN THE GIVEN INPUT STRING...
Definition: igetfxy.f:28
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:31
character *(*) function adn30(IDN, L30)
This function converts a descriptor from its bit-wise (integer) representation to its 5 or 6 characte...
Definition: adn30.f:27
function ifxy(ADSC)
THIS FUNCTION RETURNS THE INTEGER CORRESPONDING TO THE BIT-WISE REPRESENTATION OF AN INPUT CHARACTER ...
Definition: ifxy.f:49
function igetntbl(LUNT, LINE)
THIS FUNCTION GETS THE NEXT LINE FROM THE ASCII MASTER TABLE FILE SPECIFIED BY LUNT, IGNORING ANY BLANK LINES OR COMMENT LINES IN THE PROCESS.
Definition: igetntbl.f:31
subroutine jstchr(STR, IRET)
THIS SUBROUTINE LEFT-JUSTIFIES (I.E.
Definition: jstchr.f:43
subroutine sntbfe(LUNT, IFXYN, LINE)
THIS SUBROUTINE READS A COMPLETE ENTRY (CORRESPONDING TO THE INPUT FXY NUMBER) FROM AN ASCII MASTER C...
Definition: sntbfe.f:26