Setting default precision of real-valued constants to real*8 in gfortran

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Mon Sep 8 19:12:00 GMT 2008


Dennis Wassel wrote:
> Still, you mentioned floating point *constants*, and those are a whole
> different story:
> REAL, PARAMETER :: pi = 3.141592653589793 is not going to benefit from
> additional precision by -fdefault-real-8, unless you add the "_8"
> suffix to promote the numerical constant itself to double precision.
> This is also valid if your existing code uses F77-style
> PARAMETER(PI=3.141592653589793) statements instead.

This is not true:
Aschluter@pcl331 ~$ cat <<EOF > kind8.f90
 > PARAMETER(PI=3.14159265358979323846)
 > END
 > EOF
schluter@pcl331 ~$ cat kind8.f90
PARAMETER(PI=3.14159265358979323846)
END
schluter@pcl331 ~$ gfortran -fdefault-real-8 kind8.f90 -fdump-parse-tree 


         Namespace: A-H: (REAL 8) I-N: (INTEGER 4) O-Z: (REAL 8)
         procedure name = MAIN__
         symtree: pi  Ambig 0
         symbol pi (REAL 8)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS 
UNKNOWN-PRO
IMPLICIT-TYPE)
         value: 3.14159265358979

         symtree: MAIN__  Ambig 0
         symbol MAIN__ (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT PUBLIC 
UNKNOWN-PROC
UBROUTINE)



schluter@pcl331 ~$ gfortran kind8.f90 -fdump-parse-tree 


         Namespace: A-H: (REAL 4) I-N: (INTEGER 4) O-Z: (REAL 4)
         procedure name = MAIN__
         symtree: pi  Ambig 0
         symbol pi (REAL 4)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS 
UNKNOWN-PRO
IMPLICIT-TYPE)
         value: 3.141593

         symtree: MAIN__  Ambig 0
         symbol MAIN__ (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT PUBLIC 
UNKNOWN-PROC
UBROUTINE)



schluter@pcl331 ~$ gfortran --version 

GNU Fortran 95 (GCC) 4.1.2 20060907 (prerelease)
Copyright (C) 2006 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

schluter@pcl331 ~$



More information about the Fortran mailing list