I'd prefer to use awk or one of its successors such as perl; with
awk you can take each word of an input string and increment a count for
that word, creating the array element with a default initial value of 0
if that word hasn't been encountered before. Something like:
{ for (i=1; i<=NF; i++) {count[$i]++;}
}
END {for (word in count) {print word,count[word];}
}
Yes, I like awk for this type of problem.
The important part is a hash table, which I don't believe that Fortran
includes yet.
Last time I did work counting I started in awk, but when that was too
slow (I had 15GB to count) I went to Java. Using StringTokenizer to
find words and Hashtable keep track of them it isn't so hard.
With JIT on it runs reasonably fast. (It took some hours to do
15GB, though computers are faster now.)
If you have a hashtable routine for Fortran it probably isn't so
hard to do.
Re: Help! reformat the data file ... I thought mine was obvious enough that even a Fortran programmer...(awk tends to be more C like than other ... Except if you exit from a BEGIN action, ... and it is a waste to generate all the separate fields if they aren't ... (comp.lang.fortran)
Re: Reading CSV files ... >>send my programs out for production use by a user who happens to be ... > of the people I know who use Fortran are writing scientific software ... > Awk is not problematic. ... Though I agree that some scripting language (and Awk is one of the ... (comp.lang.fortran)
Re: Help! reformat the data file ... there are many other languages which do it better than fortran,... more lines of the code than in awk but you have ... (comp.lang.fortran)
Re: Help! reformat the data file ... I am sure that this can be done just fine in Fortran,... other languages.... When I need to do this, I usually use awk... gets the job done faster than you can type the compile command for ... (comp.lang.fortran)
Re: awk command ... If uppercase is necessary then have a look whether your awk supports ... For tab delimited output you may use printfinstead or set the ... For tab delimited input you may match the string $6"\t"$7 to the ... complete input string $0. ... (comp.unix.shell)