1 SUBROUTINE UFBRW
(LUN
,USR
,I1
,I2
,IO
,IRET
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR FROM
9 C THE CURRENT BUFR DATA SUBSET WITHIN INTERNAL ARRAYS, WITH THE
10 C DIRECTION OF THE DATA TRANSFER DETERMINED BY THE CONTEXT OF IO
11 C (I.E., IF IO INDICATES LUN POINTS TO A BUFR FILE THAT IS OPEN FOR
12 C INPUT, THEN DATA VALUES ARE READ FROM THE INTERNAL DATA SUBSET;
13 C OTHERWISE, DATA VALUES ARE WRITTEN TO THE INTERNAL DATA SUBSET).
14 C THE DATA VALUES CORRESPOND TO INTERNAL ARRAYS REPRESENTING PARSED
15 C STRINGS OF MNEMONICS WHICH ARE PART OF A DELAYED-REPLICATION
16 C SEQUENCE, OR FOR WHICH THERE IS NO REPLICATION AT ALL.
18 C THIS SUBROUTINE SHOULD NEVER BE CALLED BY ANY APPLICATION PROGRAM;
19 C INSTEAD, APPLICATION PROGRAMS SHOULD ALWAYS CALL BUFR ARCHIVE
20 C LIBRARY SUBROUTINE UFBINT.
22 C PROGRAM HISTORY LOG:
23 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
24 C 1996-12-11 J. WOOLLEN -- REMOVED A HARD ABORT FOR USERS WHO TRY TO
25 C WRITE NON-EXISTING MNEMONICS
26 C 1998-07-08 J. WOOLLEN -- IMPROVED MACHINE PORTABILITY
27 C 1998-10-27 J. WOOLLEN -- MODIFIED TO CORRECT PROBLEMS CAUSED BY IN-
28 C LINING CODE WITH FPP DIRECTIVES
29 C 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
30 C OPENED AT ONE TIME INCREASED FROM 10 TO 32
31 C (NECESSARY IN ORDER TO PROCESS MULTIPLE
32 C BUFR FILES UNDER THE MPI)
33 C 2002-05-14 J. WOOLLEN -- REMOVED OLD CRAY COMPILER DIRECTIVES
34 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
36 C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
37 C INCREASED FROM 15000 TO 16000 (WAS IN
38 C VERIFICATION VERSION); UNIFIED/PORTABLE FOR
39 C WRF; ADDED DOCUMENTATION (INCLUDING
41 C 2007-01-19 J. ATOR -- USE FUNCTION IBFMS
42 C 2009-03-31 J. WOOLLEN -- ADD DOCUMENTATION
43 C 2009-04-21 J. ATOR -- USE ERRWRT; USE LSTJPB INSTEAD OF LSTRPS
45 C USAGE: CALL UFBRW (LUN, USR, I1, I2, IO, IRET)
46 C INPUT ARGUMENT LIST:
47 C LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
48 C USR - ONLY IF BUFR FILE OPEN FOR OUTPUT:
49 C REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
50 C WRITTEN TO DATA SUBSET
51 C I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR
52 C I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
53 C IO - INTEGER: STATUS INDICATOR FOR BUFR FILE ASSOCIATED
58 C OUTPUT ARGUMENT LIST:
59 C USR - ONLY IF BUFR FILE OPEN FOR INPUT:
60 C REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
61 C READ FROM DATA SUBSET
63 C - IF BUFR FILE OPEN FOR INPUT: NUMBER OF "LEVELS" OF
64 C DATA VALUES READ FROM DATA SUBSET (MUST BE NO
66 C -1 = NONE OF THE MNEMONICS IN THE STRING PASSED
67 C TO UFBINT WERE FOUND IN THE SUBSET TEMPLATE
68 C - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS"
69 C OF DATA VALUES WRITTEN TO DATA SUBSET (SHOULD BE
71 C -1 = NONE OF THE MNEMONICS IN THE STRING PASSED
72 C TO UFBINT WERE FOUND IN THE SUBSET TEMPLATE
75 C THIS ROUTINE CALLS: CONWIN DRSTPL ERRWRT GETWIN
76 C IBFMS INVWIN LSTJPB NEWWIN
78 C THIS ROUTINE IS CALLED BY: TRYBUMP UFBINT
79 C Normally not called by any application
80 C programs (they should call UFBINT).
83 C LANGUAGE: FORTRAN 77
84 C MACHINE: PORTABLE TO ALL PLATFORMS
90 COMMON /BTABLES
/ MAXTAB
,NTAB
,TAG
(MAXJL
),TYP
(MAXJL
),KNT
(MAXJL
),
91 . JUMP
(MAXJL
),LINK
(MAXJL
),JMPB
(MAXJL
),
92 . IBT
(MAXJL
),IRF
(MAXJL
),ISC
(MAXJL
),
93 . ITP
(MAXJL
),VALI
(MAXJL
),KNTI
(MAXJL
),
94 . ISEQ
(MAXJL
,2),JSEQ
(MAXJL
)
95 COMMON /USRINT
/ NVAL
(NFILES
),INV
(MAXSS
,NFILES
),VAL
(MAXSS
,NFILES
)
96 COMMON /USRSTR
/ NNOD
,NCON
,NODS
(20),NODC
(10),IVLS
(10),KONS
(10)
102 REAL*8 USR
(I1
,I2
),VAL
104 C----------------------------------------------------------------------
105 C----------------------------------------------------------------------
109 C LOOP OVER COND WINDOWS
110 C ----------------------
115 1 CALL CONWIN
(LUN
,INC1
,INC2
)
119 ELSEIF
(INC1
.EQ
.0) THEN
123 IF(NODS
(I
).GT
.0) THEN
125 CALL GETWIN
(NODS
(I
),LUN
,INS1
,INS2
)
126 IF(INS1
.EQ
.0) GOTO 100
134 C LOOP OVER STORE NODES
135 C ---------------------
140 CALL ERRWRT
('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
141 WRITE ( UNIT
=ERRSTR
, FMT
='(5(A,I4))' )
142 . 'BUFRLIB: UFBRW - IRET:INS1:INS2:INC1:INC2 = ',
143 . IRET
, ':', INS1
, ':', INS2
, ':', INC1
, ':', INC2
146 DO WHILE ( ( INS2
- KK
) .GE
. 5 )
147 WRITE ( UNIT
=ERRSTR
, FMT
='(5A10)' )
148 . (TAG
(INV
(I
,LUN
)),I
=KK
,KK
+4)
152 WRITE ( UNIT
=ERRSTR
, FMT
='(5A10)' )
153 . (TAG
(INV
(I
,LUN
)),I
=KK
,INS2
)
155 CALL ERRWRT
('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
162 IF(IO
.EQ
.1 .AND
. IRET
.LE
.I2
) THEN
164 IF(NODS
(I
).GT
.0) THEN
165 IF(IBFMS
(USR
(I
,IRET
)).EQ
.0) THEN
166 INVN
= INVWIN
(NODS
(I
),LUN
,INS1
,INS2
)
168 CALL DRSTPL
(NODS
(I
),LUN
,INS1
,INS2
,INVN
)
173 CALL NEWWIN
(LUN
,INC1
,INC2
)
174 VAL
(INVN
,LUN
) = USR
(I
,IRET
)
175 ELSEIF
(LSTJPB
(NODS
(I
),LUN
,'RPS').EQ
.0) THEN
176 VAL
(INVN
,LUN
) = USR
(I
,IRET
)
177 ELSEIF
(IBFMS
(VAL
(INVN
,LUN
)).NE
.0) THEN
178 VAL
(INVN
,LUN
) = USR
(I
,IRET
)
180 CALL DRSTPL
(NODS
(I
),LUN
,INS1
,INS2
,INVN
)
185 CALL NEWWIN
(LUN
,INC1
,INC2
)
186 VAL
(INVN
,LUN
) = USR
(I
,IRET
)
196 IF(IO
.EQ
.0 .AND
. IRET
.LE
.I2
) THEN
199 IF(NODS
(I
).GT
.0) THEN
200 INVN
= INVWIN
(NODS
(I
),LUN
,INS1
,INS2
)
201 IF(INVN
.GT
.0) USR
(I
,IRET
) = VAL
(INVN
,LUN
)
206 C DECIDE WHAT TO DO NEXT
207 C ----------------------
209 IF(IO
.EQ
.1.AND
.IRET
.EQ
.I2
) GOTO 100
210 CALL NXTWIN
(LUN
,INS1
,INS2
)
211 IF(INS1
.GT
.0 .AND
. INS1
.LT
.INC2
) GOTO 2