NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
rdbfdx.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> BEGINNING AT THE CURRENT FILE POINTER LOCATION WITHIN LUNIT,
5 C> THIS SUBROUTINE READS A COMPLETE DICTIONARY TABLE (I.E. ONE OR MORE
6 C> ADJACENT BUFR DX (DICTIONARY) MESSAGES) INTO INTERNAL MEMORY ARRAYS
7 C> IN MODULE TABABD.
8 C>
9 C> PROGRAM HISTORY LOG:
10 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
11 C> 1995-06-28 J. WOOLLEN -- INCREASED THE SIZE OF INTERNAL BUFR TABLE
12 C> ARRAYS IN ORDER TO HANDLE BIGGER FILES
13 C> 1996-12-17 J. WOOLLEN -- FIXED FOR SOME MVS COMPILER'S TREATMENT OF
14 C> INTERNAL READS (INCREASES PORTABILITY)
15 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
16 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
17 C> ROUTINE "BORT"; CORRECTED SOME MINOR ERRORS
18 C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
19 C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
20 C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
21 C> BUFR FILES UNDER THE MPI)
22 C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
23 C> 10,000 TO 20,000 BYTES
24 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
25 C> INTERDEPENDENCIES
26 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
27 C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
28 C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
29 C> TERMINATES ABNORMALLY
30 C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
31 C> 20,000 TO 50,000 BYTES
32 C> 2005-11-29 J. ATOR -- USE GETLENS, IUPBS01 AND RDMSGW
33 C> 2009-03-23 J. ATOR -- USE STNTBIA; MODIFY LOGIC TO HANDLE BUFR
34 C> TABLE MESSAGES ENCOUNTERED ANYWHERE IN THE
35 C> FILE (AND NOT JUST AT THE BEGINNING!)
36 C> 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
37 C> REPLACE FORTRAN BACKSPACE WITH C BACKBUFR
38 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
39 C>
40 C> USAGE: CALL RDBFDX (LUNIT, LUN)
41 C> INPUT ARGUMENT LIST:
42 C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
43 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
44 C> (ASSOCIATED WITH FILE CONNECTED TO LOGICAL UNIT LUNIT)
45 C>
46 C> INPUT FILES:
47 C> UNIT "LUNIT" - BUFR FILE
48 C>
49 C> REMARKS:
50 C>
51 C> THIS SUBROUTINE PERFORMS A FUNCTION SIMILAR TO BUFR ARCHIVE LIBRARY
52 C> SUBROUTINE RDUSDX, EXCEPT THAT RDUSDX READS FROM A FILE CONTAINING
53 C> A USER-SUPPLIED BUFR DICTIONARY TABLE IN CHARACTER FORMAT. SEE THE
54 C> DOCBLOCK IN RDUSDX FOR A DESCRIPTION OF THE ARRAYS THAT ARE FILLED
55 C> IN MODULE TABABD.
56 C>
57 C> THIS SUBROUTINE PERFORMS A FUNCTION SIMILAR TO BUFR ARCHIVE LIBRARY
58 C> SUBROUTINE CPDXMM, EXCEPT THAT CPDXMM WRITES TO THE INTERNAL MEMORY
59 C> ARRAYS IN MODULE MSGMEM, FOR USE WITH A FILE OF BUFR MESSAGES THAT
60 C> IS BEING READ AND STORED INTO INTERNAL MEMORY BY BUFR ARCHIVE
61 C> LIBRARY SUBROUTINE UFBMEM.
62 C>
63 C> THIS ROUTINE CALLS: BORT DXINIT ERRWRT IDXMSG
64 C> IUPBS3 MAKESTAB RDMSGW STBFDX
65 C> BACKBUFR
66 C> THIS ROUTINE IS CALLED BY: POSAPX READDX READMG
67 C> Normally not called by any application
68 C> programs.
69 C>
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 
80 C-----------------------------------------------------------------------
81 C-----------------------------------------------------------------------
82 
83  CALL dxinit(lun,0)
84 
85  ict = 0
86  done = .false.
87 
88 C Read a complete dictionary table from LUNIT, as a set of one or
89 C more DX dictionary messages.
90 
91  DO WHILE ( .NOT. done )
92  CALL rdmsgw( lunit, mgwa, ier )
93  IF ( ier .EQ. -1 ) THEN
94 
95 C Don't abort for an end-of-file condition, since it may be
96 C possible for a file to end with dictionary messages.
97 C Instead, backspace the file pointer and let the calling
98 C routine diagnose the end-of-file condition and deal with
99 C 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 
107 C This is a non-DX dictionary message. Assume we've reached
108 C the end of the dictionary table, and backspace LUNIT so that
109 C the next read (e.g. in the calling routine) will get this
110 C same message.
111 
112  CALL backbufr(lun)
113  done = .true.
114  ELSE IF ( iupbs3(mgwa,'NSUB') .EQ. 0 ) THEN
115 
116 C This is a DX dictionary message, but it doesn't contain any
117 C actual dictionary information. Assume we've reached the end
118 C of the dictionary table.
119 
120  done = .true.
121  ELSE
122 
123 C 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
function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:32
void backbufr(f77int *nfile)
This subroutine backspaces a BUFR file by one BUFR message.
Definition: cread.c:76
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:37
subroutine dxinit(LUN, IOI)
THIS SUBROUTINE INITIALIZES THE INTERNAL ARRAYS (IN MODULE TABABD) HOLDING THE DICTIONARY TABLE...
Definition: dxinit.f:40
function idxmsg(MESG)
THIS FUNCTION DETERMINES WHETHER THE GIVEN BUFR MESSAGE IS A DX DICTIONARY MESSAGE THAT WAS CREATED B...
Definition: idxmsg.f:29
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 stbfdx(LUN, MESG)
THIS SUBROUTINE COPIES A BUFR TABLE (DICTIONARY) MESSAGE FROM THE INPUT ARRAY MESG INTO THE INTERNAL ...
Definition: stbfdx.f:28
subroutine rdbfdx(LUNIT, LUN)
BEGINNING AT THE CURRENT FILE POINTER LOCATION WITHIN LUNIT, THIS SUBROUTINE READS A COMPLETE DICTION...
Definition: rdbfdx.f:70
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23