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

problem with ifort 11.1

roddur
Beginner
748 Views
In an old code, while compiling correctly with ifort 9 and 10, giving problem with 11.x.
As is the output, we get, for 11.x,
[cpp]Fatal  : ALLOC : workspace overflow, need at least*********
Fatal  : ALLOC : workspace overflow, need at least*********

  total workspace size =  8000 K
  total space allocated=  1752 M
  workspace used:    max****** K   now****** K
  arrays defined:    max       9   now     9

 FEXIT :program aborted
[/cpp]
but for ifort 9.1.52, i have the correct result:
[cpp]total workspace size =  8000 K
  total space allocated=     0 M
  workspace used:    max    31 K   now    28 K
  arrays defined:    max      19   now    17

 FEXIT :LMINIT  [/cpp]
The full code is large enough to put it here. the corresponding subroutine is:
[cpp]      subroutine wkinit(wksize)
C- Simple FORTRAN dynamic memory allocation
C ----------------------------------------------------------------------
Ci Inputs:
Ci   wksize:maximum size of workfile
Ci   leng  :lenght of array to allocate (DEF..)
Ci   jprint:(WKPRNT)
Ci   lopt  :(WKSAV)
Ci   string:(WKCHK)
Co Outputs:
Co   ipname:offset of the integer array w   (DEF.. RLSE)
Co   lrest :number of words left in common pool (DEFASK)
Cr Remarks:
Cr   Memory is allocated from a single heap.  The heap is declared as
Cr   an integer array in common block W by the main program.  Its size
Cr   is fixed by the size of W as declared by the main program.  It
Cr   is possible to allocated memory from the top of the heap, and to
Cr   free memory already allocated from the top of the heap.  It is
Cr   not possible to free memory allocated from the middle of the heap.
Cr
Cr   To use these routines, first call WKINIT with NSIZE = size of W.
Cr
Cr   Character, integer, real, double precision, complex or double
Cr   complex arrays can then be allocated by calling DEFCH, DEFI,
Cr   DEFR, DEFDR, DEFC or DEFDC with an index IPNAME and LENGTH the
Cr   desired length.  IPNAME is returned as the effective offset of
Cr   the integer array W.  If it is desired that the array be
Cr   initialized to zero, pass LENGTH as the negative of the desired
Cr   length.
Cr
Cr   Allocated memory can be freed by calling RLSE(IPNAME) where
Cr   IPNAME must one of the indices from a previous allocation.  All
Cr   blocks of memory allocated after IPNAME are also released.
Cr
Cr   WKPRNT turns on or off a trace that prints a message each time
Cr          memory is allocated or released.  Also when turned on,
Cr          runs through links each time RLSE is called.
Cr   DEFASK returns the amount of memory remaining in the pool
Cr   WKSAV  sets an internal switch so that a heap allocation request
Cr          returns the negative of length of the request in IPNAME
Cr          when not enough memory is available, rather than aborting.
Cr          In this case, no memory is allocated and no other internal
Cr          parameters are changed.
Cr   WKINFO prints information about the arrays allocated
Cr   WKCHK  runs through links to see if any array was overwritten
Cr          call wkchk(string), where string terminated by '$'
C ----------------------------------------------------------------------
      implicit none
C Passed variables:
      integer ipname,leng,lrest,jprint,wksize
      logical lopt
      character*(*) string
C Local variables:
      integer chrpos,i,i1mach,ip0,ipfree,ipmax,iprint,ipx,ipy,irnd,isig,
     .        j,jopt,jpr,length,lunit,ndefd,ndefmx,ndfdmx,ndfsum,nsize
      parameter(ip0=5,ndefmx=100)
      character*72 messg1,messg2,messg3,messg4
      logical lerr
C Common blocks:
C --- dynamical memory allocation:
      integer w(1)
      common/wkarr/w
C Save statement:
      save ipfree,ipmax,jpr,lerr,ndfdmx,ndfsum,nsize
C External calls:
      external ainit,chrpos,dinit,errmsg,i1mach,iinit,iprint,lunit
C Intrinsic functions:
      intrinsic iabs,isign,max0
C Statement functions:
      irnd(i) = (i+499)/1000

C --- DEFINE STORAGE SIZE ------
C --- START OF FIRST ARRAY AND MAX NUMBER TO BE DEFINED:
      ipfree = 5
      ipmax  = 0
      jpr    = 0
      lerr   = .false.
      ndfdmx = 0
      ndfsum = 0
      nsize  = wksize
      return

      entry wkprnt(jprint)
C --- Set debug switch for heap management
      if (jprint.eq.2) then
        jpr = 1-jpr
      else
        jpr = jprint
      endif
      write(lunit(1),307)jpr
      return

      entry wksav(lopt)
      lerr = lopt
      return

      entry defask(lrest)
