FLASH-X
Doxygen Generated Documentation From Interface Source Code
findWords.F90
Go to the documentation of this file.
1!! NOTICE
2!! Copyright 2022 UChicago Argonne, LLC and contributors
3!!
4!! Licensed under the Apache License, Version 2.0 (the "License");
5!! you may not use this file except in compliance with the License.
6!!
7!! Unless required by applicable law or agreed to in writing, software
8!! distributed under the License is distributed on an "AS IS" BASIS,
9!! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10!! See the License for the specific language governing permissions and
11!! limitations under the License.
12!!
39
40subroutine findWords (string, first, last, n, nwords)
41
42 implicit none
43
44#include "constants.h"
45
46 character(len=*), intent(inout) :: string
47 integer, intent(in) :: n
48 integer, intent(inout) :: nwords, first(n), last(n)
49
50 integer, parameter :: ndel = 2, nsym = 1
51 !The deliminator characters must be a space and a TAB.
52 character :: delimiters(ndel) = (/' ', TAB_CHAR/)
53 character :: symbols(nsym) = (/'='/)
54 integer :: i, j, k, strlen
55 logical :: is_delimiter, is_symbol
56
57
58
59
60 strlen = len(string)
61 nwords = 0
62 k = 1
63
64 do i = 1, strlen
65
66 is_delimiter = .false.
67 do j = 1, ndel
68 if (string(i:i) == delimiters(j)) is_delimiter = .true.
69 enddo
70 is_symbol = .false.
71 do j = 1, nsym
72 if (string(i:i) == symbols(j)) is_symbol = .true.
73 enddo
74
75 if (is_delimiter .or. is_symbol) then
76 if (i > k) then
77 nwords = nwords + 1
78 first(nwords) = k
79 last(nwords) = i - 1
80 endif
81 k = i + 1
82 endif
83 if (is_symbol) then
84 nwords = nwords + 1
85 first(nwords) = i
86 last(nwords) = i
87 endif
88
89 enddo
90
91 ! If we ended without a delimiter or symbol, record the last
92 ! word.
93
94 if (.not. (is_delimiter .or. is_symbol)) then
95 nwords = nwords + 1
96 first(nwords) = k
97 last(nwords) = strlen
98 endif
99
100
101 return
102end subroutine findWords
103
104
subroutine findWords(string, first, last, n, nwords)
Definition: findWords.F90:41