This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] [Ping] Comments on gfortran manual


Daniel Kraft wrote:
> Comments welcome...  Hope we can apply some of them :)

Thanks for your patch. No review yet, but two comments:


 @opindex @code{fdefault-double-8}
 Set the @code{DOUBLE PRECISION} type to an 8 byte wide type.
+@c XXX: Isn't this "always" the case?  Does this affect KIND(1.d0)?


Well, on x86/x86-64  kind(1.0d0)  is always 8, independent of
-f(no-)default-real-8 - that is in line with NAG f95, ifort and g95
using "-r8". However, gfortran sets the default real to 16 on platforms
supporting it. (I think the standard somewhere implies that double
precision has a higher/double the precision than default real.)

Using the -fdefault-double-8 option, one can force the double precision
to 8 bytes even on 16bit-supporting platforms.

Maybe one should add a note to both -fdefault-double-8 and -fdefault-real-8.

(For source diggers: See gfc_default_double_kind in trans-types.c)


@@ -986,8 +985,14 @@ equivalent to the standard-conforming de
       TYPESPEC(k) x,y,z
 @end smallexample
 @noindent
-where @code{k} is equal to @code{size} for most types, but is equal to
-@code{size/2} for the @code{COMPLEX} type.
+where @code{k} is the kind parameter suitable for the intended precision.  As
+kind parameters are implementation-dependent, use the @code{KIND},
+@code{SELECTED_INT_KIND} and @code{SELECTED_REAL_KIND} intrinsics to retrieve
+the correct value, for instance @code{REAL*8 x} can be replaced by:
+@smallexample
+INTEGER, PARAMETER :: dbl = KIND(1.0d0)
+REAL(KIND=dbl) :: x
+@end smallexample


While recommending the Fortran 90+ syntax, shouldn't we also mention
somewhere that "gfortran supports the following kind values:

INTEGER   1, 2, 4, 8*, 16*, default: 4 (1)
LOGICAL   1, 2, 4, 8*, 16*, default: 4 (1)
REAL      4, 8, 10**, 16**, default: 4 (2)
COMPLEX   4, 8, 10**, 16**, default: 4 (2)
CHARACTER 1, 4, default: 1
* = not available on all systems
** = not available on all systems; additionally 10 and 16 are never
available at the same time
(1) Unless -fdefault-integer-8 is used
(2) Unless -fdefault-real-8 is used

The kind value matches the storage size in bytes. It is recommended to
use the SELECT_*_KIND functions, but as backward compatibility the
Fortran standard allows to use the type name followed by an asterisk and
then by the kind value, e.g. @code{REAL*8}, with the exception that the
number has to be doubled for COMPLEX, e.g. @code{COMPLEX*8} is the same
as @complex{COMPLEX(kind=4)} (default kind complex)."


Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]