program big_ints ! !*********************************************************************** ! !! BIG_INTS demonstrates how to set up integers with a bigger range. ! ! ! Modified: ! ! 11 April 2001 ! ! Author: ! ! John Burkardt ! implicit none ! call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'BIG_INTS' write ( *, '(a)' ) ' Demonstrate the use of "big" integers.' call test01 call test02 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'BIG_INTS' write ( *, '(a)' ) ' Normal end of execution.' stop end subroutine test01 ! !*********************************************************************** ! !! TEST01 shows what you get by default. ! implicit none ! integer i1 ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a)' ) ' Use integers of the default type.' write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' HUGE() returns the largest value of the given type.' write ( *, '(a,i12)' ) ' HUGE(I1) = ', huge ( i1 ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' RANGE provides the decimal exponent range.' write ( *, '(a,i12)' ) ' RANGE(I1) = ', range(i1) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' KIND returns the "kind" of a given integer.' write ( *, '(a,i12)' ) ' KIND(I1) = ', kind(i1) return end subroutine test02 ! !*********************************************************************** ! !! TEST02 shows what you get with KIND = 8. ! implicit none ! integer ( kind = 8 ) i1 ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST02' write ( *, '(a)' ) ' Use integers of KIND = 8.' write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' HUGE() returns the largest value of the given type.' write ( *, '(a,i24)' ) ' HUGE(I1) = ', huge ( i1 ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' RANGE provides the decimal exponent range.' write ( *, '(a,i12)' ) ' RANGE(I1) = ', range(i1) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' KIND returns the "kind" of a given integer.' write ( *, '(a,i12)' ) ' KIND(I1) = ', kind(i1) return end subroutine timestamp ( ) ! !******************************************************************************* ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! ! Example: ! ! May 31 2001 9:45:54.872 AM ! ! Modified: ! ! 31 May 2001 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none ! character ( len = 8 ) ampm integer d character ( len = 8 ) date integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer n integer s character ( len = 10 ) time integer values(8) integer y character ( len = 5 ) zone ! call date_and_time ( date, time, zone, values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(a,1x,i2,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & trim ( month(m) ), d, y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end