[comp.sys.sgi] f77 and -static option

YATES@c.chem.upenn.edu ("YATES, JOHN H.") (02/25/91)

I have a Fortran program that repeatedly builds and diagonalizes a 400x400
array using routines from a math library. I find that if I compile without
the option -static, it core dumps (after about the 7th array,
about 27 minutes of CPU time). If I build the whole code with

f77 -g -static -o pa1 pa1.f pa2.f pa3.f

It did not core dump. (roughly 2 hours of CPU time, about 29 400x400 arrays.)

I learned about using -static by example from someones Makefile for a large
Fortran code, and it is described in the f77 man page, which seems to leave
it to folklore on when to use it or when it is necessary.

My questions are, 

1. should ALL Fortran Unix codes be compiled with the -static option?

2. When is it "safe" to not use it?

3. Are the unsafe -automatic Fortran constructs things like EQUIVALENCE,
   COMMON blocks, BLOCK DATA, ... and others?

4. Is it buggy Fortran code that requires -static to be used, or just normal
   Fortran coding practices?

5. What f77 options are generally regarded as "necessary" or "useful" in
   building large codes ported from non-Unix (e.g. VMS) systems.

6. Could this perhaps be an IRIX or f77 bug?

Thanks, John
yates@c.chem.upenn.edu

blbates@aero36.larc.nasa.gov (Brent Bates ViGYAN AAD/TAB) (02/25/91)

   I don't use -static all the time, just when I need it.  If I want to
return to a routine and have the values of variables from previous calls
remain the same between calls, I use -static.  I have found, most of the
time painfully, that when porting sources from one machine to another that
sometimes the original machine had used static variable as the default and
when I ported to a machine that didn't have this it gave me problems.  I
don't consider having to use -static as "buggy".  It is just a matter of what
you are trying to do and how you wish to do it.

	Brent L. Bates
	NASA-Langley Research Center
	M.S. 361
	Hampton, Virginia  23665-5225
	(804) 864-2854
	E-mail: blbates@aero36.larc.nasa.gov or blbates@aero8.larc.nasa.gov

mas@everest.corp.sgi.com (Michael A. Schulman) (02/26/91)

In article <9102241616.AA25648@remote.dccs.upenn.edu>, YATES@c.chem.upenn.edu ("YATES, JOHN H.") writes:
|> 
|> I have a Fortran program that repeatedly builds and diagonalizes a 400x400
|> array using routines from a math library. I find that if I compile without
|> the option -static, it core dumps (after about the 7th array,
|> about 27 minutes of CPU time). If I build the whole code with
|> 
|> f77 -g -static -o pa1 pa1.f pa2.f pa3.f
|> 
|> It did not core dump. (roughly 2 hours of CPU time, about 29 400x400 arrays.)
|> 
|> I learned about using -static by example from someones Makefile for a large
|> Fortran code, and it is described in the f77 man page, which seems to leave
|> it to folklore on when to use it or when it is necessary.
|> 
|> My questions are, 
|> 
|> 1. should ALL Fortran Unix codes be compiled with the -static option?
|> 
|> 2. When is it "safe" to not use it?
|> 
|> 3. Are the unsafe -automatic Fortran constructs things like EQUIVALENCE,
|>    COMMON blocks, BLOCK DATA, ... and others?
|> 
|> 4. Is it buggy Fortran code that requires -static to be used, or just normal
|>    Fortran coding practices?
|> 
|> 5. What f77 options are generally regarded as "necessary" or "useful" in
|>    building large codes ported from non-Unix (e.g. VMS) systems.
|> 
|> 6. Could this perhaps be an IRIX or f77 bug?
|> 
|> Thanks, John
|> yates@c.chem.upenn.edu

-- 

You do not mention if the bug is in your program or in SGI fortran when you
compare the two cases ( compiled with and without -static ).

When porting codes to the SGI machine, it depends on your code whether you
want to use -static.  It is "safe" NOT to use it when the code is written
such that local variables are initialized each entrance into the subroutine.
Dont expect them to retain their value.

It is probably buggy fortran in that you need -static.

For large ( > 250,000 ) lines of code we use the following options:

	f77 -O -G 0 -static

We use -static because of the large codes are "old" and expect certain
behavior.  -O because you could see up to 30 % performance improvement in
certain cases.  -G 0 because of the large number of variable placed in 
common blocks ( the loader will tell you if you need to use -G 0 ).  Also
of note, -Olimit.




Michael Schulman

Silicon Graphics Computer Systems
2011 N. Shoreline Blvd.
Mountain View, CA 94039

415-962-3308

mas@sgi.com

khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) (02/26/91)

...4. Is it buggy Fortran code that requires -static to be used, or just normal
>   Fortran coding practices?

There are many codes which make the assumption that values defined in
one procedure call, retain their last value for the next call. This
isn't standard conforming (i.e. read is a user code bug).

There are also many codes which implicitly assume that uninitialized
variables are zero. This is also not standard conforming (x3.9-1978
true for the last paragraph also).

There are static analysis tools (ala lint) which are very handy. I
urge everyone who codes or ports Fortran codes to procure one (a short
list, and long review of one, available upon request).
--
----------------------------------------------------------------
Keith H. Bierman    kbierman@Eng.Sun.COM | khb@chiba.Eng.Sun.COM
SMI 2550 Garcia 12-33			 | (415 336 2648)   
    Mountain View, CA 94043