2
votes

I'm allocating a (n×m) array in Fortran using allocate(a(n,m)). However, later on, I need it's transpose, but no longer the original, so I do a = transpose(a). However, this does not seem to change shape(a), which is still (n×m) instead of (m×n). Is there any way to update the shape of the allocated array, or do I need to allocate space for another array, put the transpose there, and then deallocate the original array?

1

1 Answers

4
votes

According to Fortran 2003 standard, when assigning to an allocatble array, if it is not allocated with the right shape, it should be reallocated automatically. If your compiler doesn't support this yet, you have to do that manually as you wrote. For Intel Fortran you have to explicitly enable this feature.