summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-29 15:58:16 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-29 15:58:16 +0000
commit158e0e64456930a3a1d439043a9c27d6a8057d2d (patch)
tree764a8802dba0b681b9c0d6f4248a2b2513c2b2fc /gcc/testsuite/gfortran.dg
parent7b4fe863dd609e49323d9b07781a0b09d75ad9e5 (diff)
downloadgcc-158e0e64456930a3a1d439043a9c27d6a8057d2d.tar.gz
2004-08-29 Steven G. Kargl <kargls@comcast.net>
Paul Brook <paul@codesourcery.com> * check.c (gfc_check_besn, gfc_check_g77_math1): New functions. * f95-lang.c (DO_DEFINE_MATH_BUILTIN): Define. (DEFINE_MATH_BUILTIN, DEFINE_MATH_BUILTIN_C): Use it. (build_builtin_fntypes): New function. (gfc_init_builtin_functions): Use it. * gfortran.h (enum gfc_generic_isym_id): Add GFC_ISYM_{J,Y}{0,1,N} and GFC_ISYM_ERF{,C}. (gfc_c_int_kind): Declare. * intrinsic.c (add_functions): Add [d]bes* and [d]erf*. * intrinsic.h (gfc_check_besn, gfc_check_g77_math1, gfc_resolve_besn, gfc_resolve_g77_math1): Add prototypes. * resolve.c (gfc_resolve_besn, gfc_resolve_g77_math1): New functions. * mathbuiltins.def: Add comment. Change third argument. Use DEFINE_MATH_BUILTIN_C. Add bessel and error functions. * trans-intrinsic.c (BUILT_IN_FUNCTION): Define. (DEFINE_MATH_BUILTIN, DEFINE_MATH_BUILTIN_C): Use it. * trans-types.c (gfc_c_int_kind): Declare. (gfc_init_kinds): Set it. testsuite/ * gfortran.dg/g77/README: Update. * gfortran.dg/g77/erfc.f: Copy from g77.f-torture. * gfortran.dg/g77/intrinsic-unix-bessel.f: Ditto. * gfortran.dg/g77/intrinsic-unix-erf.f: Ditto. libgfortran/ * intrinsics/bessel.c: New file. * intrinsics/erf.c: New file. * Makefie.am: Add intrinsics/bessel.c and intrinsics/erf.c. * configure.ac: Test for C99 Bessel and Error functions. * Makefile.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86727 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rwxr-xr-xgcc/testsuite/gfortran.dg/g77/README6
-rw-r--r--gcc/testsuite/gfortran.dg/g77/erfc.f39
-rw-r--r--gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f109
-rw-r--r--gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f61
4 files changed, 212 insertions, 3 deletions
diff --git a/gcc/testsuite/gfortran.dg/g77/README b/gcc/testsuite/gfortran.dg/g77/README
index f5d6c35f169..2605369f2c2 100755
--- a/gcc/testsuite/gfortran.dg/g77/README
+++ b/gcc/testsuite/gfortran.dg/g77/README
@@ -167,15 +167,15 @@ cpp.F (Renamed cpp3.F) Y
cpp2.F - Compiler warnings
dcomplex.f Y
dnrm2.f Y Add dg-warning as required
-erfc.f Link errors
+erfc.f Y
exp.f Compiler warnings and fails
f90-intrinsic-bit.f F 16581 Compile errors
f90-intrinsic-mathematical.f Y
f90-intrinsic-numeric.f Y
int8421.f Y
intrinsic-f2c-z.f F Execution fail
-intrinsic-unix-bessel.f Link errors
-intrinsic-unix-erf.f Link erros
+intrinsic-unix-bessel.f Y
+intrinsic-unix-erf.f Y
intrinsic-vax-cd.f F Execution fail
intrinsic77.f F PR 16580 Compiler ICE
io0.f & io0.x
diff --git a/gcc/testsuite/gfortran.dg/g77/erfc.f b/gcc/testsuite/gfortran.dg/g77/erfc.f
new file mode 100644
index 00000000000..0ab0aee8c1c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/g77/erfc.f
@@ -0,0 +1,39 @@
+c { dg-do run }
+c============================================== test.f
+ real x, y
+ real*8 x1, y1
+ x=0.
+ y = erfc(x)
+ if (y .ne. 1.) call abort
+
+ x=1.1
+ y = erfc(x)
+ if (abs(y - .1197949) .ge. 1.e-6) call abort
+
+* modified from x=10, y .gt. 1.5e-44 to avoid lack of -mieee on Alphas.
+ x=8
+ y = erfc(x)
+ if (y .gt. 1.2e-28) call abort
+
+ x1=0.
+ y1 = erfc(x1)
+ if (y1 .ne. 1.) call abort
+
+ x1=1.1d0
+ y1 = erfc(x1)
+ if (abs(y1 - .1197949d0) .ge. 1.d-6) call abort
+
+ x1=10
+ y1 = erfc(x1)
+ if (y1 .gt. 1.5d-44) call abort
+ end
+c=================================================
+!output:
+! 0. 1.875
+! 1.10000002 1.48958981
+! 10. 5.00220949E-06
+!
+!The values should be:
+!erfc(0)=1
+!erfc(1.1)= 0.1197949
+!erfc(10)<1.543115467311259E-044
diff --git a/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f
new file mode 100644
index 00000000000..0b5789da679
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f
@@ -0,0 +1,109 @@
+c { dg-do run }
+c intrinsic-unix-bessel.f
+c
+c Test Bessel function intrinsics.
+c These functions are only available if provided by system
+c
+c David Billinghurst <David.Billinghurst@riotinto.com>
+c
+ real x, a
+ double precision dx, da
+ integer i
+ integer*2 j
+ integer*1 k
+ integer*8 m
+ logical fail
+ common /flags/ fail
+ fail = .false.
+
+ x = 2.0
+ dx = x
+ i = 2
+ j = i
+ k = i
+ m = i
+c BESJ0 - Bessel function of first kind of order zero
+ a = 0.22389077
+ da = a
+ call c_r(BESJ0(x),a,'BESJ0(real)')
+ call c_d(BESJ0(dx),da,'BESJ0(double)')
+ call c_d(DBESJ0(dx),da,'DBESJ0(double)')
+
+c BESJ1 - Bessel function of first kind of order one
+ a = 0.57672480
+ da = a
+ call c_r(BESJ1(x),a,'BESJ1(real)')
+ call c_d(BESJ1(dx),da,'BESJ1(double)')
+ call c_d(DBESJ1(dx),da,'DBESJ1(double)')
+
+c BESJN - Bessel function of first kind of order N
+ a = 0.3528340
+ da = a
+ call c_r(BESJN(i,x),a,'BESJN(integer,real)')
+ call c_r(BESJN(j,x),a,'BESJN(integer*2,real)')
+ call c_r(BESJN(k,x),a,'BESJN(integer*1,real)')
+ call c_d(BESJN(i,dx),da,'BESJN(integer,double)')
+ call c_d(BESJN(j,dx),da,'BESJN(integer*2,double)')
+ call c_d(BESJN(k,dx),da,'BESJN(integer*1,double)')
+ call c_d(DBESJN(i,dx),da,'DBESJN(integer,double)')
+ call c_d(DBESJN(j,dx),da,'DBESJN(integer*2,double)')
+ call c_d(DBESJN(k,dx),da,'DBESJN(integer*1,double)')
+
+c BESY0 - Bessel function of second kind of order zero
+ a = 0.51037567
+ da = a
+ call c_r(BESY0(x),a,'BESY0(real)')
+ call c_d(BESY0(dx),da,'BESY0(double)')
+ call c_d(DBESY0(dx),da,'DBESY0(double)')
+
+c BESY1 - Bessel function of second kind of order one
+ a = 0.-0.1070324
+ da = a
+ call c_r(BESY1(x),a,'BESY1(real)')
+ call c_d(BESY1(dx),da,'BESY1(double)')
+ call c_d(DBESY1(dx),da,'DBESY1(double)')
+
+c BESYN - Bessel function of second kind of order N
+ a = -0.6174081
+ da = a
+ call c_r(BESYN(i,x),a,'BESYN(integer,real)')
+ call c_r(BESYN(j,x),a,'BESYN(integer*2,real)')
+ call c_r(BESYN(k,x),a,'BESYN(integer*1,real)')
+ call c_d(BESYN(i,dx),da,'BESYN(integer,double)')
+ call c_d(BESYN(j,dx),da,'BESYN(integer*2,double)')
+ call c_d(BESYN(k,dx),da,'BESYN(integer*1,double)')
+ call c_d(DBESYN(i,dx),da,'DBESYN(integer,double)')
+ call c_d(DBESYN(j,dx),da,'DBESYN(integer*2,double)')
+ call c_d(DBESYN(k,dx),da,'DBESYN(integer*1,double)')
+
+ if ( fail ) call abort()
+ end
+
+ subroutine failure(label)
+c Report failure and set flag
+ character*(*) label
+ logical fail
+ common /flags/ fail
+ write(6,'(a,a,a)') 'Test ',label,' FAILED'
+ fail = .true.
+ end
+
+ subroutine c_r(a,b,label)
+c Check if REAL a equals b, and fail otherwise
+ real a, b
+ character*(*) label
+ if ( abs(a-b) .gt. 1.0e-5 ) then
+ call failure(label)
+ write(6,*) 'Got ',a,' expected ', b
+ end if
+ end
+
+ subroutine c_d(a,b,label)
+c Check if DOUBLE PRECISION a equals b, and fail otherwise
+ double precision a, b
+ character*(*) label
+ if ( abs(a-b) .gt. 1.0d-5 ) then
+ call failure(label)
+ write(6,*) 'Got ',a,' expected ', b
+ end if
+ end
diff --git a/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f
new file mode 100644
index 00000000000..460ddeea417
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f
@@ -0,0 +1,61 @@
+c { dg-do run }
+c intrinsic-unix-erf.f
+c
+c Test Bessel function intrinsics.
+c These functions are only available if provided by system
+c
+c David Billinghurst <David.Billinghurst@riotinto.com>
+c
+ real x, a
+ double precision dx, da
+ logical fail
+ common /flags/ fail
+ fail = .false.
+
+ x = 0.6
+ dx = x
+c ERF - error function
+ a = 0.6038561
+ da = a
+ call c_r(ERF(x),a,'ERF(real)')
+ call c_d(ERF(dx),da,'ERF(double)')
+ call c_d(DERF(dx),da,'DERF(double)')
+
+c ERFC - complementary error function
+ a = 1.0 - a
+ da = a
+ call c_r(ERFC(x),a,'ERFC(real)')
+ call c_d(ERFC(dx),da,'ERFC(double)')
+ call c_d(DERFC(dx),da,'DERFC(double)')
+
+ if ( fail ) call abort()
+ end
+
+ subroutine failure(label)
+c Report failure and set flag
+ character*(*) label
+ logical fail
+ common /flags/ fail
+ write(6,'(a,a,a)') 'Test ',label,' FAILED'
+ fail = .true.
+ end
+
+ subroutine c_r(a,b,label)
+c Check if REAL a equals b, and fail otherwise
+ real a, b
+ character*(*) label
+ if ( abs(a-b) .gt. 1.0e-5 ) then
+ call failure(label)
+ write(6,*) 'Got ',a,' expected ', b
+ end if
+ end
+
+ subroutine c_d(a,b,label)
+c Check if DOUBLE PRECISION a equals b, and fail otherwise
+ double precision a, b
+ character*(*) label
+ if ( abs(a-b) .gt. 1.0d-5 ) then
+ call failure(label)
+ write(6,*) 'Got ',a,' expected ', b
+ end if
+ end