(j3.2006) [Fwd: Fortran 2008 query]

Bill Long longb
Thu Oct 26 14:44:18 EDT 2017


I see two possible solutions for this problem (besides writing the program differently):

1) The option ?length ridiculously large? is too vague.  We could say that it is a processor-dependent value greater or equal to 1023.   That would probably be enough for this program, but making something processor dependent hurts portability and whatever value you  pick for the lower bound  will be seen as too low by someone.

2) Allow array sections in PARAMETER statements, similar to how we allow parts of an array in DATA.  For example, 

program init
  integer,parameter :: n = 9

  real :: a(n)
  parameter (a(1:3) = [1.23, 2.34, 3.45])
  parameter (a(4:6) = [4.56, 5.67, 6.78])
  parameter (a(7:9) = [7.89. 8.90. 9.01])

  print *, a
end program init

This is currently not allowed, but the standard could be changed to allow it. We would want reasonable restrictions, such as requiring that all of the elements of the array be defined by PARAMETER statements. 

Option 2 seems more resilient to future breakage, and is minimally invasive since PARAMETER statements are pretty rarely used.  Besides, this is only an extension - previously conforming programs would continue to be conforming. 

Cheers,
Bill

> On Oct 26, 2017, at 1:12 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:
> 
> I'm not the only one with this problem.
> 
> Can we make statement length ridiculously large in the next revision?
> 
>        I have a Fortran 2008 query I hope that you may help me with. I want to 
>        have some very long (several thousand element) arrays containing data 
>        values that are constants (these values are actually accurate values 
>        that I am using to check the output from various algorithms against). 
>        The 'obvious' way of doing this is to declare a large parameter array. e.g.,
> 
>             nmax = 4000
>             real (kind = kind(0.0d0)), parameter :: accres(nmax) = [ &
>                <lots of values> &
>             ]
> 
>        To make this standard conforming the number of continuation lines is 
>        restricted by the 2008 standard to 255 each with 132 characters. The 
>        data has been calculated to 30 dp and I don't want to lose this accuracy.
> 
>        Is there any way, within the standard, that I can split the above into 
>        several separate statements without using different array names?
> 
>        Pre-parameter statements I would have used a sequence of data statements 
>        and set up values to successive blocks of the array. But PARAMETER is 
>        better in that it is making the 'constant' nature of the array clear 
>        which is not the case with DATA.
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
Bioinformatics Software Development                      fax:  651-605-9143
Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425





More information about the J3 mailing list