1 SUBROUTINE READSB(LUNIT,IRET)
3 !$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 ! PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 ! ABSTRACT: THIS SUBROUTINE SHOULD ONLY BE CALLED WHEN LOGICAL UNIT
9 ! LUNIT HAS BEEN OPENED FOR INPUT OPERATIONS. IT READS A SUBSET FROM
10 ! A BUFR MESSAGE INTO INTERNAL SUBSET ARRAYS. THE BUFR MESSAGE MUST
11 ! HAVE BEEN PREVIOUSLY READ FROM UNIT LUNIT USING BUFR ARCHIVE
12 ! LIBRARY SUBROUTINE READMG OR READERME AND MAY BE EITHER COMPRESSED
15 ! PROGRAM HISTORY LOG:
16 ! 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
17 ! 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
18 ! "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
20 ! 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
21 ! OPENED AT ONE TIME INCREASED FROM 10 TO 32
22 ! (NECESSARY IN ORDER TO PROCESS MULTIPLE
23 ! BUFR FILES UNDER THE MPI)
24 ! 2000-09-19 J. WOOLLEN -- ADDED CALL TO NEW ROUTINE RDCMPS ALLOWING
25 ! SUBSETS TO NOW BE DECODED FROM COMPRESSED
26 ! BUFR MESSAGES; MAXIMUM MESSAGE LENGTH
27 ! INCREASED FROM 10,000 TO 20,000 BYTES
28 ! 2002-05-14 J. WOOLLEN -- CORRECTED ERROR RELATING TO CERTAIN
29 ! FOREIGN FILE TYPES; REMOVED OLD CRAY
31 ! 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
33 ! 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
34 ! DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
35 ! MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
36 ! TERMINATES ABNORMALLY
37 ! 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
38 ! 20,000 TO 50,000 BYTES
40 ! USAGE: CALL READSB (LUNIT, IRET)
41 ! INPUT ARGUMENT LIST:
42 ! LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
44 ! OUTPUT ARGUMENT LIST:
45 ! IRET - INTEGER: RETURN CODE:
47 ! -1 = there are no more subsets in the BUFR
51 ! THIS ROUTINE CALLS: BORT RDCMPS RDTREE STATUS
53 ! THIS ROUTINE IS CALLED BY: COPYSB IREADSB RDMEMS READNS
54 ! RDMSGB UFBINX UFBPOS
55 ! Also called by application programs.
58 ! LANGUAGE: FORTRAN 77
59 ! MACHINE: PORTABLE TO ALL PLATFORMS
65 COMMON /MSGCWD/ NMSG(NFILES),NSUB(NFILES),MSUB(NFILES), &
66 INODE(NFILES),IDATE(NFILES)
67 COMMON /BITBUF/ MAXBYT,IBIT,IBAY(MXMSGLD4),MBYT(NFILES), &
69 COMMON /UNPTYP/ MSGUNP(NFILES)
71 CHARACTER*128 BORT_STR
73 !-----------------------------------------------------------------------
74 !-----------------------------------------------------------------------
78 ! CHECK THE FILE STATUS
79 ! ---------------------
81 CALL STATUS(LUNIT,LUN,IL,IM)
89 ! SEE IF THERE IS ANOTHER SUBSET IN THE MESSAGE
90 ! ---------------------------------------------
92 IF(NSUB(LUN).EQ.MSUB(LUN)) THEN
96 NSUB(LUN) = NSUB(LUN) + 1
99 ! READ THE NEXT SUBSET AND RESET THE POINTERS
100 ! -------------------------------------------
102 IF(MSGUNP(LUN).EQ.0) THEN
104 CALL UPB(NBYT,16,MBAY(1,LUN),IBIT)
106 MBYT(LUN) = MBYT(LUN) + NBYT
107 ELSEIF(MSGUNP(LUN).EQ.1) THEN
108 ! .... message with "standard" Section 3
112 ELSEIF(MSGUNP(LUN).EQ.2) THEN
113 ! .... compressed message
123 900 CALL BORT('BUFRLIB: READSB - INPUT BUFR FILE IS CLOSED, IT MUST'// &
124 ' BE OPEN FOR INPUT')
125 901 CALL BORT('BUFRLIB: READSB - INPUT BUFR FILE IS OPEN FOR OUTPUT'// &
126 ', IT MUST BE OPEN FOR INPUT')
127 902 WRITE(BORT_STR,'("BUFRLIB: READSB - MESSAGE UNPACK TYPE",I3,"IS'// &
128 ' NOT RECOGNIZED")') MSGUNP
130 END SUBROUTINE READSB