NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
rdmtbd.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read master Table D information from local file system
3 
4 C> This subroutine reads master Table D 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] LUNSTD -- integer: Fortran logical unit number for
15 C> ASCII file containing standard Table D
16 C> information
17 C> @param[in] LUNLTD -- integer: Fortran logical unit number for
18 C> ASCII file containing local Table D
19 C> information
20 C> @param[in] MXMTBD -- 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[in] MXELEM -- integer: Maximum number of elements to be
25 C> stored per Table D sequence within merged
26 C> output arrays; used by the subroutine to
27 C> ensure that it doesn't overflow these arrays
28 C> @param[out] IMT -- integer: Master table
29 C> - This value is read from both ASCII
30 C> files and must be identical between them.
31 C> @param[out] IMTV -- integer: Version number of master table
32 C> - This value is read from the standard ASCII
33 C> file.
34 C> @param[out] IOGCE -- integer: Originating center
35 C> - This value is read from the local ASCII
36 C> file.
37 C> @param[out] ILTV -- integer: Version number of local table
38 C> - This value is read from the local ASCII
39 C> file.
40 C> @param[out] NMTBD -- integer: Number of entries in merged output
41 C> arrays
42 C> @param[out] IMFXYN -- integer(*): Merged array containing bit-wise
43 C> representations of FXY numbers
44 C> @param[out] CMMNEM -- character*8(*): Merged array containing
45 C> mnemonics
46 C> @param[out] CMDSC -- character*4(*): Merged array containing
47 C> descriptor codes
48 C> @param[out] CMSEQ -- character*120(*): Merged array containing
49 C> sequence names
50 C> @param[out] NMELEM -- integer(*): Merged array containing number of
51 C> elements stored for each sequence
52 C> @param[out] IEFXYN -- integer(*,*): Merged array containing bit-wise
53 C> representations of element FXY numbers
54 C> @param[out] CEELEM -- character*120(*,*): Merged array containing
55 C> element names
56 C>
57 C> <b>Program history log:</b>
58 C> | Date | Programmer | Comments |
59 C> | -----|------------|----------|
60 C> | 2007-01-19 | J. Ator | Original author |
61 C> | 2021-01-08 | J. Ator | Modified mstabs array declarations for GNUv10 portability |
62 C>
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 
79 C-----------------------------------------------------------------------
80 C-----------------------------------------------------------------------
81 
82 C Call WRDLEN to initialize some important information about the
83 C local machine, just in case it hasn't already been called.
84 
85  CALL wrdlen
86 
87 C Read and parse the header lines of both files.
88 
89  CALL gettbh( lunstd, lunltd, 'D', imt, imtv, iogce, iltv )
90 
91 C Read through the remainder of both files, merging the
92 C 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
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 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:48
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:63
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