C---- Return number of words left in common pool
      lrest = nsize - ipfree - 2
      if (jpr .gt. 0) write(lunit(1),306) lrest
      return

C --- SUBROUTINES TO DEFINE ARRAYS OF VARIOUS TYPES
      entry defi(ipname,leng)
C --- Allocate integer array
      length = leng
      jopt = 1
      goto 10

      entry defr(ipname,leng)
C --- Allocate single precision real array
      length = leng*i1mach(17)
      jopt = 2
      goto 10

      entry defrr(ipname,leng)
      entry defdr(ipname,leng)
C --- Allocate double precision real array
      length = leng*i1mach(18)
      jopt = 3
      goto 10

      entry defc(ipname,leng)
C --- Allocate single precision complex array
      length = leng*2*i1mach(17)
      jopt = 4
      goto 10

      entry defcc(ipname,leng)
      entry defdc(ipname,leng)
C --- Allocate double precision complex array
      length = leng*2*i1mach(18)
      jopt = 5
      goto 10

      entry defl(ipname,leng)
C --- Allocate logical array
      length = leng
      jopt = 6
      goto 10

      entry defch(ipname,leng)
C --- Allocate character array
      length = (leng+3)/i1mach(6)
      jopt = 7
      goto 10

   10 isig = isign(1,length)
      length = max0(iabs(-length),1)
      ndefd = 0
      ipy = 0
      ipx = ip0
      do while (ndefd.lt.ndefmx.and.ipx.ne.ipfree)
        if (ipx .lt. ip0 .or. ipx .gt. nsize) then
          write(messg1,400) ndefd,ipx,ipy
          call errmsg(messg1,4)
        endif
        ndefd = ndefd + 1
        ipy = ipx - 1
        ipx = w(ipy)
      enddo
      ipname = ipfree
      if (lerr .and. ipfree+length+2 .gt. nsize) then
        ipname = -length
        if (jpr .gt. 0)  write(lunit(2),404)-length
        return
      endif
      ipfree = ipfree + length + 1
      ipfree = 4*((ipfree+2)/4)+1
      ipmax = max0(ipmax,ipfree)
      w(ipname-1)=ipfree
      ndefd = ndefd + 1
      ndfdmx = max0(ndfdmx,ndefd)
      ndfsum = ndfsum + length
      if (jpr.gt.0) write(lunit(1),301)ndefd,leng,length,ipname,ipfree-1
      if (ipfree .gt. nsize) then
        write(messg2,401) ipfree
        call errmsg(messg2,4)
      endif
      if (isig .ne. 1) then
        if (jopt.eq.1) call iinit(w(ipname),-leng)
        if (jopt.eq.2) call ainit(w(ipname),-leng)
        if (jopt.eq.3) call dinit(w(ipname),-leng)
        if (jopt.eq.4) call ainit(w(ipname),-2*leng)
        if (jopt.eq.5) call dinit(w(ipname),-2*leng)
        if (jopt.eq.6) call linit(w(ipname),-leng)
        if (jopt.eq.7) call chinit(w(ipname),-leng)
      endif
      return

      entry rlse(ipname)
C---- Release data up to pointer
      if (ipname .gt. nsize) then
        write(messg3,402)
        call errmsg(messg3,4)
      endif
      if (ipname .lt. 3) then
        write(messg4,403)
        call errmsg(messg4,4)
      endif
      ndefd = 0
      ipy = 0
      ipx = ip0
      do while (ndefd.lt.ndefmx.and.ipx.ne.ipfree)
        if (ipx .lt. ip0 .or. ipx .gt. nsize) then
          write(messg1,400) ndefd,ipx,ipy
          call errmsg(messg1,4)
        endif
        ndefd = ndefd + 1
        ipy = ipx - 1
        ipx = w(ipy)
      enddo
      if (jpr.ne.0) write(lunit(1),308)ipname
      ipfree = ipname
      return

      entry wkinfo()
C---- Output workspace information
      ndefd = 0
      ipy = 0
      ipx = ip0
      if (jpr .gt. 0) write(lunit(1),303)
      do while (ndefd.lt.ndefmx.and.ipx.ne.ipfree)
        if (ipx .lt. ip0 .or. ipx .gt. nsize) then
          write(messg1,400) ndefd,ipx,ipy
          stop
        endif
        ndefd = ndefd + 1
        ipy = ipx - 1
        ipx = w(ipy)
        if (jpr.gt.0) write(lunit(1),'(4(i6,5x))')ndefd,ipy,ipx,ipx-ipy
      enddo
      write(lunit(1),302) irnd(nsize),irnd(irnd(ndfsum)),irnd(ipmax-1),
     .                    irnd(ipfree-1),ndfdmx,ndefd
      return

      entry wkchk(string)
