NCEPLIBS-bufr 11.7.1
rdbfdx.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> BEGINNING AT THE CURRENT FILE POINTER LOCATION WITHIN LUNIT,
5C> THIS SUBROUTINE READS A COMPLETE DICTIONARY TABLE (I.E. ONE OR MORE
6C> ADJACENT BUFR DX (DICTIONARY) MESSAGES) INTO INTERNAL MEMORY ARRAYS
7C> IN MODULE TABABD.
8C>
9C> PROGRAM HISTORY LOG:
10C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
11C> 1995-06-28 J. WOOLLEN -- INCREASED THE SIZE OF INTERNAL BUFR TABLE
12C> ARRAYS IN ORDER TO HANDLE BIGGER FILES
13C> 1996-12-17 J. WOOLLEN -- FIXED FOR SOME MVS COMPILER'S TREATMENT OF
14C> INTERNAL READS (INCREASES PORTABILITY)
15C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
16C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
17C> ROUTINE "BORT"; CORRECTED SOME MINOR ERRORS
18C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
19C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
20C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
21C> BUFR FILES UNDER THE MPI)
22C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
23C> 10,000 TO 20,000 BYTES
24C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
25C> INTERDEPENDENCIES
26C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
27C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
28C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
29C> TERMINATES ABNORMALLY
30C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
31C> 20,000 TO 50,000 BYTES
32C> 2005-11-29 J. ATOR -- USE GETLENS, IUPBS01 AND RDMSGW
33C> 2009-03-23 J. ATOR -- USE STNTBIA; MODIFY LOGIC TO HANDLE BUFR
34C> TABLE MESSAGES ENCOUNTERED ANYWHERE IN THE
35C> FILE (AND NOT JUST AT THE BEGINNING!)
36C> 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
37C> REPLACE FORTRAN BACKSPACE WITH C BACKBUFR
38C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
39C>
40C> USAGE: CALL RDBFDX (LUNIT, LUN)
41C> INPUT ARGUMENT LIST:
42C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
43C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
44C> (ASSOCIATED WITH FILE CONNECTED TO LOGICAL UNIT LUNIT)
45C>
46C> INPUT FILES:
47C> UNIT "LUNIT" - BUFR FILE
48C>
49C> REMARKS:
50C>
51C> THIS SUBROUTINE PERFORMS A FUNCTION SIMILAR TO BUFR ARCHIVE LIBRARY
52C> SUBROUTINE RDUSDX, EXCEPT THAT RDUSDX READS FROM A FILE CONTAINING
53C> A USER-SUPPLIED BUFR DICTIONARY TABLE IN CHARACTER FORMAT. SEE THE
54C> DOCBLOCK IN RDUSDX FOR A DESCRIPTION OF THE ARRAYS THAT ARE FILLED
55C> IN MODULE TABABD.
56C>
57C> THIS SUBROUTINE PERFORMS A FUNCTION SIMILAR TO BUFR ARCHIVE LIBRARY
58C> SUBROUTINE CPDXMM, EXCEPT THAT CPDXMM WRITES TO THE INTERNAL MEMORY
59C> ARRAYS IN MODULE MSGMEM, FOR USE WITH A FILE OF BUFR MESSAGES THAT
60C> IS BEING READ AND STORED INTO INTERNAL MEMORY BY BUFR ARCHIVE
61C> LIBRARY SUBROUTINE UFBMEM.
62C>
63C> THIS ROUTINE CALLS: BORT DXINIT ERRWRT IDXMSG
64C> IUPBS3 MAKESTAB RDMSGW STBFDX
65C> BACKBUFR
66C> THIS ROUTINE IS CALLED BY: POSAPX READDX READMG
67C> Normally not called by any application
68C> programs.
69C>
70 SUBROUTINE rdbfdx(LUNIT,LUN)
71
72 USE moda_mgwa
73
74 COMMON /quiet/ iprt
75
76 CHARACTER*128 ERRSTR
77
78 LOGICAL DONE
79
80C-----------------------------------------------------------------------
81C-----------------------------------------------------------------------
82
83 CALL dxinit(lun,0)
84
85 ict = 0
86 done = .false.
87
88C Read a complete dictionary table from LUNIT, as a set of one or
89C more DX dictionary messages.
90
91 DO WHILE ( .NOT. done )
92 CALL rdmsgw ( lunit, mgwa, ier )
93 IF ( ier .EQ. -1 ) THEN
94
95C Don't abort for an end-of-file condition, since it may be
96C possible for a file to end with dictionary messages.
97C Instead, backspace the file pointer and let the calling
98C routine diagnose the end-of-file condition and deal with
99C it as it sees fit.
100
101 CALL backbufr(lun)
102 done = .true.
103 ELSE IF ( ier .EQ. -2 ) THEN
104 GOTO 900
105 ELSE IF ( idxmsg(mgwa) .NE. 1 ) THEN
106
107C This is a non-DX dictionary message. Assume we've reached
108C the end of the dictionary table, and backspace LUNIT so that
109C the next read (e.g. in the calling routine) will get this
110C same message.
111
112 CALL backbufr(lun)
113 done = .true.
114 ELSE IF ( iupbs3(mgwa,'NSUB') .EQ. 0 ) THEN
115
116C This is a DX dictionary message, but it doesn't contain any
117C actual dictionary information. Assume we've reached the end
118C of the dictionary table.
119
120 done = .true.
121 ELSE
122
123C Store this message into MODULE TABABD.
124
125 ict = ict + 1
126 CALL stbfdx(lun,mgwa)
127 ENDIF
128 ENDDO
129
130 IF ( iprt .GE. 2 ) THEN
131 CALL errwrt('+++++++++++++++++++++++++++++++++++++++++++++++++')
132 WRITE ( unit=errstr, fmt='(A,I3,A)' )
133 . 'BUFRLIB: RDBFDX - STORED NEW DX TABLE CONSISTING OF (',
134 . ict, ') MESSAGES;'
135 CALL errwrt(errstr)
136 errstr = 'WILL APPLY THIS TABLE TO ALL SUBSEQUENT DATA IN '//
137 . 'FILE UNTIL NEXT DX TABLE IS FOUND'
138 CALL errwrt(errstr)
139 CALL errwrt('+++++++++++++++++++++++++++++++++++++++++++++++++')
140 CALL errwrt(' ')
141 ENDIF
142
143 CALL makestab
144
145 RETURN
146 900 CALL bort('BUFRLIB: RDBFDX - ERROR READING A BUFR DICTIONARY '//
147 . 'MESSAGE')
148 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
void backbufr(f77int *nfile)
This subroutine backspaces a BUFR file by one BUFR message.
Definition: cread.c:84
subroutine dxinit(LUN, IOI)
THIS SUBROUTINE INITIALIZES THE INTERNAL ARRAYS (IN MODULE TABABD) HOLDING THE DICTIONARY TABLE.
Definition: dxinit.f:41
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
function idxmsg(MESG)
This function determines whether a given BUFR message contains DX BUFR tables information that was ge...
Definition: idxmsg.f:24
function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:35
subroutine makestab
THIS SUBROUTINE CONSTRUCTS AN INTERNAL JUMP/LINK TABLE WITHIN MODULE TABLES, USING THE INFORMATION WI...
Definition: makestab.f:75
subroutine rdbfdx(LUNIT, LUN)
BEGINNING AT THE CURRENT FILE POINTER LOCATION WITHIN LUNIT, THIS SUBROUTINE READS A COMPLETE DICTION...
Definition: rdbfdx.f:71
subroutine rdmsgw(LUNIT, MESG, IRET)
THIS SUBROUTINE READS THE NEXT BUFR MESSAGE FROM LOGICAL UNIT LUNIT AS AN ARRAY OF INTEGER WORDS.
Definition: rdmsgw.f:38
subroutine stbfdx(LUN, MESG)
THIS SUBROUTINE COPIES A BUFR TABLE (DICTIONARY) MESSAGE FROM THE INPUT ARRAY MESG INTO THE INTERNAL ...
Definition: stbfdx.f:29