real, dimension(3), parameter :: boxlen = [4.0, 5.0, 7.0]
real, parameter :: mindist = 0.1
integer ::i
write(*,"(A)") "Operation on array"
print*, floor(boxlen/mindist)
write(*,"(/A)") "Operation on individual elements"
do i=1,3
print*, i, floor(boxlen(i)/mindist)
enddo
This is what I get when I run this code.
Operation on array
40 50 70
Operation on individual elements
1 39
2 49
3 69
Can someone explain why are the two calculations (one using operation on array and another using operation on individual elements) giving different results? I think they should be same.