NCEPLIBS-bufr  12.0.1
igetfxy.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Search for a valid FXY number within a character string.
3 C>
4 C> @author Ator @date 2007-01-19
5 
6 C> This function looks for and returns a valid FXY number
7 C> from within the given input string. The FXY number may be in
8 C> format of either FXXYYY or F-XX-YYY within the input string, but
9 C> it is always returned in format FXXYYY upon output.
10 C>
11 C> @param[in] STR - character*(*): input string.
12 C> @param[in] CFXY - character*6: FXY number in format FXXYYY.
13 C>
14 C> @return
15 C> - 0 normal return.
16 C> - -1 could not find a valid FXY number in STR.
17 C>
18 C> @author Ator @date 2007-01-19
19  FUNCTION igetfxy ( STR, CFXY )
20 
21  CHARACTER*(*) str
22  CHARACTER*6 cfxy
23 
24  parameter( lstr2 = 120 )
25  CHARACTER*(LSTR2) str2
26 
27 C-----------------------------------------------------------------------
28 C-----------------------------------------------------------------------
29 
30  igetfxy = -1
31 
32  lstr = len( str )
33  IF ( lstr .LT. 6 ) RETURN
34 
35 C Left-justify a copy of the input string.
36 
37  IF ( lstr .GT. lstr2 ) THEN
38  str2(1:lstr2) = str(1:lstr2)
39  ELSE
40  str2 = str
41  ENDIF
42  str2 = adjustl( str2 )
43  IF ( str2 .EQ. ' ' ) RETURN
44 
45 C Look for an FXY number.
46 
47  IF ( index( str2, '-' ) .NE. 0 ) THEN
48 C Format of field is F-XX-YYY.
49  cfxy(1:1) = str2(1:1)
50  cfxy(2:3) = str2(3:4)
51  cfxy(4:6) = str2(6:8)
52  ELSE
53 C Format of field is FXXYYY.
54  cfxy = str2(1:6)
55  ENDIF
56 
57 C Check that the FXY number is valid.
58 
59  IF ( numbck( cfxy ) .EQ. 0 ) igetfxy = 0
60 
61  RETURN
62  END
function igetfxy(STR, CFXY)
This function looks for and returns a valid FXY number from within the given input string.
Definition: igetfxy.f:20
function numbck(NUMB)
This function checks the input character string to determine whether it contains a valid FXY (descrip...
Definition: numbck.f:20