NCEPLIBS-bufr  12.0.1
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 C>
4 C> @author J. Ator @date 2017-11-02
5 
6 C> Store a master Code/Flag table entry into internal memory.
7 C>
8 C> This subroutine reads an entire entry from a previously-opened
9 C> ASCII master Code/Flag table file and stores it into an
10 C> internal memory structure.
11 C>
12 C> @param[in] LUNT - integer: Fortran logical unit number for
13 C> ASCII file containing Code/Flag table information.
14 C> @param[in] IFXYN - integer: Bit-wise representation of FXY number.
15 C>
16 C> @author J. Ator @date 2017-11-02
17  SUBROUTINE sntbfe ( LUNT, IFXYN )
18 
19  use bufrlib
20 
21  CHARACTER*160 CLINE, TAGS(4), CDSTR(2), ADSC(10), CVAL(25)
22  CHARACTER*128 BORT_STR1, BORT_STR2
23  CHARACTER*6 ADN30, CLEMON, CDSC
24  dimension idfxy(10), idval(25)
25 
26  LOGICAL DONE, LSTNBLK
27 
28 C-----------------------------------------------------------------------
29 C-----------------------------------------------------------------------
30 
31 C We already have the FXY number. Now we need to read and parse
32 C all of the remaining lines from the table entry for this FXY
33 C number. The information for each individual code figure or bit
34 C number will then be stored as a separate entry within the
35 C internal memory structure.
36 
37  done = .false.
38  nidfxy = 0
39  nidval = 0
40 
41  DO WHILE ( .NOT. done )
42 
43  IF ( igetntbl( lunt, cline ) .NE. 0 ) THEN
44  bort_str2 = ' IS INCOMPLETE'
45  GOTO 900
46  ENDIF
47 
48  CALL parstr ( cline, tags, 4, ntag, '|', .false. )
49  IF ( ( ntag .LT. 2 ) .OR. ( ntag .GT. 3 ) ) THEN
50  bort_str2 = ' HAS BAD CARD'
51  GOTO 900
52  ENDIF
53 
54  IF ( ntag .EQ. 2 ) THEN
55 
56 C This line contains a list of dependencies.
57 
58  CALL parstr ( tags(2), cdstr, 2, ntag, '=', .false. )
59  IF ( ntag .NE. 2 ) THEN
60  bort_str2 = ' HAS BAD DEPENDENCY CARD'
61  GOTO 900
62  ENDIF
63 
64 C Parse the list of FXY numbers.
65 
66  CALL parstr ( cdstr(1), adsc, 10, nidfxy, ',', .false. )
67  IF ( nidfxy .EQ. 0 ) THEN
68  bort_str2 = ' HAS BAD DEPENDENCY LIST (FXY)'
69  GOTO 900
70  ENDIF
71  DO ii = 1, nidfxy
72  IF ( igetfxy( adsc(ii), cdsc ) .NE. 0 ) THEN
73  bort_str2 = ' HAS BAD DEPENDENCY (FXY)'
74  GOTO 900
75  ENDIF
76  idfxy(ii) = ifxy( cdsc )
77  ENDDO
78 
79 C Parse the list of values.
80 
81  CALL parstr ( cdstr(2), cval, 25, nidval, ',', .false. )
82  IF ( nidval .EQ. 0 ) THEN
83  bort_str2 = ' HAS BAD DEPENDENCY LIST (VAL)'
84  GOTO 900
85  ENDIF
86  DO ii = 1, nidval
87  cval(ii) = adjustl( cval(ii) )
88  CALL strnum ( cval(ii), ival, ier )
89  idval(ii) = ival
90  ENDDO
91 
92  ELSE
93 
94 C This line contains a value (code figure or bit number)
95 C and corresponding meaning.
96 
97  ipt = index( tags(2), ' >' )
98  IF ( ipt .EQ. 0 ) THEN
99 
100 C This is the last line for this table entry.
101 
102  done = .true.
103  ELSE
104  tags(2)(ipt+1:ipt+1) = ' '
105  ENDIF
106 
107  tags(2) = adjustl( tags(2) )
108  CALL strnum ( tags(2), ival, ier )
109 
110 C Find the last non-blank character in the meaning string.
111 
112  tags(3) = adjustl( tags(3) )
113  lt3 = len(tags(3))
114  lstnblk = .false.
115  DO WHILE ( ( lt3 .GT. 0 ) .AND. ( .NOT. lstnblk ) )
116  IF ( tags(3)(lt3:lt3) .NE. ' ' ) THEN
117  lstnblk = .true.
118  ELSE
119  lt3 = lt3 - 1
120  ENDIF
121  ENDDO
122 
123 C Store the information for this value within the internal
124 C memory structure.
125 
126  IF ( ( nidfxy .EQ. 0 ) .AND. ( nidval .EQ. 0 ) ) THEN
127  CALL strtbfe_c ( ifxyn, ival, tags(3), lt3, -1, -1 )
128  ELSE
129  DO ii = 1, nidfxy
130  DO jj = 1, nidval
131  CALL strtbfe_c ( ifxyn, ival, tags(3), lt3,
132  + idfxy(ii), idval(jj) )
133  ENDDO
134  ENDDO
135  ENDIF
136 
137  ENDIF
138 
139  ENDDO
140 
141  RETURN
142 
143  900 clemon = adn30( ifxyn, 6 )
144  WRITE(bort_str1,'("BUFRLIB: SNTBFE - TABLE F ENTRY FOR' //
145  . ' ELEMENT DESCRIPTOR: ",5A)')
146  . clemon(1:1), '-', clemon(2:3), '-', clemon(4:6)
147  CALL bort2(bort_str1,bort_str2)
148  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
function ifxy(ADSC)
Convert an FXY value from its 6 character representation to its WMO bit-wise representation.
Definition: ifxy.f:34
function igetfxy(STR, CFXY)
This function looks for and returns a valid FXY number from within the given input string.
Definition: igetfxy.f:20
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:24
Wrap C NCEPLIBS-bufr functions so they can be called from within the Fortran part of the library.
Definition: bufrlib.F90:11
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 sntbfe(LUNT, IFXYN)
Store a master Code/Flag table entry into internal memory.
Definition: sntbfe.f:18
recursive subroutine strnum(str, num, iret)
Decode an integer from a character string.
Definition: strnum.F90:24