Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

REALLOCATION OF TWO-DIMENSIONAL TABLE

Zoran_A_
Beginner
300 Views

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
jimdempseyatthecove
Honored Contributor III
300 Views
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
Reply