Fortran DO loop syntax help

Fortran90 programming simple syntax understanding. I want to write a simple do loop which takes in a text file of integers (32 integers one after the other) and reads the integers 2 at a time. Any help on this?
do i = 1, 32 !Should I put in 64 and increment by 2 or...? 
		read(11,*) n
		print*, n
	 enddo

Open in new window


Ultimately I want to take two of those integers and multiply them with a 2x2 matrix. On other words, the two integers being read in are like a 2x1 matrix. Help?
The attached text file includes the encryption matrix at the top, just ignore it. For now, I am just focusing on the integers that follow (starting with 1488 and below).

THqnks!
Cynthia JoubiAsked:
Who is Participating?
 
Bill PrewCommented:
Okay, see if this gives you the idea...

http://rextester.com/edit/WWXDZ90497


»bp
1
 
Bill PrewCommented:
I didn't see the sample file attached?


»bp
0
 
Bill PrewCommented:
Okay, not sure how your input is formatted, so I'll assume two values per line for now.  Here is a simple example of reading the 32 pairs of values into a 2 dimensional array in a loop, and inside the loop you can process each pair (I just printed them).

Depending on the input file you might want to read until end of file, etc, but it sounded like the input file might be more complicated so I didn't take that approach for now.

Here's a demo reading from STDIN that might give you an idea...



»bp
1
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Cynthia JoubiAuthor Commented:
Bill, please find the file attached. The file is actually quite simple.
Data3.txt
0
 
Cynthia JoubiAuthor Commented:
And I mentioned above, but you'll see when you open the text file, but it's 1 value per row to help clarify. Thanks!
0
 
Cynthia JoubiAuthor Commented:
Yes, thank you, this is what I was looking for. However, when I try to compile it on my terminal (using macOS) it is extremely slow. Any particular reason why?

And while I have you, do you mind giving some guidance on how to take these two integers (termed 'v' now I'm assuming) and multiply them to a matrix and have the product assigned as a new matrix. Do I need to allocate memory for the new matrix (i.e. taking a 2x2 * 2x1 = 2x1)?

Thank you for your help! I appreciate it!!
0
 
Bill PrewCommented:
I'm not a MacOS person, so can't speak to Fortran performance there, sorry.

As far as matrix multiplication, you should be able to use the intrinsic MATMUL() function.


»bp
0
 
Cynthia JoubiAuthor Commented:
Thank You for the explanation(s)! You helped with my problem!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.