Re: Unexpected assignment statement in module?



Erik Toussaint <user@xxxxxxxxxxxxxxxxxxx> wrote:
On 30-4-2011 20:22, glen herrmannsfeldt wrote:
It was recently explained in this group that a Fortran 2008 feature
allows one to dimension a rank one array from the initialization:

real(p) :: c(*) = [1.2, 3.4, 5.6, 7.8]

It would seem that if reshape was needed, this couldn't work in 2D.

If I read the standard correct, you can use this syntax for any desired
rank:

real(p) :: ck_a(*,*) = reshape( [ ... ], [ 6, 6 ] )

Well, you still have to put in both dimensions, though into the
reshape instead. In C, this sometimes comes from initializations
that are conditional on preprocessor symbols, such that the actual
number is determined at compile time. (There is an additional C
rule that allows for a trailing comma.)

The unix I/O system is based on an array of structures, each
representing a different type of device. Sysgen compiles a routine
containing this array, one reason unix used to require a C compiler.

-- glen

.



Relevant Pages

  • Re: Using MINLOC(array)
    ... (which happens to be the only one for rank 1). ... I just spent an hour of reading up while thinking that 'dim' and 'dimension' were the same thing. ... The problem with all of the reduction functions is that ... elements of the 2 dimensional array. ...
    (comp.lang.fortran)
  • Re: Scalar integer constant expression
    ... for a long time* in Fortran is the ability to dimension an array ... based on its initialization. ... which dimensions the array 3, ...
    (comp.lang.fortran)
  • Re: How to declare an array that contains only strings
    ... > i want to declare an array of dimension.It is a column with the ... dimension 5, rather than 5x1. ... Arrays can be of any rank up to ...
    (comp.lang.fortran)
  • Re: APL question
    ... Your A is an array of rank 3; ... You can get the last dimension of an array of any rank (except 0, ... dimension you mean 'plane', and your question is 'how to get the last ...
    (comp.lang.apl)
  • Re: Unexpected assignment statement in module?
    ... allows one to dimension a rank one array from the initialization: ... It would seem that if reshape was needed, ... If I read the standard correct, you can use this syntax for any desired rank: ...
    (comp.lang.fortran)