Smart questions
Smart people
 Find A ForumFind An Expert
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Remember Me

Are you a
Computer / IT professional?
Join Tek-Tips now!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Just copy and paste the

#### Feedback

"...This is easily the most helpful website I've ever used, and this is the best forum with the quickest response time bar none...."

#### Geography

Where in the world do Tek-Tips members come from?

# Reading table input from a .txt file

 Forum Search FAQs Links Jobs Whitepapers MVPs
 bobbydrake (TechnicalUser) 12 Jun 12 4:34
 dear all,i have this problem inputing data. i have this following data:index i j value 1 1 2 2 2 1 3 10 3 2 3 10 4 2 4 5 5 3 4 6i need this data to read it in fortran and make it as a matrix a(i,j). 'i' mean the row of a matrix a, and 'j' column of matrix a. example, from index 1, it has to be a(1,2)=2 from the given data it will produces matrix:a=0 2 10 00 0 10 50 0 0 60 0 0 0 would you help me through this? :) many thanks before.
 FJacq (Programmer) 12 Jun 12 5:33
 melmacianalf (TechnicalUser) 12 Jun 12 5:39
Try something like this

#### CODE --> Fortran

implicit none
integer, parameter :: size_matrix = 4
integer :: stat
integer :: i, j, ind, val
integer :: matrix(size_matrix, size_matrix)

open(unit=100, file='input.dat')

matrix = 0
do
if (stat .ne. 0) exit
matrix(i,j) = val
enddo

do i = 1, size_matrix
print *, matrix(i,:)
enddo

close(100)

 bobbydrake (TechnicalUser) 12 Jun 12 6:03
 thx a million mel!it works for me, :)

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!