Fortran Fortran Transpose: Transform a 4D Array into 2D

  • Thread starter Thread starter Milentije
  • Start date Start date
  • Tags Tags
    Fortran Transpose
AI Thread Summary
The discussion centers around the challenges of transposing a four-dimensional array in Fortran 90, specifically the array zmdsens(iper,i,1,iprd), which stores Magnetotelluric (MT) functions related to conductivity across multiple periods and sites. The user seeks to transpose a matrix representing derivatives of MT functions but faces limitations since Fortran 90 only supports transposition for two-dimensional arrays. The conversation highlights confusion regarding the nature of the array and the concept of transposing a function. A proposed solution involves defining a three-dimensional array and using intrinsic transpose functions, but the user encounters an error related to array allocation. The discussion emphasizes the need for a method to convert a one-dimensional array into a two-dimensional format to utilize the transpose function effectively.
Milentije
Messages
47
Reaction score
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
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?
 
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.
 
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?
 
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))
------------------^
 
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...

Similar threads

Replies
4
Views
2K
Replies
8
Views
3K
Replies
2
Views
9K
Replies
10
Views
25K
Replies
8
Views
2K
Replies
2
Views
3K
Back
Top