Fortran How are numbers stored in F2 and F3 matrix in Fortran programming?

AI Thread Summary
The discussion centers on interpreting a Fortran code snippet that reads data into two matrices, F2 and F3, from a file containing 118 sequential numbers. The matrices are defined with dimensions F2(4,6,2) and F3(5,7,2). The user seeks clarification on how the numbers are stored within these matrices based on the provided input format, which consists of 30 lines of four numbers each, with the last line containing only two numbers. The user proposes a specific mapping of the numbers to the matrix indices and asks for confirmation of its accuracy. A suggestion is made to run the program and print the values to verify the proposed storage arrangement.
scorzolin
Messages
1
Reaction score
0
Hi all,
I'm stuck on a fortran line code where I have a doubt on its interpretation.

The line is the following:

-----------------------------------------
dimension F2(4,6,2), F3(5,7,2)

...

open(77,...)

read(77, '(4I3)') F2,F3
-----------------------------------------

the file contains 118 numbers in 30 lines of 4 numbers (the last line has only 2 numbers).

considering that the file contains the numbers from 1 to 118 in this way
001 002 003 004
005 006 007 008
...
117 118

how these numbers are stored in the F2 and F3 matrix?

I suppose they are stored in the following way
F2(1,1,1)= 001
F2(2,1,1)= 002
F2(3,1,1)= 003
F2(4,1,1)= 004
F2(1,2,1)= 005
F2(2,2,1)= 006
F2(3,2,1)= 007
F2(4,2,1)= 008
...
F3(1,1,1)= 049
...

Is it correct?

or, if NOT, where I'm wrong?

thank you in advance for the help!
 
Technology news on Phys.org
Well, since you know the order of the numbers in your input text file, you could simply run the program and print out the first few values to see if you are correct.
 
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...
Back
Top