Fortran Creating 2-d array from a text file in fortran

AI Thread Summary
To read a text file containing pairs of values into an array in Fortran, begin by declaring array variables that can hold the expected data. Open the file using the appropriate Fortran file handling commands. Implement a do-loop to iterate through the file, reading each pair of values and storing them in the array using the loop index. This approach encourages experimentation with coding, emphasizing that trying out code is a safe and beneficial practice in software development.
tcmoore3
Messages
1
Reaction score
0
I have a text file of the format

x1 y1
x2 y2
. .
. .
. .

I need to read this into an array. How is this done in Fortran?
 
Technology news on Phys.org
you start by declaring a couple of array variables long enough to accommodate your values.
then, you open the file
write a do-loop
read values into array with the loop variable as the index


If I tell you more, I will be writing more than what it takes to simply write the code and give it to you.

with those hints, go ahead and take a shot at it, don't be shy, write some code and see what happens...you are not going to break anything nor set the room on fire or anything...that's what so wonderful about software!
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
2
Views
1K
Replies
25
Views
3K
Replies
12
Views
3K
Replies
1
Views
3K
Replies
33
Views
5K
Replies
5
Views
5K
Replies
19
Views
6K
Back
Top