By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

Reading file error

P: n/a
Hi all,

I am writing a file by name "input" out, with a small python code below:

grid=open('input','w')
grid.write(' ')
grid.write('/*number_of_zone\n')
grid.write(' ')
grid.write('2\n')
grid.write(' ')
grid.write('/*zone_number 1\n')
grid.write(' ')
grid.write('quadratic 50 25 6 2\n')

Upon execution, I get the file "input" whose contents are as per below:

/*number_of_zone
2
/*zone_number 1
quadratic 50 25 6 2


Now, when I tried to read this through my fortran code I get the following
errors:

/*zone_number 1

Input/Output Error 153: Input file ended

In Procedure: in_and_out..read_input
At Line: 4472

Statement: List-Directed READ
Unit: 10
Connected To: Work File
Form: Formatted (contains List-Directed records)
Access: Sequential
Records Read : 2
Records Written: 2

End of diagnostics


Outline of fortran code:

SUBROUTINE read_input()
OPEN (15, FILE='input')
READ .....
......
CLOSE(15)
END SUBROUTINE read_input

Some part of the error is related to some "scratch file" with unit=10 that the
fortran code is generating, which, I don't want to pay attention to.

My main problem is that when I generate "input" without python and simply
write everything by opening the file manually in my editor and then execute
it with the same fortran code, I don't get any such strange errors and it
works perfectly fine. I am therefore, wondering if this has got to do
anything with python.
Can someone help ??
Thanks in advance
Best Regards,
Satish Kumar Chimakurthi
--
SATISH KUMAR CHIMAKURTHI
Graduate Research Assistant
CFD GROUP
UNIVERSITY OF KENTUCKY
LEXINGTON
KENTUCKY - 40508
Email: sk*****@engr.uky.edu
Mobile: 859-420-9890

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>
Can someone help ??


Whats diff telling on those two files? And - to me it looks like more of a
fortran problem, anyway.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2

P: n/a
On Thu, 19 Feb 2004 10:11:12 +0000, satish <sk*****@engr.uky.edu>
declaimed the following in comp.lang.python:
READ .....
......
And of course you suppressed all the critical information... The
declaration(s) of the variables and the actual READ statements you used.
My main problem is that when I generate "input" without python and simply
write everything by opening the file manually in my editor and then execute
it with the same fortran code, I don't get any such strange errors and it
works perfectly fine. I am therefore, wondering if this has got to do
anything with python.
Dump the two files in hex format and compare them -- maybe the
line endings are coming up differently which sets things off... Or the
EOF is marked differently...

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.