PROGRAM arith2
!
! Author: Br. David Carlson
!
! Date: January 3, 2000
!
! Revised: January 21, 2012
!
! This program tries division by zero and division by almost zero.
! Note that the section on integer division by zero has been commented off.
! This is because trying to run the program when that code is included causes
! a core dump with our current compiler.
IMPLICIT NONE
INTEGER::zero_int = 0
REAL::zero_real = 0.0
REAL:: tiny_real = 1.0E-30
WRITE (*, *) ' Program to try division by zero and almost zero:'
! WRITE (*, *) ' 1 divided by 0 (integer division) gives: ', 1 / zero_int
! WRITE (*, *) ' 0 divided by 0 (integer division) gives: ', 0 / zero_int
WRITE (*, *) ' 1.0 divided by 0.0 (real division) gives: ', 1.0 / zero_real
WRITE (*, *) ' 0.0 divided by 0.0 (real division) gives: ', 0.0 / zero_real
WRITE (*, *) ' 1.0 divided by 1.0E-30 (real division) gives: ', &
1.0 / tiny_real
WRITE (*, *) ' 1.0E30 divided by 1.0E-30 (real division) gives: ', &
1.0E30 / tiny_real
WRITE (*, *) ' End of program'
END PROGRAM