c Program to take the sum of the members of a structure c to another array program double_array_sample1_ex2 implicit none c type Vector real*8 a, b, c, d, e, f, & g, h end type Vector c type(Vector), allocatable :: vec(:) real*8, allocatable :: r(:) integer i, k, n integer*8 time0, time1, dtime real*8 time c write(*,*)"Array size Elapsed time [sec]" do k=1,20 c Array size n = k * 2000000 c Allocation allocate(vec(n), r(n)) c Initialization do i=1,n vec(i)%a = 1d0 vec(i)%b = 1d0 vec(i)%c = 1d0 vec(i)%d = 1d0 vec(i)%e = 1d0 vec(i)%f = 1d0 vec(i)%g = 1d0 vec(i)%h = 1d0 end do c Start time call system_clock(time0) c Main calculation: find the sum of all members of vec do i=1,n r(i) = vec(i)%a + vec(i)%b + vec(i)%c + vec(i)%d & + vec(i)%e + vec(i)%f + vec(i)%g + vec(i)%h end do c Finish time call system_clock(time1, dtime) c Output time time = 1d0*(time1-time0)/dtime write(*,"(i11,f16.7)")n, time c Deallocation deallocate(vec, r) end do end program