-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflpath.f
66 lines (66 loc) · 1.89 KB
/
flpath.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
SUBROUTINE FL_PATH ( fulnam, dirnam, basnam, iret )
C************************************************************************
C* FL_PATH *
C* *
C* This subroutine breaks a full UNIX file path into its directory *
C* and file names. This routine does not expand environment variables. *
C* It also does not check for the existence of the full path name. *
C* *
C* FL_PATH ( FULNAM, DIRNAM, BASNAM, IRET ) *
C* *
C* Input parameters: *
C* FULNAM CHAR* Full path name *
C* *
C* Output parameters: *
C* DIRNAM CHAR* Directory *
C* BASNAM CHAR* Last level of path *
C* IRET INTEGER Return code *
C* 0 = normal return *
C** *
C* Log: *
C* K. Tyle/GSC 5/97 *
C* S. Jacobs/NCEP 11/99 Updated for delivery *
C************************************************************************
CHARACTER*(*) fulnam, dirnam, basnam
C*
LOGICAL found
C-----------------------------------------------------------------------
iret = 0
dirnam = ' '
basnam = fulnam
found = .false.
C
C* Get the length of the input string.
C
CALL ST_LSTR ( fulnam, lenf, ier )
IF ( lenf .eq. 0 ) RETURN
C
C* Start at last character and loop backwards searching for a '/'.
C* If the full path ends with a '/', continue searching for the
C* next '/'.
C
ip = lenf
DO WHILE ( ( ip .ge. 1 ) .and. ( .not. found ) )
IF ( fulnam (ip:ip) .eq. '/' ) THEN
IF ( ip .ne. lenf ) THEN
found = .true.
dirnam = fulnam (:ip)
basnam = fulnam (ip+1:)
END IF
END IF
ip = ip - 1
END DO
C
C* If the base name ends with a '/', remove it.
C
CALL ST_LSTR ( basnam, lenb, ier )
IF ( basnam(lenb:lenb) .eq. '/' ) basnam(lenb:lenb) = ' '
C
C* If the directory name ends with a '/', remove it, unless
C* the string contains only a '/'.
C
CALL ST_LSTR ( dirnam, lend, ier )
IF ( lend .gt. 1 ) dirnam(lend:lend) = ' '
C*
RETURN
END