NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
ufbsp.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1999-11-18
3 
4 C> THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR
5 C> FROM THE CURRENT BUFR DATA SUBSET WITHIN INTERNAL ARRAYS, WITH THE
6 C> DIRECTION OF THE DATA TRANSFER DETERMINED BY THE CONTEXT OF IO
7 C> (I.E., IF IO INDICATES LUN POINTS TO A BUFR FILE THAT IS OPEN FOR
8 C> INPUT, THEN DATA VALUES ARE READ FROM THE INTERNAL DATA SUBSET;
9 C> OTHERWISE, DATA VALUES ARE WRITTEN TO THE INTERNAL DATA SUBSET).
10 C> THE DATA VALUES CORRESPOND TO INTERNAL ARRAYS REPRESENTING PARSED
11 C> STRINGS OF MNEMONICS WHICH ARE EITHER:
12 C> 1) PART OF A REGULAR (I.E., NON-DELAYED) REPLICATION SEQUENCE
13 C> OR
14 C> 2) REPLICATED BY BEING DIRECTLY LISTED MORE THAN ONCE WITHIN AN
15 C> OVERALL SUBSET DEFINITION
16 C> SO IN THAT RESPECT IT IS VERY SIMILAR TO BUFR ARCHIVE LIBRARY
17 C> SUBROUTINE UFBRP, BUT THERE IS AN IMPORTANT DIFFERENCE (SEE BELOW).
18 C>
19 C> THIS SUBROUTINE SHOULD NEVER BE CALLED BY ANY APPLICATION PROGRAM;
20 C> INSTEAD, APPLICATION PROGRAMS SHOULD ALWAYS CALL BUFR ARCHIVE
21 C> LIBRARY SUBROUTINE UFBSTP.
22 C>
23 C> SEE THE DOCBLOCK FOR BUFR ARCHIVE LIBRARY SUBROUTINE UFBREP FOR AN
24 C> EXPLANATION OF HOW UFBSTP DIFFERS FROM UFBREP, AND THEREFORE HOW
25 C> UFBSP DIFFERS FROM UFBRP.
26 C>
27 C> PROGRAM HISTORY LOG:
28 C> 1999-11-18 J. WOOLLEN -- ORIGINAL AUTHOR
29 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
30 C> INTERDEPENDENCIES
31 C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
32 C> INCREASED FROM 15000 TO 16000 (WAS IN
33 C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
34 C> WRF; ADDED DOCUMENTATION (INCLUDING
35 C> HISTORY)
36 C> 2009-03-31 J. WOOLLEN -- ADD DOCUMENTATION
37 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
38 C>
39 C> USAGE: CALL UFBSP (LUN, USR, I1, I2, IO, IRET)
40 C> INPUT ARGUMENT LIST:
41 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
42 C> USR - ONLY IF BUFR FILE OPEN FOR OUTPUT:
43 C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
44 C> WRITTEN TO DATA SUBSET
45 C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR
46 C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
47 C> IO - INTEGER: STATUS INDICATOR FOR BUFR FILE ASSOCIATED
48 C> WITH LUN:
49 C> 0 = input file
50 C> 1 = output file
51 C>
52 C> OUTPUT ARGUMENT LIST:
53 C> USR - ONLY IF BUFR FILE OPEN FOR INPUT:
54 C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
55 C> READ FROM DATA SUBSET
56 C> IRET - INTEGER:
57 C> - IF BUFR FILE OPEN FOR INPUT: NUMBER OF "LEVELS" OF
58 C> DATA VALUES READ FROM DATA SUBSET (MUST BE NO
59 C> LARGER THAN I2)
60 C> - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS"
61 C> OF DATA VALUES WRITTEN TO DATA SUBSET (SHOULD BE
62 C> SAME AS I2)
63 C>
64 C> REMARKS:
65 C> THIS ROUTINE CALLS: INVTAG
66 C> THIS ROUTINE IS CALLED BY: UFBSTP
67 C> Normally not called by any application
68 C> programs (they should call UFBSTP).
69 C>
70  SUBROUTINE ufbsp(LUN,USR,I1,I2,IO,IRET)
71 
72  USE moda_usrint
73 
74  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
75 
76  REAL*8 usr(i1,i2)
77 
78 C----------------------------------------------------------------------
79 C----------------------------------------------------------------------
80 
81  iret = 0
82  ins1 = 0
83  ins2 = 0
84 
85 C FRAME A SECTION OF THE BUFFER - RETURN WHEN NO FRAME
86 C ----------------------------------------------------
87 
88 1 IF(ins1+1.GT.nval(lun)) goto 100
89  ins1 = invtag(nods(1),lun,ins1+1,nval(lun))
90  IF(ins1.EQ.0) goto 100
91 
92  ins2 = invtag(nods(1),lun,ins1+1,nval(lun))
93  IF(ins2.EQ.0) ins2 = nval(lun)
94  iret = iret+1
95 
96 C READ USER VALUES
97 C ----------------
98 
99  IF(io.EQ.0 .AND. iret.LE.i2) THEN
100  invm = ins1
101  DO i=1,nnod
102  IF(nods(i).GT.0) THEN
103  invn = invtag(nods(i),lun,invm,ins2)
104  IF(invn.GT.0) usr(i,iret) = val(invn,lun)
105  invm = max(invn,invm)
106  ENDIF
107  ENDDO
108  ENDIF
109 
110 C WRITE USER VALUES
111 C -----------------
112 
113  IF(io.EQ.1 .AND. iret.LE.i2) THEN
114  invm = ins1
115  DO i=1,nnod
116  IF(nods(i).GT.0) THEN
117  invn = invtag(nods(i),lun,invm,ins2)
118  IF(invn.GT.0) val(invn,lun) = usr(i,iret)
119  invm = max(invn,invm)
120  ENDIF
121  ENDDO
122  ENDIF
123 
124 C GO FOR NEXT FRAME
125 C -----------------
126 
127  goto 1
128 
129 C EXIT
130 C ----
131 
132 100 RETURN
133  END
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:70
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:49