From: Richard Maine on 11 Aug 2010 04:58 Daniel Kraft <d(a)domob.eu> wrote: > I'm wondering whether the following declaration is valid Fortran 2008 > (and if so, what its semantics are): > > INTEGER, PARAMETER :: arr(*) = 0 > > I.e., whether a scalar is allowed as initializer for implied-shape > arrays. The only valid meaning I can think of is that the extend of arr > will be 1 (along each dimension if it was multidimensional). But I > can't find anything supporting this in the draft standard, nor can I > find anything explicitely forbidding this initialization. Oddly, I can't find anything explicitly forbidding this. I'd think there would be. Admitedly, I'm not intimately enough familliar with the f2008 standard to be able to be sure that my quick skim didn't miss someplace. But it implicitly forbidden because the standard (well, the FDIS, which is a close as I have) says "The extent of each dimension of an implied-shape array is the same as the extent of the corresponding dimension of the constant-expr." The constant expr 0 has rank 0 and thus does not have corresponding dimensions for an array. No, a scalar does not count as an array with extents of 1. It is not an array at all. The standard is quite explicit about distinguishing between scalars and arrays. In contexts where a scalar can be broadcast into an array, such as the assignment array_variable = scalar the standard carefully describes what this statement means, and the description does not involve pretending that the scalar is an array in any sense. -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain
|
Pages: 1 Prev: Fortran Forum - August 2010 Next: Intel Fortran 2003 Status |