Computing.Net > Forums > Programming > Fortran 77

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Fortran 77

Reply to Message Icon

Name: pball
Date: August 28, 2008 at 14:15:50 Pacific
OS: XP Pro
CPU/Ram: 2.8 ghz / 2 gig
Product: home made
Comment:

First of all are there any Fortran programmers out there?

If so I'd like some help with reading data from a file and then using it in a program.

I have a txt file with numbers in it, one per line. I would like to be able to read that into an array. I've been teaching myself Fortran and found an example where there is a do loop which will read each line until there are no lines left to read from the file.

I wasn't able to copy that and make it work. So any help would be appreciated.

P.S. I'm only learning Fortran since my engineering company has some stuff in it and me being the co-op, I have to add stuff and make it work.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 28, 2008 at 14:28:05 Pacific
Reply:

"I wasn't able to copy that and make it work."

Maybe not a great example.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: pball
Date: August 28, 2008 at 15:28:02 Pacific
Reply:

I guess your right but I'm thinking it's more the read statement that was used.

I think I might have found somthing to help out. Tomorrow at work I'm gonna have to try and format the the list to be inputed and then use format for the reading part too.

best guess i have


0

Response Number 3
Name: pball
Date: August 29, 2008 at 04:49:39 Pacific
Reply:

Yay I got it on my own. I just had to format the file i was inputting and the read statement that was reading the file.

My input file is made using this format
write (7,fmt='(1x, I12)') p
which places the 1's digit in the 12th column.

This read statement will read the first 100 lines and store them in an array called ar

do 110 i= 1, 100
read(unit=1,fmt='(1x, I12)', end=150) ar(i)
110 continue
150 continue

If only I could figure out batch scripting this easy.
Now I just have to make the rest of the program work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Fortran 77

Fortran 77 Mac toolbox problem www.computing.net/answers/programming/fortran-77-mac-toolbox-problem/757.html

can FORTRAN work with large numbers? www.computing.net/answers/programming/can-fortran-work-with-large-numbers/1140.html

Converting Fortran 4 to Fortran 90 www.computing.net/answers/programming/converting-fortran-4-to-fortran-90/9855.html