1 year ago

#340291

test-img

Fitch

Script is not Finding End of File from Data Input File

I hope this makes sense. I have a Python script that reads an input (created from csv with commmas stripped out) file of geographic coordinates and I get this error:

forrtl: severe (24): end of file during read. unit 23 file /home/filename

This seems to relate that the code was expecting an EOF in the input file but this was perhaps absent. Would someone be able to tell how I check for this in the input file and what keystroke(s) are required for an EOF and exactly where this is placed. this is an extract of the script that creates the file:

f = open(file_ls, "w")
#first line contains 3 integers: the grid dimension, nx and ny, and the total number of snapshots nt
print("%d %d %d" % (np.shape(kxx)[1], np.shape(kxx)[0],     collapse_steps), file(f))
# then it follows by the X coordinates of gridded data (from lines 2 to nx+1), Y coordinates of gridded data (from lines nx+1 to nx+ny+1), and the times at which the snapshots are created (from lines nx+ny+2 to nx+ny+nt+1)
for ii in np.arange(np.shape(kxx)[1]):
        print("%.8f" % (kxx[0, ii]), file(f))
# for ii in arrange(shape(kyy)[0]):
for ii in range(np.shape(kyy)[0] - 1, -1, -1):
print("%.8f" % (kyy[ii, 0]), file(f))
for ii in np.arange(collapse_steps):
mytime = collapse_times[ii] + collapse_starttime
print("%.8f" % mytime, file(f))

# all the nt snapshots of seafloor variation are written into a single column one by one from t=t1 to t=tn; for each snapshot, deltah, the data should be written row by row from the left (i=1) to the right (i=nx) from the bottom (j=1) to the top (j=nx)
# deltaH > 0 corresponds to UPLIFT
# deltaH < 0 corresponds to SUBSIDE

deltaH = elev_t0 - elev_t1
###### time - start of collapse => initial bath => zero difference ??? bit stupid ??? check w/comcot sources
for ii in np.arange(np.shape(elev_t1)[0]):
for jj in np.arange(np.shape(elev_t1)[1]):
    print("%.8f" % 0.0, file(f))

for ii in np.arange(np.shape(elev_t1)[0]):
for jj in np.arange(np.shape(elev_t1)[1]):
    print("%.8f" % (deltaH[ii, jj]), file(f))

f.close()

This is an extract of the input file from 1st line:

1488 903 2 3560181.70300000 3560191.70300000 3560201.70300000 3560211.70300000 3560221.70300000 3560231.70300000 3560241.70300000 3560251.70300000 3560261.70300000 3560271.70300000 3560281.70300000 3560291.70300000 3560301.70300000 3560311.70300000 3560321.70300000 3560331.70300000 3560341.70300000 3560351.70300000 3560361.70300000 3560371.70300000 3560381.70300000 3560391.70300000 3560401.70300000 3560411.70300000 3560421.70300000 3560431.70300000 3560441.70300000 3560451.70300000 3560461.70300000 3560471.70300000 3560481.70300000

python

csv

input

eof

keystroke

0 Answers

Your Answer

Accepted video resources