NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
gettbh.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 AND PARSES THE HEADER LINES FROM TWO
5 C> SEPARATE (I.E. ONE STANDARD AND ONE LOCAL) ASCII FILES CONTAINING
6 C> EITHER MASTER TABLE B OR MASTER TABLE D INFORMATION.
7 C>
8 C> PROGRAM HISTORY LOG:
9 C> 2007-01-19 J. ATOR -- ORIGINAL AUTHOR
10 C>
11 C> USAGE: CALL GETTBH ( LUNS, LUNL, TAB, IMT, IMTV, IOGCE, ILTV )
12 C>
13 C> INPUT ARGUMENT LIST:
14 C> LUNS - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
15 C> CONTAINING STANDARD TABLE INFORMATION
16 C> LUNL - INTEGER: FORTRAN LOGICAL UNIT NUMBER OF ASCII FILE
17 C> CONTAINING LOCAL TABLE INFORMATION
18 C> TAB - CHARACTER*1: TABLE TYPE ('B' OR 'D')
19 C>
20 C> OUTPUT ARGUMENT LIST:
21 C> IMT - INTEGER: MASTER TABLE, READ FROM EACH ASCII FILE
22 C> (NOTE: THESE VALUES MUST BE THE SAME IN EACH FILE!)
23 C> IMTV - INTEGER: VERSION NUMBER OF MASTER TABLE, READ FROM
24 C> STANDARD ASCII FILE
25 C> IOGCE - INTEGER: ORIGINATING CENTER, READ FROM LOCAL ASCII FILE
26 C> ILTV - INTEGER: VERSION NUMBER OF LOCAL TABLE, READ FROM
27 C> LOCAL ASCII FILE
28 C>
29 C> REMARKS:
30 C> THIS ROUTINE CALLS: BORT IGETNTBL PARSTR VALX
31 C> THIS ROUTINE IS CALLED BY: RDMTBB RDMTBD RDMTBF
32 C> Also called by application programs.
33 C>
34  SUBROUTINE gettbh ( LUNS, LUNL, TAB, IMT, IMTV, IOGCE, ILTV )
35 
36 
37 
38  character*128 bort_str
39  character*40 header
40  character*30 tags(5), label
41  character*3 cftyp
42  character*2 cttyp
43  character*1 tab
44 
45  logical badlabel
46 
47 C-----------------------------------------------------------------------
48 C Statement function to check for bad header line label:
49 
50  badlabel( label ) = ( ( index( label, cttyp ) .EQ. 0 ) .OR.
51  . ( index( label, cftyp ) .EQ. 0 ) )
52 C-----------------------------------------------------------------------
53 
54  cttyp = tab // ' '
55 
56 C Read and parse the header line of the standard file.
57 
58  cftyp = 'STD'
59  IF ( igetntbl( luns, header ) .NE. 0 ) goto 900
60  CALL parstr( header, tags, 5, ntag, '|', .false. )
61  IF ( ntag .LT. 3 ) goto 900
62  IF ( badlabel( tags(1) ) ) goto 900
63  imt = valx( tags(2) )
64  imtv = valx( tags(3) )
65 
66 C Read and parse the header line of the local file.
67 
68  cftyp = 'LOC'
69  IF ( igetntbl( lunl, header ) .NE. 0 ) goto 900
70  CALL parstr( header, tags, 5, ntag, '|', .false. )
71  IF ( ntag .LT. 4 ) goto 900
72  IF ( badlabel( tags(1) ) ) goto 900
73  imt2 = valx( tags(2) )
74  iogce = valx( tags(3) )
75  iltv = valx( tags(4) )
76 
77 C Verify that both files are for the same master table.
78 
79  IF ( imt .NE. imt2 ) goto 901
80 
81  RETURN
82 
83  900 WRITE(bort_str,'("BUFRLIB: GETTBH - BAD OR MISSING HEADER '//
84  . 'WITHIN ",A," TABLE ",A)') cftyp, tab
85  CALL bort(bort_str)
86  901 WRITE(bort_str,'("BUFRLIB: GETTBH - MASTER TABLE NUMBER '//
87  . 'MISMATCH BETWEEN STD AND LOC TABLE ",A)') tab
88  CALL bort(bort_str)
89  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:39
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
function igetntbl(LUNT, LINE)
THIS FUNCTION GETS THE NEXT LINE FROM THE ASCII MASTER TABLE FILE SPECIFIED BY LUNT, IGNORING ANY BLANK LINES OR COMMENT LINES IN THE PROCESS.
Definition: igetntbl.f:31
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23