From: Richard E Maine on
dpb <dpbozarth(a)swko.net> wrote:

> Elijah Cardon wrote:
> > "FX" <coudert(a)alussinan.org> wrote in message
> ...
> > > program main
> > > real ::array_name(12,4) = reshape((/ (real(i), i = 1, 48) /), &
> > > (/ 12, 4 /))

> Interesting, what compiler? The problem is that the compiler didn't
> recognize the use of real() in the argument to reshape() as an array,
> but as the intrinsic function REAL() which isn't allowable in the
> context as the error indicated.

Huh? What alleged array named REAL is this suppose to be? I see no such
thing anywhere. While it is allowed to have an array named REAL, I see
no such thing in this code. It looks to me like the compiler is
completely correct in identifying this as the intrinsic function REAL.

The compiler is also correct in identifying this use as prohibitted by
f95, although it is allowed in f2003 and would not be surprising as an
extension in f95 compilers.

> The workaround would be to use some other name for the temporary array
> in the reshape() argument as in
>
> real ::array_name(12,4) = reshape((/ (r(i), i = 1, 48) /), &
> (/ 12, 4 /))
>
> where I used "r" instead of "real".

And where is this alleged array r declared? One doesn't declare an array
just by using it. This has nothing to do with implicit none. You can
implicitly declare types, but there is no implicit declaration of
arrayness.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
From: Steven G. Kargl on
In article <1160590477.989518.251380(a)h48g2000cwc.googlegroups.com>,
"dpb" <dpbozarth(a)swko.net> writes:
>
> Elijah Cardon wrote:
>> "FX" <coudert(a)alussinan.org> wrote in message
> ...
>> > program main
>> > real ::array_name(12,4) = reshape((/ (real(i), i = 1, 48) /), &
>> > (/ 12, 4 /))
> ...
>
>> The snippet doesn't compile for me:
>> Compiling file: array1.f95
>> C:\Documents and Settings\All Users\Documents\fortran_stuff\array1.F95(3) :
>> error 921 - The REAL intrinsic function is not permitted in an
>> initialisation expression
>> Ideas? EC
>
> Interesting, what compiler? The problem is that the compiler didn't
> recognize the use of real() in the argument to reshape() as an array,
> but as the intrinsic function REAL() which isn't allowable in the
> context as the error indicated.

FX is using gfortran. REAL() is permitted in an initialization
expression in Fortran 2003. See Section 7.1.7, item (4). By
default gfortran enforces the F2003 rule.

In Fortran 95, you are correct that REAL() isn't allowed.

troutmask:sgk[204] gfortran -o z -std=f95 -pedantic f.f90
In file f.f90:2

real :: a(3) = (/ (real(i), i = 1, 3) /)
1
Error: Extension: Evaluation of nonstandard initialization expression at (1)

troutmask:sgk[205] cat f.f90
program f
real :: a(3) = (/ (real(i), i = 1, 3) /)
print *, a
end program f

--
Steve
http://troutmask.apl.washington.edu/~kargl/
From: dpb on

Richard E Maine wrote:
> dpb <dpbozarth(a)swko.net> wrote:
>
...

> Huh? What alleged array named REAL ...

Mea culpa, _I_ misread the code...

Guess I ought to retire permanently... :(

From: Richard E Maine on
dpb <dpbozarth(a)swko.net> wrote:

> Guess I ought to retire permanently... :(

Join the club. (I embarasssed myself by an egregious misstatement in a
post about a week ago. Yes, I posted a correction, but it was still
embarassing.) :-(

And I become eligible in about a week and a half. :-)

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
From: Elijah Cardon on

"Richard E Maine" <nospam(a)see.signature> wrote in message
news:1hn1p8r.1s0le4u9vmrf4N%nospam(a)see.signature...
> dpb <dpbozarth(a)swko.net> wrote:
>
>> Guess I ought to retire permanently... :(
>
> Join the club. (I embarasssed myself by an egregious misstatement in a
> post about a week ago. Yes, I posted a correction, but it was still
> embarassing.) :-(
>
> And I become eligible in about a week and a half. :-)
Mistakes by veteran fortran programmers just make the rest of us feel
better. I use silverfrost's ide that they give away, but I was pretty sure
that it wasn't a problem limited to me because I took it to the Lahey source
checker and got:


Source file : SOURCE.F90

Main program "main"
(line-no.)(nest)
1 program main
2 real ::array_name(12,4) = reshape((/ (real(i), i = 1,
48) /), &
3 (/ 12, 4 /))
4 print *, array_name
5 call xx(array_name)
6 end

Diagnostic messages: program name(main)
0531-S: "SOURCE.F90", line 2: Invalid initialization expression.
1143-S: "SOURCE.F90", line 2, column 31: Missing constant expression.

Procedure information
Lines : 6
Statements : 5

Scoping unit of program : main
Attribute and Cross reference of name
array_name
|(Class and Type) : variable name, REAL(4)
|(Attributes) : DIMENSION
|(Declaration) : 2
|(Definition) : 5
|(Reference) : 4
main
|(Class and Type) : program name
|(Attributes) :
|(Declaration) : 1
|(Definition) :
|(Reference) :
xx
|(Class and Type) : external subroutine name
|(Attributes) :
|(Declaration) :
|(Definition) :
|(Reference) : 5

External subroutine subprogram "xx"
(line-no.)(nest)
7
8 subroutine xx(arrayname)
9 real::arrayname(12,4)
10 print *, arrayname
11 endsubroutine

Procedure information
Lines : 5
Statements : 4

Scoping unit of external sub-program : xx
Attribute and Cross reference of name
arrayname
|(Class and Type) : variable name, REAL(4)
|(Attributes) : DIMENSION, dummy-argument
|(Declaration) : 8 9
|(Definition) :
|(Reference) : 10
xx
|(Class and Type) : external subroutine name
|(Attributes) :
|(Declaration) :
|(Definition) : 8
|(Reference) :

Total information
Procedures : 2
Total lines : 11
Total statements : 9

What a nice resource that is. EC