I am struggling with use of ALLOCATE with /check and this error is stumping me. I have done a lot of software development lately, using ALLOCATE, to make the program more flexible for problem size and memory size. I have returned to an old program and am trying to check code, so selectively compile some routines with /check, mainly for argument and bounds checking. The following snippet of code uses /check, while most libaray routines use /opt, /debug or no option
INTEGER*4 MULC, MUM_FEM, L3, L4, L5, L6, L7, Le, P_end, stat
!
real*8, allocatable, dimension(:,:) :: EPROP
real*8, allocatable, dimension(:,:) :: COPROP
!
! read and save beam element info
!
call check_allocate ( 'at entry to BEAM' )
!
IF (NUM_MAT <= 0) NUM_MAT = 1
Le = (L6+15*NUME)*4 + (L3+L4+L5+L7+NUME)*8
call allocate_report (le)
stat = 0
!
call check_allocate ( 'about to allocate EPROP' )
!
ALLOCATE ( EPROP(4,NUM_MAT), stat=stat ) ; call alloc_test (stat, 'EPROP(4,NUM_MAT)', 4,NUM_MAT)
The resulting report is: Checking if ALLOCATE is working at entry to BEAM Allocate target = 0.989 mb Check of ALLOCATE completed Allocate target = 0.010 mb Checking if ALLOCATE is working about to allocate EPROP Allocate target = 0.989 mb Check of ALLOCATE completed Error allocating EPROP(4,NUM_MAT) : stat = 1 dimensions are 4 1
My called library routines are:
subroutine alloc_test (stat, array, n1,n2)
integer*4 stat, n1,n2
character *(*) array
!
if ( stat == 0) return
write (*,*) 'Error allocating ',array,' : stat =',stat
write (*,*) 'dimensions are',n1,n2
stop
end subroutine alloc_test
subroutine check_allocate (from)
!
! This routine allocates a 1mb array to check that ALLOCATE works
!
character from*(*)
integer*4 :: n = 360
real*8, allocatable, dimension(:,:) :: EPROP
real*8, allocatable, dimension(:,:) :: aa
integer*4 stat, le, num_mat
!
write (*,*) 'Checking if ALLOCATE is working ', from
NUM_MAT = 1
Le = (n*n + 4*NUM_MAT)*8
call allocate_report (le)
!
ALLOCATE ( EPROP(4,NUM_MAT), stat=stat ) ; call alloc_test (stat, 'EPROP(4,NUM_MAT)', 4,NUM_MAT)
ALLOCATE ( aa(n,n), stat=stat ) ; call alloc_test (stat, 'aa(n,n)', n,n)
!
DEALLOCATE ( aa )
DEALLOCATE ( EPROP )
write (*,*) 'Check of ALLOCATE completed'
!
end subroutine check_allocate
The program is failing trying to allocate an array of 32 bytes, when use of ALLOCATE outside the routine compiled with /check are ok. Is this a known problem ?
I am using FTN95/Win32 Ver. 7.10.0
John