Fortran Transpose: Transform a 4D Array into 2D

In summary: Error stalling program io_test. In summary, the problem is that I can't find the transpose of an MT function in a 2D array, and I need to do it in a different way.
  • #1
Milentije
48
0
Here is the problem.I have this array zmdsens(iper,i,1,iprd) where iper is period,i site,1 mt function and iprd conductivity.This array stores MT functions for all above mentioned.I need tot find transpose of MT function,but fortran 90 can easily do that only with 2dimensional arrays.How to transform this?
 
Technology news on Phys.org
  • #2
Milentije said:
Here is the problem.I have this array zmdsens(iper,i,1,iprd) where iper is period,i site,1 mt function and iprd conductivity.This array stores MT functions for all above mentioned.I need tot find transpose of MT function,but fortran 90 can easily do that only with 2dimensional arrays.How to transform this?
This doesn't make much sense. What you are describing as an array - zmdsens - looks like a function call or subroutine call to me.

What does it mean to take the transpose of a function?
What is an MT function?
 
  • #3
Well I will try to explain more.I have two-dimensional mesh,every cell has conductivity.On the surface I calculate MT functions with respect to conductivity.The reason why we store them in 4-dimensional array is that we measure MT for more periods and sites on the surface.I need transpose of matrix which represents derivatives of MT with respect to conductivity.FORTRAN 90 requires 2d array for such operation.
 
  • #4
For example we define a 3D array, like f(9, 9, 9). I think transpose f with the second index fixed would be: transpose( f ( :, 1, : ) ). Does this solve your problem?
 
  • #5
No actually I will try to cope in the different way.Still I have problems how to go from 1d to 2d array,then just use intrinsic transpose.
program io_test
real, dimension(:,:), allocatable :: x
real, dimension(:,:), allocatable :: y
integer :: n
open (unit=99, file='array.txt', status='old', action='read')
read(99, *), n
allocate(x(n))
read(99,*) x
write(*,*) x
y=transpose(x)
write(*,*)y
end
I get this:
ifort -c io.f
io.f(8): error #6792: The rank of the allocate-shape-spec-list differs from the rank of the allocate-object. [X]
allocate(x(n))
------------------^
 

1. What is Fortran Transpose?

Fortran Transpose is a function in the Fortran programming language that rearranges the elements of a multi-dimensional array into a different order. This allows for easier manipulation and analysis of data in the array.

2. How does Fortran Transpose work?

Fortran Transpose takes in a multi-dimensional array, such as a 4D array, and rearranges the elements according to a specified order. In the case of transforming a 4D array into a 2D array, the elements are rearranged in a way that combines the elements from the innermost dimensions into the rows of a 2D array.

3. Why would I use Fortran Transpose?

Fortran Transpose is useful for reorganizing data in multi-dimensional arrays to make it easier to work with. In the case of transforming a 4D array into a 2D array, it can help simplify data analysis and manipulation tasks.

4. Can Fortran Transpose handle arrays with more than 4 dimensions?

Yes, Fortran Transpose can handle arrays with any number of dimensions. However, the specific syntax for specifying the order of the dimensions may differ depending on the number of dimensions in the array.

5. Are there any limitations to using Fortran Transpose?

Fortran Transpose can only be used on arrays that have a fixed size and shape. It cannot be used on dynamic arrays or arrays with varying sizes. Additionally, the resulting array from the transpose must fit within the memory limits of the system.

Similar threads

  • Programming and Computer Science
Replies
15
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
8K
  • Programming and Computer Science
Replies
2
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • Programming and Computer Science
Replies
1
Views
932
  • Advanced Physics Homework Help
Replies
12
Views
2K
  • Programming and Computer Science
Replies
6
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
15
Views
7K
Back
Top