Reading file error

S

satish

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: (e-mail address removed)
Mobile: 859-420-9890
 
D

Dennis Lee Bieber

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...

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top