aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/erf_3.F90
blob: 32c1ba6e54e66baec02ec9b421cc7fc105ab1252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
! { dg-do run { xfail spu-*-* ia64-*-linux* } }
! { dg-options "-fno-range-check -ffree-line-length-none -O0" }
! { dg-add-options ieee }
! { dg-skip-if "PR libfortran/59313" { sparc*-*-solaris2.9* hppa*-*-hpux* } }
!
! Check that simplification functions and runtime library agree on ERF,
! ERFC and ERFC_SCALED, for quadruple-precision.
!
! XFAILed for SPU targets because our library implementation of
! the double-precision erf/erfc functions is not accurate enough.
!
! XFAILed for IA64 Linux because of a glibc bug:
! http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59227

program test
  use, intrinsic :: iso_fortran_env
  implicit none

  ! QP will be the largest supported real kind, possibly real(kind=16)
  integer, parameter :: qp = real_kinds(ubound(real_kinds,dim=1))
  real(kind=qp) :: x

#define CHECK(a) \
  x = a ; \
  call check(erf(real(a,kind=qp)), erf(x)) ; \
  call check(erfc(real(a,kind=qp)), erfc(x)) ; \
  call check(erfc_scaled(real(a,kind=qp)), erfc_scaled(x))

  CHECK(0.0)
  CHECK(0.9)
  CHECK(1.9)
  CHECK(10.)
  CHECK(11.)
  CHECK(12.)
  CHECK(13.)
  CHECK(14.)
  CHECK(49.)
  CHECK(190.)

  CHECK(-0.0)
  CHECK(-0.9)
  CHECK(-1.9)
  CHECK(-19.)
  CHECK(-190.)

contains

  subroutine check (a, b)
    real(kind=qp), intent(in) :: a, b
    print *, abs(a-b) / spacing(a)
    if (abs(a - b) > 10 * spacing(a)) call abort
  end subroutine

end program test