NCEPLIBS-bufr 11.7.1
rdmtbd.f
Go to the documentation of this file.
1C> @file
2C> @brief Read master Table D information from local file system
3
4C> This subroutine reads master Table D 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] LUNSTD -- integer: Fortran logical unit number for
15C> ASCII file containing standard Table D
16C> information
17C> @param[in] LUNLTD -- integer: Fortran logical unit number for
18C> ASCII file containing local Table D
19C> information
20C> @param[in] MXMTBD -- 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[in] MXELEM -- integer: Maximum number of elements to be
25C> stored per Table D sequence within merged
26C> output arrays; used by the subroutine to
27C> ensure that it doesn't overflow these arrays
28C> @param[out] IMT -- integer: Master table
29C> - This value is read from both ASCII
30C> files and must be identical between them.
31C> @param[out] IMTV -- integer: Version number of master table
32C> - This value is read from the standard ASCII
33C> file.
34C> @param[out] IOGCE -- integer: Originating center
35C> - This value is read from the local ASCII
36C> file.
37C> @param[out] ILTV -- integer: Version number of local table
38C> - This value is read from the local ASCII
39C> file.
40C> @param[out] NMTBD -- integer: Number of entries in merged output
41C> arrays
42C> @param[out] IMFXYN -- integer(*): Merged array containing bit-wise
43C> representations of FXY numbers
44C> @param[out] CMMNEM -- character*8(*): Merged array containing
45C> mnemonics
46C> @param[out] CMDSC -- character*4(*): Merged array containing
47C> descriptor codes
48C> @param[out] CMSEQ -- character*120(*): Merged array containing
49C> sequence names
50C> @param[out] NMELEM -- integer(*): Merged array containing number of
51C> elements stored for each sequence
52C> @param[out] IEFXYN -- integer(*,*): Merged array containing bit-wise
53C> representations of element FXY numbers
54C> @param[out] CEELEM -- character*120(*,*): Merged array containing
55C> element names
56C>
57C> <b>Program history log:</b>
58C> | Date | Programmer | Comments |
59C> | -----|------------|----------|
60C> | 2007-01-19 | J. Ator | Original author |
61C> | 2021-01-08 | J. Ator | Modified mstabs array declarations for GNUv10 portability |
62C>
63 SUBROUTINE rdmtbd ( LUNSTD, LUNLTD, MXMTBD, MXELEM,
64 . IMT, IMTV, IOGCE, ILTV,
65 . NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ,
66 . NMELEM, IEFXYN, CEELEM )
67
68 character*200 stline, ltline
69 character*128 bort_str
70 character*120 ceelem(mxmtbd,mxelem)
71 character*6 cmatch, adn30
72 character*4 cmdsc(*)
73 character cmseq(120,*)
74 character cmmnem(8,*)
75
76 integer imfxyn(*), nmelem(*),
77 . iefxyn(mxmtbd,mxelem)
78
79C-----------------------------------------------------------------------
80C-----------------------------------------------------------------------
81
82C Call WRDLEN to initialize some important information about the
83C local machine, just in case it hasn't already been called.
84
85 CALL wrdlen
86
87C Read and parse the header lines of both files.
88
89 CALL gettbh ( lunstd, lunltd, 'D', imt, imtv, iogce, iltv )
90
91C Read through the remainder of both files, merging the
92C contents into a unified set of master Table D arrays.
93
94 nmtbd = 0
95 CALL getntbe ( lunstd, isfxyn, stline, iers )
96 CALL getntbe ( lunltd, ilfxyn, ltline, ierl )
97 DO WHILE ( ( iers .EQ. 0 ) .OR. ( ierl .EQ. 0 ) )
98 IF ( ( iers .EQ. 0 ) .AND. ( ierl .EQ. 0 ) ) THEN
99 IF ( isfxyn .EQ. ilfxyn ) THEN
100 cmatch = adn30( isfxyn, 6 )
101 GOTO 900
102 ELSE IF ( isfxyn .LT. ilfxyn ) THEN
103 CALL sntbde ( lunstd, isfxyn, stline, mxmtbd, mxelem,
104 . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
105 . nmelem, iefxyn, ceelem )
106 CALL getntbe ( lunstd, isfxyn, stline, iers )
107 ELSE
108 CALL sntbde ( lunltd, ilfxyn, ltline, mxmtbd, mxelem,
109 . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
110 . nmelem, iefxyn, ceelem )
111 CALL getntbe ( lunltd, ilfxyn, ltline, ierl )
112 ENDIF
113 ELSE IF ( iers .EQ. 0 ) THEN
114 CALL sntbde ( lunstd, isfxyn, stline, mxmtbd, mxelem,
115 . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
116 . nmelem, iefxyn, ceelem )
117 CALL getntbe ( lunstd, isfxyn, stline, iers )
118 ELSE IF ( ierl .EQ. 0 ) THEN
119 CALL sntbde ( lunltd, ilfxyn, ltline, mxmtbd, mxelem,
120 . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
121 . nmelem, iefxyn, ceelem )
122 CALL getntbe ( lunltd, ilfxyn, ltline, ierl )
123 ENDIF
124 ENDDO
125
126 RETURN
127 900 WRITE(bort_str,'("BUFRLIB: RDMTBD - STANDARD AND LOCAL'//
128 . ' TABLE D FILES BOTH CONTAIN SAME FXY NUMBER: ",5A)')
129 . cmatch(1:1), '-', cmatch(2:3), '-', cmatch(4:6)
130 CALL bort(bort_str)
131 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 rdmtbd(LUNSTD, LUNLTD, MXMTBD, MXELEM, IMT, IMTV, IOGCE, ILTV, NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ, NMELEM, IEFXYN, CEELEM)
This subroutine reads master Table D information from two separate ASCII files (one standard and one ...
Definition: rdmtbd.f:67
subroutine sntbde(LUNT, IFXYN, LINE, MXMTBD, MXELEM, NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ, NMELEM, IEFXYN, CEELEM)
This subroutine stores the first line of an entry that was previously read from an ASCII master Table...
Definition: sntbde.f:51
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:36