NCEPLIBS-bufr  12.0.0
gettbh.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read the header lines from a master table B, table D or
3 C> Code/Flag table
4 C>
5 C> @author J. Ator @date 2007-01-19
6 
7 C> This subroutine reads the header lines from two separate ASCII
8 C> files (one standard and one local) containing master table B,
9 C> table D or Code/Flag table information.
10 C>
11 C> @param[in] LUNS -- integer: Fortran logical unit number for
12 C> ASCII file containing standard table
13 C> information
14 C> @param[in] LUNL -- integer: Fortran logical unit number for
15 C> ASCII file containing local table
16 C> information
17 C> @param[out] TAB -- character: Type of table
18 C> - 'B' = Table B
19 C> - 'D' = Table D
20 C> - 'F' = Code/Flag table
21 C> @param[out] IMT -- integer: Master table
22 C> - This value is read from both ASCII
23 C> files and must be identical between them.
24 C> @param[out] IMTV -- integer: Version number of master table
25 C> - This value is read from the standard ASCII
26 C> file.
27 C> @param[out] IOGCE -- integer: Originating center
28 C> - This value is read from the local ASCII
29 C> file.
30 C> @param[out] ILTV -- integer: Version number of local table
31 C> - This value is read from the local ASCII
32 C> file.
33 C>
34 C> @author J. Ator @date 2007-01-19
35  SUBROUTINE gettbh ( LUNS, LUNL, TAB, IMT, IMTV, IOGCE, ILTV )
36 
37  CHARACTER*128 BORT_STR
38  CHARACTER*40 HEADER
39  CHARACTER*30 TAGS(5), LABEL
40  CHARACTER*3 CFTYP
41  CHARACTER*2 CTTYP
42  CHARACTER*1 TAB
43 
44  LOGICAL BADLABEL
45 
46 C-----------------------------------------------------------------------
47 C Statement function to check for bad header line label:
48 
49  badlabel( label ) = ( ( index( label, cttyp ) .EQ. 0 ) .OR.
50  . ( index( label, cftyp ) .EQ. 0 ) )
51 C-----------------------------------------------------------------------
52 
53  cttyp = tab // ' '
54 
55 C Read and parse the header line of the standard file.
56 
57  cftyp = 'STD'
58  IF ( igetntbl( luns, header ) .NE. 0 ) GOTO 900
59  CALL parstr ( header, tags, 5, ntag, '|', .false. )
60  IF ( ntag .LT. 3 ) GOTO 900
61  IF ( badlabel( tags(1) ) ) GOTO 900
62  CALL strnum ( tags(2), imt, iersn )
63  CALL strnum ( tags(3), imtv, iersn )
64 
65 C Read and parse the header line of the local file.
66 
67  cftyp = 'LOC'
68  IF ( igetntbl( lunl, header ) .NE. 0 ) GOTO 900
69  CALL parstr ( header, tags, 5, ntag, '|', .false. )
70  IF ( ntag .LT. 4 ) GOTO 900
71  IF ( badlabel( tags(1) ) ) GOTO 900
72  CALL strnum ( tags(2), imt2, iersn )
73  CALL strnum ( tags(3), iogce, iersn )
74  CALL strnum ( tags(4), iltv, iersn )
75 
76 C Verify that both files are for the same master table.
77 
78  IF ( imt .NE. imt2 ) GOTO 901
79 
80  RETURN
81 
82  900 WRITE(bort_str,'("BUFRLIB: GETTBH - BAD OR MISSING HEADER '//
83  . 'WITHIN ",A," TABLE ",A)') cftyp, tab
84  CALL bort(bort_str)
85  901 WRITE(bort_str,'("BUFRLIB: GETTBH - MASTER TABLE NUMBER '//
86  . 'MISMATCH BETWEEN STD AND LOC TABLE ",A)') tab
87  CALL bort(bort_str)
88  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
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
function igetntbl(LUNT, LINE)
This subroutine reads the next line from an ASCII master table B, table D or Code/Flag table file,...
Definition: igetntbl.f:24
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
Parse a string containing one or more substrings into an array of substrings.
Definition: parstr.f:24
recursive subroutine strnum(str, num, iret)
Decode an integer from a character string.
Definition: strnum.F90:24