Catherine Moroney writes:
> I recently saw this bit of code in a colleague's program and even though
> it's obviously a typo, I'm wondering how it even compiled in the first place
> and exactly what the compiler interpreted it as.
>
> I'm using SGI's F90 compilers, v7.2 and v7.3.
>
> real, dimension(size(ug_temp,1),size(ug_temp,2),size(ug_temp,3)) :: Z
> real, dimension(size(ug_temp,1),size(ug_temp,2),size(ug_temp+1,3)) :: radius
> ^^^^^^
Making plausible assumptions about the declarations not shown, the
code should compile ok. Although you underline a part, you don't say
exactly what is wring with it, but I'm guessing that it's the +1.
Presumably ug_temp is a numeric array of rank at least 3. In that
case, ug_temp+1 is an array of the same shape as ug_temp, with 1 added
to each element. F90 allows such array operations. It seems a bit
silly to take the size of ug_temp+1, as it would be the same as the
size of ug_temp, but the standard has no prohibition against doing
silly things. So this compiles fine. Isn't even in the category of
things I'd expect a warning about. There are some typos that a
compiler isn't going to catch.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|