Prev: Matlab mexing with gfortran -- String handling.
Next: XLF V13.1 release for AIX -- fully compliant Fortran 2003 standard
From: robin on 20 Apr 2010 12:08 "Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message news:hqjgq0$iad$1(a)speranza.aioe.org... | Should one rely on allocated arrays being initialized to zero? Nothing is ever initialized to zero automatically.
From: Colin Watters on 20 Apr 2010 15:35 "robin" <robin51(a)dodo.com.au> wrote in message news:4bcdd1a5$0$893$c30e37c6(a)exi-reader.telstra.net... > "Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message > news:hqjgq0$iad$1(a)speranza.aioe.org... > | Should one rely on allocated arrays being initialized to zero? > > Nothing is ever initialized to zero automatically. > > Rubbish. See for example the compiler option "-zero" on Intel Fortran. http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/win/compiler_f/index.htm -- Qolin Email: my qname at domain dot com Domain: qomputing
From: Gordon Sande on 20 Apr 2010 16:07 On 2010-04-20 16:35:40 -0300, "Colin Watters" <boss(a)qomputing.com> said: > > "robin" <robin51(a)dodo.com.au> wrote in message > news:4bcdd1a5$0$893$c30e37c6(a)exi-reader.telstra.net... >> "Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message >> news:hqjgq0$iad$1(a)speranza.aioe.org... >> | Should one rely on allocated arrays being initialized to zero? >> >> Nothing is ever initialized to zero automatically. >> >> > > Rubbish. > > See for example the compiler option "-zero" on Intel Fortran. > > http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/win/compiler_f/index.htm The > qualifiers you seemed to have missed are local and scalar in addition to the fact that this is for one compiler only. There is also the technical question of the interaction with the saved attributes as the option is only for variables that have been saved but not otherwise initialized according to the cited page. Allocated arrays are not scalars and not local. The option does not exist on all compilers. The fact that it is an option should have been a loud and clear warning that this is feature to only be used in duress, such as a poorly written legacy code and even then it will not be of much help as there the problem is often the assumption that variables are saved without having been declared as such. That is why some compilers offer to initialize all local variables to zero and forcing the save atribute for all variables (see save option for Intel). One can not but help notice that the legacy problems often arise from the sort of misreading with jumping to conclusions that your comment typifies.
From: Gib Bogle on 20 Apr 2010 20:37 Richard Maine wrote: > Gib Bogle <g.bogle(a)auckland.no.spam.ac.nz> wrote: > >> Should one rely on allocated arrays being initialized to zero? > > No. Nowhere does the standard even hint at such a thing. > > Even on compilers that initialize static arrays to zero, either by > happenstance or as a "feature", your odds of it happening to act that > way for allocated arrays are probably low. The compiler would likely > have to actively insert code to zero the array because it likely is > using memory that was formerly used for something else. > > I recommend against relying on such nonstandard features at all. Code > that uses such features quite commonly needs to be fixed later for one > reason or other, and it is sometimes a lot of work to fix - hugely more > work than it would have been to just explicitly initialize things > properly in the first place. I often take such failure to explicitly > initialize as indicative of failure to think about what the program > needs, which sometimes is more than just initializing variables to zero. > > In the case of allocated arrays, odds are fairly high that it just won't > work at all. > > One thing that does happen when an array is allocated is default > initialization. But default initialization applies only to derived > types. It is specified in the type definition. > Thanks.
From: robin on 20 Apr 2010 22:18 "Colin Watters" <boss(a)qomputing.com> wrote in message news:hqkvmd$t8d$1(a)news.eternal-september.org... | | "robin" <robin51(a)dodo.com.au> wrote in message | news:4bcdd1a5$0$893$c30e37c6(a)exi-reader.telstra.net... | > "Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message | > news:hqjgq0$iad$1(a)speranza.aioe.org... | > | Should one rely on allocated arrays being initialized to zero? | > | > Nothing is ever initialized to zero automatically. | Rubbish. | | See for example the compiler option "-zero" on Intel Fortran. Is that standard Fortran?
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Matlab mexing with gfortran -- String handling. Next: XLF V13.1 release for AIX -- fully compliant Fortran 2003 standard |