PROGRAM arith4 ! ! Author: Br. David Carlson ! ! Date: January 21, 2010 ! ! This program reports on integer and real capabilities ! with the current Fortran compiler on the current computer. IMPLICIT NONE INTEGER::k REAL::x WRITE (*,*) 'Integer-related items:' WRITE (*,*) 'BIT_SIZE(k) gives number of bits used to represent an integer: ', BIT_SIZE(k) WRITE (*,*) 'DIGITS(k) gives number of significant bits in an integer: ', DIGITS(k) WRITE (*,*) 'KIND(k) gives: ', KIND(k) WRITE (*,*) 'HUGE(k) gives largest integer: ', HUGE(k) WRITE (*,*) 'RANGE(k) gives the decimal exponent range for integers: ', RANGE(k) WRITE (*,*) 'SELECTED_INT_KIND(3) gives smallest kind number for integers less than 10**3: ', SELECTED_INT_KIND(3) WRITE (*,*) 'SELECTED_INT_KIND(6) gives smallest kind number for integers less than 10**6: ', SELECTED_INT_KIND(6) WRITE (*,*) 'SELECTED_INT_KIND(9) gives smallest kind number for integers less than 10**9: ', SELECTED_INT_KIND(9) WRITE (*,*) 'SELECTED_INT_KIND(12) gives smallest kind number for integers less than 10**12: ', SELECTED_INT_KIND(12) WRITE (*,*) 'SELECTED_INT_KIND(15) gives smallest kind number for integers less than 10**15: ', SELECTED_INT_KIND(15) WRITE (*,*) 'SELECTED_INT_KIND(18) gives smallest kind number for integers less than 10**18: ', SELECTED_INT_KIND(18) WRITE (*,*) 'SELECTED_INT_KIND(21) gives smallest kind number for integers less than 10**21: ', SELECTED_INT_KIND(21) WRITE (*,*) 'SELECTED_INT_KIND(27) gives smallest kind number for integers less than 10**27: ', SELECTED_INT_KIND(27) WRITE (*,*) 'SELECTED_INT_KIND(36) gives smallest kind number for integers less than 10**36: ', SELECTED_INT_KIND(36) WRITE (*,*) 'SELECTED_INT_KIND(39) gives smallest kind number for integers less than 10**39: ', SELECTED_INT_KIND(39) WRITE (*,*) WRITE (*,*) 'Real-related items:' WRITE (*,*) 'DIGITS(x) gives number of significant bits in the mantissa of a real: ', DIGITS(x) WRITE (*,*) 'EPSILON(x) gives the machine epsilon (distance between 1.0 and next real): ', EPSILON(x) WRITE (*,*) 'KIND(x) gives: ', KIND(x) WRITE (*,*) 'HUGE(x) gives largest real: ', HUGE(x) WRITE (*,*) 'MAXEXPONENT(x) gives the max exponent (on a base of 2) for a real: ', MAXEXPONENT(x) WRITE (*,*) 'MINEXPONENT(x) gives the min exponent (on a base of 2) for a real: ', MINEXPONENT(x) WRITE (*,*) 'PRECISION(x) gives the number of decimal digits of precision for a real: ', PRECISION(x) WRITE (*,*) 'RANGE(x) gives the decimal exponent range for reals: ', RANGE(x) WRITE (*,*) 'SPACING(x) gives the minimum spacing between reals: ', SPACING(x) WRITE (*,*) 'TINY(x) gives the smallest positive real: ', TINY(x) WRITE (*,*) 'SELECTED_REAL_KIND(4, 12) gives the smallest real kind with 4 digits of precision and at least 10**12: ', & SELECTED_REAL_KIND(4, 12) WRITE (*,*) 'SELECTED_REAL_KIND(6, 37) gives the smallest real kind with 6 digits of precision and at least 10**37: ', & SELECTED_REAL_KIND(6, 37) WRITE (*,*) 'SELECTED_REAL_KIND(6, 65) gives the smallest real kind with 6 digits of precision and at least 10**65: ', & SELECTED_REAL_KIND(6, 65) WRITE (*,*) 'SELECTED_REAL_KIND(7, 37) gives the smallest real kind with 7 digits of precision and at least 10**37: ', & SELECTED_REAL_KIND(7, 37) WRITE (*,*) 'SELECTED_REAL_KIND(7, 65) gives the smallest real kind with 7 digits of precision and at least 10**65: ', & SELECTED_REAL_KIND(7, 65) WRITE (*,*) 'SELECTED_REAL_KIND(7, 95) gives the smallest real kind with 7 digits of precision and at least 10**95: ', & SELECTED_REAL_KIND(7, 95) WRITE (*,*) 'SELECTED_REAL_KIND(12, 95) gives the smallest real kind with 12 digits of precision and at least 10**95: ', & SELECTED_REAL_KIND(12, 95) WRITE (*,*) 'SELECTED_REAL_KIND(12, 125) gives the smallest real kind with 12 digits of precision and at least 10**125: ', & SELECTED_REAL_KIND(12, 125) WRITE (*,*) 'SELECTED_REAL_KIND(16, 125) gives the smallest real kind with 16 digits of precision and at least 10**125: ', & SELECTED_REAL_KIND(16, 125) WRITE (*,*) 'SELECTED_REAL_KIND(16, 155) gives the smallest real kind with 16 digits of precision and at least 10**155: ', & SELECTED_REAL_KIND(16, 155) WRITE (*,*) 'SELECTED_REAL_KIND(22, 155) gives the smallest real kind with 22 digits of precision and at least 10**155: ', & SELECTED_REAL_KIND(22, 155) WRITE (*,*) 'SELECTED_REAL_KIND(16, 195) gives the smallest real kind with 16 digits of precision and at least 10**195: ', & SELECTED_REAL_KIND(16, 195) WRITE (*,*) 'SELECTED_REAL_KIND(16, 755) gives the smallest real kind with 16 digits of precision and at least 10**755: ', & SELECTED_REAL_KIND(16, 755) WRITE (*,*) 'SELECTED_REAL_KIND(16, 2955) gives the smallest real kind with 16 digits of precision and at least 10**2955: ', & SELECTED_REAL_KIND(16, 2955) WRITE (*,*) 'SELECTED_REAL_KIND(16, 4955) gives the smallest real kind with 16 digits of precision and at least 10**4955: ', & SELECTED_REAL_KIND(16, 4955) END PROGRAM