allow size of parameter array to be inferred? 
Author Message
 allow size of parameter array to be inferred?

I wish fortran allowed the compiler to infer the size of a parameter
array from the right-hand-side of the assignment, so that (for example)

integer, parameter :: ivec(:) = (/1,4,9/)

would be equivalent to

integer, parameter :: ivec(3) = (/1,4,9/)

This would be similar to the currently allowed usage

character (len=*), parameter :: word = "dog"

although I understand the difference -- word is a scalar. Has the
Fortran standards committee considered this idea?



Mon, 07 Jul 2008 05:09:23 GMT  
 allow size of parameter array to be inferred?

Quote:

> I wish Fortran allowed the compiler to infer the size of a parameter
> array from the right-hand-side of the assignment, so that (for example)

> integer, parameter :: ivec(:) = (/1,4,9/)

> would be equivalent to

> integer, parameter :: ivec(3) = (/1,4,9/)

> This would be similar to the currently allowed usage

> character (len=*), parameter :: word = "dog"

> although I understand the difference -- word is a scalar. Has the
> Fortran standards committee considered this idea?

Yes, it's on the list of things to go into F2008.  In fact,
it has passed on from specs to actual edits to the standard.
BUT, nothing is final until it's final.  This is a pretty
small thing, but there's always a chance that things will
come or go ar get changed before the final version.  The
paper that describes it is 05-194r1 if you want to see it.
(Actually, that's also the number even if you don't want
to see it. ;) )

The form is a little different from your example.  It allows
any number of dimensions, and the upper bound for each must
be an asterisk.  So you'd do
integer, parameter :: ivec(*) = (/1,4,9/)
or perhaps
integer, parameter :: ivec(-137:*) = (/1,4,9/)

Dick Hendrickson



Mon, 07 Jul 2008 05:36:18 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Size of array parameter in f2008

2. parameter syntax for array parameter

3. Run Time Error - Parameter not in allowed range

4. PARAMETER doesn't allow MAX in g77

5. Size(ASSUMED Size ARRAY)

6. flush file?/buffer size is not allowed

7. Fatal error: Allowed memory size of 8388608

8. Allowed memory size of 16777216 bytes exhausted

9. Setting allowed size of text object on canvas in Tkinter

10. Array Selection Start / Array Selection Size

11. Numerical Python array math with different sized arrays

12. Variable Size arrays Was: Indeterminate arrays??

 

 
Powered by phpBB® Forum Software