forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Allocated array is smaller than requested size

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Sep 26, 2020 4:02 am    Post subject: Allocated array is smaller than requested size Reply with quote

The following stripped down program exhibits peculiar behavior when compiled with FTN95 8.65, with /64 and either /check or /checkmate. No error is seen when the test program is compiled with /64 /debug.

The size of the allocated array is 40, which is a fraction of the requested size, 130, even though there was no detected error when the ALLOCATE statement was executed (i.e., ISTAT was 0).

In the real program where this error was first encountered, the failure occurred with an array subscript bound error in another subroutine where the allocated array was accessed and the program had been compiled with /64 /check.

Code:
module globals
   implicit none
   integer, parameter :: double=kind(0.0d0)
end module globals

Program main
   use globals, only : double
   Implicit None
   Integer :: nf
   Integer :: i
   Real (double), Dimension (10) :: x = [(-1d0,1d0, i = 1,5)]
!
   nf = 10
   Call plisu (nf, x)
   Stop
End Program main

Subroutine plisu(NF,X)
   use globals, only : double
   implicit none
   integer  ::  NF, istat
   real(double), dimension(*)  ::  X
   integer  ::  lgf, ls, lxo, mf, lRA
   real(double), allocatable, dimension(:)  ::  ra
   mf = 5
   lRA = 2*NF+2*NF*mf+2*mf
   print *,'NF, MF, reqd. size = ',nf,mf,lRA
   allocate (ra(2*NF+2*NF*mf+2*mf), stat=istat)   ! <<<=== Problem?
   if (istat /= 0)stop 'Error allocating RA'
   print *,'Size (Ra) = ',size(ra)
   if (size(ra) /= lRA)stop 'Error in allocated size of RA'
   lgf = 1
   ls = lgf + NF
   lxo = ls + NF
   call plis(NF, X, ra(lgf), ra(ls), ra(lxo))
   deallocate (ra)
   return
end subroutine plisu
   
Subroutine plis(NF,X,GF,S,XO)
   use globals, only : double
   implicit none
   integer  ::  NF
   real(double), dimension(*)  ::  X, GF, S, XO
   print *,'PLIS Entered'
   Return
end subroutine plis


The output when the program is compiled with version 8.65, with /64 /check:

Code:
R:\MATH\LUKSAN\PLIS>tlisu
 NF, MF, reqd. size =           10           5         130
 Size (Ra) =                    40
**** STOP: Error in allocated size of RA


Last edited by mecej4 on Sat Sep 26, 2020 8:44 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Sep 26, 2020 7:56 am    Post subject: Reply with quote

mecej4

Many thanks for the feedback. Your help is much appreciated.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Sep 29, 2020 11:09 am    Post subject: Reply with quote

This failure has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group