NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
igetfxy.f
Go to the documentation of this file.
1 C> @file
2 C> @author ATOR @date 2007-01-19
3 
4 C> THIS FUNCTION LOOKS FOR AND RETURNS A VALID FXY NUMBER
5 C> FROM WITHIN THE GIVEN INPUT STRING. THE FXY NUMBER MAY BE IN
6 C> FORMAT OF EITHER FXXYYY OR F-XX-YYY WITHIN THE INPUT STRING, BUT
7 C> IT IS ALWAYS RETURNED IN FORMAT FXXYYY UPON OUTPUT.
8 C>
9 C> PROGRAM HISTORY LOG:
10 C> 2007-01-19 J. ATOR -- ORIGINAL AUTHOR
11 C> - 2021-09-30 J. Ator -- Replace jstchr with Fortran intrinsic
12 C> adjustl
13 C>
14 C> USAGE: IGETFXY ( STR, CFXY )
15 C> INPUT ARGUMENT LIST:
16 C> STR - CHARACTER*(*): INPUT STRING
17 C>
18 C> OUTPUT ARGUMENT LIST:
19 C> CFXY - CHARACTER*6: FXY NUMBER IN FORMAT FXXYYY
20 C> IGETFXY - INTEGER: RETURN CODE:
21 C> 0 = normal return
22 C> -1 = could not find a valid FXY number in STR
23 C>
24 C> REMARKS:
25 C> THIS ROUTINE CALLS: NUMBCK
26 C> THIS ROUTINE IS CALLED BY: GETNTBE SNTBDE SNTBFE
27 C> Normally not called by any application
28 C> programs.
29 C>
30  FUNCTION igetfxy ( STR, CFXY )
31 
32 
33 
34  character*(*) str
35  character*6 cfxy
36 
37  parameter( lstr2 = 120 )
38  CHARACTER*(LSTR2) str2
39 
40 C-----------------------------------------------------------------------
41 C-----------------------------------------------------------------------
42 
43  igetfxy = -1
44 
45  lstr = len( str )
46  IF ( lstr .LT. 6 ) RETURN
47 
48 C Left-justify a copy of the input string.
49 
50  IF ( lstr .GT. lstr2 ) THEN
51  str2(1:lstr2) = str(1:lstr2)
52  ELSE
53  str2 = str
54  ENDIF
55  str2 = adjustl( str2 )
56  IF ( str2 .EQ. ' ' ) RETURN
57 
58 C Look for an FXY number.
59 
60  IF ( index( str2, '-' ) .NE. 0 ) THEN
61 C Format of field is F-XX-YYY.
62  cfxy(1:1) = str2(1:1)
63  cfxy(2:3) = str2(3:4)
64  cfxy(4:6) = str2(6:8)
65  ELSE
66 C Format of field is FXXYYY.
67  cfxy = str2(1:6)
68  ENDIF
69 
70 C Check that the FXY number is valid.
71 
72  IF ( numbck( cfxy ) .EQ. 0 ) igetfxy = 0
73 
74  RETURN
75  END
function numbck(NUMB)
THIS FUNCTION CHECKS THE INPUT CHARACTER STRING TO DETERMINE WHETHER IT CONTAINS A VALID FXY (DESCRIP...
Definition: numbck.f:46
function igetfxy(STR, CFXY)
THIS FUNCTION LOOKS FOR AND RETURNS A VALID FXY NUMBER FROM WITHIN THE GIVEN INPUT STRING...
Definition: igetfxy.f:30