Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / external / bufr / nvnwin.f
blobd06ce97adfc1cde9f195aabc5bee6f557fa06825
1 FUNCTION NVNWIN(NODE,LUN,INV1,INV2,INVN,NMAX)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: NVNWIN
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS FUNCTION LOOKS FOR AND RETURNS ALL OCCURRENCES OF A
9 C SPECIFIED NODE WITHIN THE PORTION OF THE CURRENT SUBSET BUFFER
10 C BOUNDED BY THE INDICES INV1 AND INV2. THE RESULTING LIST IS A
11 C STACK OF "EVENT" INDICES FOR THE REQUESTED NODE.
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
17 C ROUTINE "BORT"
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 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
23 C INTERDEPENDENCIES
24 C 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
25 C INCREASED FROM 15000 TO 16000 (WAS IN
26 C VERIFICATION VERSION); UNIFIED/PORTABLE FOR
27 C WRF; ADDED DOCUMENTATION (INCLUDING
28 C HISTORY); OUTPUTS MORE COMPLETE DIAGNOSTIC
29 C INFO WHEN ROUTINE TERMINATES ABNORMALLY OR
30 C UNUSUAL THINGS HAPPEN
31 C 2009-03-23 J. ATOR -- USE 1E9 TO PREVENT OVERFLOW WHEN
32 C INITIALIZING INVN; USE ERRWRT
33 C 2009-03-31 J. WOOLLEN -- ADDED DOCUMENTATION
35 C USAGE: NVNWIN (NODE, LUN, INV1, INV2, INVN, NMAX)
36 C INPUT ARGUMENT LIST:
37 C NODE - INTEGER: JUMP/LINK TABLE INDEX TO LOOK FOR
38 C LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
39 C INV1 - INTEGER: STARTING INDEX OF THE PORTION OF THE SUBSET
40 C BUFFER IN WHICH TO LOOK
41 C INV2 - INTEGER: ENDING INDEX OF THE PORTION OF THE SUBSET
42 C BUFFER IN WHICH TO LOOK
43 C NMAX - INTEGER: DIMENSIONED SIZE OF INVN; USED BY THE
44 C FUNCTION TO ENSURE THAT IT DOES NOT OVERFLOW THE
45 C INVN ARRAY
47 C OUTPUT ARGUMENT LIST:
48 C INVN - INTEGER: ARRAY OF STACK "EVENT" INDICES FOR NODE
49 C NVNWIN - INTEGER: NUMBER OF INDICES RETURNED WITHIN INVN
51 C REMARKS:
52 C THIS ROUTINE CALLS: BORT ERRWRT
53 C THIS ROUTINE IS CALLED BY: UFBEVN
54 C Normally not called by any application
55 C programs.
57 C ATTRIBUTES:
58 C LANGUAGE: FORTRAN 77
59 C MACHINE: PORTABLE TO ALL PLATFORMS
61 C$$$
63 INCLUDE 'bufrlib.prm'
65 COMMON /USRINT/ NVAL(NFILES),INV(MAXSS,NFILES),VAL(MAXSS,NFILES)
66 COMMON /QUIET / IPRT
68 CHARACTER*128 BORT_STR
69 DIMENSION INVN(NMAX)
70 REAL*8 VAL
72 C----------------------------------------------------------------------
73 C----------------------------------------------------------------------
75 NVNWIN = 0
77 IF(NODE.EQ.0) THEN
78 IF(IPRT.GE.1) THEN
79 CALL ERRWRT('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
80 CALL ERRWRT('BUFRLIB: NVNWIN - NODE=0, IMMEDIATE RETURN')
81 CALL ERRWRT('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
82 CALL ERRWRT(' ')
83 ENDIF
84 GOTO 100
85 ENDIF
87 DO I=1,NMAX
88 INVN(I) = 1E9
89 ENDDO
91 C SEARCH BETWEEN INV1 AND INV2
92 C ----------------------------
94 DO N=INV1,INV2
95 IF(INV(N,LUN).EQ.NODE) THEN
96 IF(NVNWIN+1.GT.NMAX) GOTO 900
97 NVNWIN = NVNWIN+1
98 INVN(NVNWIN) = N
99 ENDIF
100 ENDDO
102 C EXITS
103 C -----
105 100 RETURN
106 900 WRITE(BORT_STR,'("BUFRLIB: NVNWIN - THE NUMBER OF EVENTS, '//
107 . 'NVNWIN (",I5,") EXCEEDS THE LIMIT, NMAX (",I5,")")') NVNWIN,NMAX
108 CALL BORT(BORT_STR)