program machparm ! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/machparm.f90 ! !===Short test driver to compute some Machine Parameters ! Runs under Windows using compilers: ! Lahey LF95, Salford FTN95, Compaq-Intel CVF, ! and under AIX using compiler XLF90. Results below used CVF. ! ! For computation of Machine Parameters see MACHPARM.FOR ! W. J. Cody, "MACHAR: A subroutine to dynamically determine machine ! parameters, " TOMS 14, December, 1988; or ! Alan C. Hindmarsh at http://www.netlib.org/lapack/util/dlamch.f ! Alan Miller at http://users.bigpond.net.au/amiller/NSWC/constant.f90 ! ! Fortran 90"s related intrinsic (built-in) functions: ! DIGITS, EPSILON, EXPONENT, FRACTION, HUGE, MAXEXPONENT, ! MINEXPONENT, NEAREST, PRECISION, RADIX, RANGE, RRSPACING, ! SCALE, SET EXPONENT, SPACING, TINY. ! ! Results for running on an IBM PC (with or without FPU) with ! above compilers. ! ! integer, parameter :: SP = selected_real_kind(6) integer, parameter :: DP = selected_real_kind(15) integer, parameter :: QP = selected_real_kind(30) real(kind=SP) :: xsngl,ysngl real(kind=DP) :: xdbl, ydbl real(kind=QP) :: xqp, yqp print *, "!Single Precision results on a PC:" print *, "! " print *, "!DIGITS=",DIGITS(xsngl) xsngl=1 print *, "!Epsilon=",Epsilon(xsngl) print *, "!ExsnglExponent=",Exponent(xsngl) print *, "!Fraction=",Fraction(xsngl) print *, "!Huge=",Huge(xsngl) print *, "!MaxsnglExponent=",Maxexponent(xsngl) print *, "!MinExsnglponent=",Minexponent(xsngl) ysngl=1 print *, "!Nearest=",Nearest(xsngl,ysngl) print *, "!Precision=",Precision(xsngl) print *, "!Radixsngl=",Radix(xsngl) print *, "!Range=",Range(xsngl) xsngl=1 print *, "!Spacing=",Spacing(xsngl) print *, "!Tiny=",Tiny(xsngl) print *, " " print *, "!Double Precision results on a PC:" print *, "! " print *, "!DIGITS=",DIGITS(xdbl) xdbl=1 print *, "!Epsilon=",Epsilon(xdbl) print *, "!ExdblExponent=",Exponent(xdbl) print *, "!Fraction=",Fraction(xdbl) print *, "!Huge=",Huge(xdbl) print *, "!MaxdblExponent=",Maxexponent(xdbl) print *, "!MinExdblponent=",Minexponent(xdbl) ydbl=1 print *, "!Nearest=",Nearest(xdbl,ydbl) print *, "!Precision=",Precision(xdbl) print *, "!Radixdbl=",Radix(xdbl) print *, "!Range=",Range(xdbl) xdbl=1 print *, "!Spacing=",Spacing(xdbl) print *, "!Tiny=",Tiny(xdbl) print *, " " print *, "!Quadruple Precision results on a PC:" print *, "! " print *, "!DIGITS=",DIGITS(xqp) xqp=1 print *, "!Epsilon=",Epsilon(xqp) print *, "!ExqpExponent=",Exponent(xqp) print *, "!Fraction=",Fraction(xqp) print *, "!Huge=",Huge(xqp) print *, "!MaxqpExponent=",Maxexponent(xqp) print *, "!MinExqpponent=",Minexponent(xqp) yqp=1 print *, "!Nearest=",Nearest(xqp,yqp) print *, "!Precision=",Precision(xqp) print *, "!Radixdbl=",Radix(xqp) print *, "!Range=",Range(xqp) xqp=1 print *, "!Spacing=",Spacing(xqp) print *, "!Tiny=",Tiny(xqp) !Single Precision results on a PC: ! !DIGITS= 24 !Epsilon= 1.1920929E-07 !Exsnglponent= 1 !Fraction= 0.5000000 !Huge= 3.4028235E+38 !MaxsnglExponent= 128 !MinExsnglponent= -125 !Nearest= 1.000000 !Precision= 6 !Radixsngl= 2 !Range= 37 !Spacing= 1.1920929E-07 !Tiny= 1.1754944E-38 !Double Precision results on a PC: ! !DIGITS= 53 !Epsilon= 2.220446049250313E-016 !Exdblponent= 1 !Fraction= 0.500000000000000 !Huge= 1.797693134862316E+308 !MaxdblExponent= 1024 !MinExdblponent= -1021 !Nearest= 1.00000000000000 !Precision= 15 !Radixdbl= 2 !Range= 307 !Spacing= 2.220446049250313E-016 !Tiny= 2.225073858507201E-308 !Quadruple Precision results on a PC: ! !DIGITS= 113 !Epsilon= 1.925929944387235853055977942584927E-0034 !ExqpExponent= 1 !Fraction= 0.500000000000000000000000000000000 !Huge= 1.189731495357231765085759326628007E+4932 !MaxqpExponent= 16384 !MinExqpponent= -16381 !Nearest= 1.00000000000000000000000000000000 !Precision= 33 !Radixdbl= 2 !Range= 4931 !Spacing= 1.925929944387235853055977942584927E-0034 !Tiny= 3.362103143112093506262677817321753E-4932 end program machparm