NCEPLIBS-bufr  12.0.1
ufbrp.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read/write one or more data values from/to a data subset.
3 C>
4 C> @author J. Woollen @date 1994-01-06
5 
6 C> This subroutine writes or reads specified data values to or
7 C> from the current BUFR data subset within internal arrays, with the
8 C> direction of the data transfer determined by the context of IO.
9 C> The data values correspond to internal arrays representing parsed
10 C> strings of mnemonics which are either part of a fixed (i.e. non-delayed)
11 C> replication sequence, or for mnememonics which are replicated by being
12 C> directly listed more than once within an overall subset definition.
13 C>
14 C> This subroutine should never be directly called by an application
15 C> program; instead, an application program should directly call ufbrep()
16 C> which will internally call this subroutine.
17 C>
18 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
19 C> @param[inout] USR - real*8(*,*): Data values
20 C> @param[in] I1 - integer: length of first dimension of USR.
21 C> @param[in] I2 - integer: length of second dimension of USR.
22 C> @param[in] IO - integer: status indicator for BUFR file associated
23 C> with LUN:
24 C> - 0 input file
25 C> - 1 output file
26 C> @param[out] IRET - integer: number of "levels" of data values read
27 C> from or written to data subset
28 C>
29 C> @author J. Woollen @date 1994-01-06
30  SUBROUTINE ufbrp(LUN,USR,I1,I2,IO,IRET)
31 
32  USE moda_usrint
33 
34  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
35 
36  real*8 usr(i1,i2)
37 
38 C----------------------------------------------------------------------
39 C----------------------------------------------------------------------
40 
41  iret = 0
42  ins1 = 0
43  ins2 = 0
44 
45 C FIND FIRST NON-ZERO NODE IN STRING
46 C ----------------------------------
47 
48  DO nz=1,nnod
49  IF(nods(nz).GT.0) GOTO 1
50  ENDDO
51  GOTO 100
52 
53 C FRAME A SECTION OF THE BUFFER - RETURN WHEN NO FRAME
54 C ----------------------------------------------------
55 
56 1 IF(ins1+1.GT.nval(lun)) GOTO 100
57  IF(io.EQ.1 .AND. iret.EQ.i2) GOTO 100
58  ins1 = invtag(nods(nz),lun,ins1+1,nval(lun))
59  IF(ins1.EQ.0) GOTO 100
60 
61  ins2 = invtag(nods(nz),lun,ins1+1,nval(lun))
62  IF(ins2.EQ.0) ins2 = nval(lun)
63  iret = iret+1
64 
65 C READ USER VALUES
66 C ----------------
67 
68  IF(io.EQ.0 .AND. iret.LE.i2) THEN
69  DO i=1,nnod
70  IF(nods(i).GT.0) THEN
71  invn = invtag(nods(i),lun,ins1,ins2)
72  IF(invn.GT.0) usr(i,iret) = val(invn,lun)
73  ENDIF
74  ENDDO
75  ENDIF
76 
77 C WRITE USER VALUES
78 C -----------------
79 
80  IF(io.EQ.1 .AND. iret.LE.i2) THEN
81  DO i=1,nnod
82  IF(nods(i).GT.0) THEN
83  invn = invtag(nods(i),lun,ins1,ins2)
84  IF(invn.GT.0) val(invn,lun) = usr(i,iret)
85  ENDIF
86  ENDDO
87  ENDIF
88 
89 C GO FOR NEXT FRAME
90 C -----------------
91 
92  GOTO 1
93 
94 C EXIT
95 C ----
96 
97 100 RETURN
98  END
function invtag(NODE, LUN, INV1, INV2)
This function looks for a specified mnemonic within the portion of the current subset buffer bounded ...
Definition: invtag.f:24
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:), allocatable nval
Number of data values in BUFR data subset.
real *8, dimension(:,:), allocatable, target val
Data values.
subroutine ufbrp(LUN, USR, I1, I2, IO, IRET)
This subroutine writes or reads specified data values to or from the current BUFR data subset within ...
Definition: ufbrp.f:31