Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

REALLOCATION OF TWO-DIMENSIONAL TABLE

Hi! I would appreciate very much if anybody could give me a hint on how to reallocate the two-dimensional table (integer and DP) in Fortran 90? Reallocation of one-dimensional tables I do by using the tools from Numerical Recipes. Thanks in advance for your help!

 

0 Kudos
1 Reply
Highlighted

program move_alloc_test

program move_alloc_test
    implicit none
    real(8), allocatable :: a(:,:),temp(:,:)
    integer :: x,y
    allocate(a(5,5))
    do y=1,ubound(a,2)
        do x=1,ubound(a,1)
            a(x,y) = x*100+y
        enddo
    enddo
    
    print *,size(a)
    print *,a
    ! increase size of each dimension of a
    allocate(temp(ubound(a,1)+2,ubound(a,2)+2))
    temp(1:ubound(a,1), 1:ubound(a,2)) = a
    temp(ubound(a,1)+1:, ubound(a,2)+1:) = 0.0
    call move_alloc(temp, a)
    print *,size(a)
    print *,a
    
end program move_alloc_test

Jim Dempsey

0 Kudos