Fortran Maximum Number of Continuation Lines

Continuation lines in f90 (trouble?)


 Continuation lines in f90 (trouble?)

Author Message

 Continuation lines in f90 (trouble?)

Let say you want to build a module containing large constant valued arrays:
(Could be multidimensional integration quadratures or Chebyshev coefficients)

double precision, dimension(400), parameter :: x =                  &
(/ 1.834734464564556d0, -4.235642445677834d0, 3.952866543169867d0, &
6.332453511246747d0, ................ /)

This statement can NOT fit into the f90 requirements:
a) Maximum 132 characters on each line
b) Maximum 39 continuation lines

1) Why does f90 include the latter restriction ???

2) How should I circumvent this restriction in order to define the constant
valued array x(400) ???

Best Regards,

Jens B. Helmers

Tue, 06 May 1997 22:44:57 GMT

 Continuation lines in f90 (trouble?)

   Let say you want to build a module containing large constant valued arrays:
(Could be multidimensional integration quadratures or Chebyshev coefficients)

   double precision, dimension(400), parameter :: x =                  &
(/ 1.834734464564556d0, -4.235642445677834d0, 3.952866543169867d0, &
6.332453511246747d0, ................ /)

   This statement can NOT fit into the f90 requirements:
a) Maximum 132 characters on each line
b) Maximum 39 continuation lines

   2) How should I circumvent this restriction in order to define the constant
valued array x(400) ???

Hmm, maybe you could build it up using smaller named constant arrays?

Does seem kind of a drag to have to do that, though.  Too bad
more "sophisticated" things like DATA cannot be used to specify
values for named constants (parameters).
--

Fri, 09 May 1997 13:39:52 GMT

 Continuation lines in f90 (trouble?)

Quote:

> This statement can NOT fit into the f90 requirements:
>     a) Maximum 132 characters on each line
>     b) Maximum 39 continuation lines

> 1) Why does f90 include the latter restriction ???

> 2) How should I circumvent this restriction in order to define the constant
>    valued array x(400) ???

These maximum restrictions on programs correspond to minimum
requirements on processors, and thus enhance the portability of
programs that adhere to them.
Processors are always permitted to extend the standard, and many
probably do so with these restrictions in particular.

To circumvent this limit, you could, as suggested by Craig Burley,
build them up from smaller named constant arrays.  For example,

      DOUBLE PRECISION, PARAMETER, DIMENSION(25) :: X_01 = &
& (/ ...
DOUBLE PRECISION, PARAMETER, DIMENSION(25) :: X_02 = &
& (/ ...
.
.
.
DOUBLE PRECISION, PARAMETER, DIMENSION(25) :: X_16 = &
& (/ ...

      DOUBLE PRECISION, PARAMETER, DIMENSION(400) :: X =   &
& (/ X_01, X_02,... X_16 /)

--

necessarily
Stanford Linear Accelerator Center, MS 97 | reflect those of SLAC,
P.O. Box 4349; Stanford, CA  94309        | Stanford or the DOE

Sat, 10 May 1997 02:14:57 GMT

 Continuation lines in f90 (trouble?)

Quote:

>   Let say you want to build a module containing large constant valued arrays:
>   (Could be multidimensional integration quadratures or Chebyshev coefficients)
>   double precision, dimension(400), parameter :: x =                  &
>    (/ 1.834734464564556d0, -4.235642445677834d0, 3.952866543169867d0, &
>       6.332453511246747d0, ................ /)
>   This statement can NOT fit into the f90 requirements:
>       a) Maximum 132 characters on each line
>       b) Maximum 39 continuation lines
>   2) How should I circumvent this restriction in order to define the constant
>      valued array x(400) ???
>Hmm, maybe you could build it up using smaller named constant arrays?
>Does seem kind of a drag to have to do that, though.  Too bad
>more "sophisticated" things like DATA cannot be used to specify
>values for named constants (parameters).
>--

Of course your compiler may allow you to override the line continuation
limit as well. Alternatively use an implied do:

C234567
INTEGER   TI(10)
C
DATA      (TI(I),I=1,5)
&              /       1,
&                      2,
&                      3,
&                      4,
&                      5       /
C
DATA      (TI(I),I=6,10)
&              /       6,
&                      7,
&                      8,
&                      9,
&                      10      /

