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

  • Context: Fortran 
  • Thread starter Thread starter scorzolin
  • Start date Start date
  • Tags Tags
    Fortran Programming
Click For Summary
SUMMARY

The discussion centers on the storage of numbers in the F2 and F3 matrices in Fortran programming, specifically using the line of code "read(77, '(4I3)') F2,F3". The matrices are defined as F2(4,6,2) and F3(5,7,2), and the file contains 118 numbers formatted in a specific way. The user correctly interprets the storage of the first few numbers in F2, confirming that F2(1,1,1) through F2(4,2,1) correspond to the first 8 numbers in the file. The suggestion to run the program for verification is a practical approach to confirm the matrix population.

PREREQUISITES
  • Understanding of Fortran programming syntax
  • Knowledge of multi-dimensional arrays in Fortran
  • Familiarity with file I/O operations in Fortran
  • Basic understanding of data formatting (e.g., I/O formats like '(4I3)')
NEXT STEPS
  • Explore Fortran array indexing and memory layout
  • Learn about Fortran file handling and I/O operations
  • Investigate the implications of data types in Fortran
  • Practice reading and writing multi-dimensional arrays in Fortran
USEFUL FOR

This discussion is beneficial for Fortran programmers, students learning about multi-dimensional arrays, and anyone involved in numerical computing or data processing in Fortran.

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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
18K
Replies
6
Views
6K
  • · Replies 11 ·
Replies
11
Views
5K