Re: grep can help?

Just to point out the obvious: This does not take into account
exclamation marks in string constants, and the standard also allows
you to write F90 in fixed format in which case you might use ! in
column 5 (?) for continuation lines. Of course it depends on your
code whether this is a problem; a general solution would need to parse
F90 in both formats.
Albert.

I see. I think your 2nd point is not an example of good programming, so
I would not worry about it. But your 1st point needs to be taken care
of: replace-regexp "\B!.*" " " and all the comments will be gone,
respecting the ! inside the strings, as long as they don't come with a
preceding whitespace. But if they do, this is again not a good practice,
normally for example you write "Nice to see you!", but not "Nice to see
you !".