Software Archive
Read-only legacy content
17061 Discussions

Unable To Read Data - servere(24)

Intel_C_Intel
Employee
456 Views
I am a new user to fortran and CVF. There's 'end of file' problem when I tried to read a time series data.

I created a new project by selecting the 'console application' and then add one f77 file and one data file (sp500.dat) to the project.

After I compiled and linked the project, 'severe(24) end-of file during read' error message appeared when the program was executed. It seems that there was some problem in READ statement. After I added IOSTAT in READ statement, IOSTAT = -1 and all price indices printed out are zero.

However, I had successfully run this short program in UNIX machine with other compiler before. I am not sure if there's anything wrong with the above procedure or the program.

Could anyone help me to solve this problem? Thanks in advance.

Below is the program for reference

integer*4 eof, i, inf, ndret, outf
parameter (ndret=2779)
real*4 price(0:ndret)
data outf /19/
open(outf, file = 'sp500.dat', status = 'unknown')
do 10 i = 0, ndret
read(outf,*, iostat=eof) price(i)
print*, 'eof', eof
print*, i, price(i)
10 continue
close(outf)
stop
end
0 Kudos
2 Replies
Steven_L_Intel1
Employee
456 Views
You don't need to add a data file to the project, though it doesn't hurt to do so.

My guess is that the program is opening the file in a different location from where you created sp500.dat. By default, when run from Developer Studio, it looks for it in the project folder (the one your project is created in), but the executable is put in a Debug or Release folder.

Where is your sp500.dat file? Is it in the same folder as the .dsp project file? If not, copy it there and see if it works. I suspect that your program created a new, empty sp500.dat file.

Steve
0 Kudos
Intel_C_Intel
Employee
456 Views
If a data file already exists from which you wish to read, it is unwise / bad practice in my view to open without STATUS = 'OLD'. Otherwise, as Steve says, with STATUS = 'UNKNOWN', if the program cannot find it, it opens an new, empty file.

If it is any consolation, we have all been here before.

Bear of little brain
0 Kudos
Reply