From owner-sc22wg5+sc22wg5-dom9=www.open-std.org@open-std.org  Thu Feb  1 20:04:48 2024
Return-Path: <owner-sc22wg5+sc22wg5-dom9=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom9
Delivered-To: sc22wg5-dom9@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id 483BF356C60; Thu,  1 Feb 2024 20:04:48 +0100 (CET)
Delivered-To: sc22wg5@open-std.org
X-Greylist: delayed 1736 seconds by postgrey-1.34 at www5.open-std.org; Thu, 01 Feb 2024 20:04:47 CET
Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21])
	by www.open-std.org (Postfix) with ESMTP id B197C356C48
	for <sc22wg5@open-std.org>; Thu,  1 Feb 2024 20:04:47 +0100 (CET)
Received: from troutmask.apl.washington.edu (localhost [127.0.0.1])
	by troutmask.apl.washington.edu (8.17.1/8.17.1) with ESMTP id 411IZjrg004493;
	Thu, 1 Feb 2024 10:35:45 -0800 (PST)
	(envelope-from kargl@uw.edu)
DKIM-Filter: OpenDKIM Filter v2.10.3 troutmask.apl.washington.edu 411IZjrg004493
Received: (from kargl@localhost)
	by troutmask.apl.washington.edu (8.17.1/8.17.1/Submit) id 411IZjGo004492;
	Thu, 1 Feb 2024 10:35:45 -0800 (PST)
	(envelope-from kargl@uw.edu)
Date: Thu, 1 Feb 2024 10:35:45 -0800
From: "Steven G. Kargl" <kargl@uw.edu>
To: General J3 interest list <j3@mailman.j3-fortran.org>
Cc: WG5 <sc22wg5@open-std.org>, Jeff Hammond <jehammond@nvidia.com>
Subject: Re: [J3] [SC22WG5.6537] question about storage sequences and default
 kind modification
Message-ID: <ZbvkgVMeQyxog-6X@troutmask.apl.washington.edu>
Reply-To: kargl@uw.edu
References: <DM6PR12MB313081F07DE72F3CFB98DADECB432@DM6PR12MB3130.namprd12.prod.outlook.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
In-Reply-To: <DM6PR12MB313081F07DE72F3CFB98DADECB432@DM6PR12MB3130.namprd12.prod.outlook.com>
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

Jeff,

Having dealt with many bugs reports about gfortran's
-fdefault-*, -freal-*, and -finteger-* options, I'll
suggest that you may not want to go down the route of
supporting users redefining storage association.=20
Consider the following with gfortran on an AMD64 system,

   program foo
   real dr              ! Default real
   double precision dd  ! Default double precision
   real(4)  sp          ! gfortran kind=3D4 (single precision )
   real(8)  dp          ! gfortran kind=3D8 (double precision)=20
   real(10) xp          ! gfortran kind=3D10 (Intel 80-bit extended DP)=20
   real(16) qp          ! gfortran kind=3D16 (quad precision)

   print '(A,*(1X,I0))', 'Default:', &
   &  storage_size(dr), storage_size(dd)
   print '(A,*(1X,I0))', '  Kinds:', &
   &  storage_size(sp), storage_size(dp), storage_size(xp), storage_size(qp)
   end program foo

% gfortran13 -o z a.f90 && ./z
Default: 32 64
  Kinds: 32 64 128 128

% gfortran13 -o z -fdefault-real-8 a.f90 && ./z
Default: 64 128
  Kinds: 32 64 128 128

Default REAL is now 8 bytes and default DOUBLE PRECISION
is 16 bytes.  The entities declared via KIND=3D are unchanged.

% gfortran13 -o z -freal-4-real-8 a.f90 && ./z
Default: 64 64
  Kinds: 64 64 128 128

All entities that map to a 4-byte real are promoted to
an 8-byte real.

--=20
steve


On Thu, Feb 01, 2024 at 04:30:27PM +0000, Jeff Hammond via J3 wrote:
> Bill has mentioned this to me before but I want to verify my understand o=
f storage sequences.
>=20
> If I have a compiler like Intel Fortran that offers many options to the s=
ize of INTEGER to 2/4/8 bytes and REAL to 4/8/16 bytes, the only conforming=
 options set INTEGER and REAL to the same size and DOUBLE PRECISION to twic=
e that, correct?
>=20
> This is not intended to pick on Intel because most implementations have t=
hese options, they just have the most as far as I can see.  My goal is to b=
ound the scope of the MPI ABI proposal by only bothering to support conform=
ing uses of these options, or these plus the most widely used non-conformin=
g use (-integer-size 8 -double-size 8).
>=20
> Thanks,
>=20
> Jeff
>=20
> 19.5.3.2 Storage sequence
>=20
> A storage sequence is a sequence of storage units. The size of a storage =
sequence is the number of storage units in the storage sequence. A storage =
unit is a character storage unit, a numeric storage unit, a file storage un=
it (12.3.5), or an unspecified storage unit. The sizes of the numeric stora=
ge unit, the character storage unit and the file storage unit are the value=
s of constants in the ISO_FORTRAN_ENV intrinsic module (16.10.2).
>=20
> In a storage association context
>=20
> (1) a nonpointer scalar object that is default integer, default real, or =
default logical occupies a single numeric storage unit,
> (2) a nonpointer scalar object that is double precision real or default c=
omplex occupies two contiguous numeric storage units,
>=20
>=20
> $ ifort -help data
>=20
> Data
> ----
>=20
> -i{2|4|8}
>           set default KIND of integer and logical variables to 2, 4, or 8
> -integer-size <size>
>           specifies the default size of integer and logical variables
>             size:  16, 32, 64
> -r{8|16}  set default size of real to 8 or 16 bytes
> -real-size <size>
>           specify the size of REAL and COMPLEX declarations, constants,
>           functions, and intrinsics
>             size: 32, 64, 128
> -autodouble
>           same as -real-size 64 or -r8
> -double-size <size>
>           defines the size of DOUBLE PRECISION and DOUBLE COMPLEX declara=
tions,
>           constants, functions, and intrinsics
>             size:  64, 128

--=20
Steve
