1 SUBROUTINE parse_extension(file_to_parse, file_or_extension, lnc)
6 CHARACTER(LEN=*),
INTENT(in) :: file_or_extension
7 CHARACTER(LEN=*),
INTENT(inout) :: file_to_parse
8 LOGICAL,
INTENT(out) :: lnc
12 INTEGER :: index_path, index_comp, index_nc, istat=0
14 CHARACTER(len=LEN(file_to_parse)) :: path
15 CHARACTER(len=LEN(file_to_parse)) :: temp
16 CHARACTER(LEN=1),
PARAMETER :: ch_test =
'.'
22 index_path = index(file_or_extension, trim(file_to_parse))
23 index_comp = index_path
25 IF (index_path .gt. 0)
THEN
29 index_nc = index_path + len_trim(file_to_parse)
30 index_path = index(file_or_extension(index_nc:),ch_test)
34 IF (index_path .gt. 0)
THEN
35 file_to_parse = file_or_extension
39 index_nc = index(file_to_parse,
".nc",back=.true.)
40 lnc = (index_nc .eq. (len_trim(file_to_parse)-2))
44 INQUIRE(file=file_to_parse, exist=ltxt, iostat=istat)
45 IF (istat.ne.0 .or. .not.ltxt)
THEN
46 file_to_parse = trim(file_to_parse) //
".nc"
56 IF (file_or_extension(1:1) ==
'.' .or.
57 1 file_or_extension(1:1) ==
'_')
THEN
58 temp = trim(path) // file_or_extension
59 ELSE IF (index_comp == 0)
THEN
60 temp = trim(path) //
'_' // file_or_extension
62 temp = trim(file_or_extension)
68 file_to_parse = trim(temp)
69 index_nc = index(file_to_parse,
".nc",back=.true.)
70 lnc = (index_nc .eq. (len_trim(file_to_parse)-2))
75 index_nc = index(file_to_parse,
".txt",back=.true.)
76 ltxt = (index_nc .eq. (len_trim(file_to_parse)-3))
81 file_to_parse = trim(temp) //
'.nc'
82 INQUIRE (file=file_to_parse, exist=lnc, iostat=istat)
83 IF (istat.ne.0 .or. .not.lnc)
THEN
84 file_to_parse = trim(path) //
'.'
85 1 // trim(file_or_extension) //
'.nc'
86 INQUIRE (file=file_to_parse, exist=lnc, iostat=istat)
87 IF (istat.ne.0 .or. .not.lnc)
THEN
88 file_to_parse = trim(temp) //
'.txt'
89 INQUIRE (file=file_to_parse, exist=ltxt,
92 file_to_parse = trim(path) //
'.' //
93 1 trim(file_or_extension) //
'.txt'
94 INQUIRE (file=file_to_parse, exist=ltxt,
103 IF ((istat.ne.0 .or. .not.ltxt) .and. .not.lnc)
THEN
104 file_to_parse = trim(path) //
'.' // file_or_extension
111 END SUBROUTINE parse_extension