Dear colleagues,
the following code gives me an end of file error.
This is a FORTRAN 75 file from the book “CFD for wind engineering” I tried to translate to a more modern style.
The error: At line 27 of file freq3.f90 (unit = 15, file = ‘fs-i.txt’)
Fortran runtime error: End of file
Error termination. Backtrace:
Could not print backtrace: libbacktrace could not find executable to open
program freq3
use, intrinsic :: iso_fortran_env
implicit none
real(real64) :: ttime, dt, fre, fre1
real(real64) :: xa, temp, time, an, bn, amb
real(real64), parameter :: pi=4.0_real64*atan(1.0_real64), pi2=2.0_real64*pi
integer :: i, n, nfreq, np, iostat
character(len=13), parameter :: fmt="(4(1x,f10.4))"
open(15, file="fs-i.txt")
open(20, file="fs-o.plt")
write(20,*) "freq, an, bn, amb"
read(15,*) np, ttime, dt, nfreq
fre = 1.0_real64/ttime
do n = 1, nfreq
if (n /= 1) then
if (iostat /= 0) exit ! Exit loop if read fails
end if
fre1 = fre*n
an = 0.0_real64
bn = 0.0_real64
do i = 1, np
read(15,*) time, xa
temp = n*pi2*time/ttime
an = an + xa*cos(temp)
bn = bn + xa*sin(temp)
end do
an = 2.0_real64*an*dt/ttime
bn = 2.0_real64*bn*dt/ttime
amb = sqrt(an*an + bn*bn)
print *, fre1, an, bn, amb
write(20,fmt) fre1, an, bn, amb
rewind 15
end do
close(15)
close(20)
end program freq3
Roger