1 SUBROUTINE UPFTBV
(LUNIT
,NEMO
,VAL
,MXIB
,IBIT
,NIB
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: JATOR ORG: NP12 DATE: 2005-11-29
8 C ABSTRACT: GIVEN A MNEMONIC OF TYPE "FLAG TABLE" ALONG WITH ITS
9 C CORRESPONDING VALUE, THIS SUBROUTINE DETERMINES THE BIT SETTINGS
10 C EQUIVALANT TO THAT VALUE. NOTE THAT THIS SUBROUTINE IS THE
11 C LOGICAL INVERSE OF BUFRLIB SUBROUTINE PKFTBV.
13 C PROGRAM HISTORY LOG:
14 C 2005-11-29 J. ATOR -- ORIGINAL VERSION
16 C USAGE: UPFTBV (LUNIT,NEMO,VAL,MXIB,IBIT,NIB)
17 C INPUT ARGUMENT LIST:
18 C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
19 C NEMO - CHARACTER*(*): MNEMONIC OF TYPE "FLAG TABLE"
20 C VAL - REAL*8: VALUE CORRESPONDING TO NEMO
21 C MXIB - INTEGER: DIMENSIONED SIZE OF IBIT IN CALLING PROGRAM
23 C OUTPUT ARGUMENT LIST:
24 C IBIT - INTEGER(*): BIT NUMBERS WHICH WERE SET TO "ON"
25 C (I.E. SET TO "1") IN VAL
26 C NIB - INTEGER: NUMBER OF BIT NUMBERS RETURNED IN IBIT
29 C THIS ROUTINE CALLS: BORT NEMTAB STATUS VALX
30 C THIS ROUTINE IS CALLED BY: UFBDMP UFDUMP
31 C Also called by application programs.
34 C LANGUAGE: FORTRAN 77
35 C MACHINE: PORTABLE TO ALL PLATFORMS
41 COMMON /TABABD
/ NTBA
(0:NFILES
),NTBB
(0:NFILES
),NTBD
(0:NFILES
),
42 . MTAB
(MAXTBA
,NFILES
),IDNA
(MAXTBA
,NFILES
,2),
43 . IDNB
(MAXTBB
,NFILES
),IDND
(MAXTBD
,NFILES
),
44 . TABA
(MAXTBA
,NFILES
),TABB
(MAXTBB
,NFILES
),
55 CHARACTER*128 BORT_STR
58 C----------------------------------------------------------------------
59 C----------------------------------------------------------------------
61 C Perform some sanity checks.
63 CALL STATUS
(LUNIT
,LUN
,IL
,IM
)
66 CALL NEMTAB
(LUN
,NEMO
,IDN
,TAB
,N
)
68 IF(TABB
(N
,LUN
)(71:74).NE
.'FLAG') GOTO 902
70 C Figure out which bits are set.
74 NBITS
= VALX
(TABB
(N
,LUN
)(110:112))
77 IF(ABS
(R8VAL
-R82I
).LT
.(0.005)) THEN
79 IF(NIB
.GT
.MXIB
) GOTO 903
82 ELSEIF
(R82I
.LT
.R8VAL
) THEN
84 IF(NIB
.GT
.MXIB
) GOTO 903
91 900 CALL BORT
('BUFRLIB: UPFTBV - INPUT BUFR FILE IS CLOSED, IT '//
92 . 'MUST BE OPEN FOR INPUT')
93 901 WRITE(BORT_STR
,'("BUFRLIB: UPFTBV - MNEMONIC ",A,'//
94 . '" NOT FOUND IN TABLE B")') NEMO
96 902 WRITE(BORT_STR
,'("BUFRLIB: UPFTBV - MNEMONIC ",A,'//
97 . '" IS NOT A FLAG TABLE")') NEMO
99 903 CALL BORT
('BUFRLIB: UPFTBV - IBIT ARRAY OVERFLOW')