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