NCEPLIBS-bufr 11.7.1
ufbrw.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR FROM
5C> THE CURRENT BUFR DATA SUBSET WITHIN INTERNAL ARRAYS, WITH THE
6C> DIRECTION OF THE DATA TRANSFER DETERMINED BY THE CONTEXT OF IO
7C> (I.E., IF IO INDICATES LUN POINTS TO A BUFR FILE THAT IS OPEN FOR
8C> INPUT, THEN DATA VALUES ARE READ FROM THE INTERNAL DATA SUBSET;
9C> OTHERWISE, DATA VALUES ARE WRITTEN TO THE INTERNAL DATA SUBSET).
10C> THE DATA VALUES CORRESPOND TO INTERNAL ARRAYS REPRESENTING PARSED
11C> STRINGS OF MNEMONICS WHICH ARE PART OF A DELAYED-REPLICATION
12C> SEQUENCE, OR FOR WHICH THERE IS NO REPLICATION AT ALL.
13C>
14C> THIS SUBROUTINE SHOULD NEVER BE CALLED BY ANY APPLICATION PROGRAM;
15C> INSTEAD, APPLICATION PROGRAMS SHOULD ALWAYS CALL BUFR ARCHIVE
16C> LIBRARY SUBROUTINE UFBINT.
17C>
18C> PROGRAM HISTORY LOG:
19C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
20C> 1996-12-11 J. WOOLLEN -- REMOVED A HARD ABORT FOR USERS WHO TRY TO
21C> WRITE NON-EXISTING MNEMONICS
22C> 1998-07-08 J. WOOLLEN -- IMPROVED MACHINE PORTABILITY
23C> 1998-10-27 J. WOOLLEN -- MODIFIED TO CORRECT PROBLEMS CAUSED BY IN-
24C> LINING CODE WITH FPP DIRECTIVES
25C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
26C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
27C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
28C> BUFR FILES UNDER THE MPI)
29C> 2002-05-14 J. WOOLLEN -- REMOVED OLD CRAY COMPILER DIRECTIVES
30C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
31C> INTERDEPENDENCIES
32C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
33C> INCREASED FROM 15000 TO 16000 (WAS IN
34C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
35C> WRF; ADDED DOCUMENTATION (INCLUDING
36C> HISTORY)
37C> 2007-01-19 J. ATOR -- USE FUNCTION IBFMS
38C> 2009-03-31 J. WOOLLEN -- ADD DOCUMENTATION
39C> 2009-04-21 J. ATOR -- USE ERRWRT; USE LSTJPB INSTEAD OF LSTRPS
40C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
41C>
42C> USAGE: CALL UFBRW (LUN, USR, I1, I2, IO, IRET)
43C> INPUT ARGUMENT LIST:
44C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
45C> USR - ONLY IF BUFR FILE OPEN FOR OUTPUT:
46C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
47C> WRITTEN TO DATA SUBSET
48C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR
49C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
50C> IO - INTEGER: STATUS INDICATOR FOR BUFR FILE ASSOCIATED
51C> WITH LUN:
52C> 0 = input file
53C> 1 = output file
54C>
55C> OUTPUT ARGUMENT LIST:
56C> USR - ONLY IF BUFR FILE OPEN FOR INPUT:
57C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
58C> READ FROM DATA SUBSET
59C> IRET - INTEGER:
60C> - IF BUFR FILE OPEN FOR INPUT: NUMBER OF "LEVELS" OF
61C> DATA VALUES READ FROM DATA SUBSET (MUST BE NO
62C> LARGER THAN I2)
63C> -1 = NONE OF THE MNEMONICS IN THE STRING PASSED
64C> TO UFBINT WERE FOUND IN THE SUBSET TEMPLATE
65C> - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS"
66C> OF DATA VALUES WRITTEN TO DATA SUBSET (SHOULD BE
67C> SAME AS I2)
68C> -1 = NONE OF THE MNEMONICS IN THE STRING PASSED
69C> TO UFBINT WERE FOUND IN THE SUBSET TEMPLATE
70C>
71C> REMARKS:
72C> THIS ROUTINE CALLS: CONWIN DRSTPL ERRWRT GETWIN
73C> IBFMS INVWIN LSTJPB NEWWIN
74C> NXTWIN
75C> THIS ROUTINE IS CALLED BY: TRYBUMP UFBINT
76C> Normally not called by any application
77C> programs (they should call UFBINT).
78C>
79 SUBROUTINE ufbrw(LUN,USR,I1,I2,IO,IRET)
80
81 USE modv_bmiss
82 USE moda_usrint
83 USE moda_tables
84
85 COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
86 COMMON /quiet / iprt
87
88 CHARACTER*128 ERRSTR
89 real*8 usr(i1,i2)
90
91C----------------------------------------------------------------------
92C----------------------------------------------------------------------
93
94 iret = 0
95
96C LOOP OVER COND WINDOWS
97C ----------------------
98
99 inc1 = 1
100 inc2 = 1
101
1021 CALL conwin(lun,inc1,inc2)
103 IF(nnod.EQ.0) THEN
104 iret = i2
105 GOTO 100
106 ELSEIF(inc1.EQ.0) THEN
107 GOTO 100
108 ELSE
109 DO i=1,nnod
110 IF(nods(i).GT.0) THEN
111 ins2 = inc1
112 CALL getwin(nods(i),lun,ins1,ins2)
113 IF(ins1.EQ.0) GOTO 100
114 GOTO 2
115 ENDIF
116 ENDDO
117 iret = -1
118 GOTO 100
119 ENDIF
120
121C LOOP OVER STORE NODES
122C ---------------------
123
1242 iret = iret+1
125
126 IF(iprt.GE.2) THEN
127 CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
128 WRITE ( unit=errstr, fmt='(5(A,I7))' )
129 . 'BUFRLIB: UFBRW - IRET:INS1:INS2:INC1:INC2 = ',
130 . iret, ':', ins1, ':', ins2, ':', inc1, ':', inc2
131 CALL errwrt(errstr)
132 kk = ins1
133 DO WHILE ( ( ins2 - kk ) .GE. 5 )
134 WRITE ( unit=errstr, fmt='(5A10)' )
135 . (tag(inv(i,lun)),i=kk,kk+4)
136 CALL errwrt(errstr)
137 kk = kk+5
138 ENDDO
139 WRITE ( unit=errstr, fmt='(5A10)' )
140 . (tag(inv(i,lun)),i=kk,ins2)
141 CALL errwrt(errstr)
142 CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
143 CALL errwrt(' ')
144 ENDIF
145
146C WRITE USER VALUES
147C -----------------
148
149 IF(io.EQ.1 .AND. iret.LE.i2) THEN
150 DO i=1,nnod
151 IF(nods(i).GT.0) THEN
152 IF(ibfms(usr(i,iret)).EQ.0) THEN
153 invn = invwin(nods(i),lun,ins1,ins2)
154 IF(invn.EQ.0) THEN
155 CALL drstpl(nods(i),lun,ins1,ins2,invn)
156 IF(invn.EQ.0) THEN
157 iret = 0
158 GOTO 100
159 ENDIF
160 CALL newwin(lun,inc1,inc2)
161 val(invn,lun) = usr(i,iret)
162 ELSEIF(lstjpb(nods(i),lun,'RPS').EQ.0) THEN
163 val(invn,lun) = usr(i,iret)
164 ELSEIF(ibfms(val(invn,lun)).NE.0) THEN
165 val(invn,lun) = usr(i,iret)
166 ELSE
167 CALL drstpl(nods(i),lun,ins1,ins2,invn)
168 IF(invn.EQ.0) THEN
169 iret = 0
170 GOTO 100
171 ENDIF
172 CALL newwin(lun,inc1,inc2)
173 val(invn,lun) = usr(i,iret)
174 ENDIF
175 ENDIF
176 ENDIF
177 ENDDO
178 ENDIF
179
180C READ USER VALUES
181C ----------------
182
183 IF(io.EQ.0 .AND. iret.LE.i2) THEN
184 DO i=1,nnod
185 usr(i,iret) = bmiss
186 IF(nods(i).GT.0) THEN
187 invn = invwin(nods(i),lun,ins1,ins2)
188 IF(invn.GT.0) usr(i,iret) = val(invn,lun)
189 ENDIF
190 ENDDO
191 ENDIF
192
193C DECIDE WHAT TO DO NEXT
194C ----------------------
195
196 IF(io.EQ.1.AND.iret.EQ.i2) GOTO 100
197 CALL nxtwin(lun,ins1,ins2)
198 IF(ins1.GT.0 .AND. ins1.LT.inc2) GOTO 2
199 IF(ncon.GT.0) GOTO 1
200
201C EXIT
202C ----
203
204100 RETURN
205 END
subroutine conwin(LUN, INC1, INC2)
THIS SUBROUTINE SEARCHES CONSECUTIVE SUBSET BUFFER SEGMENTS FOR AN ELEMENT IDENTIFIED IN THE USER STR...
Definition: conwin.f:65
subroutine drstpl(INOD, LUN, INV1, INV2, INVN)
THIS SUBROUTINE IS CALLED BY BUFR ARCHIVE LIBRARY SUBROUTINE UFBRW WHENEVER IT CAN'T FIND A MNEMONIC ...
Definition: drstpl.f:58
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
subroutine getwin(NODE, LUN, IWIN, JWIN)
GIVEN A NODE INDEX WITHIN THE INTERNAL JUMP/LINK TABLE, THIS SUBROUTINE LOOKS WITHIN THE CURRENT SUBS...
Definition: getwin.f:82
integer function ibfms(R8VAL)
This function provides a handy way to check whether a real*8 data value returned from a previous call...
Definition: ibfms.f:39
function invwin(NODE, LUN, INV1, INV2)
THIS FUNCTION LOOKS FOR A SPECIFIED NODE WITHIN THE PORTION OF THE CURRENT SUBSET BUFFER BOUNDED BY T...
Definition: invwin.f:49
function lstjpb(NODE, LUN, JBTYP)
THIS FUNCTION SEARCHES BACKWARDS, BEGINNING FROM A GIVEN NODE WITHIN THE JUMP/LINK TABLE,...
Definition: lstjpb.f:58
This module contains array and variable declarations used to store the internal jump/link table.
Definition: moda_tables.F:13
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
Definition: moda_tables.F:132
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
real *8, public bmiss
Current placeholder value to represent "missing" data when reading from or writing to BUFR files; thi...
Definition: modv_BMISS.f90:15
subroutine newwin(LUN, IWIN, JWIN)
GIVEN AN INDEX WITHIN THE INTERNAL JUMP/LINK TABLE WHICH POINTS TO THE START OF AN "RPC" WINDOW (I....
Definition: newwin.f:52
subroutine nxtwin(LUN, IWIN, JWIN)
GIVEN INDICES WITHIN THE INTERNAL JUMP/LINK TABLE WHICH POINT TO THE START AND END OF AN "RPC" WINDOW...
Definition: nxtwin.f:53
subroutine ufbrw(LUN, USR, I1, I2, IO, IRET)
THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR FROM THE CURRENT BUFR DATA SUBSET WITHIN INTER...
Definition: ufbrw.f:80