- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
If it is any consolation, we have all been here before.
Bear of little brain

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page