Asking for help with an old data statement

Asking for help with an old data statement

Hello,

i have two data statements out of old Fortran (Fortran 77?) programs. I would like to transfer those programs toward newer standards.

      IMPLICIT DOUBLE PRECISION (A-H, O-Z)
      DATA P0,P1,P2,P3,P4,P5,P6/
     *  0.22020 68679 12376 1D3,    0.22121 35961 69931 1D3,
     *  0.11207 92914 97870 9D3,    0.33912 86607 83830 0D2,
     *  0.63739 62203 53165 0D1,    0.70038 30644 43688 1D0,
     *  0.35262 49659 98910 9D-1/

IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DATA RTHALF/0.70710 67811 86547 524D0/

How do those data statements look in up to date fortran programms?

Thanks in advance
Frank

11 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

One way is below, beware of the SAVE status of the values , I would see what other answers you get, there are many ways...

DOUBLE PRECISION :: P0=0.2202068679123761D3
DOUBLE PRECISION :: P1=0.2212135961699311D3

Hello app4619,

if i read your reply correctly it says that i have to remove all spaces between the numbers to build one coherent value.

Does this mean that old fortran versions have allowed to write a value in the way:
0.22020 68679 12376 1 
meaning:
0.2202068679123761

Frank

I do not know if that is conforming to some old standard but the (ifort) compiler ignores the spaces, the comma is the deliminator...

I guess the space makes manual checking of the numbers easier

Zitat:

tropfen schrieb:

if i read your reply correctly it says that i have to remove all spaces between the numbers to build one coherent value.

Does this mean that old fortran versions have allowed to write a value in the way:
0.22020 68679 12376 1 
meaning:
0.2202068679123761

Frank

The spaces are ignored in standard F77 fixed form source code.  If you want it to work the same in free form, the embedded spaces must be removed.

In fixed format Fortran sources, blanks are insignificant. As generations of Fortran beginners have learned to savor, this property and the juxtaposition of the period and comma characters on the QWERTY keyboards and cardpunches made DO loops such as

      DO 100 I = 123, 456
...
  100 CONTINUE

behave mysteriously when mistyped as 

      DO 100 I = 123. 456
...
  100 CONTINUE

Zitat:

app4619 schrieb:
One way is below, beware of the SAVE status...
The presense of a variable in a DATA statement also implies the SAVE attribute for that variable. Unlike the corresponding initializations in C, the presence of an initialization expression in a Fortran 90+ variable declaration in a subprogram does not imply that the initialization takes place each time the subprogram is executed.

If you really wanted to be "up to date", you'd replace DOUBLE PRECISION by REAL(DP) where you define DP as an integer PARAMETER constant with a value of SELECTED_REAL_KIND(15). But in general I am not in favor of rewriting working code just for the sake of making it look more modern.

Steve - Intel Developer Support

@ Steve

the source code contains 22 subroutines/functions in fixed format. All i have to do is removing the fixed format and bringing it into a f95-module (this change is essenziell). Due to the fact that i have 16 significant digits(0.22020 68679 12376 1D3)  in the data statement i have used real(16) :: P0, ...

Frank

Careful,

use  REAL(SELECTED_REAL_KIND(15)) :: P0, ...

Which on Intel systems is equivilent to REAL(8), meaning 8 bytes, which can hold approximately 15 and a half digits of precision.
Using REAL(16) forces use of software library to compute using 16-byte quad precision (very slowly). REAL(16) carries about 71 digits of precision.

Jim Dempsey

www.quickthreadprogramming.com

What Jim said....

Steve - Intel Developer Support

@ Jim and Steve
Thanks for this information and warning.

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!