Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

need help with read end-of-line error

sjmyers
Beginner
1,183 Views

Hi all,

I'm an ecologist who dabbles in programming for various projects. I am currently using intel visual fortran within visual studio 2005. Previously, I used lahey essential fortran for various tasks. I migrated to intel visual fortran because 1) it's compatible with vista and 2) compaq visual fortran can read binary files from my favorite geographic information system software (IDRISI) and I was hoping the intel version could as well. To get started, I've tried to read in a binary file from IDRISI (extension is .rst) which is a 2D array representing geographic space as seen from satellite. My only objective was to read in the file and then write it to another file of the same type and then see if this file displayed within IDRISI. The read-in file was integer data type and 5,003 rows by 5,458 columns. Everything works fine as long as Ionly readand write to the other file a portion of the original. For instance, if I only read in the first 1,000 rows and 1,000 columns the program executes properly. If I attempt to read in everything, I get an error that I have reached the end of the line for the read file. Ireduced the size of the read in file to 1,000 rows by 1,000 columns and tried to readand write the whole array.I got the same error. If I read only a portion of this, let's say 100 rows and 100 columns then everything works properly. I am not a computer scientist and my needs are meager. Most ofmy time isspent crafting algorithms with the numbersonce I have access to them. Can anyone point me in theright direction forfixing this problem? Thanks, Seth

0 Kudos
4 Replies
DavidWhite
Valued Contributor II
1,183 Views

Seth,

can you post the lines of code for the file open and for the reads?

Thanks,

David

0 Kudos
sjmyers
Beginner
1,183 Views
Hi David,
Thanks for the quick reply. I found the error. I wasn't specifying the integer kind correctly. I was calling it kind=8 and found through trial and error it should be kind = 2. So, I figured out sequential read and write with binary. Now, I'm working on direct access. The stumbling block, I think, is that I don't know how to properly determine the record length to specify in the open statements. The array is very large. Do I need to say how long it is (5,003 X 5,458)? Here's the code I'm working on right now. What is shown as a 2D array in IDRISI (once you tell it row and column number) is actually a 1D vector. So, I'm trying to use the S variable to increment a counter to specify the rec in the read/write statements. Right now, I'm leaving that as is and playingwith the record length. Any help is greatly appreciated!-Seth
ps trying to post code properly, tried to paste below and didn't work
0 Kudos
sjmyers
Beginner
1,183 Views

hope this works

0 Kudos
DavidWhite
Valued Contributor II
1,183 Views

Seth,

Do you plan to do any operations on the data, or just create a new file? If you are creating a new file which contains all of the data in the original, why not use SYSTEMQQ and run a copy command to create the new file? This would be much quicker than reading and writing byte by byte.

David

0 Kudos
Reply