1 SUBROUTINE USRTPL
(LUN
,INVN
,NBMP
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS SUBROUTINE STORES THE SUBSET TEMPLATE INTO INTERNAL
9 C SUBSET ARRAYS IN COMMON BLOCK /USRINT/ FOR CASES OF NODE EXPANSION
10 C (I.E. WHEN THE NODE IS EITHER A TABLE A MNEMONIC OR A DELAYED
11 C REPLICATION FACTOR).
13 C PROGRAM HISTORY LOG:
14 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
15 C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
16 C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
18 C 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
19 C OPENED AT ONE TIME INCREASED FROM 10 TO 32
20 C (NECESSARY IN ORDER TO PROCESS MULTIPLE
21 C BUFR FILES UNDER THE MPI)
22 C 2002-05-14 J. WOOLLEN -- REMOVED OLD CRAY COMPILER DIRECTIVES
23 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
25 C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
26 C INCREASED FROM 15000 TO 16000 (WAS IN
27 C VERIFICATION VERSION); UNIFIED/PORTABLE FOR
28 C WRF; ADDED DOCUMENTATION (INCLUDING
29 C HISTORY) (INCOMPLETE); OUTPUTS MORE
30 C COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
31 C TERMINATES ABNORMALLY OR UNUSUAL THINGS
32 C HAPPEN; COMMENTED OUT HARDWIRE OF VTMP TO
33 C "BMISS" (10E10) WHEN IT IS > 10E9 (CAUSED
34 C PROBLEMS ON SOME FOREIGN MACHINES)
35 C 2009-03-31 J. WOOLLEN -- ADD DOCUMENTATION
36 C 2009-04-21 J. ATOR -- USE ERRWRT
38 C USAGE: CALL USRTPL (LUN, INVN, NBMP)
39 C INPUT ARGUMENT LIST:
40 C LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
41 C INVN - INTEGER: STARTING JUMP/LINK TABLE INDEX OF THE NODE
42 C TO BE EXPANDED WITHIN THE SUBSET TEMPLATE
43 C NBMP - INTEGER: NUMBER OF TIMES BY WHICH INVN IS TO BE
44 C EXPANDED (I.E. NUMBER OF REPLICATIONS OF NODE)
47 C THIS ROUTINE CALLS: BORT ERRWRT
48 C THIS ROUTINE IS CALLED BY: DRFINI DRSTPL MSGUPD OPENMB
49 C OPENMG RDCMPS TRYBUMP UFBGET
50 C UFBTAB UFBTAM WRCMPS WRITLC
51 C Normally not called by any application
55 C LANGUAGE: FORTRAN 77
56 C MACHINE: PORTABLE TO ALL PLATFORMS
62 COMMON /MSGCWD
/ NMSG
(NFILES
),NSUB
(NFILES
),MSUB
(NFILES
),
63 . INODE
(NFILES
),IDATE
(NFILES
)
64 COMMON /BTABLES
/ MAXTAB
,NTAB
,TAG
(MAXJL
),TYP
(MAXJL
),KNT
(MAXJL
),
65 . JUMP
(MAXJL
),LINK
(MAXJL
),JMPB
(MAXJL
),
66 . IBT
(MAXJL
),IRF
(MAXJL
),ISC
(MAXJL
),
67 . ITP
(MAXJL
),VALI
(MAXJL
),KNTI
(MAXJL
),
68 . ISEQ
(MAXJL
,2),JSEQ
(MAXJL
)
69 COMMON /USRINT
/ NVAL
(NFILES
),INV
(MAXSS
,NFILES
),VAL
(MAXSS
,NFILES
)
72 CHARACTER*128 BORT_STR
,ERRSTR
76 LOGICAL DRP
,DRS
,DRB
,DRX
77 REAL*8 VAL
,VTMP
(MAXJL
)
79 C-----------------------------------------------------------------------
80 C-----------------------------------------------------------------------
83 CALL ERRWRT
('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
84 WRITE ( UNIT
=ERRSTR
, FMT
='(A,I3,A,I5,A,I5,A,A10)' )
85 . 'BUFRLIB: USRTPL - LUN:INVN:NBMP:TAG(INODE(LUN)) = ',
86 . LUN
, ':', INVN
, ':', NBMP
, ':', TAG
(INODE
(LUN
))
88 CALL ERRWRT
('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
94 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
95 CALL ERRWRT
('BUFRLIB: USRTPL - NBMP .LE. 0 - IMMEDIATE RETURN')
96 CALL ERRWRT
('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
106 C SET UP A NODE EXPANSION
107 C -----------------------
110 c .... case where node is a Table A mnemonic (nodi is positional index)
114 IF(NBMP
.NE
.1) GOTO 900
115 ELSEIF
(INVN
.GT
.0 .AND
. INVN
.LE
.NVAL
(LUN
)) THEN
116 c .... case where node is (hopefully) a delayed replication factor
118 DRP
= TYP
(NODI
) .EQ
. 'DRP'
119 DRS
= TYP
(NODI
) .EQ
. 'DRS'
120 DRB
= TYP
(NODI
) .EQ
. 'DRB'
121 DRX
= DRP
.OR
. DRS
.OR
. DRB
123 JVAL
= 2**IBT
(NODI
)-1
124 VAL
(INVN
,LUN
) = IVAL
+NBMP
125 IF(DRB
.AND
.NBMP
.NE
.1) GOTO 901
126 IF(.NOT
.DRX
) GOTO 902
127 IF(IVAL
.LT
.0. ) GOTO 903
128 IF(IVAL
+NBMP
.GT
.JVAL
) GOTO 904
133 C RECALL A PRE-FAB NODE EXPANSION SEGMENT
134 C ---------------------------------------
140 IF(N1
.EQ
.0 ) GOTO 906
141 IF(N2
-N1
+1.GT
.MAXJL
) GOTO 907
146 VTMP
(NEWN
) = VALI
(JSEQ
(N
))
149 C MOVE OLD NODES - STORE NEW ONES
150 C -------------------------------
152 IF(NVAL
(LUN
)+NEWN*NBMP
.GT
.MAXSS
) GOTO 908
154 DO J
=NVAL
(LUN
),INVN
+1,-1
155 INV
(J
+NEWN*NBMP
,LUN
) = INV
(J
,LUN
)
156 VAL
(J
+NEWN*NBMP
,LUN
) = VAL
(J
,LUN
)
159 IF(DRP
.OR
.DRS
) VTMP
(1) = NEWN
165 INV
(KNVN
,LUN
) = ITMP
(J
)
166 VAL
(KNVN
,LUN
) = VTMP
(J
)
170 C RESET POINTERS AND COUNTERS
171 C ---------------------------
173 NVAL
(LUN
) = NVAL
(LUN
) + NEWN*NBMP
176 CALL ERRWRT
('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
177 WRITE ( UNIT
=ERRSTR
, FMT
='(A,A,A10,3(A,I5))' )
178 . 'BUFRLIB: USRTPL - TAG(INV(INVN,LUN)):NEWN:NBMP:',
179 . 'NVAL(LUN) = ', TAG
(INV
(INVN
,LUN
)), ':', NEWN
, ':',
180 . NBMP
, ':', NVAL
(LUN
)
183 WRITE ( UNIT
=ERRSTR
, FMT
='(2(A,I5),A,A10)' )
184 . 'For I = ', I
, ', ITMP(I) = ', ITMP
(I
),
185 . ', TAG(ITMP(I)) = ', TAG
(ITMP
(I
))
188 CALL ERRWRT
('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
197 IF(ITP
(NODE
).EQ
.0) THEN
199 IF(INV
(INVR
,LUN
).EQ
.NODE
) THEN
200 VAL
(INVR
,LUN
) = VAL
(INVR
,LUN
)+NEWN*NBMP
215 900 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - THIRD ARGUMENT (INPUT) = ",'//
216 . 'I4,", MUST BE 1 WHEN SECOND ARGUMENT (INPUT) IS 1 (SUBSET '//
217 . 'NODE) (",A,")")') NBMP
,TAG
(NODI
)
219 901 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - THIRD ARGUMENT (INPUT) = ",'//
220 . 'I4,", MUST BE 1 WHEN NODE IS DRB (1-BIT DELAYED REPL. FACTOR)'//
221 . ' (",A,")")') NBMP
,TAG
(NODI
)
223 902 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - NODE IS OF TYPE ",A," - IT '//
224 . 'MUST BE EITHER A SUBSET OR DELAYED REPL. FACTOR (",A,")")')
225 . TYP
(NODI
),TAG
(NODI
)
227 903 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - REPLICATION FACTOR IS '//
228 . 'NEGATIVE (=",I5,") (",A,")")') IVAL
,TAG
(NODI
)
230 904 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - REPLICATION FACTOR OVERFLOW'//
231 . ' (EXCEEDS MAXIMUM OF",I6," (",A,")")') JVAL
,TAG
(NODI
)
233 905 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - INVENTORY INDEX {FIRST '//
234 . 'ARGUMENT (INPUT)} OUT OF BOUNDS (=",I5,", RANGE IS 1 TO",I6,"'//
235 . ') (",A,")")') INVN
,NVAL
(LUN
),TAG
(NODI
)
237 906 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - UNSET EXPANSION SEGMENT (",'//
238 . 'A,")")') TAG
(NODI
)
240 907 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - TEMPLATE ARRAY OVERFLOW, '//
241 . 'EXCEEDS THE LIMIT (",I6,") (",A,")")') MAXJL
,TAG
(NODI
)
243 908 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - INVENTORY OVERFLOW (",I6,")'//
244 . ', EXCEEDS THE LIMIT (",I6,") (",A,")")')
245 . NVAL
(LUN
)+NEWN*NBMP
,MAXSS
,TAG
(NODI
)
247 909 WRITE(BORT_STR
,'("BUFRLIB: USRTPL - BAD BACKUP STRATEGY (",A,'//