1 SUBROUTINE UFBPOS (LUNIT, IREC, ISUB, SUBSET, JDATE)
3 !$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 ! PRGMMR: WOOLLEN ORG: NP20 DATE: 1995-11-22
8 ! ABSTRACT: THIS SUBROUTINE SHOULD ONLY BE CALLED WHEN LOGICAL UNIT
9 ! LUNIT HAS BEEN OPENED FOR INPUT OPERATIONS. IT POSITIONS THE
10 ! MESSAGE POINTER TO A USER-SPECIFIED BUFR MESSAGE NUMBER IN THE FILE
11 ! CONNECTED TO LUNIT AND THEN CALLS BUFR ARCHIVE LIBRARY SUBROUTINE
12 ! READMG TO READ THIS BUFR MESSAGE INTO A MESSAGE BUFFER (ARRAY MBAY
13 ! IN COMMON BLOCK /BITBUF/). IT THEN POSITIONS THE SUBSET POINTER TO
14 ! A USER-SPECIFIED SUBSET NUMBER WITHIN THE BUFR MESSAGE AND CALLS
15 ! BUFR ARCHIVE LIBRARY SUBROUTINE READSB TO READ THIS SUBSET INTO
16 ! INTERNAL SUBSET ARRAYS. THE BUFR MESSAGE HERE MAY BE EITHER
17 ! COMPRESSED OR UNCOMPRESSED. THE USER-SPECIFIED MESSAGE NUMBER DOES
18 ! NOT INCLUDE ANY DICTIONARY MESSAGES THAT MAY BE AT THE TOP OF THE
21 ! PROGRAM HISTORY LOG:
22 ! 1995-11-22 J. WOOLLEN -- ORIGINAL AUTHOR (WAS IN-LINED IN PROGRAM
24 ! 2005-03-04 D. KEYSER -- ADDED TO BUFR ARCHIVE LIBRARY; ADDED
26 ! 2005-11-29 J. ATOR -- USE IUPBS01 AND RDMSGW
27 ! 2006-04-14 J. ATOR -- REMOVE UNNECESSARY MOIN INITIALIZATION
29 ! USAGE: CALL UFBPOS( LUNIT, IREC, ISUB, SUBSET, JDATE )
30 ! INPUT ARGUMENT LIST:
31 ! LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
32 ! IREC - INTEGER: POINTER TO BUFR MESSAGE NUMBER (RECORD) IN
33 ! FILE (DOES NOT INCLUDE ANY DICTIONARY MESSSAGES THAT
34 ! MAY BE AT THE TOP OF THE FILE)
35 ! ISUB - INTEGER: POINTER TO SUBSET NUMBER TO READ IN BUFR
38 ! OUTPUT ARGUMENT LIST:
39 ! SUBSET - CHARACTER*8: TABLE A MNEMONIC FOR TYPE OF BUFR MESSAGE
41 ! JDATE - INTEGER: DATE-TIME STORED WITHIN SECTION 1 OF BUFR
42 ! MESSAGE BEING READ, IN FORMAT OF EITHER YYMMDDHH OR
43 ! YYYYMMDDHH, DEPENDING ON DATELEN() VALUE
46 ! THIS ROUTINE CALLS: BORT IUPBS01 NMSUB RDMSGW
47 ! READMG READSB STATUS UFBCNT
49 ! THIS ROUTINE IS CALLED BY: None
50 ! Normally called only by application
54 ! LANGUAGE: FORTRAN 77
55 ! MACHINE: PORTABLE TO ALL PLATFORMS
61 COMMON / MSGCWD / NMSG (NFILES), NSUB (NFILES), MSUB (NFILES), &
62 INODE (NFILES), IDATE (NFILES)
63 COMMON / BITBUF / MAXBYT, IBIT, IBAY (MXMSGLD4), MBYT (NFILES), &
64 MBAY (MXMSGLD4, NFILES)
66 CHARACTER(128) BORT_STR
68 DIMENSION MOIN (MXMSGLD4)
70 !-----------------------------------------------------------------------
71 !----------------------------------------------------------------------
73 ! MAKE SURE A FILE IS OPEN FOR INPUT
74 ! ----------------------------------
76 CALL STATUS (LUNIT, LUN, IL, IM)
80 IF (IREC.LE.0) GOTO 902
81 IF (ISUB.LE.0) GOTO 903
83 ! SEE WHERE POINTERS ARE CURRENTLY LOCATED
84 ! ----------------------------------------
86 CALL UFBCNT (LUNIT, JREC, JSUB)
88 ! POSSIBLY REWIND AND POSITION AFTER THE DICTIONARY
89 ! (IF REQUESTED POINTERS ARE BEHIND CURRENT POINTERS)
90 ! ----------------------------------------------------
92 IF (IREC.LT.JREC.OR. (IREC.EQ.JREC.AND.ISUB.LT.JSUB) ) THEN
97 CALL RDMSGW (LUNIT, MOIN, IER)
98 MSGT = IUPBS01 (MOIN, 'MTYP')
103 CALL RDMSGW (LUNIT, MOIN, IER)
107 CALL UFBCNT (LUNIT, JREC, JSUB)
110 ! READ SUBSET #ISUB FROM MESSAGE #IREC FROM FILE
111 ! ----------------------------------------------
113 DO WHILE (IREC.GT.JREC)
114 CALL READMG (LUNIT, SUBSET, JDATE, IRET)
115 IF (IRET.NE.0) GOTO 904
116 CALL UFBCNT (LUNIT, JREC, JSUB)
120 IF (ISUB.GT.KSUB) GOTO 905
122 DO WHILE (ISUB - 1.GT.JSUB)
123 IBIT = MBYT (LUN) * 8
124 CALL UPB (NBYT, 16, MBAY (1, LUN), IBIT)
125 MBYT (LUN) = MBYT (LUN) + NBYT
126 NSUB (LUN) = NSUB (LUN) + 1
127 CALL UFBCNT (LUNIT, JREC, JSUB)
130 CALL READSB (LUNIT, IRET)
131 IF (IRET.NE.0) GOTO 905
137 900 CALL BORT ('BUFRLIB: UFBPOS - INPUT BUFR FILE IS CLOSED, IT MUST'/&
138 &/' BE OPEN FOR INPUT')
139 901 CALL BORT ('BUFRLIB: UFBPOS - INPUT BUFR FILE IS OPEN FOR OUTPUT'/&
140 &/', IT MUST BE OPEN FOR INPUT')
141 902 WRITE (BORT_STR, '("BUFRLIB: UFBPOS - REQUESTED MESSAGE NUMBER '//&
142 'TO READ IN (",I5,") IS NOT VALID")') IREC
144 903 WRITE (BORT_STR, '("BUFRLIB: UFBPOS - REQUESTED SUBSET NUMBER '// &
145 'TO READ IN (",I5,") IS NOT VALID")') ISUB
147 904 WRITE (BORT_STR, '("BUFRLIB: UFBPOS - REQUESTED MESSAGE NUMBER '//&
148 'TO READ IN (",I5,") EXCEEDS THE NUMBER OF MESSAGES IN THE '// &
149 'FILE (",I5,")")') IREC, JREC
151 905 WRITE (BORT_STR, '("BUFRLIB: UFBPOS - REQ. SUBSET NUMBER TO READ'/&
152 &/' IN (",I3,") EXCEEDS THE NUMBER OF SUBSETS (",I3,") IN THE '//'R&
153 &EQ. MESSAGE (",I5,")")') ISUB, KSUB, IREC
155 END SUBROUTINE UFBPOS