NCEPLIBS-bufr  12.0.0
ufbsp.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 1999-11-18
5 
6 C> This subroutine writes or reads specified 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 ufbstp()
16 C> which will internally call this subroutine.
17 C>
18 C> This subroutine is similar to subroutine ufbrp(), but it is designed
19 C> for different use cases. For a more detailed explanation of how
20 C> subroutine ufbstp() differs from subroutine ufbrep(), and therefore
21 C> how this subroutine differs from subroutine ufbrp(), see the
22 C> discussion in [DX BUFR Tables](@ref ufbsubs).
23 C>
24 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
25 C> @param[inout] USR - real*8(*,*): Data values
26 C> @param[in] I1 - integer: length of first dimension of USR.
27 C> @param[in] I2 - integer: length of second dimension of USR.
28 C> @param[in] IO - integer: status indicator for BUFR file associated
29 C> with LUN:
30 C> - 0 input file
31 C> - 1 output file
32 C> @param[out] IRET - integer: number of "levels" of data values read
33 C> from or written to data subset
34 C>
35 C> @author J. Woollen @date 1999-11-18
36  SUBROUTINE ufbsp(LUN,USR,I1,I2,IO,IRET)
37 
38  USE moda_usrint
39 
40  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
41 
42  real*8 usr(i1,i2)
43 
44 C----------------------------------------------------------------------
45 C----------------------------------------------------------------------
46 
47  iret = 0
48  ins1 = 0
49  ins2 = 0
50 
51 C FRAME A SECTION OF THE BUFFER - RETURN WHEN NO FRAME
52 C ----------------------------------------------------
53 
54 1 IF(ins1+1.GT.nval(lun)) GOTO 100
55  ins1 = invtag(nods(1),lun,ins1+1,nval(lun))
56  IF(ins1.EQ.0) GOTO 100
57 
58  ins2 = invtag(nods(1),lun,ins1+1,nval(lun))
59  IF(ins2.EQ.0) ins2 = nval(lun)
60  iret = iret+1
61 
62 C READ USER VALUES
63 C ----------------
64 
65  IF(io.EQ.0 .AND. iret.LE.i2) THEN
66  invm = ins1
67  DO i=1,nnod
68  IF(nods(i).GT.0) THEN
69  invn = invtag(nods(i),lun,invm,ins2)
70  IF(invn.GT.0) usr(i,iret) = val(invn,lun)
71  invm = max(invn,invm)
72  ENDIF
73  ENDDO
74  ENDIF
75 
76 C WRITE USER VALUES
77 C -----------------
78 
79  IF(io.EQ.1 .AND. iret.LE.i2) THEN
80  invm = ins1
81  DO i=1,nnod
82  IF(nods(i).GT.0) THEN
83  invn = invtag(nods(i),lun,invm,ins2)
84  IF(invn.GT.0) val(invn,lun) = usr(i,iret)
85  invm = max(invn,invm)
86  ENDIF
87  ENDDO
88  ENDIF
89 
90 C GO FOR NEXT FRAME
91 C -----------------
92 
93  GOTO 1
94 
95 C EXIT
96 C ----
97 
98 100 RETURN
99  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 ufbsp(LUN, USR, I1, I2, IO, IRET)
This subroutine writes or reads specified values to or from the current BUFR data subset within inter...
Definition: ufbsp.f:37