NCEPLIBS-bufr 11.7.1
mesgbf.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE READS AND EXAMINES SECTION 1 OF MESSAGES
5C> IN A BUFR FILE IN SEQUENCE UNTIL IT FINDS THE FIRST MESSAGE THAT
6C> IS NOT A BUFR TABLE (DICTIONARY) MESSAGE. IT THEN RETURNS THE
7C> MESSAGE TYPE FOR THIS FIRST NON-DICTIONARY MESSAGE. THE BUFR FILE
8C> SHOULD NOT BE OPEN VIA BUFR ARCHIVE LIBRARY SUBROUTINE OPENBF PRIOR
9C> TO CALLING THIS SUBROUTINE; HOWEVER, THE BUFR FILE MUST BE CONNECTED
10C> TO UNIT LUNIT. THIS SUBROUTINE IS IDENTICAL TO BUFR ARCHIVE LIBRARY
11C> SUBROUTINE MESGBC EXCEPT THAT MESGBC RETURNS THE MESSAGE TYPE FOR
12C> THE FIRST NON-DICTIONARY MESSAGE THAT ACTUALLY CONTAINS REPORT DATA
13C> (WHEREAS MESGBF WOULD RETURN THE REPORT TYPE OF A DUMMY MESSAGE
14C> CONTAINING THE CENTER TIME FOR DUMP FILES), AND MESGBC ALSO
15C> INDICATES WHETHER OR NOT THE FIRST REPORT DATA MESSAGE IS BUFR
16C> COMPRESSED. MESGBC ALSO HAS AN OPTION TO OPERATE ON THE CURRENT
17C> MESSAGE STORED IN MEMORY, WHICH IS SOMETHING THAT MESGBF CANNOT DO.
18C>
19C> PROGRAM HISTORY LOG:
20C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
21C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
22C> 10,000 TO 20,000 BYTES
23C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
24C> INTERDEPENDENCIES
25C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
26C> DOCUMENTATION (INCLUDING HISTORY)
27C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
28C> 20,000 TO 50,000 BYTES
29C> 2005-11-29 J. ATOR -- USE IUPBS01 AND RDMSGW
30C> 2009-03-23 J. ATOR -- USE IDXMSG
31C> 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
32C> USE NEW OPENBF TYPE 'INX' TO OPEN AND CLOSE
33C> THE C FILE WITHOUT CLOSING THE FORTRAN FILE
34C> 2013-01-25 J. WOOLLEN -- ALWAYS CALL CLOSBF BEFORE EXITING
35C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
36C>
37C> USAGE: CALL MESGBF (LUNIT, MESGTYP)
38C> INPUT ARGUMENT LIST:
39C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
40C>
41C> OUTPUT ARGUMENT LIST:
42C> MESGTYP - INTEGER: BUFR MESSAGE TYPE FOR FIRST NON-DICTIONARY
43C> MESSAGE
44C> -1 = no messages read or error
45C> 11 = if only BUFR table messages in BUFR file
46C>
47C> INPUT FILES:
48C> UNIT "LUNIT" - BUFR FILE
49C>
50C> REMARKS:
51C> THIS ROUTINE CALLS: CLOSBF IDXMSG IUPBS01 OPENBF
52C> RDMSGW
53C> THIS ROUTINE IS CALLED BY: None
54C> Normally called only by application
55C> programs.
56C>
57 SUBROUTINE mesgbf(LUNIT,MESGTYP)
58
59 USE moda_mgwa
60
61C-----------------------------------------------------------------------
62C-----------------------------------------------------------------------
63
64 mesgtyp = -1
65
66C SINCE OPENBF HAS NOT YET BEEN CALLED, CALL IT
67C ---------------------------------------------
68
69 CALL openbf(lunit,'INX',lunit)
70
71C READ PAST ANY BUFR TABLES AND RETURN THE FIRST MESSAGE TYPE FOUND
72C -----------------------------------------------------------------
73
741 CALL rdmsgw(lunit,mgwa,ier)
75 IF(ier.EQ.0) THEN
76 mesgtyp = iupbs01(mgwa,'MTYP')
77 IF(idxmsg(mgwa).EQ.1) GOTO 1
78 ENDIF
79
80C CLOSE THE FILE
81C --------------
82
83 CALL closbf(lunit)
84
85C EXIT
86C ----
87
88100 RETURN
89 END
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
Definition: closbf.f:35
function idxmsg(MESG)
This function determines whether a given BUFR message contains DX BUFR tables information that was ge...
Definition: idxmsg.f:24
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:74
subroutine mesgbf(LUNIT, MESGTYP)
THIS SUBROUTINE READS AND EXAMINES SECTION 1 OF MESSAGES IN A BUFR FILE IN SEQUENCE UNTIL IT FINDS TH...
Definition: mesgbf.f:58
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
Definition: openbf.f:139
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