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