forked from avikhlinin/wvdecomp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
splitwords.f
40 lines (32 loc) · 897 Bytes
/
splitwords.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
subroutine splitwords (string,words,nwords)
implicit none
character string*(*)
character words(*)*(*)
integer nwords
integer len,i,j,lnblnk
len=lnblnk(string)
i=1
nwords=0
do while (i.le.len)
do while ((string(i:i).eq.' '.or.string(i:i).eq.'\t').and.i.lt.len)
i=i+1
enddo
if (i.eq.len) then
if (string(i:i).ne.' '.and.string(i:i).ne.'\t') then
nwords=nwords+1
words(nwords)=string(i:i)
endif
goto 100
endif
nwords=nwords+1
j=1
words(nwords)=' '
do while ((string(i:i).ne.' '.and.string(i:i).ne.'\t').and.i.le.len)
words(nwords)(j:j)=string(i:i)
i=i+1
j=j+1
enddo
enddo
100 continue
return
end