I have written my program, it compiles properly but then when I go to run the .exe file it does the following: ./finalprojectavg.exe
Reading file...
File cannot be opened !
Floating point exception
Can somebody explain to me what this is? I have never had a program pop-up a floating point exception
DATA-002.csv file is here:Link
Reading file...
File cannot be opened !
Floating point exception
Can somebody explain to me what this is? I have never had a program pop-up a floating point exception
Code:
program WSUPhys_csv
implicit none
integer :: stat, num_lines, ivar1, ivar2, ivar3
integer :: Sum_ivar1, Sum_ivar2, Sum_ivar3, Avg_ivar1, Avg_ivar2, Avg_ivar3,MaxVert,MaxSide,MaxForward
real :: rvar
character*80 :: line
write(*,*) "Reading file..."
! open input file
open(10,file='DATA-002.csv',status='old',iostat=stat)
if (stat .ne. 0) then
write(*,*) 'File cannot be opened !'
go to 99
end if
num_lines = 0
Sum_ivar1 = 0
Sum_ivar1 = 0
Sum_ivar1 = 0
MaxVert=0
MaxSide=0
MaxForward=0
do
read(10,'(A)',end=99, iostat=stat) line
if (stat .ne. 0) then
write(*,*) 'Error reading data !'
go to 99
end if
! skip comment/header lines beginning with ";"
if (adjustl(trim(line(1:1))) .eq. ';') then
cycle
end if
! read string line into numeric variables
read(line,*) rvar, ivar1, ivar2, ivar3
num_lines = num_lines + 1
if (num_lines <= 10) then
write(*,*) num_lines, ':', rvar, ivar1, ivar2, ivar3
end if
Sum_ivar1 = Sum_ivar1 + ABS(ivar1)
Sum_ivar2 = Sum_ivar2 + ABS(ivar2)
Sum_ivar3 = Sum_ivar3 + ABS(ivar3)
If (ABS(ivar1) > MaxVert) then
MaxVert=ivar1
end if
If (ABS(ivar2) > MaxSide) then
MaxSide=ivar1
end if
If (ABS(ivar3) > MaxForward) then
MaxForward=ivar1
end if
end do
! close file
99 continue
Avg_ivar1 = (Sum_ivar1 / num_lines)
Avg_ivar2 = (Sum_ivar2 / num_lines)
Avg_ivar3 = (Sum_ivar3 / num_lines)
close (10)
!
write(*,*) '...done.'
write(*,*) 'Lines processed: ', num_lines
write(*,*) 'Average vertical acceleration', Avg_ivar1/1000
write(*,*) 'Average sideways acceleration', Avg_ivar2/1000
write(*,*) 'Average forwards acceleration', Avg_ivar3/1000
write(*,*) 'Maximum vertical acceleration', MaxVert
write(*,*) 'Maximum sideways acceleration', MaxSide
write(*,*) 'Maximum forward acceleration', MaxForward
end program WSUPhys_csv
DATA-002.csv file is here:Link