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