Silverfrost Forums

Welcome to our forums

Use of parameter in ALLOCATE produces ICE

4 May 2020 2:40 #25327

When allocating a large array, if the array size is an integer parameter, I get an ICE, but an integer variable works ok.

   PROGRAM monster_1
!
        integer*8, parameter :: four     = 12 ! 4
        integer*8, parameter :: thousand = 1000
        integer*8, parameter :: million  = thousand*thousand
        integer*8, parameter :: billion  = thousand*million
        INTEGER*8, PARAMETER :: fourgb   = four*billion
!
        INTEGER*1, allocatable :: i4gb(:)
        INTEGER*8 :: i8, step, fgb
        integer*4 :: astat, pass
        INTEGER*1 :: b
!
        call wait_for_response ( 'about to start - not allocated')
!
!        fgb = fourgb
!        allocate ( i4gb(fgb), stat=astat )       ! this works
        allocate ( i4gb(fourgb), stat=astat )      ! this produces ICE with Ver 8.62.0
        write (*,*) 'allocate ( i4gb(fourgb), stat=',astat
        call wait_for_response ( 'array allocated')
!
      do pass = 1,2
        if ( pass == 1 ) step = 500*million+3
        if ( pass == 2 ) step = 500*thousand+3
        write (*,fmt='(a,i0,a,i0)') 'Pass =',pass,' : Step = ',step
!
        b = 1
        DO i8 = 1,fourgb,step
           IF (b == 127) THEN
              b = 0
           ELSE
              b = b+1
           END IF
           i4gb(i8) = b
        END DO
        call wait_for_response ( 'initialised loop')
!
        DO i8 = 1,fourgb,step
           WRITE(*,*)i8,i4gb(i8)
        END DO
        call wait_for_response ( 'finished check')
!
      end do
!
   END PROGRAM monster_1

   subroutine wait_for_response (prompt)
      character prompt*(*), a
      write (*,*) prompt,' : Waiting ?'
      read (*,fmt='(a)') a
   end subroutine wait_for_response

Apart from the ICE, this example is interesting as it demonstrates that sparse use of a large array does not demand physical (possibly virtual) memory being allocated. The above array has a memory 'Comit' of 11.7 GB, but for pass=1 only uses 7Mb of working memory, for pass=2 only uses 126Mb of working memory and no working/physical memory is required at ALLOCATE.

This physical memory would be allocated as 4Kb pages so careful use of a large virtual array can work with much less physical memory. However, get it wrong or use array syntax, then everything will stop !

4 May 2020 8:23 #25328

This FTN95 failure has now been fixed for the next release.

Please login to reply.