Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

stack overflow even with allocatable array

$
0
0

I don't know why the following program throw overflow, since all the large arrays are dynamic, this is just an example, y = sum(u) works, but why partial sum does not work?

program test
    implicit none
    integer, parameter :: n = 1000000, m = 10
    real(8), allocatable, dimension(:,:) :: x
    real(8) :: y
    allocate(x(n,m))
    x = 1.0d0
    call tt(x,y,n,m)
    print *, y
end

subroutine tt(x,y,n,m)
    implicit none
    integer, intent(in) :: n, m
    real(8), intent(in), dimension(n,m) :: x
    real(8), intent(out) :: y
    real(8), allocatable, dimension(:) :: z
    real(8), allocatable, dimension(:,:) :: u
    allocate(z(n),u(n,m))
    u = exp(x)
    z = sum(u,2)

    y = sum(z)

    return
end

Many thanks


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>