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