NCEPLIBS-bufr 11.7.1
rdmtbb.f
Go to the documentation of this file.
1C> @file
2C> @brief Read master Table B information from local file system
3
4C> This subroutine reads master Table B information from two separate
5C> ASCII files (one standard and one local) and then merges the
6C> output into a single set of arrays.
7C>
8C> <p>Each of the two ASCII files must already be individually sorted
9C> in ascending order with respect to the FXY numbers.
10C>
11C> @author J. Ator
12C> @date 2007-01-19
13C>
14C> @param[in] LUNSTB -- integer: Fortran logical unit number for
15C> ASCII file containing standard Table B
16C> information
17C> @param[in] LUNLTB -- integer: Fortran logical unit number for
18C> ASCII file containing local Table B
19C> information
20C> @param[in] MXMTBB -- integer: Dimensioned size (in integers) of
21C> merged output arrays; used by the subroutine
22C> to ensure that it doesn't overflow these
23C> arrays
24C> @param[out] IMT -- integer: Master table
25C> - This value is read from both ASCII
26C> files and must be identical between them.
27C> @param[out] IMTV -- integer: Version number of master table
28C> - This value is read from the standard ASCII
29C> file.
30C> @param[out] IOGCE -- integer: Originating center
31C> - This value is read from the local ASCII
32C> file.
33C> @param[out] ILTV -- integer: Version number of local table
34C> - This value is read from the local ASCII
35C> file.
36C> @param[out] NMTBB -- integer: Number of entries in merged output
37C> arrays
38C> @param[out] IMFXYN -- integer(*): Merged array containing bit-wise
39C> representations of FXY numbers
40C> @param[out] CMSCL -- character*4(*): Merged array containing
41C> scale factors
42C> @param[out] CMSREF -- character*12(*): Merged array containing
43C> reference values
44C> @param[out] CMBW -- character*4(*): Merged array containing
45C> bit widths
46C> @param[out] CMUNIT -- character*24(*): Merged array containing units
47C> @param[out] CMMNEM -- character*8(*): Merged array containing
48C> mnemonics
49C> @param[out] CMDSC -- character*4(*): Merged array containing
50C> descriptor codes
51C> @param[out] CMELEM -- character*120(*): Merged array containing
52C> element names
53C>
54C> <b>Program history log:</b>
55C> | Date | Programmer | Comments |
56C> | -----|------------|----------|
57C> | 2007-01-19 | J. Ator | Original author |
58C> | 2021-01-08 | J. Ator | Modified mstabs array declarations for GNUv10 portability |
59C> | 2021-05-17 | J. Ator | Allow up to 24 characters in cmunit |
60C>
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
78C-----------------------------------------------------------------------
79C-----------------------------------------------------------------------
80
81C Call WRDLEN to initialize some important information about the
82C local machine, just in case it hasn't already been called.
83
84 CALL wrdlen
85
86C Read and parse the header lines of both files.
87
88 CALL gettbh ( lunstb, lunltb, 'B', imt, imtv, iogce, iltv )
89
90C Read through the remainder of both files, merging the
91C 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
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 bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
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:31
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:41
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:65
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:45
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:36