NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
rdmtbb.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 B 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 B 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 RDMTBB ( LUNSTB, LUNLTB, MXMTBB, IMT, IMTV, IOGCE,
16 C> ILTV, NMTBB, IMFXYN, CMSCL, CMSREF, CMBW,
17 C> CMUNIT, CMMNEM, CMDSC, CMELEM )
18 C> INPUT ARGUMENT LIST:
19 C> LUNSTB - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
20 C> CONTAINING STANDARD TABLE B INFORMATION
21 C> LUNLTB - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
22 C> CONTAINING LOCAL TABLE B INFORMATION
23 C> MXMTBB - INTEGER: MAXIMUM NUMBER OF ENTRIES TO BE STORED IN
24 C> MERGED MASTER TABLE B ARRAYS; THIS SHOULD BE THE SAME
25 C> NUMBER AS WAS USED TO DIMENSION THE OUTPUT ARRAYS IN
26 C> THE CALLING PROGRAM, AND IT IS USED BY THIS SUBROUTINE
27 C> TO ENSURE THAT IT DOESN'T OVERFLOW THESE ARRAYS
28 C>
29 C> OUTPUT ARGUMENT LIST:
30 C> IMT - INTEGER: MASTER TABLE, READ FROM EACH ASCII FILE
31 C> (NOTE: THESE VALUES MUST BE THE SAME IN EACH FILE!)
32 C> IMTV - INTEGER: VERSION NUMBER OF MASTER TABLE, READ FROM
33 C> STANDARD ASCII FILE
34 C> IOGCE - INTEGER: ORIGINATING CENTER, READ FROM LOCAL ASCII FILE
35 C> ILTV - INTEGER: VERSION NUMBER OF LOCAL TABLE, READ FROM
36 C> LOCAL ASCII FILE
37 C> NMTBB - INTEGER: NUMBER OF ENTRIES IN MERGED MASTER TABLE B
38 C> ARRAYS
39 C> IMFXYN(*)- INTEGER: MERGED ARRAY CONTAINING BIT-WISE
40 C> REPRESENTATIONS OF FXY NUMBERS
41 C> CMSCL(*) - CHARACTER*4: MERGED ARRAY CONTAINING SCALE FACTORS
42 C> CMSREF(*)- CHARACTER*12: MERGED ARRAY CONTAINING REFERENCE VALUES
43 C> CMBW(*) - CHARACTER*4: MERGED ARRAY CONTAINING BIT WIDTHS
44 C> CMUNIT(*)- CHARACTER*14: MERGED ARRAY CONTAINING UNITS
45 C> CMMNEM(*)- CHARACTER*8: MERGED ARRAY CONTAINING MNEMONICS
46 C> CMDSC(*) - CHARACTER*4: MERGED ARRAY CONTAINING DESCRIPTOR CODES
47 C> CMELEM(*)- CHARACTER*120: MERGED ARRAY CONTAINING ELEMENT NAMES
48 C>
49 C> REMARKS:
50 C> THIS ROUTINE CALLS: ADN30 BORT GETNTBE GETTBH
51 C> SNTBBE WRDLEN
52 C> THIS ROUTINE IS CALLED BY: IREADMT
53 C> Not normally called by any application
54 C> programs but it could be.
55 C>
56  SUBROUTINE rdmtbb ( LUNSTB, LUNLTB, MXMTBB,
57  . imt, imtv, iogce, iltv,
58  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
59  . cmunit, cmmnem, cmdsc, cmelem )
60 
61 
62 
63  character*200 stline, ltline
64  character*128 bort_str
65  character*6 cmatch, adn30
66  character*4 cmdsc(*)
67  character cmelem(120,*)
68  character cmunit(14,*)
69  character cmsref(12,*)
70  character cmmnem(8,*)
71  character cmscl(4,*), cmbw(4,*)
72 
73  integer imfxyn(*)
74 
75 C-----------------------------------------------------------------------
76 C-----------------------------------------------------------------------
77 
78 C Call WRDLEN to initialize some important information about the
79 C local machine, just in case it hasn't already been called.
80 
81  CALL wrdlen
82 
83 C Read and parse the header lines of both files.
84 
85  CALL gettbh( lunstb, lunltb, 'B', imt, imtv, iogce, iltv )
86 
87 C Read through the remainder of both files, merging the
88 C contents into a unified set of master Table B arrays.
89 
90  nmtbb = 0
91  CALL getntbe( lunstb, isfxyn, stline, iers )
92  CALL getntbe( lunltb, ilfxyn, ltline, ierl )
93  DO WHILE ( ( iers .EQ. 0 ) .OR. ( ierl .EQ. 0 ) )
94  IF ( ( iers .EQ. 0 ) .AND. ( ierl .EQ. 0 ) ) THEN
95  IF ( isfxyn .EQ. ilfxyn ) THEN
96  cmatch = adn30( isfxyn, 6 )
97  goto 900
98  ELSE IF ( isfxyn .LT. ilfxyn ) THEN
99  CALL sntbbe( isfxyn, stline, mxmtbb,
100  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
101  . cmunit, cmmnem, cmdsc, cmelem )
102  CALL getntbe( lunstb, isfxyn, stline, iers )
103  ELSE
104  CALL sntbbe( ilfxyn, ltline, mxmtbb,
105  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
106  . cmunit, cmmnem, cmdsc, cmelem )
107  CALL getntbe( lunltb, ilfxyn, ltline, ierl )
108  ENDIF
109  ELSE IF ( iers .EQ. 0 ) THEN
110  CALL sntbbe( isfxyn, stline, mxmtbb,
111  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
112  . cmunit, cmmnem, cmdsc, cmelem )
113  CALL getntbe( lunstb, isfxyn, stline, iers )
114  ELSE IF ( ierl .EQ. 0 ) THEN
115  CALL sntbbe( ilfxyn, ltline, mxmtbb,
116  . nmtbb, imfxyn, cmscl, cmsref, cmbw,
117  . cmunit, cmmnem, cmdsc, cmelem )
118  CALL getntbe( lunltb, ilfxyn, ltline, ierl )
119  ENDIF
120  ENDDO
121 
122  RETURN
123  900 WRITE(bort_str,'("BUFRLIB: RDMTBB - STANDARD AND LOCAL'//
124  . ' TABLE B FILES BOTH CONTAIN SAME FXY NUMBER: ",5A)')
125  . cmatch(1:1), '-', cmatch(2:3), '-', cmatch(4:6)
126  CALL bort(bort_str)
127  END
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 (I.E.
Definition: rdmtbb.f:56
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 sntbbe(IFXYN, LINE, MXMTBB, NMTBB, IMFXYN, CMSCL, CMSREF, CMBW, CMUNIT, CMMNEM, CMDSC, CMELEM)
THIS SUBROUTINE PARSES AN ENTRY THAT WAS PREVIOUSLY READ FROM AN ASCII MASTER TABLE B FILE AND THEN S...
Definition: sntbbe.f:47
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