NCEPLIBS-bufr 11.7.1
numbck.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS FUNCTION CHECKS THE INPUT CHARACTER STRING TO DETERMINE
5C> WHETHER IT CONTAINS A VALID FXY (DESCRIPTOR) VALUE.
6C>
7C> PROGRAM HISTORY LOG:
8C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
9C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
10C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
11C> INTERDEPENDENCIES
12C> 2003-11-04 D. KEYSER -- SPLIT NON-ZERO RETURN INTO -1 FOR INVALID
13C> CHARACTER IN POSITION 1, -2 FOR INVALID
14C> CHARACTERS IN POSITIONS 2 THROUGH 6, -3 FOR
15C> INVALID CHARACTERS IN POSITIONS 2 AND 3 DUE
16C> TO BEING OUT OF RANGE, AND -4 FOR INVALID
17C> CHARACTERS IN POSITIONS 4 THROUGH 6 DUE TO
18C> BEING OUT OF RANGE (RETURN ONLY -1 BEFORE
19C> FOR ALL PROBLEMATIC CASES); UNIFIED/
20C> PORTABLE FOR WRF; ADDED HISTORY
21C> DOCUMENTATION
22C> 2007-01-19 J. ATOR -- CLEANED UP AND SIMPLIFIED LOGIC
23C>
24C> USAGE: NUMBCK (NUMB)
25C> INPUT ARGUMENT LIST:
26C> NUMB - CHARACTER*6: FXY VALUE TO BE CHECKED
27C>
28C> OUTPUT ARGUMENT LIST:
29C> NUMBCK - INTEGER: INDICATOR AS TO WHETHER NUMB IS VALID:
30C> 0 = YES
31C> -1 = NO - first character ("F" value) is not '0',
32C> '1', '2' OR '3'
33C> -2 = NO - remaining characters (2-6) ("X" and "Y"
34C> values) are not all numeric
35C> -3 = NO - characters 2-3 ("X" value) are not
36C> between '00' and '63'
37C> -4 = NO - characters 4-6 ("Y" value) are not
38C> between '000' and '255'
39C>
40C> REMARKS:
41C> THIS ROUTINE CALLS: DIGIT
42C> THIS ROUTINE IS CALLED BY: IGETFXY RDUSDX
43C> Normally not called by any application
44C> programs.
45C>
46 FUNCTION numbck(NUMB)
47
48
49
50 CHARACTER*6 numb
51 LOGICAL digit
52
53C-----------------------------------------------------------------------
54C-----------------------------------------------------------------------
55
56C CHECK THE FIRST CHARACTER OF NUMB
57C ---------------------------------
58
59 IF( llt(numb(1:1),'0') .OR. lgt(numb(1:1),'3') ) THEN
60 numbck = -1
61 RETURN
62 ENDIF
63
64C CHECK FOR A VALID DESCRIPTOR
65C ----------------------------
66
67 IF(digit(numb(2:6))) THEN
68 READ(numb,'(1X,I2,I3)') ix,iy
69 ELSE
70 numbck = -2
71 RETURN
72 ENDIF
73
74 IF(ix.LT.0 .OR. ix.GT. 63) THEN
75 numbck = -3
76 RETURN
77 ELSE IF(iy.LT.0 .OR. iy.GT.255) THEN
78 numbck = -4
79 RETURN
80 ENDIF
81
82 numbck = 0
83
84 RETURN
85 END
logical function digit(STR)
This logical function checks whether the characters in a string are all numeric.
Definition: digit.f:22
function numbck(NUMB)
THIS FUNCTION CHECKS THE INPUT CHARACTER STRING TO DETERMINE WHETHER IT CONTAINS A VALID FXY (DESCRIP...
Definition: numbck.f:47