Link to home
Start Free TrialLog in
Avatar of Cynthia Joubi
Cynthia Joubi

asked on

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!
Avatar of Bill Prew
Bill Prew

I didn't see the sample file attached?


»bp
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cynthia Joubi

ASKER

Bill, please find the file attached. The file is actually quite simple.
Data3.txt
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!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!!
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
Thank You for the explanation(s)! You helped with my problem!