nums(2:4) selects three elements as a new array. Slices participate in whole-array operations.

Program

Play the program to take a middle slice and sum it.

array_slice.f90
program array_slice
    implicit none
    integer :: nums(6)
    integer :: middle(3)
    nums = [10, 20, 30, 40, 50, 60]
    middle = nums(2:4)
    print '(I0)', sum(middle)
end program array_slice
slice `nums(2:4)` selects elements 2, 3, and 4.
range syntax `first:last` is a contiguous slice.
assignment Array assignment copies element-wise into a same-shape target.