> OK,
> I tried the Sun compiler and it gave me a warning (not safe
> to transfer
> to ELSE loop or something), but it still compiled the code.
> So do all f77
> compilers I have access to. Lahey F95 wrongly diagnoses the
> error as jumping
> into a DO loop and also won't compile.
> Anyway, these kind of constructs confuse me too, so I don't blame the
> compilers. What is a nice solution to this (as little code
> rewriting as
> possible)?
Compaq Fortran also complains, but just issues a warning and still compiles.
Looking at the code, I think it is safe to change the lines:
*
* A new arc enters the tree. We update the
* vectors PR, THR, RTHR, DEPTH and BA.
*
100 continue
pr(mxt) = mxp
depth(mxt) = depth(mxp) + 1
ison = thr(mxp)
thr(mxp) = mxt
rthr(mxt) = mxp
thr(mxt) = ison
rthr(ison) = mxt
call sxba(xst(mxa))
call sxndis(xst(mxt))
nba = nba + 1
ba(mxt) = mxa
su(ik) = -su(ik)
endif
To:
endif ! Moved up from below
*
* A new arc enters the tree. We update the
* vectors PR, THR, RTHR, DEPTH and BA.
*
100 continue
pr(mxt) = mxp
depth(mxt) = depth(mxp) + 1
ison = thr(mxp)
thr(mxp) = mxt
rthr(mxt) = mxp
thr(mxt) = ison
rthr(ison) = mxt
call sxba(xst(mxa))
call sxndis(xst(mxt))
nba = nba + 1
ba(mxt) = mxa
su(ik) = -su(ik)
The reason this looks safe is that the IF part of the IF-THEN-ELSE this was
contained in has an unconditional RETURN, so the lines after label 100
always get executed if the "graph is connected". I haven't tried to
understand the whole code, though, so I don't promise that this works, but
I'm pretty confident it's ok.
Steve Lionel
Compaq Fortran Engineering
http://www.compaq.com/fortran
|