Data to Parameter

Description:  When a variable declared in a DATA statement is intended to be a constant, Data to Parameter can be used to change it to a variable with the PARAMETER attribute. Using the PARAMETER attribute makes it more clear which variables are constants and which ones are not; it can also result in performance gains, since it may allow an optimizing compiler to replace some variable accesses with the constant value.

State: Implemeted         Author: Gustavo Rissetti, Timofey Yuvashev,  Jeff Overbey      Version:   Photran 5.0

Code Example:

    program main

    implicit none
    real :: x, y, z
    integer :: a, b, c !A comment
    !Another comment on a new line
    data x,y,z/1.,2.,3./ !Those values are assigned
    !About to assign more values
    data a/10/,b/15/,c/20/ !More values are assigned
    !About to change some assigned values
    x = 5.4
    b = 6

end program

    program main

    implicit none
    real :: x, y, z
    integer :: a, b, c !A comment
    !Another comment on a new line
    data x/1./ !Those values are assigned
    parameter ( z = 3. ) !Those values are assigned
    parameter ( y = 2. ) !Those values are assigned
        !About to assign more values
    data b/15/ !More values are assigned
    parameter ( c = 20 ) !More values are assigned
    parameter ( a = 10 ) !More values are assigned
    !About to change some assigned values
    x = 5.4
    b = 6

end program

ScreenShots

       

HTML Comment Box is loading comments...