JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2003

COMP-FORTRAN-90 2003

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Fortran 95 on Opteron

From:

Jim Riley <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Wed, 17 Dec 2003 02:45:16 -0600

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (170 lines)

On Tue, 16 Dec 2003 10:10:16 -0800, Richard Maine <[log in to unmask]>
wrote:

>Jim Riley wrote:
> > Would set X(51) to 123., but its effect on I(51) would be undefined.
>
>and Bill Long replied:
> > Actually, the *effect* on I(51) is well defined by the standard. I(51)
> > becomes undefined.
>
>Of course, to fully appreciate Bill's (accurate) comment, you need
>to understand how the standard defines "undefined". I'm tempted
>to add a smiley...except that the question is real and nontrivial.

If an undefined variable is used where a defined variable is required,
isn't the program non-conforming? And if a program is non-conforming does
the standard define what will happen?

What I was really saying that setting the value of a datum of one type,
would have no defined (by the standard) effect on a datum of another type
that it shares a numeric storage unit with. That is, if an Integer I and
Real X were equivalenced, then setting the value X would leave no bit
residue for I.

Couldn't I realize my Fortran storage as text representing Fortran
constants (the syntax of constants denotes their type). So in the
following code:

    REAL X
    INTEGER I
    EQUIVALENCE (X,I)

Would initially set the value of I and X to ' ' (i.e. undefined).

    I = 2

This would set the value of I and X to '2' (which is not a valid value for
X).

    X = I + 2

This would set the value of I and X to '4.0E0' which is not a valid value
for I. If the code then had a:

    WRITE (UNIT=*, FMT=*, IOSTAT=ISTAT) I

My processor could set ISTAT to a positive non-zero value.

A program could not rely on this behavior, but it would be a reasonable way
for that processor to handle that non-conforming program.


Alternatively, I could realize a numeric storage unit as a sequence of bit
fields:

   1-1: Logical
   2-33: Integer
   34-65: Real
   66-145: Double Precision

Double Precision values would be stored in the 80 bits of a storage unit,
and 0 bits of the next storage unit. A storage sequence could hold both an
odd and even array of Double Precision values.

So if I had:

    REAL X
    INTEGER I
    EQUIVALENCE (X,I)

    I = 2

This would set the integer field of the storage unit to 2 .

    X = I + 2

This would set the real field of the storage unit to 4.0E0 .

    WRITE (UNIT=*, FMT=*, IOSTAT=ISTAT) I

This particular processor might print

    2

Even though I is undefined at that point in the program.


The next step would be to convert a storage sequence from a sequence of
4-field elements to 5 sequences of single-field elements of different
lengths (there would be two sequences of double precision values of 1/2 the
length). I could eliminate the parts of the sequences that aren't declared
in the program (IIUC, the only way to have mixed type storage sequences is
through Common association and Equivalence association which are all
resolvable when the program is compiled).

    REAL X(3)
    INTEGER I(5)
    EQUIVALENCE (X,I)

Would create a storage sequence of 5 145-bit storage units, which would be
converted to a 5 element 1-bit Logical array, a 5-element 32-bit Integer
array, a 5-element 32-bit Real Array, a 2-element 80-bit Double Precision
array (corressponding to I(1:2) and I(3:4)), and a 2-element 80-bit Double
Precision array (corresponding to I(2:3) and I(4:5)). I could discard the
Double Precision and Logical arrays, and the last 2 elements of the Real
array.

The tricky part would be if I had something like:

    INTEGER I(3)
    REAL X,Y
    EQUIVALENCE (I(1), X)
    EQUIVALENCE (I(3), Y)

If these were local declarations, I could separate the storage of X and Y
only storing 2 reals, rather than 3 reals. But if there was also a common
declaration:

    COMMON /COM/ I

I would have to worry about something like this in another program unit.

    INTEGER I(3)
    REAL Z(3)
    EQUIVALENCE (I, Z)
    COMMON /COM/ I

>To other matters..note that the cases mentioned are very simple ones
>because of their homogeneity. You don't have to get very complicated
>at all before valid implementation strategies get severely
>constrained. The non-obvious ones start needing to get very messy.
>Consider (assume implicit typing)
>
> subroutine sub1
> common /com/ x(3),i,y,j
> save /com/
> y = 123.4
> j = 567
> ...
> end
>
> subroutine sub2
> common /com/ i(3),x,y,j
> save /com/
> ...
> end
>
>The assignments to y and j in sub1 will cause y and j in
>sub2 to be defined (and being defined is a much less tricky
>concept in the standard than being undefined is).

The linker could generate code that could get the actual address of the
variables. Even in a conventional implementation, it would have
to get the base address of the common for use with fixed offsets generated
by the compiler. A whole set of addresses for each variable used in
program unit shouldn't be that much more difficult.

>It is certainly posible in theory for a compiler to implement this
>with separate storage areas for reals and integers. Whether it is
>practical is a different matter - I'd guess not.

The toughest practical aspect might be handling the expectations of
programmers that non-conforming use of equivalence and commons would work
in a certain way (e.g to reduce the use of memory, to implement structures,
to map to certain external data layouts, to allow precice definition of
floating point values).

--
Jim Riley

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager