NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
rdmtbb.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read master Table B information from local file system
3 
4 C> This subroutine reads master Table B information from two separate
5 C> ASCII files (one standard and one local) and then merges the
6 C> output into a single set of arrays.
7 C>
8 C> <p>Each of the two ASCII files must already be individually sorted
9 C> in ascending order with respect to the FXY numbers.
10 C>
11 C> @author J. Ator
12 C> @date 2007-01-19
13 C>
14 C> @param[in] LUNSTB -- integer: Fortran logical unit number for
15 C> ASCII file containing standard Table B
16 C> information
17 C> @param[in] LUNLTB -- integer: Fortran logical unit number for
18 C> ASCII file containing local Table B
19 C> information
20 C> @param[in] MXMTBB -- integer: Dimensioned size (in integers) of
21 C> merged output arrays; used by the subroutine
22 C> to ensure that it doesn't overflow these
23 C> arrays
24 C> @param[out] IMT -- integer: Master table
25 C> - This value is read from both ASCII
26 C> files and must be identical between them.
27 C> @param[out] IMTV -- integer: Version number of master table
28 C> - This value is read from the standard ASCII
29 C> file.
30 C> @param[out] IOGCE -- integer: Originating center
31 C> - This value is read from the local ASCII
32 C> file.
33 C> @param[out] ILTV -- integer: Version number of local table
34 C> - This value is read from the local ASCII
35 C> file.
36 C> @param[out] NMTBB -- integer: Number of entries in merged output
37 C> arrays
38 C> @param[out] IMFXYN -- integer(*): Merged array containing bit-wise
39 C> representations of FXY numbers
40 C> @param[out] CMSCL -- character*4(*): Merged array containing
41 C> scale factors
42 C> @param[out] CMSREF -- character*12(*): Merged array containing
43 C> reference values
44 C> @param[out] CMBW -- character*4(*): Merged array containing
45 C> bit widths
46 C> @param[out] CMUNIT -- character*24(*): Merged array containing units
47 C> @param[out] CMMNEM -- character*8(*): Merged array containing
48 C> mnemonics
49 C> @param[out] CMDSC -- character*4(*): Merged array containing
50 C> descriptor codes
51 C> @param[out] CMELEM -- character*120(*): Merged array containing
52 C> element names
53 C>
54 C> <b>Program history log:</b>
55 C> | Date | Programmer | Comments |
56 C> | -----|------------|----------|
57 C> | 2007-01-19 | J. Ator | Original author |
58 C> | 2021-01-08 | J. Ator | Modified mstabs array declarations for GNUv10 portability |
59 C> | 2021-05-17 | J. Ator | Allow up to 24 characters in cmunit |
60 C>
61  SUBROUTINE rdmtbb ( LUNSTB, LUNLTB, MXMTBB,
62  . imt, imtv, iogce, iltv,
63  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
64  . cmunit, cmmnem, cmdsc, cmelem )
65 
66  character*200 stline, ltline
67  character*128 bort_str
68  character*6 cmatch, adn30
69  character*4 cmdsc(*)
70  character cmelem(120,*)
71  character cmunit(24,*)
72  character cmsref(12,*)
73  character cmmnem(8,*)
74  character cmscl(4,*), cmbw(4,*)
75 
76  integer imfxyn(*)
77 
78 C-----------------------------------------------------------------------
79 C-----------------------------------------------------------------------
80 
81 C Call WRDLEN to initialize some important information about the
82 C local machine, just in case it hasn't already been called.
83 
84  CALL wrdlen
85 
86 C Read and parse the header lines of both files.
87 
88  CALL gettbh( lunstb, lunltb, 'B', imt, imtv, iogce, iltv )
89 
90 C Read through the remainder of both files, merging the
91 C contents into a unified set of master Table B arrays.
92 
93  nmtbb = 0
94  CALL getntbe( lunstb, isfxyn, stline, iers )
95  CALL getntbe( lunltb, ilfxyn, ltline, ierl )
96  DO WHILE ( ( iers .EQ. 0 ) .OR. ( ierl .EQ. 0 ) )
97  IF ( ( iers .EQ. 0 ) .AND. ( ierl .EQ. 0 ) ) THEN
98  IF ( isfxyn .EQ. ilfxyn ) THEN
99  cmatch = adn30( isfxyn, 6 )
100  goto 900
101  ELSE IF ( isfxyn .LT. ilfxyn ) THEN
102  CALL sntbbe( isfxyn, stline, mxmtbb,
103  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
104  . cmunit, cmmnem, cmdsc, cmelem )
105  CALL getntbe( lunstb, isfxyn, stline, iers )
106  ELSE
107  CALL sntbbe( ilfxyn, ltline, mxmtbb,
108  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
109  . cmunit, cmmnem, cmdsc, cmelem )
110  CALL getntbe( lunltb, ilfxyn, ltline, ierl )
111  ENDIF
112  ELSE IF ( iers .EQ. 0 ) THEN
113  CALL sntbbe( isfxyn, stline, mxmtbb,
114  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
115  . cmunit, cmmnem, cmdsc, cmelem )
116  CALL getntbe( lunstb, isfxyn, stline, iers )
117  ELSE IF ( ierl .EQ. 0 ) THEN
118  CALL sntbbe( ilfxyn, ltline, mxmtbb,
119  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
120  . cmunit, cmmnem, cmdsc, cmelem )
121  CALL getntbe( lunltb, ilfxyn, ltline, ierl )
122  ENDIF
123  ENDDO
124 
125  RETURN
126  900 WRITE(bort_str,'("BUFRLIB: RDMTBB - STANDARD AND LOCAL'//
127  . ' TABLE B FILES BOTH CONTAIN SAME FXY NUMBER: ",5A)')
128  . cmatch(1:1), '-', cmatch(2:3), '-', cmatch(4:6)
129  CALL bort(bort_str)
130  END
subroutine rdmtbb(LUNSTB, LUNLTB, MXMTBB, IMT, IMTV, IOGCE, ILTV, NMTBB, IMFXYN, CMSCL, CMSREF, CMBW, CMUNIT, CMMNEM, CMDSC, CMELEM)
This subroutine reads master Table B information from two separate ASCII files (one standard and one ...
Definition: rdmtbb.f:61
subroutine gettbh(LUNS, LUNL, TAB, IMT, IMTV, IOGCE, ILTV)
This subroutine reads the header lines from two separate ASCII files (one standard and one local) con...
Definition: gettbh.f:40
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
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:35
subroutine sntbbe(IFXYN, LINE, MXMTBB, NMTBB, IMFXYN, CMSCL, CMSREF, CMBW, CMUNIT, CMMNEM, CMDSC, CMELEM)
This subroutine stores an entry that was previously read from an ASCII master Table B file into a set...
Definition: sntbbe.f:42
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
subroutine getntbe(LUNT, IFXYN, LINE, IRET)
This subroutine reads the first line of the next entry from the specified ASCII master table B...
Definition: getntbe.f:30