C --- Run through links to see if any dynamic array was overwritten
      i=chrpos(string,'$',1,60)
      write(lunit(1),304)string(1:i-1)
      ndefd = 0
      ipy = 0
      ipx = ip0
      do while (ndefd.lt.ndefmx.and.ipx.ne.ipfree)
        if (ipx.lt.ip0 .or. ipx.gt.nsize) then
          write(messg1,400) ndefd,ipx,ipy
          call errmsg(messg1,4)
        endif
        ndefd = ndefd + 1
        ipy = ipx - 1
        ipx = w(ipy)
      enddo
      write(lunit(1),305) ndefd,ipfree-1
      return


300   format( ' WKINIT:  size=',i5,'K'/)
301   format( ' define array',i4,': leng=',i7,'  length=',i7,',',i8,
     .        ' to',i8)
302   format(/'  total workspace size =',i6,' K',
     .       /'  total space allocated=',i6,' M',
     .       /'  workspace used:    max',i6,' K   now',i6,' K',
     .       /'  arrays defined:    max',i8,  '   now',i6)
303   format(/'  array',6x,'begin',7x,'end',7x,'length')
304   format( ' WKCHK : ',60a1)
305   format( ' WKCHK : LINKS OK   NDEFD=',i3,'   SPACE USED=',i7)
306   format(/' DEFASK: SPACE LEFT',i8,' SINGLE WORDS')
307   format(/' WKPRNT: JPR=',i2)
308   format( ' RLSE  : released from: ',i7)

400   format(' ALLOC : link destroyed at start of array',i3,',  ptr=',
     .       i8,' at',i8,'$')
401   format(' ALLOC : workspace overflow, need at least',i9,'$')
402   format(' RLSE  : release pointer exceeds limit.$')
403   format(' RLSE  : release pointer less than 3.$')
404   format(' ALLOC : heap storage exceeded; returning -LENGTH=',
     .       i8,'$')
      end
[/cpp]
can you plz comment on this?
0 Kudos
5 Replies
roddur
Beginner
748 Views
Since no one is replying, is this a bug or what?
0 Kudos
Steven_L_Intel1
Employee
748 Views
Quoting - roddur
Since no one is replying, is this a bug or what?
What investigation have you done? Have you run this in the debugger to see where things start to diverge? You have provided only part of the application, so others can't even try it for themselves.

When you have found the point of divergence, and then investigated to see if perhaps you have a coding error, post again.
0 Kudos
joseph-krahn
New Contributor I
748 Views
It looks like you are getting a huge number somewhere. It may have nothing to do with the routine you posted. You need to check the sizes passed to this routine, and if the function I1MACH is giving the right size values. I would also cautios of accidentally getting 32-bit and 64-bit numbers mixed somewhere. Is the ifort 11.1 version getting compiled on a 64-bit machine? If you are compiling with -i8 to get 64-bit default integers, those MAX0() specific functions might be a problem. Try changed then to the generic MAX().
0 Kudos
roddur
Beginner
748 Views
What investigation have you done? Have you run this in the debugger to see where things start to diverge? You have provided only part of the application, so others can't even try it for themselves.

When you have found the point of divergence, and then investigated to see if perhaps you have a coding error, post again.
Dear Steve,
I know this shortcoming of my post, but this is a std. package and used to run well under ifort11.0. by the way, i compiled it with
ifort -g -c -O2 -w
and the got the result:
$ gdb ../lminit.run
GNU gdb (GDB) Fedora (6.8.50.20090302-33.fc11)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i586-redhat-linux-gnu".
For bug reporting instructions, please see:
<>...
(gdb) run
Starting program: /home/rudra/Recursion/lmto-try/LMTO_A/lminit.run
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address
warning: difference appears to be caused by prelink, adjusting expectations

Space group: Im-3m No.:229
Crystal system: cubic
Generators: I R4X R3D

CTRLUC: PLAT ALAT= 5.98099
-0.50000 0.50000 0.50000
0.50000 -0.50000 0.50000
0.50000 0.50000 -0.50000


Fatal : ALLOC : workspace overflow, need at least*********
Fatal : ALLOC : workspace overflow, need at least*********

total workspace size = 8000 K
total space allocated= 1750 M
workspace used: max****** K now****** K
arrays defined: max 9 now 9

FEXIT :program aborted


Program exited normally.
Missing separate debuginfos, use: debuginfo-install glibc-2.10.1-2.i686 libgcc-4.4.0-4.i586
(gdb)

plz tell me how to proceed.

0 Kudos
Steven_L_Intel1
Employee
748 Views
Sorry, but just because the program worked before, that doesn't mean it is error-free. You need to run the program under control of the debugger and determine at which point something goes wrong. We can't tell you what to do based on output from a partial program. It should be easy enough to step through the code that comes up with the values displayed and see where they come from.

Since you are using ENTRY, be very sure that you do not reference dummy arguments that were not in the list for the entry point through which you entered.
0 Kudos
Reply