Re: BOZ literal constants, a puzzle for us Standard-loving types.



Steven G. Kargl wrote:

(snip)

int(123) and real(1.23) aren't valid data-stmt-constants. Lahey's web base checker gives

It seems that initialization expressions are allowed in PARAMETERs,
and parameters in DATA statements, but initialization expressions
are not allowed in DATA statements.

program test
integer, parameter :: ip = int(-Z'00008000')
real, parameter :: rp = real(-Z'00008000')
integer i
data i/ip/
data r/rp/
print *, i, r
end

Then initializes i as appropriate for the OP on twos complement
machines. It does seem that F2003 doesn't supply a way to
initialize the bit pattern for integers in DATA statements.

The variable r is not initialized to the bit pattern of the BOZ
constant, but to its integer value.

For Fortran 2003 intrinsic REAL function:

"If A is a boz-literal-constant, the value of the result is equal to
the value that a variable of the same type and kind type parameters
as the result would have if its value was the bit pattern specified
by the boz-literal-constant. The interpretation of the value of the
bit pattern is processor dependent. "

Fortran 66 and Fortran 77 compilers with BOZ constants as an extension
would use the bit value of the constant.

-- glen

.



Relevant Pages

  • Re: 2+2=4, but only once !?
    ... It is true that initialization is not done with each call, but it does not necessarily follow that having initialization is a problem. ... In f77, it is fine to initialize variables with DATA. ... So just because the OP has DATA statements, that does not mean there is any problem at all. ... But it sounded to me as though Ancient Hacker is referring to matters related to the Fortran standard instead of to DLL-specific matters (if not, his reference to f77 threw me off - DLLs are not related to Fortran standard versions). ...
    (comp.lang.fortran)
  • Re: 2+2=4, but only once !?
    ... that way in F77. ... true that initialization is not done with each call, ... So just because the OP has DATA statements, that does not mean there is ... matters related to the Fortran standard instead of to DLL-specific ...
    (comp.lang.fortran)
  • Re: Opinions on thread-safety-ness of DATA statement initialisations in a module
    ... Paul van Delst wrote: ... the initialization is deferred to another statement: ... The thing is that DATA statements are the only way to initialize ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)
  • Re: BOZ literal constants, a puzzle for us Standard-loving types.
    ... Richard Maine told me I was splitting the standard's hairs far too fine when I suggested that this meant that an integer equal to -HUGE-1 ought to be allowable in DATA statements even though it's an overflow elsewhere. ... datatype, because a lot of this actually starts having some sort of coherency if one thinks of it as conversions between different datatypes. ... completely alien to Fortran and thus fits quite poorly into the rest of the language. ...
    (comp.lang.fortran)
  • Interface Visual Fortran and VB6
    ... I am trying to program an interface for a long Fortran ... DATA STATEMENTS ... are supposed to be passed between the VB6 and Fortran code? ...
    (comp.lang.fortran)