NCEPLIBS-bufr  12.0.0
mesgbf.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Get information about a BUFR message
3 C>
4 C> @author J. Woollen @date 1994-01-06
5 
6 C> This subroutine reads through a BUFR file (starting from the beginning
7 C> of the file) and returns the message type (from Section 1) of the
8 C> first message it encounters which does not contain DX BUFR table
9 C> information.
10 C>
11 C> The BUFR file should not have already been opened via a call
12 C> to subroutine openbf(); however, it should already be associated
13 C> with Fortran logical unit number LUNIT.
14 C>
15 C> This subroutine is similar to subroutine mesgbc(), except that
16 C> this subroutine will only skip past DX BUFR table messages at the
17 C> beginning of a file, whereas mesgbc() will also skip past any "dummy"
18 C> messages containing the dump center time or dump initiation time
19 C> within NCEP dump files. Furthermore, mesgbc() also returns a
20 C> message compression indicator, and it also has an option to operate
21 C> on a BUFR message that has already been read into the internal arrays.
22 C>
23 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file
24 C> @param[out] MESGTYP - integer: Message type
25 C> - -1 = error reading the BUFR file, or no
26 C> messages were read from the file
27 C> - 11 = BUFR file only contained DX BUFR table
28 C> messages
29 C>
30 C> @author J. Woollen @date 1994-01-06
31 
32  RECURSIVE SUBROUTINE mesgbf(LUNIT,MESGTYP)
33 
34  USE moda_mgwa
35  USE modv_im8b
36 
37 C-----------------------------------------------------------------------
38 C-----------------------------------------------------------------------
39 
40 C CHECK FOR I8 INTEGERS
41 C ---------------------
42 
43  IF(im8b) THEN
44  im8b=.false.
45 
46  CALL x84(lunit,my_lunit,1)
47  CALL mesgbf(my_lunit,mesgtyp)
48  CALL x48(mesgtyp,mesgtyp,1)
49 
50  im8b=.true.
51  RETURN
52  ENDIF
53 
54  mesgtyp = -1
55 
56 C SINCE OPENBF HAS NOT YET BEEN CALLED, CALL IT
57 C ---------------------------------------------
58 
59  CALL openbf(lunit,'INX',lunit)
60 
61 C READ PAST ANY BUFR TABLES AND RETURN THE FIRST MESSAGE TYPE FOUND
62 C -----------------------------------------------------------------
63 
64 1 CALL rdmsgw(lunit,mgwa,ier)
65  IF(ier.EQ.0) THEN
66  mesgtyp = iupbs01(mgwa,'MTYP')
67  IF(idxmsg(mgwa).EQ.1) GOTO 1
68  ENDIF
69 
70 C CLOSE THE FILE
71 C --------------
72 
73  CALL closbf(lunit)
74 
75 C EXIT
76 C ----
77 
78  RETURN
79  END
recursive subroutine closbf(LUNIT)
Close the connection between logical unit LUNIT and the NCEPLIBS-bufr software.
Definition: closbf.f:24
recursive function idxmsg(MESG)
Check whether a BUFR message contains DX BUFR tables information.
Definition: idxmsg.f:23
recursive function iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
recursive subroutine mesgbf(LUNIT, MESGTYP)
This subroutine reads through a BUFR file (starting from the beginning of the file) and returns the m...
Definition: mesgbf.f:33
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.
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
recursive subroutine openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124
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 x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19