SpectraRust/synspec/extracted/count_words.f
2026-03-19 14:05:33 +08:00

17 lines
362 B
Fortran

subroutine count_words(cadena,n)
C
C Counts the number of words separated by blanks in a string
C
character*1000 cadena
character*1 a,b
n=0
a=cadena(1:1)
if (a.ne.' ') n=1
do i=2,len(cadena)
b=cadena(i:i)
if(b.ne.' '.and.a.eq.' ') n=n+1
a=b
enddo
end