NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
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 
5 C> This subroutine reads the header lines from two separate ASCII
6 C> files (one standard and one local) containing master table B,
7 C> table D or Code/Flag table information.
8 C>
9 C> @author J. Ator
10 C> @date 2007-01-19
11 C>
12 C> @param[in] LUNS -- integer: Fortran logical unit number for
13 C> ASCII file containing standard table
14 C> information
15 C> @param[in] LUNL -- integer: Fortran logical unit number for
16 C> ASCII file containing local table
17 C> information
18 C> @param[out] TAB -- character: Type of table
19 C> - 'B' = Table B
20 C> - 'D' = Table D
21 C> - 'F' = Code/Flag table
22 C> @param[out] IMT -- integer: Master table
23 C> - This value is read from both ASCII
24 C> files and must be identical between them.
25 C> @param[out] IMTV -- integer: Version number of master table
26 C> - This value is read from the standard ASCII
27 C> file.
28 C> @param[out] IOGCE -- integer: Originating center
29 C> - This value is read from the local ASCII
30 C> file.
31 C> @param[out] ILTV -- integer: Version number of local table
32 C> - This value is read from the local ASCII
33 C> file.
34 C>
35 C> <b>Program history log:</b>
36 C> | Date | Programmer | Comments |
37 C> | -----|------------|----------|
38 C> | 2007-01-19 | J. Ator | Original author |
39 C>
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 
51 C-----------------------------------------------------------------------
52 C 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 ) )
56 C-----------------------------------------------------------------------
57 
58  cttyp = tab // ' '
59 
60 C 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 
70 C 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 
81 C 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 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:37
function valx(STR)
This function decodes a real number from a character string.
Definition: valx.f:25
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:40
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:28
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22