c=========================================================== c Demonstrates sample use of SLATEC routine dgaus8 c to integrate a real function of one variable c over a finite interval. c c % maple c > Digits := 16: c > evalf(); c c SUBROUTINE DGAUS8 (FUN, A, B, ERR, ANS, IERR) c=========================================================== program tdgaus8 implicit none integer iargc real*8 r8arg logical ltrace external fun real*8 fun real*8 default_err parameter ( default_err = 1.0d-8 ) real*8 a, b, err, ans integer ierr c----------------------------------------------------------- c Argument parsing. c----------------------------------------------------------- if( iargc() .lt. 2 ) go to 900 a = r8arg(1,-99.0d0) b = r8arg(2,-99.0d0) err = r8arg(3,default_err) ltrace = iargc() .gt. 3 if( ltrace ) then write(0,*) 'tdgaus8: a = ', a write(0,*) 'tdgaus8: b = ', b write(0,*) 'tdgaus8: err = ', err end if call dgaus8 (fun, a, b, err, ans, ierr) if( ierr .ne. 1 ) then write(0,*) 'tdgaus8: Requested error criterion '// & 'could not be achieved' end if write(*,*) ans stop 900 continue write(0,*) 'usage: tdgaus8 [ ]' write(0,*) ' ' write(0,*) & ' Computes aproximate value of Int(exp(-x^2),x=a..b)' write(0,*) & ' with an approximate error ' stop end real*8 function fun(x) implicit none real*8 x fun = exp(-x**2) return end