----------------------------------------------------------------------------------
@MSGID: TPw2.99944@fx17.iad>
72339a46
@REPLY:
<3883c7bc-48d1-4910-bd1a-c55cb92c92bdn@googlegroups.com> edabbf55
@REPLYADDR Ron Shepard <nospam@nowhere.org>
@REPLYTO 2:5075/128 Ron Shepard
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:
<873f9cc4-6139-4bd3-9ed8-de7e37a76730n@googlegroups.com> <d24b9f27-36da-4011-963d-eba713b1f16an@googlegroups.com>
<3cb57395-be28-4451-9e98-c20ed41386fbn@googlegroups.com> <3883c7bc-48d1-4910-bd1a-c55cb92c92bdn@googlegroups.com>
@RFC-Message-ID:
TPw2.99944@fx17.iad>
@TZUTC: -0500
@PID: Mozilla/5.0 (Macintosh; Intel Mac OS X
10.13; rv:102.0) Gecko/20100101 Thunderbird/102.14.0
@TID: FIDOGATE-5.12-ge4e8b94
On 8/28/23 8:19 AM, gah4 wrote:
> The second version of the Fortran standard in 1977 didn`t change much of
> the way floating point was done, but did introduce a CHARACTER data type
> for the first time.
This is true regarding the floating point formats themselves, but an
important feature of f77 was the idea of generic functions. Before f77,
for example, the programmer was required to use SIN(X) for REAL argument
X and DSIN(X) for double precision argument X. The same was true for all
of the intrinsic functions ABS/DABS, SQRT/DSQRT, and so on.
At that time, a REAL variable was likely to be any of 24-bits, 32-bits,
36-bits, 48-bits, 60-bits, or 64-bits on a given compiler, so that made
writing portable programs, where the source code could be used
unchanged, difficult. If your application required, say 8 decimal digits
of precision, then on some machines you needed to use double precision
while on other machines real was sufficient. The generic functions
introduced with f77 helped with that portability issue.
However, f77 did not define a generic way to specify literal constants.
A constant written without an exponent or with an E exponent was REAL
(e.g. 3.14 or 3.14E0), while a constant written with a D exponent was
double precision (e.g. 3.14D0).
You will see many workarounds for these limitations in legacy code. One
of the common ones, which I used when applicable, was to define
parameter constants of the appropriate type, but to specify their values
with double precision literal constants.
parameter (PI = 3.1415926535897932384626433832795028841971D0)
No matter how PI is defined, REAL or DOUBLE PRECISION, it always has the
correct value. Another common practice in legacy codes was to avoid the
REAL and DOUBLE PRECISION declarations and to use the nonstandard REAL*8
declaration instead.
REAL*8 PI
Compilers would then typically map this to either REAL or DOUBLE
PRECISION as appropriate, meaning 48-bit, 60-bit, 64-bit, or 72-bit
floating point. With these two conventions, the programmer could write
portable code that would compile unchanged and run correctly on a wide
variety of hardware and software combinations.
> With the Fortran 90 and 95 standards, it was desired to keep as much as
> possible compatible with the previous versions, so old programs would still
> work the same way they always did.
F90 kept all of these old conventions, but it introduced the new KIND
system. This is one of the nicest features of modern fortran. It allows
portable code to be written in a standard way, and it is open ended to
allow new floating point KIND values to be incorporated in the future.
For example, there are compilers that support 16-bit floating point,
80-bit floating point, and 128-bit floating point, in addition to the
traditional 32-bit REAL and 64-bit DOUBLE PRECISION KINDs. The fortran
KIND system also allows decimal floating point KINDs to be supported,
although none of the compilers I use right now are doing this.
F77 allowed intrinsic procedures to be generic, but it did not allow
programmers to write generic procedures. F90 also allowed this. This is
a nice feature when writing library code and when an application
required mixed-precision and multiple-precision floating point computations.
$.02 -Ron Shepard
--- Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:102.0)
Gecko/20100101 Thunderbird/102.14.0
* Origin: Forte - www.forteinc.com (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441