The price you may be reduced portability but on the other hand, at
least in fortran 77 I've not had problems on a number ( admittedly
not large ) of platforms using a number of compilers.

IBM
--
################ No Times Like The Maritimes, Eh! ######################

########## Opinions expressed here are mine, mine, mine. ###############

Sun, 11 May 1997 00:02:55 GMT

 Continuation lines in f90 (trouble?)

Quote:

> Of course your compiler may allow you to override the line continuation
> limit as well. Alternatively use an implied do:

The original poster was asking, I believe, about large _constant_
arrays, i.e., with the PARAMETER attribute in Fortran 90.  Such
arrays cannot be initialized via the DATA statement and thus cannot
make use of an implied-do on their indexes (though if the
initialization values are regularly spaced, an implied-do in the
array constructor may help).

--

necessarily
Stanford Linear Accelerator Center, MS 97 | reflect those of SLAC,
P.O. Box 4349; Stanford, CA  94309        | Stanford or the DOE

Sun, 11 May 1997 05:41:18 GMT

 Continuation lines in f90 (trouble?)

Quote:

>   Let say you want to build a module containing large constant valued arrays:
>   (Could be multidimensional integration quadratures or Chebyshev coefficients)

>   double precision, dimension(400), parameter :: x =                  &
>    (/ 1.834734464564556d0, -4.235642445677834d0, 3.952866543169867d0, &
>       6.332453511246747d0, ................ /)

>   This statement can NOT fit into the f90 requirements:
>       a) Maximum 132 characters on each line
>       b) Maximum 39 continuation lines

>   2) How should I circumvent this restriction in order to define the constant
>      valued array x(400) ???

Since you should not care much about readability, just use

double precision, parameter :: x00 =  1.834734464564556d0
double precision, parameter :: x01 = -4.235642445677834d0
double precision, parameter :: x02 =  3.952866543169867d0
double precision, parameter :: x03 =  6.332453511246747d0
! ...
double precision, parameter :: xzz =  ! whatever
!
double precision, dimension(400), parameter :: x =  &
(/x00,x01,x02,..........,xzy,xzz/)

With 3 character names like this, you can handle up to about dimension 1250.

If it is not sufficient, define for instance x1to1250 (1250), x1251to2500 (1250)
and
double precision, dimension(2500), parameter :: x =  &
(/ (x1to1250 (i), i=1,1250), (x1250to2500 (i), i=1,1250) /)

Michel

---

| IFREMER: Institut Francais de Recherches pour l'Exploitation de la Mer|

Sun, 11 May 1997 17:05:50 GMT

 Continuation lines in f90 (trouble?)

Quote:

>    Let say you want to build a module containing large constant valued arrays:
>    (Could be multidimensional integration quadratures or Chebyshev coefficients)

>    double precision, dimension(400), parameter :: x =                  &
>     (/ 1.834734464564556d0, -4.235642445677834d0, 3.952866543169867d0, &
>        6.332453511246747d0, ................ /)

>    This statement can NOT fit into the f90 requirements:
>        a) Maximum 132 characters on each line
>        b) Maximum 39 continuation lines

>    2) How should I circumvent this restriction in order to define the constant
>       valued array x(400) ???

The same problem comes up if you try to initialize a non-parameter array as part of the initial
specification statement.  In the latter case a sequence of DATA statements provides a way out. I
would question the purpose of making such a large object a parameter in the first place. It is true
that parameter status would prevent its reassignment in the program. But beyond that there is
probably little practical difference between the parameter object above and a simple array which is
initialized with data statements.  It is quite unlikely that the compiler would actually completely
unroll loops involving x and directly insert the constants one-by-one.

Cheers,
Bill Long
Department of Physics
University of Wisconsin-Madison

Thu, 15 May 1997 11:27:36 GMT

Powered by phpBB® Forum Software

cheekeforl1975.blogspot.com

Source: http://computer-programming-forum.com/49-fortran/a79ab45ec5afd1a3.htm

0 Response to "Fortran Maximum Number of Continuation Lines"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel