Re: Need a FORTRAN compiler for Win7 (or XP)

On 8/18/11 1:40 PM, glen herrmannsfeldt wrote:
Richard Maine<nospam@xxxxxxxxxxxxx> wrote:
JB<foo@xxxxxxxxxxx> wrote:

IIRC at some point there was discussion about passing scalar
intent(in) arguments by value for procedures with an explicit
interface; I don't think this has been done so far.

I won't say it is impossible, but that would have complications that
might not be obvious to some at first glance. Mostly the complication
has to do with having the implementation of a procedure depend on
whether it has an explicit interface. That's a complication because
having an explicit interface is a concept defined only in the scope
where a procedure is referenced - not where the procedure is defined.
There are some properties of a procedure that mean it will require an
explicit interface in order to be referenced, but intent(in) isn't one
of those.

You could do it in cases where the explicit interface was already
required. If a routine has an assumed shape array, then use
pass by value for other intent(in) arguments. That does seem
strange, though.

Thus, a procedure with an intent(in) dummy might be referenced with an
explicit interface in some places, but without an explicit interface in
others. Having two versions of the procedure might work in some cases,
but would be tricky if there were saved local variables. So-called
link-time optimization has been mentioned here recently. I suppose that
might be used to procrastinate the decision until "link time", which
could allow the compiler to know things about all the referencing

You could have two entry points to the same procedure, though a
previous post indicates that many object formats don't allow
for multiple entry points.

-- glen

Back in the late 80s (or so) the Convex compiler would make clones of routines. Mostly, they looked for routines that were called (hopefully) many times and had an integer argument (or 2 or 3) that was a constant. The clone was compiled "as if" the argument(s) were replaced by parameters with the same value. Frequently the optimizer could do a very good job when it knew the value of the integers. The same could be done for reals, logicals, etc., but the payoff seems likely to be smaller.

There's no reason why you couldn't do a similar thing for INTENT(IN) arguments, compile a clone and call it when it makes clear sense. But, IMO, calling by value is a very very very small optimization for integer arguments, especially intent(in). Any half-way decent optimizer will pull the values up into a register during the entry set-up and keep it there as long as it is needed. The net saving on the called side will be an instruction issue or two. And, those cycles will likely have occurred on the calling side.

Dick Hendrickson