NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
rdmtbd.f
Go to the documentation of this file.
1 C> @file
2 C> @author ATOR @date 2007-01-19
3 
4 C> THIS SUBROUTINE READS MASTER TABLE D INFORMATION FROM TWO
5 C> SEPARATE (I.E. ONE STANDARD AND ONE LOCAL) ASCII FILES AND THEN
6 C> MERGES IT INTO A UNIFIED SET OF MASTER TABLE D ARRAYS FOR OUTPUT.
7 C> EACH OF THE TWO INPUT FILES MUST ALREADY BE INDIVIDUALLY SORTED IN
8 C> ASCENDING ORDER WITH RESPECT TO THE FXY NUMBERS.
9 C>
10 C> PROGRAM HISTORY LOG:
11 C> 2007-01-19 J. ATOR -- ORIGINAL AUTHOR
12 C> 2021-01-08 J. ATOR -- MODIFIED MSTABS ARRAY DECLARATIONS
13 C> FOR GNUv10 PORTABILITY
14 C>
15 C> USAGE: CALL RDMTBD ( LUNSTD, LUNLTD, MXMTBD, MXELEM,
16 C> IMT, IMTV, IOGCE, ILTV,
17 C> NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ,
18 C> NMELEM, IEFXYN, CEELEM )
19 C> INPUT ARGUMENT LIST:
20 C> LUNSTD - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
21 C> CONTAINING STANDARD TABLE D INFORMATION
22 C> LUNLTD - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
23 C> CONTAINING LOCAL TABLE D INFORMATION
24 C> MXMTBD - INTEGER: MAXIMUM NUMBER OF ENTRIES TO BE STORED IN
25 C> MERGED MASTER TABLE D ARRAYS; THIS SHOULD BE THE SAME
26 C> NUMBER AS WAS USED TO DIMENSION THE OUTPUT ARRAYS IN
27 C> THE CALLING PROGRAM, AND IT IS USED BY THIS SUBROUTINE
28 C> TO ENSURE THAT IT DOESN'T OVERFLOW THESE ARRAYS
29 C> MXELEM - INTEGER: MAXIMUM NUMBER OF ELEMENTS TO BE STORED PER
30 C> ENTRY WITHIN THE MERGED MASTER TABLE D ARRAYS; THIS
31 C> SHOULD BE THE SAME NUMBER AS WAS USED TO DIMENSION THE
32 C> OUTPUT ARRAYS IN THE CALLING PROGRAM, AND IT IS USED
33 C> BY THIS SUBROUTINE TO ENSURE THAT IT DOESN'T OVERFLOW
34 C> THESE ARRAYS
35 C>
36 C> OUTPUT ARGUMENT LIST:
37 C> IMT - INTEGER: MASTER TABLE, READ FROM EACH ASCII FILE
38 C> (NOTE: THESE VALUES MUST BE THE SAME IN EACH FILE!)
39 C> IMTV - INTEGER: VERSION NUMBER OF MASTER TABLE, READ FROM
40 C> STANDARD ASCII FILE
41 C> IOGCE - INTEGER: ORIGINATING CENTER, READ FROM LOCAL ASCII FILE
42 C> ILTV - INTEGER: VERSION NUMBER OF LOCAL TABLE, READ FROM
43 C> LOCAL ASCII FILE
44 C> NMTBD - INTEGER: NUMBER OF ENTRIES IN MERGED MASTER TABLE D
45 C> ARRAYS
46 C> IMFXYN(*)- INTEGER: MERGED ARRAY CONTAINING BIT-WISE
47 C> REPRESENTATIONS OF FXY NUMBERS (I.E. SEQUENCE
48 C> DESCRIPTORS)
49 C> CMMNEM(*)- CHARACTER*8: MERGED ARRAY CONTAINING MNEMONICS
50 C> CMDSC(*) - CHARACTER*4: MERGED ARRAY CONTAINING DESCRIPTOR CODES
51 C> CMSEQ(*) - CHARACTER*120: MERGED ARRAY CONTAINING SEQUENCE NAMES
52 C> NMELEM(*)- INTEGER: MERGED ARRAY CONTAINING NUMBER OF ELEMENTS
53 C> STORED FOR EACH ENTRY
54 C> IEFXYN(*,*)- INTEGER: MERGED ARRAY CONTAINING BIT-WISE
55 C> REPRESENTATIONS OF ELEMENT FXY NUMBERS
56 C> CEELEM(*,*)- CHARACTER*120: MERGED ARRAY CONTAINING ELEMENT NAMES
57 C>
58 C> REMARKS:
59 C> THIS ROUTINE CALLS: ADN30 BORT GETNTBE GETTBH
60 C> SNTBDE WRDLEN
61 C> THIS ROUTINE IS CALLED BY: IREADMT
62 C> Not normally called by any application
63 C> programs but it could be.
64 C>
65  SUBROUTINE rdmtbd ( LUNSTD, LUNLTD, MXMTBD, MXELEM,
66  . imt, imtv, iogce, iltv,
67  . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
68  . nmelem, iefxyn, ceelem )
69 
70 
71 
72  character*200 stline, ltline
73  character*128 bort_str
74  character*120 ceelem(mxmtbd,mxelem)
75  character*6 cmatch, adn30
76  character*4 cmdsc(*)
77  character cmseq(120,*)
78  character cmmnem(8,*)
79 
80  integer imfxyn(*), nmelem(*),
81  . iefxyn(mxmtbd,mxelem)
82 
83 C-----------------------------------------------------------------------
84 C-----------------------------------------------------------------------
85 
86 C Call WRDLEN to initialize some important information about the
87 C local machine, just in case it hasn't already been called.
88 
89  CALL wrdlen
90 
91 C Read and parse the header lines of both files.
92 
93  CALL gettbh( lunstd, lunltd, 'D', imt, imtv, iogce, iltv )
94 
95 C Read through the remainder of both files, merging the
96 C contents into a unified set of master Table D arrays.
97 
98  nmtbd = 0
99  CALL getntbe( lunstd, isfxyn, stline, iers )
100  CALL getntbe( lunltd, ilfxyn, ltline, ierl )
101  DO WHILE ( ( iers .EQ. 0 ) .OR. ( ierl .EQ. 0 ) )
102  IF ( ( iers .EQ. 0 ) .AND. ( ierl .EQ. 0 ) ) THEN
103  IF ( isfxyn .EQ. ilfxyn ) THEN
104  cmatch = adn30( isfxyn, 6 )
105  goto 900
106  ELSE IF ( isfxyn .LT. ilfxyn ) THEN
107  CALL sntbde( lunstd, isfxyn, stline, mxmtbd, mxelem,
108  . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
109  . nmelem, iefxyn, ceelem )
110  CALL getntbe( lunstd, isfxyn, stline, iers )
111  ELSE
112  CALL sntbde( lunltd, ilfxyn, ltline, mxmtbd, mxelem,
113  . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
114  . nmelem, iefxyn, ceelem )
115  CALL getntbe( lunltd, ilfxyn, ltline, ierl )
116  ENDIF
117  ELSE IF ( iers .EQ. 0 ) THEN
118  CALL sntbde( lunstd, isfxyn, stline, mxmtbd, mxelem,
119  . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
120  . nmelem, iefxyn, ceelem )
121  CALL getntbe( lunstd, isfxyn, stline, iers )
122  ELSE IF ( ierl .EQ. 0 ) THEN
123  CALL sntbde( lunltd, ilfxyn, ltline, mxmtbd, mxelem,
124  . nmtbd, imfxyn, cmmnem, cmdsc, cmseq,
125  . nmelem, iefxyn, ceelem )
126  CALL getntbe( lunltd, ilfxyn, ltline, ierl )
127  ENDIF
128  ENDDO
129 
130  RETURN
131  900 WRITE(bort_str,'("BUFRLIB: RDMTBD - STANDARD AND LOCAL'//
132  . ' TABLE D FILES BOTH CONTAIN SAME FXY NUMBER: ",5A)')
133  . cmatch(1:1), '-', cmatch(2:3), '-', cmatch(4:6)
134  CALL bort(bort_str)
135  END
subroutine gettbh(LUNS, LUNL, TAB, IMT, IMTV, IOGCE, ILTV)
THIS SUBROUTINE READS AND PARSES THE HEADER LINES FROM TWO SEPARATE (I.E.
Definition: gettbh.f:34
character *(*) function adn30(IDN, L30)
This function converts a descriptor from its bit-wise (integer) representation to its 5 or 6 characte...
Definition: adn30.f:27
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:43
subroutine sntbde(LUNT, IFXYN, LINE, MXMTBD, MXELEM, NMTBD, IMFXYN, CMMNEM, CMDSC, CMSEQ, NMELEM, IEFXYN, CEELEM)
THIS SUBROUTINE PARSES THE FIRST LINE OF AN ENTRY THAT WAS PREVIOUSLY READ FROM AN ASCII MASTER TABLE...
Definition: sntbde.f:61
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 (I.E.
Definition: rdmtbd.f:65
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 gets the first line of the next entry in the specified ASCII master table B...
Definition: getntbe.f:26