1 SUBROUTINE RDMSGB
(LUNIT
,MESG
,IRET
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: ATOR ORG: NP12 DATE: 2005-11-29
8 C ABSTRACT: THIS SUBROUTINE READS THE NEXT BUFR MESSAGE FROM LOGICAL
9 C UNIT LUNIT AS AN ARRAY OF BYTES, WHICH ARE THEN TRANSFERRED TO
10 C AN ARRAY OF INTEGER WORDS FOR OUTPUT.
12 C PROGRAM HISTORY LOG:
13 C 2005-11-29 J. ATOR -- ORIGINAL AUTHOR
14 C 2009-03-23 D. KEYSER -- CALLS BORT IN CASE OF MESG OVERFLOW
16 C USAGE: CALL RDMSGB (LUNIT, MESG, IRET)
17 C INPUT ARGUMENT LIST:
18 C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
20 C OUTPUT ARGUMENT LIST:
21 C MESG - *-WORD ARRAY CONTAINING BUFR MESSAGE READ FROM LUNIT
22 C IRET - INTEGER: RETURN CODE:
24 C -1 = end-of-file encountered while reading
26 C -2 = I/O error encountered while reading
30 C UNIT "LUNIT" - BUFR FILE
33 C THIS ROUTINE CALLS: BORT ICHKSTR IUPBS01 LMSG
34 C THIS ROUTINE IS CALLED BY: None
35 C Normally not called by any application
39 C LANGUAGE: FORTRAN 77
40 C MACHINE: PORTABLE TO ALL PLATFORMS
46 COMMON /HRDWRD
/ NBYTW
,NBITW
,IORD
(8)
50 CHARACTER*128 BORT_STR
52 CHARACTER*1 CBAY
(8*MXMSGLD4
)
53 DIMENSION JBAY
(MXMSGLD4
)
55 EQUIVALENCE
(CBAY
(1),JBAY
(1),SEC0
)
57 C-----------------------------------------------------------------------
58 C-----------------------------------------------------------------------
62 C Read Section 0 from the next message in the file.
64 READ(LUNIT
,END=100,ERR
=200) SEC0
66 C Confirm that the first 4 bytes contain 'BUFR' encoded in
67 C CCITT IA5 (i.e. ASCII).
69 IF(ICHKSTR
('BUFR',CBAY
,4).NE
.0) GOTO 200
71 C Check the length of the next message to make sure it will fit
72 C within the output array.
75 IF(LNMSG*NBYTW
.GT
.MXMSGL
) GOTO 900
77 C Read the rest of the message as an array of bytes.
79 READ(LUNIT
,END=100,ERR
=200) (CBAY
(I
),I
=9,IUPBS01
(JBAY
,'LENM'))
81 C Transfer the message to the output array.
99 900 WRITE(BORT_STR
,'("BUFRLIB: RDMSGB - INPUT BUFR MESSAGE LENGTH (",
100 . I6," BYTES) IS LARGER THAN LIMIT OF ",I6," BYTES")')