1 SUBROUTINE RDMEMM
(IMSG
,SUBSET
,JDATE
,IRET
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS SUBROUTINE READS A PARTICULAR BUFR MESSAGE FROM
9 C INTERNAL MEMORY (ARRAY MSGS IN COMMON BLOCK /MSGMEM/) INTO A
10 C MESSAGE BUFFER (ARRAY MBAY IN COMMON BLOCK /BITBUF/). IT IS
11 C IDENTICAL TO BUFR ARCHIVE LIBRARY SUBROUTINE READMM EXCEPT IT DOES
12 C NOT ADVANCE THE VALUE OF IMSG PRIOR TO RETURNING TO CALLING
15 C PROGRAM HISTORY LOG:
16 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
17 C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
18 C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
19 C ROUTINE "BORT"; MODIFIED TO MAKE Y2K
21 C 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
22 C OPENED AT ONE TIME INCREASED FROM 10 TO 32
23 C (NECESSARY IN ORDER TO PROCESS MULTIPLE
24 C BUFR FILES UNDER THE MPI); THE MAXIMUM
25 C NUMBER OF BYTES REQUIRED TO STORE ALL
26 C MESSAGES INTERNALLY WAS INCREASED FROM 4
28 C 2000-09-19 J. WOOLLEN -- REMOVED MESSAGE DECODING LOGIC THAT HAD
29 C BEEN REPLICATED IN THIS AND OTHER READ
30 C ROUTINES AND CONSOLIDATED IT INTO A NEW
31 C ROUTINE CKTABA, CALLED HERE, WHICH IS
32 C ENHANCED TO ALLOW COMPRESSED AND STANDARD
33 C BUFR MESSAGES TO BE READ; MAXIMUM MESSAGE
34 C LENGTH INCREASED FROM 10,000 TO 20,000
36 C 2001-08-15 D. KEYSER -- PARAMETER MAXMEM (THE MAXIMUM NUMBER OF
37 C BYTES REQUIRED TO STORE ALL MESSAGES
38 C INTERNALLY) WAS INCREASED FROM 8 MBYTES TO
40 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
42 C 2003-11-04 D. KEYSER -- PARAMETER MAXMSG (THE MAXIMUM NUMBER OF
43 C BUFR MESSAGES WHICH CAN BE STORED
44 C INTERNALLY) INCREASED FROM 50000 TO 200000;
45 C UNIFIED/PORTABLE FOR WRF; ADDED
46 C DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
47 C MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
48 C TERMINATES ABNORMALLY OR UNUSUAL THINGS
50 C 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
51 C 20,000 TO 50,000 BYTES
52 C 2004-11-15 D. KEYSER -- PARAMETER MAXMEM (THE MAXIMUM NUMBER OF
53 C BYTES REQUIRED TO STORE ALL MESSAGES
54 C INTERNALLY) WAS INCREASED FROM 16 MBYTES TO
56 C 2009-03-23 J. ATOR -- MODIFIED TO HANDLE EMBEDDED BUFR TABLE
57 C (DICTIONARY) MESSAGES; USE ERRWRT
60 C USAGE: CALL RDMEMM (IMSG, SUBSET, JDATE, IRET)
61 C INPUT ARGUMENT LIST:
62 C IMSG - INTEGER: POINTER TO BUFR MESSAGE NUMBER (RECORD) IN
65 C OUTPUT ARGUMENT LIST:
66 C SUBSET - CHARACTER*8: TABLE A MNEMONIC FOR TYPE OF BUFR MESSAGE
68 C JDATE - INTEGER: DATE-TIME STORED WITHIN SECTION 1 OF BUFR
69 C MESSAGE BEING READ, IN FORMAT OF EITHER YYMMDDHH OR
70 C YYYYMMDDHH, DEPENDING ON DATELEN() VALUE
71 C IRET - INTEGER: RETURN CODE:
73 C -1 = IMSG is either zero or greater than the
74 C number of messages in memory
77 C NOTE THAT UFBMEM IS CALLED PRIOR TO THIS TO STORE THE BUFR
78 C MESSAGES INTO INTERNAL MEMORY.
80 C THIS ROUTINE CALLS: BORT CKTABA DXINIT ERRWRT
81 C MAKESTAB STATUS STBFDX WTSTAT
82 C THIS ROUTINE IS CALLED BY: READMM UFBMMS UFBRMS UFBTAM
83 C Also called by application programs.
86 C LANGUAGE: FORTRAN 77
87 C MACHINE: PORTABLE TO ALL PLATFORMS
93 COMMON /MSGCWD
/ NMSG
(NFILES
),NSUB
(NFILES
),MSUB
(NFILES
),
94 . INODE
(NFILES
),IDATE
(NFILES
)
95 COMMON /BITBUF
/ MAXBYT
,IBIT
,IBAY
(MXMSGLD4
),MBYT
(NFILES
),
96 . MBAY
(MXMSGLD4
,NFILES
)
97 COMMON /MSGMEM
/ MUNIT
,MLAST
,MSGP
(0:MAXMSG
),MSGS
(MAXMEM
),
98 . MDX
(MXDXW
),IPDXM
(MXDXM
),LDXM
,NDXM
,LDXTS
,NDXTS
,
99 . IFDXTS
(MXDXTS
),ICDXTS
(MXDXTS
),IPMSGS
(MXDXTS
)
102 DIMENSION MSGDX
(MXMSGLD4
)
104 CHARACTER*128 BORT_STR
,ERRSTR
109 C-----------------------------------------------------------------------
110 C-----------------------------------------------------------------------
112 C CHECK THE MESSAGE REQUEST AND FILE STATUS
113 C -----------------------------------------
115 CALL STATUS
(MUNIT
,LUN
,IL
,IM
)
116 CALL WTSTAT
(MUNIT
,LUN
,IL
, 1)
121 IF(IMSG
.EQ
.0 .OR
.IMSG
.GT
.MSGP
(0)) THEN
122 CALL WTSTAT
(MUNIT
,LUN
,IL
,0)
124 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
126 ERRSTR
= 'BUFRLIB: RDMEMM - REQUESTED MEMORY MESSAGE '//
127 . 'NUMBER {FIRST (INPUT) ARGUMENT} IS 0, RETURN WITH '//
130 WRITE ( UNIT
=ERRSTR
, FMT
='(A,I6,A,I6,A)' )
131 . 'BUFRLIB: RDMEMM - REQ. MEMORY MESSAGE #', IMSG
,
132 . ' {= 1ST (INPUT) ARG.} > # OF MESSAGES IN MEMORY (',
133 . MSGP
(0), '), RETURN WITH IRET = -1'
136 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
143 C ENSURE THAT THE PROPER DICTIONARY TABLE IS IN SCOPE
144 C ---------------------------------------------------
146 C Determine which table applies to this message.
150 DO WHILE ((.NOT
.KNOWN
).AND
.(JJ
.GE
.1))
151 IF (IPMSGS
(JJ
).LE
.IMSG
) THEN
157 IF (.NOT
.KNOWN
) GOTO 902
159 C Is this table the one that is currently in scope?
161 IF (JJ
.NE
.LDXTS
) THEN
163 C No, so reset the software to use the proper table.
166 CALL ERRWRT
('+++++++++++++++++++++++++++++++++++++++++++++')
167 WRITE ( UNIT
=ERRSTR
, FMT
='(A,I3,A,I3,A,I6)' )
168 . 'BUFRLIB: RDMEMM - RESETTING TO USE DX TABLE #', JJ
,
169 . ' INSTEAD OF DX TABLE #', LDXTS
,
170 . ' FOR REQUESTED MESSAGE #', IMSG
172 CALL ERRWRT
('+++++++++++++++++++++++++++++++++++++++++++++')
177 C Store each of the DX dictionary messages which constitute
180 DO II
= IFDXTS
(JJ
), (IFDXTS
(JJ
)+ICDXTS
(JJ
)-1)
182 NWRD
= LDXM
- IPDXM
(II
) + 1
184 NWRD
= IPDXM
(II
+1) - IPDXM
(II
)
187 MSGDX
(KK
) = MDX
(IPDXM
(II
)+KK
-1)
189 CALL STBFDX
(LUN
,MSGDX
)
192 C Rebuild the internal jump/link table.
198 C READ MEMORY MESSAGE NUMBER IMSG INTO A MESSAGE BUFFER
199 C -----------------------------------------------------
202 IF(IMSG
.LT
.MSGP
(0)) LPTR
= MSGP
(IMSG
+1)-IPTR
203 IF(IMSG
.EQ
.MSGP
(0)) LPTR
= MLAST
-IPTR
+1
207 MBAY
(I
,LUN
) = MSGS
(IPTR
+I
)
210 C PARSE THE MESSAGE SECTION CONTENTS
211 C ----------------------------------
213 CALL CKTABA
(LUN
,SUBSET
,JDATE
,JRET
)
220 900 CALL BORT
('BUFRLIB: RDMEMM - INPUT BUFR FILE IS CLOSED, IT '//
221 . 'MUST BE OPEN FOR INPUT')
222 901 CALL BORT
('BUFRLIB: RDMEMM - INPUT BUFR FILE IS OPEN FOR '//
223 . 'OUTPUT, IT MUST BE OPEN FOR INPUT')
224 902 WRITE(BORT_STR
,'("BUFRLIB: RDMEMM - UNKNOWN DX TABLE FOR '//
225 . 'REQUESTED MESSAGE #",I5)') IMSG