Creating 2-d array from a text file in fortran

Click For Summary
SUMMARY

This discussion focuses on reading a two-dimensional array from a text file in Fortran. The process involves declaring array variables, opening the file, and utilizing a do-loop to read values into the array using the loop variable as the index. Participants emphasize the importance of hands-on coding and experimentation to understand the implementation fully.

PREREQUISITES
  • Fortran programming language basics
  • Understanding of array data structures
  • File I/O operations in Fortran
  • Control structures, specifically do-loops
NEXT STEPS
  • Explore Fortran array declaration and initialization techniques
  • Learn about Fortran file handling and the OPEN statement
  • Investigate the use of do-loops for iterative data processing in Fortran
  • Practice writing and debugging Fortran code to read from text files
USEFUL FOR

This discussion is beneficial for Fortran developers, students learning Fortran, and anyone interested in data manipulation and file handling in scientific computing.

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!
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 33 ·
2
Replies
33
Views
6K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 19 ·
Replies
19
Views
7K