gnu optimization: -O3 for Fortran flags, -O2 for C flags?

Tom Roche Tom_Roche@pobox.com
Tue Nov 22 00:38:00 GMT 2011


Tom Roche Mon, 21 Nov 2011 17:18:42 -0500
>> For this build, I'm trying

>> MFLAGS    = -m64 -march=native
>> OPTFLAGS = -O2 ${MFLAGS} -funroll-loops --param max-unroll-times=4 -ftree-vectorize
>> COPTFLAGS = ${OPTFLAGS} -Wall
>> FOPTFLAGS = ${OPTFLAGS}

>> which hopefully is neither too conservative nor too aggressive.
>> Please lemme know if anything looks obviously wrong, other than -Wall:
>> unfortunately gfortran goes nuts (and I go scrollblind) on this
>> old code with -Wall.

Steve Kargl Mon, 21 Nov 2011 14:28:49 -0800
> If it is dusty, moldy, old code,

I wouldn't go that far--this is production code, very much in use. The
problem is (as I perceive it, which could be very wrong, since I
haven't been using it very long),

* the code was initially written long ago (by folks who are no longer
  around--defunct contract company IIRC)

* it's been worked on by scientists who are mostly interested in tiny
  aspects of the overall domain (atmospheric modeling), and who are
  not particularly software developers

* there hasn't been the <interest|money|time> to rearchitect the code
  (though I keep hearing rumors of a rewrite)

so it's just old, apparently kinda weird (e.g., it uses a 132-column
fixed-length format, but is otherwise F90), quite "doc-challenged"
(though that's getting better), and (as previously mentioned) not
nearly ready for -Wall. Other than that ... :-)

> while debugging the code, if you have gfortran 4.6.0 or newer,

(which I do)

> use the -fcheck=all option [to] catch out-of-bound array index
> references.

Though I hope never to hafta look @ this code from the business end of
`gdb`, I'll keep that in mind.

thanks again, Tom Roche <Tom_Roche@pobox.com>



More information about the Fortran mailing list