Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / external / bufr / lstjpb.f
blobffd10845ee2371db7deef5f22e897e56e728db2c
1 FUNCTION LSTJPB(NODE,LUN,JBTYP)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: LSTJPB
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS FUNCTION SEARCHES BACKWARDS, BEGINNING FROM A GIVEN
9 C NODE WITHIN THE JUMP/LINK TABLE, UNTIL IT FINDS THE MOST RECENT
10 C NODE OF TYPE JBTYP. THE INTERNAL JMPB ARRAY IS USED TO JUMP
11 C BACKWARDS WITHIN THE JUMP/LINK TABLE, AND THE FUNCTION RETURNS
12 C THE TABLE INDEX OF THE FOUND NODE. IF THE INPUT NODE ITSELF IS
13 C OF TYPE JBTYP, THEN THE FUNCTION SIMPLY RETURNS THE INDEX OF THAT
14 C SAME NODE.
16 C PROGRAM HISTORY LOG:
17 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
18 C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
19 C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
20 C ROUTINE "BORT"
21 C 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
22 C OPENED AT ONE TIME INCREASED FROM 10 TO 32
23 C (NECESSARY IN ORDER TO PROCESS MULTIPLE
24 C BUFR FILES UNDER THE MPI)
25 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
26 C INTERDEPENDENCIES
27 C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
28 C INCREASED FROM 15000 TO 16000 (WAS IN
29 C VERIFICATION VERSION); UNIFIED/PORTABLE FOR
30 C WRF; ADDED DOCUMENTATION (INCLUDING
31 C HISTORY); OUTPUTS MORE COMPLETE DIAGNOSTIC
32 C INFO WHEN ROUTINE TERMINATES ABNORMALLY
33 C 2009-03-31 J. WOOLLEN -- ADDED ADDITIONAL DOCUMENTATION
35 C USAGE: LSTJPB (NODE, LUN, JBTYP)
36 C INPUT ARGUMENT LIST:
37 C NODE - INTEGER: JUMP/LINK TABLE INDEX OF ENTRY TO BEGIN
38 C SEARCHING BACKWARDS FROM
39 C LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
40 C JBTYP - CHARACTER*(*): TYPE OF NODE FOR WHICH TO SEARCH
42 C OUTPUT ARGUMENT LIST:
43 C LSTJPB - INTEGER: INDEX OF FIRST NODE OF TYPE JBTYP FOUND BY
44 C JUMPING BACKWARDS FROM INPUT NODE
45 C 0 = NO SUCH NODE FOUND
47 C REMARKS:
49 C SEE THE DOCBLOCK IN BUFR ARCHIVE LIBRARY SUBROUTINE TABSUB FOR AN
50 C EXPLANATION OF THE VARIOUS NODE TYPES PRESENT WITHIN AN INTERNAL
51 C JUMP/LINK TABLE
53 C THIS ROUTINE CALLS: BORT
54 C THIS ROUTINE IS CALLED BY: GETWIN NEVN NEWWIN NXTWIN
55 C PARUSR TRYBUMP UFBRW
56 C Normally not called by any application
57 C programs.
59 C ATTRIBUTES:
60 C LANGUAGE: FORTRAN 77
61 C MACHINE: PORTABLE TO ALL PLATFORMS
63 C$$$
65 INCLUDE 'bufrlib.prm'
67 COMMON /MSGCWD/ NMSG(NFILES),NSUB(NFILES),MSUB(NFILES),
68 . INODE(NFILES),IDATE(NFILES)
69 COMMON /BTABLES/ MAXTAB,NTAB,TAG(MAXJL),TYP(MAXJL),KNT(MAXJL),
70 . JUMP(MAXJL),LINK(MAXJL),JMPB(MAXJL),
71 . IBT(MAXJL),IRF(MAXJL),ISC(MAXJL),
72 . ITP(MAXJL),VALI(MAXJL),KNTI(MAXJL),
73 . ISEQ(MAXJL,2),JSEQ(MAXJL)
75 CHARACTER*(*) JBTYP
76 CHARACTER*128 BORT_STR
77 CHARACTER*10 TAG
78 CHARACTER*3 TYP
80 C----------------------------------------------------------------------
81 C----------------------------------------------------------------------
83 IF(NODE.LT.INODE(LUN)) GOTO 900
84 IF(NODE.GT.ISC(INODE(LUN))) GOTO 901
86 NOD = NODE
88 C FIND THIS OR THE PREVIOUS "JBTYP" NODE
89 C --------------------------------------
91 10 IF(TYP(NOD).NE.JBTYP) THEN
92 NOD = JMPB(NOD)
93 IF(NOD.NE.0) GOTO 10
94 ENDIF
96 LSTJPB = NOD
98 C EXITS
99 C -----
101 RETURN
102 900 WRITE(BORT_STR,'("BUFRLIB: LSTJPB - TABLE NODE (",I7,") IS OUT '//
103 . 'OF BOUNDS, < LOWER BOUNDS (",I7,"); TAG IS ",A10)')
104 . NODE,INODE(LUN),TAG(NODE)
105 CALL BORT(BORT_STR)
106 901 WRITE(BORT_STR,'("BUFRLIB: LSTJPB - TABLE NODE (",I7,") IS OUT '//
107 . 'OF BOUNDS, > UPPER BOUNDS (",I7,"); TAG IS ",A10)')
108 . NODE,ISC(INODE(LUN)),TAG(NODE)
109 CALL BORT(BORT_STR)