NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
readdx.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE GENERATES INTERNAL ARRAYS CONTAINING BUFR
5 C> DICTIONARY TABLES WHICH ARE NEEDED TO READ, WRITE, INITIALIZE OR
6 C> APPEND A BUFR FILE. THE INFORMATION USED TO CREATE THE INTERNAL
7 C> DICTIONARY TABLE ARRAYS (IN MODULE TABABD) AND THE DICTIONARY
8 C> MESSAGE CONTROL WORD PARTITION ARRAYS (IN MODULE MSGCWD)
9 C> (WHICH ARE ALWAYS THEN ASSOCIATED WITH THE BUFR FILE IN LUNIT)
10 C> MAY COME FROM AN EXTERNAL, USER-SUPPLIED, BUFR DICTIONARY
11 C> TABLE FILE IN CHARACTER FORMAT (I.E., A BUFR MNEMONIC TABLE), FROM
12 C> THE BUFR FILE BEING ACTED UPON (IN WHICH CASE THE FILE MUST BE
13 C> OPENED FOR INPUT PROCESSING AND POSITIONED AT A DICTIONARY TABLE
14 C> MESSAGE SOMEWHERE IN THE FILE), OR FROM ANOTHER CURRENTLY OPENED
15 C> AND DEFINED BUFR FILE. IN THIS LATTER CASE, THE BUFR FILE WOULD
16 C> MOST LIKELY BE OPENED FOR INPUT, HOWEVER THERE IS NOTHING
17 C> PREVENTING THE USE OF A FILE OPEN FOR OUTPUT AS LONG AS IT IS
18 C> ASSOCIATED WITH INTERNAL DICTIONARY ARRAYS THAT CAN BE USED.
19 C>
20 C> PROGRAM HISTORY LOG:
21 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
22 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
23 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
24 C> ROUTINE "BORT"
25 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
26 C> INTERDEPENDENCIES
27 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
28 C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
29 C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
30 C> TERMINATES ABNORMALLY OR FOR INFORMATIONAL
31 C> PURPOSES
32 C> 2009-04-21 J. ATOR -- USE ERRWRT
33 C>
34 C> USAGE: CALL READDX (LUNIT, LUN, LUNDX)
35 C> INPUT ARGUMENT LIST:
36 C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
37 C> BEING READ, WRITTEN, INITIALIZED OR APPENDED
38 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
39 C> (ASSOCIATED WITH FILE CONNECTED TO LOGICAL UNIT LUNIT)
40 C> LUNDX - INTEGER: FORTRAN LOGICAL UNIT NUMBER CONTAINING
41 C> DICTIONARY TABLE INFORMATION TO BE USED IN READING/
42 C> WRITING FROM/TO LUNIT (DEPENDING ON THE CASE); MAY BE
43 C> SET EQUAL TO LUNIT IF DICTIONARY TABLE INFORMATION IS
44 C> ALREADY EMBEDDED IN LUNIT (BUT ONLY IF LUNIT IS BEING
45 C> READ)
46 C>
47 C> REMARKS:
48 C> THIS ROUTINE CALLS: BORT CPBFDX ERRWRT MAKESTAB
49 C> RDBFDX RDUSDX STATUS
50 C> THIS ROUTINE IS CALLED BY: OPENBF WRITDX
51 C> Normally not called by any application
52 C> programs.
53 C>
54  SUBROUTINE readdx(LUNIT,LUN,LUNDX)
55 
56 
57 
58  COMMON /quiet/ iprt
59 
60  CHARACTER*128 errstr
61 
62 C-----------------------------------------------------------------------
63 C-----------------------------------------------------------------------
64 
65 C GET THE BUFR STATUS OF UNIT LUNDX
66 C ---------------------------------
67 
68  CALL status(lundx,lud,ildx,imdx)
69 
70 C READ A DICTIONARY TABLE FROM THE INDICATED SOURCE
71 C -------------------------------------------------
72 
73  IF (lunit.EQ.lundx) THEN
74 c .... Source is input BUFR file in LUNIT
75  IF(iprt.GE.2) THEN
76  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
77  WRITE ( unit=errstr, fmt='(A,A,I3,A)' )
78  . 'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ',
79  . 'INPUT BUFR FILE IN UNIT ', lundx, ' INTO INTERNAL ARRAYS'
80  CALL errwrt(errstr)
81  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
82  CALL errwrt(' ')
83  ENDIF
84  rewind lunit
85  CALL rdbfdx(lunit,lun)
86  ELSEIF(ildx.EQ.-1) THEN
87 c .... Source is input BUFR file in LUNDX
88 c .... BUFR file in LUNIT may be input or output
89  IF(iprt.GE.2) THEN
90  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
91  WRITE ( unit=errstr, fmt='(A,A,I3,A,A,I3)' )
92  . 'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ',
93  . 'ARRAYS ASSOC. W/ INPUT UNIT ', lundx, ' TO THOSE ASSOC. ',
94  . 'W/ UNIT ', lunit
95  CALL errwrt(errstr)
96  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
97  CALL errwrt(' ')
98  ENDIF
99  CALL cpbfdx(lud,lun)
100  CALL makestab
101  ELSEIF(ildx.EQ.1) THEN
102 c .... Source is output BUFR file in LUNDX
103 c .... BUFR file in LUNIT may be input or output
104  IF(iprt.GE.2) THEN
105  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
106  WRITE ( unit=errstr, fmt='(A,A,I3,A,A,I3)' )
107  . 'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ',
108  . 'ARRAYS ASSOC. W/ OUTPUT UNIT ', lundx, ' TO THOSE ASSOC. ',
109  . 'W/ UNIT ', lunit
110  CALL errwrt(errstr)
111  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
112  CALL errwrt(' ')
113  ENDIF
114  CALL cpbfdx(lud,lun)
115  CALL makestab
116  ELSEIF(ildx.EQ.0) THEN
117 c .... Source is user-supplied character table in LUNDX
118 c .... BUFR file in LUNIT may be input or output
119  IF(iprt.GE.2) THEN
120  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
121  WRITE ( unit=errstr, fmt='(A,A,I3,A)' )
122  . 'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ',
123  . 'USER-SUPPLIED TEXT FILE IN UNIT ', lundx,
124  . ' INTO INTERNAL ARRAYS'
125  CALL errwrt(errstr)
126  CALL errwrt('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
127  CALL errwrt(' ')
128  ENDIF
129  rewind lundx
130  CALL rdusdx(lundx,lun)
131  ELSE
132  goto 900
133  ENDIF
134 
135 C EXITS
136 C -----
137 
138  RETURN
139 900 CALL bort('BUFRLIB: READDX - CANNOT DETERMINE SOURCE OF '//
140  . 'INPUT DICTIONARY TABLE')
141  END
subroutine cpbfdx(LUD, LUN)
THIS SUBROUTINE COPIES BUFR TABLE (DICTIONARY) MESSAGES FROM ONE LOCATION TO ANOTHER WITHIN INTERNAL ...
Definition: cpbfdx.f:35
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:61
subroutine readdx(LUNIT, LUN, LUNDX)
THIS SUBROUTINE GENERATES INTERNAL ARRAYS CONTAINING BUFR DICTIONARY TABLES WHICH ARE NEEDED TO READ...
Definition: readdx.f:54
subroutine makestab
THIS SUBROUTINE CONSTRUCTS AN INTERNAL JUMP/LINK TABLE WITHIN MODULE TABLES, USING THE INFORMATION WI...
Definition: makestab.f:74
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39
subroutine rdbfdx(LUNIT, LUN)
BEGINNING AT THE CURRENT FILE POINTER LOCATION WITHIN LUNIT, THIS SUBROUTINE READS A COMPLETE DICTION...
Definition: rdbfdx.f:70
subroutine rdusdx(LUNDX, LUN)
THIS SUBROUTINE READS AND PARSES A FILE CONTAINING A USER- SUPPLIED BUFR DICTIONARY TABLE IN CHARACTE...
Definition: rdusdx.f:64
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23