NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
mesgbc.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine mesgbc (LUNIN, MESGTYP, ICOMP)
 THIS SUBROUTINE EXAMINES A BUFR MESSAGE AND RETURNS BOTH THE MESSAGE TYPE FROM SECTION 1 AND A MESSAGE COMPRESSION INDICATOR UNPACKED FROM SECTION 3. More...
 

Detailed Description

Author
KEYSER
Date
2003-11-04

Definition in file mesgbc.f.

Function/Subroutine Documentation

subroutine mesgbc (   LUNIN,
  MESGTYP,
  ICOMP 
)

THIS SUBROUTINE EXAMINES A BUFR MESSAGE AND RETURNS BOTH THE MESSAGE TYPE FROM SECTION 1 AND A MESSAGE COMPRESSION INDICATOR UNPACKED FROM SECTION 3.

IT OBTAINS THE BUFR MESSAGE VIA TWO DIFFERENT METHODS, BASED UPON THE SIGN OF LUNIN. IF LUNIN IS GREATER THAN ZERO, THIS SUBROUTINE READS AND EXAMINES SECTION 1 OF MESSAGES IN A BUFR FILE IN SEQUENCE UNTIL IT FINDS THE FIRST MESSAGE THAT ACTUALLY CONTAINS REPORT DATA {I.E., BEYOND THE BUFR TABLE (DICTIONARY) MESSAGES AT THE TOP AND, FOR DUMP FILES, BEYOND THE TWO DUMMY MESSAGES CONTAINING THE CENTER TIME AND THE DUMP TIME}. IT THEN RETURNS THE MESSAGE TYPE AND COMPRESSION INDICATOR FOR THIS FIRST DATA MESSAGE. IN THIS CASE, THE BUFR FILE SHOULD NOT BE OPENED VIA BUFR ARCHIVE LIBRARY SUBROUTINE OPENBF PRIOR TO CALLING THIS SUBROUTINE. HOWEVER, THE BUFR FILE MUST BE CONNECTED TO UNIT ABS(LUNIN). WHEN USED THIS WAY, THIS SUBROUTINE IS IDENTICAL TO BUFR ARCHIVE LIBRARY SUBROUTINE MESGBF EXCEPT MESGBF DOES NOT RETURN ANY INFORMATION ABOUT COMPRESSION AND MESGBF READS UNTIL IT FINDS THE FIRST NON-DICTIONARY MESSAGE REGARDLESS OF WHETHER OR NOT IT CONTAINS ANY REPORTS (I.E., IT WOULD STOP AT THE DUMMY MESSAGE CONTAINING THE CENTER TIME FOR DUMP FILES). THE SECOND METHOD IN WHICH THIS SUBROUTINE CAN BE USED OCCURS WHEN LUNIN IS PASSED IN WITH A VALUE LESS THAN ZERO. IN THIS CASE, IT SIMPLY RETURNS THE MESSAGE TYPE AND COMPRESSION INDICATOR FOR THE BUFR MESSAGE CURRENTLY STORED IN THE INTERNAL MESSAGE BUFFER (ARRAY MBAY IN MODULE BITBUF). IN THIS CASE, THE BUFR FILE CONNECTED TO ABS(LUNIN) MUST HAVE BEEN PREVIOUSLY OPENED FOR INPUT OPERATIONS BY BUFR ARCHIVE LIBRARY SUBROUTINE OPENBF, AND THE BUFR MESSAGE MUST HAVE BEEN READ INTO MEMORY BY BUFR ARCHIVE LIBRARY ROUTINE READMG OR EQUIVALENT.

PROGRAM HISTORY LOG: 2003-11-04 D. KEYSER – ORIGINAL AUTHOR 2004-06-29 D. KEYSER – ADDED NEW OPTION TO RETURN MESSAGE TYPE AND COMPRESSION INDICATOR FOR BUFR MESSAGE CURRENTLY STORED IN MEMORY (TRIGGERED BY INPUT ARGUMENT LUNIN LESS THAN ZERO) 2004-08-09 J. ATOR – MAXIMUM MESSAGE LENGTH INCREASED FROM 20,000 TO 50,000 BYTES 2005-11-29 J. ATOR – USE IUPBS01, GETLENS AND RDMSGW 2009-03-23 J. ATOR – USE IUPBS3 AND IDXMSG 2012-09-15 J. WOOLLEN – CONVERT TO C LANGUAGE I/O INTERFACE ADD OPENBF AND CLOSBF FOR THE CASE WHEN LUNIN GT 0 2014-12-10 J. ATOR – USE MODULES INSTEAD OF COMMON BLOCKS

USAGE: CALL MESGBC (LUNIN, MESGTYP, ICOMP) INPUT ARGUMENT LIST: LUNIN - INTEGER: ABSOLUTE VALUE IS FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE

  • IF LUNIN IS GREATER THAN ZERO, THIS SUBROUTINE READS THROUGH ALL BUFR MESSAGES FROM BEGINNING OF FILE UNTIL IT FINDS THE FIRST MESSAGE CONTAINING REPORT DATA
  • IF LUNIN IS LESS THAN ZERO, THIS SUBROUTINE OPERATES ON THE BUFR MESSAGE CURRENTLY STORED IN MEMORY

OUTPUT ARGUMENT LIST: MESGTYP - INTEGER: BUFR MESSAGE TYPE FOR EITHER THE FIRST MESSAGE IN FILE CONTAINING REPORT DATA (IF LUNIN > 0), OR FOR THE MESSAGE CURRENTLY IN MEMORY (IF LUNIN < 0) -256 = for LUNIN > 0 case only: no messages read or error reading file < 0 = for LUNIN > 0 case only: none of the messages read contain reports; this is the negative of the message type the last message read (i.e., -11 indicates the BUFR file contains only BUFR table messages) ICOMP - INTEGER: BUFR MESSAGE COMPRESSION SWITCH: -3 = for LUNIN > 0 case only: BUFR file does not exist -2 = for LUNIN > 0 case only: BUFR file does not contain any report messages -1 = for LUNIN > 0 case only: cannot determine if first BUFR message containing report data is compressed due to error reading file 0 = BUFR message (either first containing report data if LUNIN > 0, or that currently in memory if LUNIN < 0) is NOT compressed 1 = BUFR message (either first containing report data if LUNIN > 0, or that currently in memory if LUNIN < 0) IS compressed

INPUT FILES: UNIT ABS(LUNIN) - BUFR FILE

REMARKS: THIS ROUTINE CALLS: CLOSBF IDXMSG IUPBS01 IUPBS3 OPENBF RDMSGW STATUS THIS ROUTINE IS CALLED BY: COPYSB UFBTAB Also called by application programs.

Definition at line 96 of file mesgbc.f.

References closbf(), idxmsg(), iupbs01(), iupbs3(), openbf(), rdmsgw(), and status().

Referenced by copysb(), and ufbtab().