sending part of array to subroutine in fortran -segmentation error only for ifort compiler

sending part of array to subroutine in fortran -segmentation error only for ifort compiler

I have written the Test code

      program test
      integer n,i
      parameter (n=10000)
      REAL a(n,n),b(n),c(n)
      a(1:n,1:n) = 0.0
      read(*,*)i
      call partarray(i,a(1:i,1:i))
      end

      subroutine partarray(I,a)
      integer i
      real a(i,i)
      write(*,*)"i",i
      write(*,*)"Reached the end of part array subroutine"
      return
      end

which works completely fine in gfortran. But ifort compiler throws segmentation error for i value in the range 1445 to 9999.

Any help in this regard will be greatly appreciated

4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Your program would allocate storage for the array section, and might work better with -heap-arrays or with an increase in stack limit.  gfortran probably uses heap automatically, seeing that the array is large.

Thanks for your relpy TimP.

The same program works for the particular value i=10000 but not say 9999(1444< i <1000). what can u comment about this. will the usage of any compiler flag help?

The way your program is coded, partarray requires a to be a contiguous block of memory of shape a(i,i). The generated code therefor must produce a temporary from the outer scoped array a(n,n). You have 3 ways to fix your code

a) increase stack (should you have large temps allocate from stack)
b) use heap arrays
c) declare an interface to partarray and in partarray use "real a(:,:)" (with interface reflecting this change)

Jim Dempsey

www.quickthreadprogramming.com

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui