This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: gfortran.dg/gamma_(1|2).f90 fail on Darwin
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "Dominique Dhumieres" <dominiq at lps dot ens dot fr>
- Cc: fortran at gcc dot gnu dot org, burnus at net-b dot de
- Date: Tue, 28 Aug 2007 15:22:00 +0100
- Subject: Re: gfortran.dg/gamma_(1|2).f90 fail on Darwin
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Uch9QGAHGJ/i/GpD5U+OpRqm/J5exs0zdK1TDGIZsdB12qgIrSKZinqISAfIdow6jF4xDZW/yFQcmfdAVH5QFk/6BxokJntZuP29s8mOXx9e8ED+oSLbROI/SfCXp4CzbrEiIS1r1ba6/KDn0y7hz4SG+FM1yLz5m3VvVYN18Zg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=I2rxfzw3kFA24KQVTt29+l9nNek6hGq5uifN85cEqr4Ec0bMss+/xBlHj48ZF1KeGGe3yCOEod/4tcJoJ/TmuBsQMX0JKO4+oiaqjw1Cq4Zn5lIv+EKwBZ1abzmBMBvs4xvUJXveeMegicdZAy/Irrl3tOStsJ7jgvuas5cAsoI=
- References: <20070828133503.905255BBB8@mailhost.lps.ens.fr>
> gfortran.dg/gamma_(1|2).f90 fail on Darwin (and probably on any
> system with real(16) instead of real(10)) because
> selected_real_kind(p=15,r=900) returns -2: maximum range is
> 291. Using selected_real_kind (precision (0.0_8) + 1) solves
> the problem.
It won't work on all systems, because some targets don't have a
floating-point type with more precision that real(8). These tests
should be put in a separate file, and they should be annotated with {
dg-require-effective-target fortran_large_real }, which is the Right
Way of doing this in the current framework (see
gfortran.dg/large_real_kind_1.f90, for example).
Furthermore, there is what looks like a copy-paste typo, real(dp)
being used twice instead of real(qp). I propose the following patch
(cannot test nor commit, sorry):
Index: gamma_1.f90
===================================================================
--- gamma_1.f90 (revision 127859)
+++ gamma_1.f90 (working copy)
@@ -11,20 +11,16 @@
intrinsic :: gamma, lgamma
integer, parameter :: sp = kind(1.0)
integer, parameter :: dp = kind(1.0d0)
-integer, parameter :: qp = selected_real_kind(p=15,r=900)
real(sp) :: rsp
real(dp) :: rdp
-real(dp) :: rqp
if (abs(gamma(1.0_sp) - 1.0_sp) > tiny(1.0_sp)) call abort()
if (abs(gamma(1.0_dp) - 1.0_dp) > tiny(1.0_dp)) call abort()
-if (abs(gamma(1.0_qp) - 1.0_qp) > tiny(1.0_qp)) call abort()
if (abs(dgamma(1.0_dp) - 1.0_dp) > tiny(1.0_dp)) call abort()
if (abs(lgamma(1.0_sp)) > tiny(1.0_sp)) call abort()
if (abs(lgamma(1.0_dp)) > tiny(1.0_dp)) call abort()
-if (abs(lgamma(1.0_qp)) > tiny(1.0_qp)) call abort()
if (abs(algama(1.0_sp)) > tiny(1.0_sp)) call abort()
if (abs(dlgama(1.0_dp)) > tiny(1.0_dp)) call abort()
end program gamma_test
Index: gamma_2.f90
===================================================================
--- gamma_2.f90 (revision 127859)
+++ gamma_2.f90 (working copy)
@@ -16,20 +16,16 @@
integer, parameter :: sp = kind(1.0)
integer, parameter :: dp = kind(1.0d0)
-integer, parameter :: qp = selected_real_kind(p=15,r=900)
real(sp) :: rsp = 1.0_sp
real(dp) :: rdp = 1.0_dp
-real(dp) :: rqp = 1.0_qp
rsp = gamma(rsp) ! FIXME: "is not included in the selected standard"
rdp = gamma(rdp) ! FIXME: "is not included in the selected standard"
-rqp = gamma(rqp) ! FIXME: "is not included in the selected standard"
rdp = dgamma(rdp) ! { dg-error "is not included in the selected standard" }
rsp = lgamma(rsp) ! FIXME: "is not included in the selected standard"
rdp = lgamma(rdp) ! FIXME: "is not included in the selected standard"
-rqp = lgamma(rqp) ! FIXME: "is not included in the selected standard"
rsp = algama(rsp) ! { dg-error "is not included in the selected standard" }
rdp = dlgama(rdp) ! { dg-error "is not included in the selected standard" }
end subroutine foo
Index: gamma_4.f90
===================================================================
--- gamma_4.f90 (revision 0)
+++ gamma_4.f90 (revision 0)
@@ -0,0 +1,20 @@
+! { dg-do run }
+! { dg-require-effective-target fortran_large_real }
+!
+! Test the vendor intrinsic (d)gamma, lgamma and algama/dlgama
+! gamma is also part of the Fortran 2008 draft; lgamma is called
+! log_gamma in the Fortran 2008 draft.
+!
+! PR fortran/32980
+!
+program gamma_test
+implicit none
+intrinsic :: gamma, lgamma
+integer, parameter :: qp = selected_real_kind(p=15,r=900)
+
+real(qp) :: rqp
+
+if (abs(gamma(1.0_qp) - 1.0_qp) > tiny(1.0_qp)) call abort()
+if (abs(lgamma(1.0_qp)) > tiny(1.0_qp)) call abort()
+end program gamma_test
+