finit-local-zero and default initialization
Tobias Burnus
burnus@net-b.de
Wed Jun 6 07:40:00 GMT 2007
Hi Asher, hi all,
Asher Langton wrote:
> The default initializations would be done only if specified at compile
> time. The runtime option would just change the values used for
> default initialization. So if default initialization was specified at
> compile time, the compiled code would be something like:
>
> i = get_default_integer()
> print i
> end
I see two uses for the initialization:
a) old programs which blindly assume that everything is initialized to zero
b) programs where this has been done inadvertently, here NaN is a good
choice for debugging, INF, -INF or 0 might be also useful and
set_default_*() is cool!
For (a) I would like to have "i = 0" as this is faster and one does care
about whether the initialization is due to -finit-local-zero or not. (I
have such a number crunching program which already takes "too long", is
very big, commercial [programmed at a university] and buggy, but I don't
want to debug/rewrite this program.)
For (b) having the (s|g)et_default_integer() is very nice!
The next question is how to call the option - and what should be
initialized how (logical to .false.? Saved variables? Pointers, e.g. to
0xFFFFF (add as many Fs as fit), which should segfault when accessed.
Other compilers have the following options:
*** g77 ***
-finit-local-zero initialize with zero (what is with logical,
character and pointers?)
*** g95 ***
-fzero (pointers: NULL, logical: false)
-finteger=<n>
-flogical=<none|true|false>
-freal=<none|zero|nan|inf|+inf|-inf>
-fpointer=<none|null|invalid>
*** NAG f95 ***
-nan (otherwise automatically sets local variables to zero)
*** ifort ***
-zero (applies to SAVEd local variables, the others are always zero
initialized)
Tobias
More information about the Fortran
mailing list