1 SUBROUTINE UFBSTP
(LUNIO
,USR
,I1
,I2
,IRET
,STR
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1999-11-18
8 C ABSTRACT: THIS SUBROUTINE WRITES OR READS SPECIFIED VALUES TO OR FROM
9 C THE CURRENT BUFR DATA SUBSET WITHIN INTERNAL ARRAYS, WITH THE
10 C DIRECTION OF THE DATA TRANSFER DETERMINED BY THE CONTEXT OF
11 C ABS(LUNIO) (I.E., IF ABS(LUNIO) POINTS TO A BUFR FILE THAT IS OPEN
12 C FOR INPUT, THEN DATA VALUES ARE READ FROM THE INTERNAL DATA SUBSET;
13 C OTHERWISE, DATA VALUES ARE WRITTEN TO THE INTERNAL DATA SUBSET).
14 C THE DATA VALUES CORRESPOND TO INTERNAL ARRAYS REPRESENTING PARSED
15 C STRINGS OF MNEMONICS WHICH ARE EITHER:
16 C 1) PART OF A REGULAR (I.E., NON-DELAYED) REPLICATION SEQUENCE
18 C 2) REPLICATED BY BEING DIRECTLY LISTED MORE THAN ONCE WITHIN AN
19 C OVERALL SUBSET DEFINITION
20 C SO IN THAT RESPECT IT IS VERY SIMILAR TO BUFR ARCHIVE LIBRARY
21 C SUBROUTINE UFBREP. HOWEVER, THERE IS AN IMPORTANT DIFFERENCE IN
22 C HOW UFBSTP PROCESSES THE INPUT MNEMONIC STRING STR; FOR MORE DETAILS
23 C SEE THE EXAMPLE IN THE DOCBLOCK FOR SUBROUTINE UFBREP.
25 C PROGRAM HISTORY LOG:
26 C 1999-11-18 J. WOOLLEN -- ORIGINAL AUTHOR
27 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
29 C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
30 C INCREASED FROM 15000 TO 16000 (WAS IN
31 C VERIFICATION VERSION); UNIFIED/PORTABLE FOR
32 C WRF; ADDED DOCUMENTATION (INCLUDING
33 C HISTORY) (INCOMPLETE); OUTPUTS MORE
34 C COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
35 C TERMINATES ABNORMALLY OR UNUSUAL THINGS
36 C HAPPEN; CHANGED CALL FROM BORT TO BORT2 IN
38 C 2004-08-18 J. ATOR -- ADDED SAVE FOR IFIRST1 AND IFIRST2 FLAGS
39 C 2009-04-21 J. ATOR -- USE ERRWRT
41 C USAGE: CALL UFBSTP (LUNIO, USR, I1, I2, IRET, STR)
42 C INPUT ARGUMENT LIST:
43 C LUNIO - INTEGER: ABSOLUTE VALUE IS FORTRAN LOGICAL UNIT
44 C NUMBER FOR BUFR FILE
45 C - IF BUFR FILE OPEN FOR OUTPUT AND LUNIO IS LESS
46 C THAN ZERO, UFBSTP TREATS THE BUFR FILE AS THOUGH
47 C IT WERE OPEN FOR INPUT
48 C USR - ONLY IF BUFR FILE OPEN FOR OUTPUT:
49 C REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
50 C WRITTEN TO DATA SUBSET
51 C I1 - INTEGER: LENGTH OF FIRST DIMENSION OF USR OR THE
52 C NUMBER OF BLANK-SEPARATED MNEMONICS IN STR (FORMER
53 C MUST BE AT LEAST AS LARGE AS LATTER)
55 C - IF BUFR FILE OPEN FOR INPUT: LENGTH OF SECOND
57 C - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS
58 C OF DATA VALUES TO BE WRITTEN TO DATA SUBSET
59 C STR - CHARACTER*(*): STRING OF BLANK-SEPARATED TABLE B
60 C MNEMONICS IN ONE-TO-ONE CORRESPONDENCE WITH FIRST
62 C - IF BUFR FILE OPEN FOR INPUT: THERE ARE THREE
63 C "GENERIC" MNEMONICS NOT RELATED TO TABLE B,
64 C THESE RETURN THE FOLLOWING INFORMATION IN
65 C CORRESPONDING USR LOCATION:
66 C 'NUL' WHICH ALWAYS RETURNS BMISS ("MISSING")
67 C 'IREC' WHICH ALWAYS RETURNS THE CURRENT BUFR
68 C MESSAGE (RECORD) NUMBER IN WHICH THIS
70 C 'ISUB' WHICH ALWAYS RETURNS THE CURRENT SUBSET
71 C NUMBER OF THIS SUBSET WITHIN THE BUFR
72 C MESSAGE (RECORD) NUMBER 'IREC'
74 C OUTPUT ARGUMENT LIST:
75 C USR - ONLY IF BUFR FILE OPEN FOR INPUT:
76 C REAL*8: (I1,I2) STARTING ADDRESS OF DATA VALUES
77 C READ FROM DATA SUBSET
79 C - IF BUFR FILE OPEN FOR INPUT: NUMBER OF "LEVELS" OF
80 C DATA VALUES READ FROM DATA SUBSET (MUST BE NO
82 C - IF BUFR FILE OPEN FOR OUTPUT: NUMBER OF "LEVELS"
83 C OF DATA VALUES WRITTEN TO DATA SUBSET (SHOULD BE
87 C THIS ROUTINE CALLS: BORT BORT2 ERRWRT STATUS
89 C THIS ROUTINE IS CALLED BY: None
90 C Normally called only by application
94 C LANGUAGE: FORTRAN 77
95 C MACHINE: PORTABLE TO ALL PLATFORMS
101 COMMON /MSGCWD
/ NMSG
(NFILES
),NSUB
(NFILES
),MSUB
(NFILES
),
102 . INODE
(NFILES
),IDATE
(NFILES
)
103 COMMON /USRINT
/ NVAL
(NFILES
),INV
(MAXSS
,NFILES
),VAL
(MAXSS
,NFILES
)
107 CHARACTER*128 BORT_STR1
,BORT_STR2
,ERRSTR
108 REAL*8 USR
(I1
,I2
),VAL
110 DATA IFIRST1
/0/,IFIRST2
/0/
112 SAVE IFIRST1
, IFIRST2
114 C----------------------------------------------------------------------
115 C----------------------------------------------------------------------
119 C CHECK THE FILE STATUS AND I-NODE
120 C --------------------------------
123 CALL STATUS
(LUNIT
,LUN
,IL
,IM
)
126 IF(INODE
(LUN
).NE
.INV
(1,LUN
)) GOTO 902
128 IO
= MIN
(MAX
(0,IL
),1)
129 IF(LUNIO
.NE
.LUNIT
) IO
= 0
133 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
134 ERRSTR
= 'BUFRLIB: UFBSTP - 3rd ARG. (INPUT) IS .LE. 0, ' //
135 . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
138 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
143 IF(IPRT
.EQ
.-1) IFIRST1
= 1
144 IF(IO
.EQ
.0 .OR
. IFIRST1
.EQ
.0 .OR
. IPRT
.GE
.1) THEN
145 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
146 ERRSTR
= 'BUFRLIB: UFBSTP - 4th ARG. (INPUT) IS .LE. 0, ' //
147 . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
150 IF(IPRT
.EQ
.0 .AND
. IO
.EQ
.1) THEN
151 ERRSTR
= 'Note: Only the first occurrence of this WARNING ' //
152 . 'message is printed, there may be more. To output all ' //
155 ERRSTR
= 'modify your application program to add ' //
156 . '"CALL OPENBF(0,''QUIET'',1)" prior to the first call ' //
157 . 'to a BUFRLIB routine.'
160 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
167 C INITIALIZE USR ARRAY PRECEEDING AN INPUT OPERATION
168 C --------------------------------------------------
178 C PARSE OR RECALL THE INPUT STRING - READ/WRITE VALUES
179 C ----------------------------------------------------
181 CALL STRING
(STR
,LUN
,I1
,IO
)
183 C CALL THE MNEMONIC READER/WRITER
184 C -------------------------------
186 CALL UFBSP
(LUN
,USR
,I1
,I2
,IO
,IRET
)
188 IF(IO
.EQ
.1 .AND
. IRET
.NE
.I2
) GOTO 903
193 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
194 ERRSTR
= 'BUFRLIB: UFBSTP - NO SPECIFIED VALUES READ IN, ' //
195 . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
198 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
202 IF(IPRT
.EQ
.-1) IFIRST2
= 1
203 IF(IFIRST2
.EQ
.0 .OR
. IPRT
.GE
.1) THEN
204 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
205 ERRSTR
= 'BUFRLIB: UFBSTP - NO SPECIFIED VALUES WRITTEN OUT, ' //
206 . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
209 CALL ERRWRT
('MAY NOT BE IN THE BUFR TABLE(?)')
211 ERRSTR
= 'Note: Only the first occurrence of this WARNING ' //
212 . 'message is printed, there may be more. To output all ' //
215 ERRSTR
= 'modify your application program to add ' //
216 . '"CALL OPENBF(0,''QUIET'',1)" prior to the first call ' //
217 . 'to a BUFRLIB routine.'
220 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
231 900 CALL BORT
('BUFRLIB: UFBSTP - BUFR FILE IS CLOSED, IT MUST BE'//
233 901 CALL BORT
('BUFRLIB: UFBSTP - A MESSAGE MUST BE OPEN IN BUFR '//
235 902 CALL BORT
('BUFRLIB: UFBSTP - LOCATION OF INTERNAL TABLE FOR '//
236 . 'BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN INTERNAL '//
238 903 WRITE(BORT_STR1
,'("BUFRLIB: UFBSTP - MNEMONIC STRING READ IN IS'//
240 WRITE(BORT_STR2
,'(18X,"THE NUMBER OF ''LEVELS'' ACTUALLY '//
241 . 'WRITTEN (",I3,") DOES NOT EQUAL THE NUMBER REQUESTED (",I3,")'//
242 . ' - INCOMPLETE WRITE")') IRET
,I2
243 CALL BORT2
(BORT_STR1
,BORT_STR2
)