when have an array of the type [-4:8], how many elements make up the array? a little bit confuse when calculating the number of elements of this type. thanks for assistance
how to calculate elements in an array!
23 Mar 2012 9:59
#9890
23 Mar 2012 12:24
#9893
-4 -3 -2 -1 0 1 2 3 4 5 6 7 8
=13
31 Mar 2012 4:39
#9930
In the following example, it shows there are 13x2 elements in either array, but the size of each element depends on what it is defined. Size does not return the upper limit of the array.
TYPE ACTIVE_DAY_RECORD
integer*2 trains
integer*2 ships
integer*2 movements
END TYPE ACTIVE_DAY_RECORD
!
type (active_day_Record), parameter :: active_day_zero = active_day_record (0, 0, 0)
!
type (active_day_record) active_days(-4:8,2)
integer*4 aa(-4:8,2)
!
aa = 0
active_days = active_day_zero
!
write (*,*) 'size aa ', size (aa,1), size(aa)
write (*,*) 'size active_days ', size (active_days,1), size (active_days)
!
end
Please login to reply.