NCEPLIBS-bufr  12.0.1
rdbfdx.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read a complete DX BUFR table.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> Beginning at the current file pointer location within LUNIT,
7 C> this subroutine reads a complete DX BUFR table into internal memory arrays
8 C> in module @ref moda_tababd. A DX BUFR table consists of one or more consecutive
9 C> DX BUFR messages.
10 C>
11 C> This subroutine performs a function similar to
12 C> rdusdx(), except that rdusdx() reads from a file containing
13 C> a user-supplied DX BUFR table in character format. See rdusdx()
14 C> for a description of the arrays that are filled
15 C> in module @ref moda_tababd.
16 C>
17 C> This subroutine performs a function similar to
18 C> cpdxmm(), except that cpdxmm() writes to the internal memory
19 C> arrays in module @ref moda_msgmem, for use with a file of BUFR messages that
20 C> is being read and stored into internal memory via subroutine ufbmem().
21 C>
22 C> @param[in] LUNIT - integer: fortran logical unit number for BUFR file.
23 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
24 C> (associated with file connected to logical unit LUNIT).
25 C>
26 C> @author Woollen @date 1994-01-06
27  SUBROUTINE rdbfdx(LUNIT,LUN)
28 
29  use bufrlib
30 
31  USE moda_mgwa
32 
33  COMMON /quiet/ iprt
34 
35  CHARACTER*128 ERRSTR
36 
37  LOGICAL DONE
38 
39 C-----------------------------------------------------------------------
40 C-----------------------------------------------------------------------
41 
42  CALL dxinit(lun,0)
43 
44  ict = 0
45  done = .false.
46 
47 C Read a complete dictionary table from LUNIT, as a set of one or
48 C more DX dictionary messages.
49 
50  DO WHILE ( .NOT. done )
51  CALL rdmsgw ( lunit, mgwa, ier )
52  IF ( ier .EQ. -1 ) THEN
53 
54 C Don't abort for an end-of-file condition, since it may be
55 C possible for a file to end with dictionary messages.
56 C Instead, backspace the file pointer and let the calling
57 C routine diagnose the end-of-file condition and deal with
58 C it as it sees fit.
59 
60  CALL backbufr_c(lun)
61  done = .true.
62  ELSE IF ( ier .EQ. -2 ) THEN
63  GOTO 900
64  ELSE IF ( idxmsg(mgwa) .NE. 1 ) THEN
65 
66 C This is a non-DX dictionary message. Assume we've reached
67 C the end of the dictionary table, and backspace LUNIT so that
68 C the next read (e.g. in the calling routine) will get this
69 C same message.
70 
71  CALL backbufr_c(lun)
72  done = .true.
73  ELSE IF ( iupbs3(mgwa,'NSUB') .EQ. 0 ) THEN
74 
75 C This is a DX dictionary message, but it doesn't contain any
76 C actual dictionary information. Assume we've reached the end
77 C of the dictionary table.
78 
79  done = .true.
80  ELSE
81 
82 C Store this message into MODULE TABABD.
83 
84  ict = ict + 1
85  CALL stbfdx(lun,mgwa)
86  ENDIF
87  ENDDO
88 
89  IF ( iprt .GE. 2 ) THEN
90  CALL errwrt('+++++++++++++++++++++++++++++++++++++++++++++++++')
91  WRITE ( unit=errstr, fmt='(A,I3,A)' )
92  . 'BUFRLIB: RDBFDX - STORED NEW DX TABLE CONSISTING OF (',
93  . ict, ') MESSAGES;'
94  CALL errwrt(errstr)
95  errstr = 'WILL APPLY THIS TABLE TO ALL SUBSEQUENT DATA IN '//
96  . 'FILE UNTIL NEXT DX TABLE IS FOUND'
97  CALL errwrt(errstr)
98  CALL errwrt('+++++++++++++++++++++++++++++++++++++++++++++++++')
99  CALL errwrt(' ')
100  ENDIF
101 
102  CALL makestab
103 
104  RETURN
105  900 CALL bort('BUFRLIB: RDBFDX - ERROR READING A BUFR DICTIONARY '//
106  . 'MESSAGE')
107  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine dxinit(LUN, IOI)
This subroutine initializes the internal arrays (in module moda_tababd) holding the DX BUFR table.
Definition: dxinit.f:18
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
recursive function idxmsg(MESG)
Check whether a BUFR message contains DX BUFR tables information.
Definition: idxmsg.f:23
recursive function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:30
subroutine makestab
This subroutine constructs the internal jump/link table within module tables, using all of the intern...
Definition: makestab.f:24
Wrap C NCEPLIBS-bufr functions so they can be called from within the Fortran part of the library.
Definition: bufrlib.F90:11
This module contains a declaration for an array used by various subroutines and functions to hold a t...
integer, dimension(:), allocatable mgwa
Temporary working copy of BUFR message.
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 rdmsgw(lunit, mesg, iret)
Read the next BUFR message from logical unit lunit as an array of integer words.
Definition: rdmsgw.F90:16
subroutine stbfdx(LUN, MESG)
This subroutine copies a DX BUFR tables message from the input array mesg into the internal memory ar...
Definition: stbfdx.f:15