Topic: Arithmetic overflow error
Hi,
I typed in an example Fortran code from a textbook. But when I compiled it, the arithmetic overflow error occurs. I am using a 64-bit computer. So I was thinking that all the numbers should be in the range. Please help identify what may cause this problem. The code and the compiler message were copied below.
program ch0504
implicit none
real :: Light_Minute, Distance, Elapse
integer :: Minute, Second
real , parameter :: Light_Year = 9.46*10**12
! Light_Year : Distance travelled by light
! in one year in km
! Light_Minute : Distance travelled by light
! in one minute in km
! Distance : Distance from sun to earth in km
! Elapse : Time taken to travel a
! distance (Distance) in minutes
! Minute : integer number part of elapse
! Second: integer number of seconds
! equivalent to fractional part of elapse
!
Light_Minute = Light_Year/(365.25*24.0*60.0)
Distance = 150.0*10**6
Elapse = Distance / Light_Minute
Minute = Elapse
Second = (Elapse - Minute) *60
print *, 'Light takes',Minute, 'Minutes'
print *, ' ',Second, 'Seconds'
print *, 'to reach the earth from the sun'
end program ch0504
-----------------------build status
==============================================================================
Open Watcom Make Version 1.9 (Modified 3 Mar 2012)
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
"C:\Program Files (x86)\Simply Fortran\mingw-w64\bin\gfortran.exe" -c -o build\ch0504.o -Jmodules .\ch0504.f08
.\ch0504.f08:5.40:
real , parameter :: Light_Year = 9.46*10**12
1
Error: Arithmetic overflow at (1)
.\ch0504.f08:17.29:
Light_Minute = Light_Year/(365.25*24.0*60.0)
1
Error: Symbol 'light_year' at (1) has no IMPLICIT type
Error(E42): Last command making (build\ch0504.o) returned a bad status
Should this file be deleted [Yes/No] ? Error(E02): Make execution terminated
* Complete *