Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

Is this is bug? Error: Invalid signal or error

billpeace
Beginner
1,962 Views

Program Test
    implicit none
  INTEGER, PARAMETER :: dble = SELECTED_REAL_KIND(P=10,R=50)
  INTEGER, PARAMETER :: sngl = SELECTED_REAL_KIND(P=5)
  REAL (KIND = dble), ALLOCATABLE, DIMENSION(:), TARGET  ::  wk3 , wk10,rsb0
  REAL (KIND = dble), DIMENSION(:), POINTER :: cpmu,rhocp,rsn
   INTEGER  err
   INTEGER  mswk10,mswk3,mst,ncomp,mstart
   integer m221,mrrb,msn,m
    REAL (KIND=dble)::result11

      mswk10=20352600
      mswk3=70480200
      mst=6784000
      ncomp=2
      mstart=1
     ALLOCATE(wk10(mswk10),wk3 (mswk3 ), STAT = err )
     ALLOCATE (rsb0(mst*ncomp), STAT = err )
    
       rhocp    => wk10(1:mst) 
       cpmu     => wk3(1:mst) 
       rsn      => rsb0( mstart:mst*ncomp )

       m221=37
       mrrb=mst-200
       msn=0
       cpmu=10104414.9170140
       rsn=1.138435243319734D-003

       rhocp(m221:mrrb) = rhocp(m221:mrrb) + cpmu(m221:mrrb)*rsn(m221+msn:mrrb+msn)
       !DO m = m221, mrrb
       !    rhocp(m) = rhocp(m) + cpmu(m)*rsn(m+msn)
       !ENDDO
       !  DO m = m221, mrrb
       !ENDDO
       DO m = m221, mrrb
           result11 =result11+ rhocp(m)
       ENDDO
       write(*,*)result11
end program Test

 

when mst =67840 or 678400  the calculation is correct.

if  mst =678400  there was an error :Program Exception - stack overflow

But if I use gfortran compile and run, there was no error

 

0 Kudos
3 Replies
mecej4
Honored Contributor III
1,962 Views

There is no bug here. Copying/assigning large array sections consumes stack space, for which provision must be made.

Your program runs correctly if you use either the /link /stack:0x4000000 option or the -heap-arrays:10000 option.

0 Kudos
Les_Neilson
Valued Contributor II
1,962 Views

A style comment: (In a small example such as this) it may not be totally necessary but I always have one Allocate statement per array.

And I always check the status. You have not checked the allocation status. It may be just a precaution but I think it is a good habit to develop.

Les

0 Kudos
Steven_L_Intel1
Employee
1,962 Views

Don't bother using a number with -heap-arrays. It doesn't do anything useful. Just say -heap-arrays. If you are doing this in Visual Studio, though, you must put in 0 under Fortran > Optimization > Heap Arrays.

0 Kudos
Reply