Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussões

Is this is bug? Error: Invalid signal or error

billpeace
Principiante
1.938 Visualizações

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 Respostas
mecej4
Colaborador honorário III
1.938 Visualizações

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.

Les_Neilson
Contribuidor valorado II
1.938 Visualizações

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

Steven_L_Intel1
Funcionário
1.938 Visualizações

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.

Responder