I have a test code here that does not work, as I suspect. I am using the gfortran compiler.
program test implicit none integer, allocatable, dimension(:) :: a integer, allocatable, dimension(:) :: b allocate(a(2)) allocate(b(4)) a = 1 b = 2 write(*,*) a write(*,*) ' ' write(*,*) b write(*,*) ' ' write(*,*) 'a size before', size(a) a = b a = 1 write(*,*) a write(*,*) ' ' write(*,*) b write(*,*) ' ' write(*,*) 'a size after', size(a) end program test
And I get the following output.
eleven
2 2 2 2
size up to 2
1 1 1 1
2 2 2 2
size after 4
Why am I not getting an error when assigning arrays of different dimensions? Why resized?
source share