NCEPLIBS-bufr 11.7.1
ufbsp.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1999-11-18
3
4C> THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR
5C> FROM 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 EITHER:
12C> 1) PART OF A REGULAR (I.E., NON-DELAYED) REPLICATION SEQUENCE
13C> OR
14C> 2) REPLICATED BY BEING DIRECTLY LISTED MORE THAN ONCE WITHIN AN
15C> OVERALL SUBSET DEFINITION
16C> SO IN THAT RESPECT IT IS VERY SIMILAR TO BUFR ARCHIVE LIBRARY
17C> SUBROUTINE UFBRP, BUT THERE IS AN IMPORTANT DIFFERENCE (SEE BELOW).
18C>
19C> THIS SUBROUTINE SHOULD NEVER BE CALLED BY ANY APPLICATION PROGRAM;
20C> INSTEAD, APPLICATION PROGRAMS SHOULD ALWAYS CALL BUFR ARCHIVE
21C> LIBRARY SUBROUTINE UFBSTP.
22C>
23C> SEE THE DOCBLOCK FOR BUFR ARCHIVE LIBRARY SUBROUTINE UFBREP FOR AN
24C> EXPLANATION OF HOW UFBSTP DIFFERS FROM UFBREP, AND THEREFORE HOW
25C> UFBSP DIFFERS FROM UFBRP.
26C>
27C> PROGRAM HISTORY LOG:
28C> 1999-11-18 J. WOOLLEN -- ORIGINAL AUTHOR
29C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
30C> INTERDEPENDENCIES
31C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
32C> INCREASED FROM 15000 TO 16000 (WAS IN
33C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
34C> WRF; ADDED DOCUMENTATION (INCLUDING
35C> HISTORY)
36C> 2009-03-31 J. WOOLLEN -- ADD DOCUMENTATION
37C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
38C>
39C> USAGE: CALL UFBSP (LUN, USR, I1, I2, IO, IRET)
40C> INPUT ARGUMENT LIST:
41C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
42C> USR - ONLY IF BUFR FILE OPEN FOR OUTPUT:
43C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
44C> WRITTEN TO DATA SUBSET
45C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR
46C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
47C> IO - INTEGER: STATUS INDICATOR FOR BUFR FILE ASSOCIATED
48C> WITH LUN:
49C> 0 = input file
50C> 1 = output file
51C>
52C> OUTPUT ARGUMENT LIST:
53C> USR - ONLY IF BUFR FILE OPEN FOR INPUT:
54C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
55C> READ FROM DATA SUBSET
56C> IRET - INTEGER:
57C> - IF BUFR FILE OPEN FOR INPUT: NUMBER OF "LEVELS" OF
58C> DATA VALUES READ FROM DATA SUBSET (MUST BE NO
59C> LARGER THAN I2)
60C> - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS"
61C> OF DATA VALUES WRITTEN TO DATA SUBSET (SHOULD BE
62C> SAME AS I2)
63C>
64C> REMARKS:
65C> THIS ROUTINE CALLS: INVTAG
66C> THIS ROUTINE IS CALLED BY: UFBSTP
67C> Normally not called by any application
68C> programs (they should call UFBSTP).
69C>
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
78C----------------------------------------------------------------------
79C----------------------------------------------------------------------
80
81 iret = 0
82 ins1 = 0
83 ins2 = 0
84
85C FRAME A SECTION OF THE BUFFER - RETURN WHEN NO FRAME
86C ----------------------------------------------------
87
881 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
96C READ USER VALUES
97C ----------------
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
110C WRITE USER VALUES
111C -----------------
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
124C GO FOR NEXT FRAME
125C -----------------
126
127 GOTO 1
128
129C EXIT
130C ----
131
132100 RETURN
133 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:50
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:71