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