Fortran runtime error: End of file

Hello,

i have been programming for a while in all sorts of languages and now i am trying to use Xcode/Gfortran out. Unfortunately, so far it has been a bit troublesome.

i wrote a small testprogram:
program caca
integer :: a,b,c

open(25,file="testfile")
read(25,*) a,b,c
write(*,*) a,b,c

return
end

where testfile is a file containing: 1 2 3

It builds fine but when i run it, it tells me: "Fortran runtime error: End of file"
It hiccups on the read command.

I cannot find the error in my program, so i must assume it is an error with the compiler.

Does anyone have any insights, or similar errors?

thank you

glenn

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

End of File

I think you probably have testfile in the wrong place. It is running the executable, but it doesn't find 'testfile', so it creates an empty file, and then tries to read it. You just need to move the input file.

drew

---------------------------
Drew McCormack
http://www.maccoremac.com
http://www.macanics.net
http://www.macresearch.org

End of file

thanks drew,

i had put testfile in the same directory as my source code, however, it seems xcode/fortran searched for the file in /build/debug/ directory. When i open a new file from inside the code, it creates the file in this directory.

However, once i placed the original to be read file in this directory, the same error persists!

What do you think?

End of file

Since you are just testing, why not just fill in a full path to the input file. Eg

/Users/blah/Desktop/testfile

Drew

---------------------------
Drew McCormack
http://www.maccoremac.com
http://www.macanics.net
http://www.macresearch.org

Try a new text editor on your Mac

Hi,

I came across this some time ago. It turned out that that was something to do with the text editor I used at that time. If you use TextEdit (coming with Mac OS) to edit your .txt, it will put a 'mac' end-of-line symbol at the end of each line. Fortran doesn't seem to recognise it well and would spit out that it encountered 'end-of-file'.

Open your text file by BBEdit or simply in Terminal and you can see whehter this is the issue. ^_* In BBEdit, you should choose to save your .txt in 'Mac', 'Unix' or Dos format. This would save you days finding the truth of the "inconvenience".

wish you luck,

################
Rich
Searching for sub-optimum and reliabiity

I think you should take care

I think you should take care about comments made by Rich. Most of the time to select the adequate editor is of paramount importance; you won't get problems with, e.g., nano. Why don't you try a constructor in your program in order to test whether or not your compiler works?
santi

Other tips

Changing the open command to something like
OPEN(UNIT=25,FILE='test.txt',ACTION='READ',STATUS='OLD')
might also help a lot when it comes to getting useful diagnostics.

Dear glenn I have a problem

Dear glenn
I have a problem like you.
Did you solve your problem that time?
thanks