Re: How to Make F77 Program Faster (g95 compiler) ??



monir wrote:
Hello;

Realizing that Fortran programming skills are not within my grasp, I
thought and for a good reason to post my question in this discussion
group seeking your expert advice.

1) One of my F77 programs is about 14,000 lines and applies 10s of
special functions and many more complex computational methods
developed over the years (in the aero field).

2) The program currently takes about 4 hrs to run on a 3.2 GHz m/c to
advance the solution from 0.0 to 0.01. (Couple of years ago, the same
program would have taken probably 24 hrs to run, and in the 90s,
probably 2 weeks!!!)

3) The program works perfectly, except for one last bug, as always
seems to be the case!

4) The program calls one particular procedure 10,000s of times. The
routine is about 100 lines. If I'm able to make that procedure a
centi- or milli-second faster, then I would probably save 0.5 hrs or
more in runtime on the same m/c.

5) What I'm looking for is some general guidelines on what I should or
shouldn't do. For example, where applicable, should I:
i. reduce the number of statements ??
use: x2 = a + b + c*d
rather than: x1 = a + b
x2 = x1 + c*d
or is it still a 2-operation process ??
ii. pass info in data blocks rather than in subprogram
arguments ??
iii. limit the use of nested DO loops and nested IF statements ??
iv. clean-up the routine from all unnecessary (and necessary!!)
comments ??
v. etc. ??

6) It's a bit risky at this point to change program structure, data
types, data flow, etc.

Thank you kindly for your expert suggestions.
Monir

You are more likely to realize big possible gains by considering the semantics of the code than by trying to help the compiler to do a better job.

Consider this example:

....
s=0
do i=1,10000
s = s + a(i)*Tugh_Fn(pi*t/1d4,a,b,c,i)
enddo
....

Now, if 'i' is an unused argument to Tugh_Fn or if 'i' is seemingly used in the function but it so happens that the function value is actually independent of 'i', that function is called 10,000 times, whereas the following equivalent code would be much faster:

s=0
do i=1,10000
s = s + a(i)
end do
i=0 ! some dummy value,
! assuming that Tugh_Fn is independent of the 5th argument
s=s*Tugh_Fn(pi*t/1d4,a,b,c,i)

since the function is called just once.

None of this will apply if the function has side-effects.

-- mecej4
.



Relevant Pages

  • Re: How to Make F77 Program Faster (g95 compiler) ??
    ... monir writes: ... routine is about 100 lines. ... then I would probably save 0.5 hrs or ...
    (comp.lang.fortran)
  • How to Make F77 Program Faster (g95 compiler) ??
    ... group seeking your expert advice. ... The program currently takes about 4 hrs to run on a 3.2 GHz m/c to ... routine is about 100 lines. ...
    (comp.lang.fortran)
  • Re: Still Having Application.Match trouble
    ... It turns out that the problem wasn't the routine at all, ... the fact that my array was more than 5461 elements long (a max in ... post that separately in hopes that someone can help me review - because ... its still taking more than 8 hrs to run.... ...
    (microsoft.public.excel.programming)