NCEPLIBS-bufr  12.0.0
readdx.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read DX BUFR table information into internal arrays.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> This subroutine initializes modules @ref moda_tababd and @ref
7 C> moda_msgcwd with DX BUFR (dictionary) tables. These tables are needed
8 C> to read, write, initialize or append a BUFR file.
9 C>
10 C> The modules are initialized from:
11 C> 1. an external, user-supplied BURF dictionary table file (i.e., a
12 C> BUFR mnemonic table).
13 C> 2. the BUFR file indicated by LUNIT.
14 C> 3. another currently opened BUFR file.
15 C>
16 C> If the modules are initialized by the BUFF file indicated by LUNIT,
17 C> then it must have been opened for input processing and positioned at a
18 C> dictionary table > message somewhere in the file.
19 C>
20 C> Once initialzed, the dictionary arrays are associated with the BUFR
21 C> file indicated by LUNIT, until the file is closed with closbf().
22 C>
23 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file
24 C> being read, written, initialized or appended.
25 C> @param[in] LUN - integer: I/O stream index into internal memory arrays
26 C> (associated with file connected to logical unit LUNIT)
27 C> @param[in] LUNDX - integer: Fortran logical unit number
28 C> containing dictionary table information to be used in reading/
29 C> writing from/to LUNIT (depending on the case); may be
30 C> set equal to LUNIT if dictionary table information is
31 C> already embedded in LUNIT (but only if LUNIT is being read).
32 C>
33 C> @author Woollen @date 1994-01-06
34  SUBROUTINE readdx(LUNIT,LUN,LUNDX)
35 
36  COMMON /quiet/ iprt
37 
38  CHARACTER*128 ERRSTR
39 
40 C-----------------------------------------------------------------------
41 C-----------------------------------------------------------------------
42 
43 C GET THE BUFR STATUS OF UNIT LUNDX
44 C ---------------------------------
45 
46  CALL status(lundx,lud,ildx,imdx)
47 
48 C READ A DICTIONARY TABLE FROM THE INDICATED SOURCE
49 C -------------------------------------------------
50 
51  IF (lunit.EQ.lundx) THEN
52 c .... Source is input BUFR file in LUNIT
53  IF(iprt.GE.2) THEN
54  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
55  WRITE ( unit=errstr, fmt='(A,A,I3,A)' )
56  . 'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ',
57  . 'INPUT BUFR FILE IN UNIT ', lundx, ' INTO INTERNAL ARRAYS'
58  CALL errwrt(errstr)
59  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
60  CALL errwrt(' ')
61  ENDIF
62  rewind lunit
63  CALL rdbfdx(lunit,lun)
64  ELSEIF(ildx.EQ.-1) THEN
65 c .... Source is input BUFR file in LUNDX
66 c .... BUFR file in LUNIT may be input or output
67  IF(iprt.GE.2) THEN
68  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
69  WRITE ( unit=errstr, fmt='(A,A,I3,A,A,I3)' )
70  . 'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ',
71  . 'ARRAYS ASSOC. W/ INPUT UNIT ', lundx, ' TO THOSE ASSOC. ',
72  . 'W/ UNIT ', lunit
73  CALL errwrt(errstr)
74  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
75  CALL errwrt(' ')
76  ENDIF
77  CALL cpbfdx(lud,lun)
78  CALL makestab
79  ELSEIF(ildx.EQ.1) THEN
80 c .... Source is output BUFR file in LUNDX
81 c .... BUFR file in LUNIT may be input or output
82  IF(iprt.GE.2) THEN
83  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
84  WRITE ( unit=errstr, fmt='(A,A,I3,A,A,I3)' )
85  . 'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ',
86  . 'ARRAYS ASSOC. W/ OUTPUT UNIT ', lundx, ' TO THOSE ASSOC. ',
87  . 'W/ UNIT ', lunit
88  CALL errwrt(errstr)
89  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
90  CALL errwrt(' ')
91  ENDIF
92  CALL cpbfdx(lud,lun)
93  CALL makestab
94  ELSEIF(ildx.EQ.0) THEN
95 c .... Source is user-supplied character table in LUNDX
96 c .... BUFR file in LUNIT may be input or output
97  IF(iprt.GE.2) THEN
98  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
99  WRITE ( unit=errstr, fmt='(A,A,I3,A)' )
100  . 'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ',
101  . 'USER-SUPPLIED TEXT FILE IN UNIT ', lundx,
102  . ' INTO INTERNAL ARRAYS'
103  CALL errwrt(errstr)
104  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
105  CALL errwrt(' ')
106  ENDIF
107  rewind lundx
108  CALL rdusdx(lundx,lun)
109  ELSE
110  GOTO 900
111  ENDIF
112 
113 C EXITS
114 C -----
115 
116  RETURN
117 900 CALL bort('BUFRLIB: READDX - CANNOT DETERMINE SOURCE OF '//
118  . 'INPUT DICTIONARY TABLE')
119  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine cpbfdx(LUD, LUN)
This subroutine copies all of the DX BUFR table information from one unit to another within internal ...
Definition: cpbfdx.f:17
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
subroutine makestab
This subroutine constructs the internal jump/link table within module tables, using all of the intern...
Definition: makestab.f:24
subroutine rdbfdx(LUNIT, LUN)
Beginning at the current file pointer location within LUNIT, this subroutine reads a complete DX BUFR...
Definition: rdbfdx.f:28
subroutine rdusdx(LUNDX, LUN)
Read a complete DX BUFR table.
Definition: rdusdx.f:22
subroutine readdx(LUNIT, LUN, LUNDX)
This subroutine initializes modules moda_tababd and moda_msgcwd with DX BUFR (dictionary) tables.
Definition: readdx.f:35
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36