1 SUBROUTINE RDMGSB
(LUNIT
,IMSG
,ISUB
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 2003-11-04
8 C ABSTRACT: THIS SUBROUTINE OPENS A BUFR FILE IN LOGICAL UNIT LUNIT FOR
9 C INPUT OPERATIONS, THEN READS A PARTICULAR SUBSET INTO INTERNAL
10 C SUBSET ARRAYS FROM A PARTICULAR BUFR MESSAGE IN A MESSAGE BUFFER.
11 C THIS IS BASED ON THE SUBSET NUMBER IN THE MESSAGE AND THE MESSAGE
12 C NUMBER IN THE BUFR FILE. THE MESSAGE NUMBER DOES NOT INCLUDE THE
13 C DICTIONARY MESSAGES AT THE BEGINNING OF THE FILE.
15 C PROGRAM HISTORY LOG:
16 C 2003-11-04 J. WOOLLEN -- ORIGINAL AUTHOR (WAS IN VERIFICATION
17 C VERSION BUT MAY HAVE BEEN IN THE PRODUCTION
18 C VERSION AT ONE TIME AND THEN REMOVED)
19 C 2003-11-04 D. KEYSER -- INCORPORATED INTO "UNIFIED" BUFR ARCHIVE
20 C LIBRARY; UNIFIED/PORTABLE FOR WRF; ADDED
21 C DOCUMENTATION; OUTPUTS MORE COMPLETE
22 C DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
24 C 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
25 C 20,000 TO 50,000 BYTES
26 C 2009-03-23 J. ATOR -- MODIFY LOGIC TO HANDLE BUFR TABLE MESSAGES
27 C ENCOUNTERED ANYWHERE IN THE FILE (AND NOT
28 C JUST AT THE BEGINNING!)
30 C USAGE: CALL RDMGSB (LUNIT, IMSG, ISUB)
31 C INPUT ARGUMENT LIST:
32 C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
33 C IMSG - INTEGER: POINTER TO BUFR MESSAGE NUMBER TO READ IN
35 C ISUB - INTEGER: POINTER TO SUBSET NUMBER TO READ IN BUFR
39 C UNIT "LUNIT" - BUFR FILE
42 C THIS ROUTINE CALLS: BORT OPENBF READMG READSB
44 C THIS ROUTINE IS CALLED BY: None
45 C Normally called only by application
49 C LANGUAGE: FORTRAN 77
50 C MACHINE: PORTABLE TO ALL PLATFORMS
56 COMMON /MSGCWD
/ NMSG
(NFILES
),NSUB
(NFILES
),MSUB
(NFILES
),
57 . INODE
(NFILES
),IDATE
(NFILES
)
58 COMMON /BITBUF
/ MAXBYT
,IBIT
,IBAY
(MXMSGLD4
),MBYT
(NFILES
),
59 . MBAY
(MXMSGLD4
,NFILES
)
61 CHARACTER*128 BORT_STR
64 C-----------------------------------------------------------------------
65 C-----------------------------------------------------------------------
67 C OPEN THE FILE AND SKIP TO MESSAGE # IMSG
68 C ----------------------------------------
70 CALL OPENBF
(LUNIT
,'IN',LUNIT
)
71 CALL STATUS
(LUNIT
,LUN
,IL
,IM
)
73 C Note that we need to use subroutine READMG to actually read in all
74 C of the messages (including the first (IMSG-1) messages!), just in
75 C case there are any embedded dictionary messages in the file.
78 CALL READMG
(LUNIT
,SUBSET
,JDATE
,IRET
)
79 IF(IRET
.LT
.0) GOTO 901
82 C POSITION AT SUBSET # ISUB
83 C -------------------------
86 IF(NSUB
(LUN
).GT
.MSUB
(LUN
)) GOTO 902
88 CALL UPB
(NBYT
,16,MBAY
(1,LUN
),IBIT
)
89 MBYT
(LUN
) = MBYT
(LUN
) + NBYT
90 NSUB
(LUN
) = NSUB
(LUN
) + 1
93 CALL READSB
(LUNIT
,IRET
)
94 IF(IRET
.NE
.0) GOTO 902
100 900 WRITE(BORT_STR
,'("BUFRLIB: RDMGSB - ERROR READING MESSAGE '//
101 . '(RECORD) NUMBER",I5," IN INPUT BUFR FILE CONNECTED TO UNIT",'//
104 901 WRITE(BORT_STR
,'("BUFRLIB: RDMGSB - HIT END OF FILE BEFORE '//
105 . 'READING REQUESTED MESSAGE NO.",I5," IN BUFR FILE CONNECTED TO'//
106 . ' UNIT",I4)') IMSG
,LUNIT
108 902 WRITE(BORT_STR
,'("BUFRLIB: RDMGSB - ALL SUBSETS READ BEFORE '//
109 . 'READING REQ. SUBSET NO.",I3," IN REQ. MSG NO.",I5," IN BUFR '//
110 . 'FILE CONNECTED TO UNIT",I4)') ISUB
,IMSG
,LUNIT