NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
ufbrp.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
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>
17 C> THIS SUBROUTINE SHOULD NEVER BE CALLED BY ANY APPLICATION PROGRAM;
18 C> INSTEAD, APPLICATION PROGRAMS SHOULD ALWAYS CALL BUFR ARCHIVE
19 C> LIBRARY SUBROUTINE UFBREP.
20 C>
21 C> PROGRAM HISTORY LOG:
22 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
23 C> 1998-07-08 J. WOOLLEN -- IMPROVED MACHINE PORTABILITY
24 C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
25 C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
26 C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
27 C> BUFR FILES UNDER THE MPI)
28 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
29 C> INTERDEPENDENCIES
30 C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
31 C> INCREASED FROM 15000 TO 16000 (WAS IN
32 C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
33 C> WRF; ADDED DOCUMENTATION (INCLUDING
34 C> HISTORY)
35 C> 2009-03-31 J. WOOLLEN -- ADD DOCUMENTATION
36 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
37 C>
38 C> USAGE: CALL UFBRP (LUN, USR, I1, I2, IO, IRET)
39 C> INPUT ARGUMENT LIST:
40 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
41 C> USR - ONLY IF BUFR FILE OPEN FOR OUTPUT:
42 C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
43 C> WRITTEN TO DATA SUBSET
44 C> I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR
45 C> I2 - INTEGER: LENGTH OF SECOND DIMENSION OF USR
46 C> IO - INTEGER: STATUS INDICATOR FOR BUFR FILE ASSOCIATED
47 C> WITH LUN:
48 C> 0 = input file
49 C> 1 = output file
50 C>
51 C> OUTPUT ARGUMENT LIST:
52 C> USR - ONLY IF BUFR FILE OPEN FOR INPUT:
53 C> REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
54 C> READ FROM DATA SUBSET
55 C> IRET - INTEGER:
56 C> - IF BUFR FILE OPEN FOR INPUT: NUMBER OF "LEVELS" OF
57 C> DATA VALUES READ FROM DATA SUBSET (MUST BE NO
58 C> LARGER THAN I2)
59 C> - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS"
60 C> OF DATA VALUES WRITTEN TO DATA SUBSET (SHOULD BE
61 C> SAME AS I2)
62 C>
63 C> REMARKS:
64 C> THIS ROUTINE CALLS: INVTAG
65 C> THIS ROUTINE IS CALLED BY: UFBREP
66 C> Normally not called by any application
67 C> programs (they should call UFBREP).
68 C>
69  SUBROUTINE ufbrp(LUN,USR,I1,I2,IO,IRET)
70 
71  USE moda_usrint
72 
73  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
74 
75  REAL*8 usr(i1,i2)
76 
77 C----------------------------------------------------------------------
78 C----------------------------------------------------------------------
79 
80  iret = 0
81  ins1 = 0
82  ins2 = 0
83 
84 C FIND FIRST NON-ZERO NODE IN STRING
85 C ----------------------------------
86 
87  DO nz=1,nnod
88  IF(nods(nz).GT.0) goto 1
89  ENDDO
90  goto 100
91 
92 C FRAME A SECTION OF THE BUFFER - RETURN WHEN NO FRAME
93 C ----------------------------------------------------
94 
95 1 IF(ins1+1.GT.nval(lun)) goto 100
96  IF(io.EQ.1 .AND. iret.EQ.i2) goto 100
97  ins1 = invtag(nods(nz),lun,ins1+1,nval(lun))
98  IF(ins1.EQ.0) goto 100
99 
100  ins2 = invtag(nods(nz),lun,ins1+1,nval(lun))
101  IF(ins2.EQ.0) ins2 = nval(lun)
102  iret = iret+1
103 
104 C READ USER VALUES
105 C ----------------
106 
107  IF(io.EQ.0 .AND. iret.LE.i2) THEN
108  DO i=1,nnod
109  IF(nods(i).GT.0) THEN
110  invn = invtag(nods(i),lun,ins1,ins2)
111  IF(invn.GT.0) usr(i,iret) = val(invn,lun)
112  ENDIF
113  ENDDO
114  ENDIF
115 
116 C WRITE USER VALUES
117 C -----------------
118 
119  IF(io.EQ.1 .AND. iret.LE.i2) THEN
120  DO i=1,nnod
121  IF(nods(i).GT.0) THEN
122  invn = invtag(nods(i),lun,ins1,ins2)
123  IF(invn.GT.0) val(invn,lun) = usr(i,iret)
124  ENDIF
125  ENDDO
126  ENDIF
127 
128 C GO FOR NEXT FRAME
129 C -----------------
130 
131  goto 1
132 
133 C EXIT
134 C ----
135 
136 100 RETURN
137  END
subroutine ufbrp(LUN, USR, I1, I2, IO, IRET)
THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR FROM THE CURRENT BUFR DATA SUBSET WITHIN INTER...
Definition: ufbrp.f:69
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