program q7 implicit none interface subroutine display(n) integer,dimension(:)::n end subroutine logical function ok(n) integer,dimension(:)::n end function end interface integer,dimension(9)::x integer,dimension(6:10)::y integer::j,l,u do j = 1,9 x(j) = j end do l = lbound(x,1) u = ubound(x,1) call display(x) print*,l,u do j = 6,10 y(j) = j+10 end do l = lbound(y,1) u = ubound(y,1) print*,l,u y(7) = -1 call display(y) if (ok(x)) then print*,"x is ok" else print*,"x is not ok" end if if (ok(y)) then print*,"y is ok" else print*,"y is not ok" end if end program subroutine display(a) implicit none integer,dimension(:)::a integer::i do i = 1,size(a) print*,"a(",i,") =",a(i) end do end subroutine logical function ok(a) ! output condition: ok = all entries of a are non-negative implicit none integer,dimension(:)::a logical::ok_so_far integer::i ok_so_far = .true. do i = 1,size(a) if (a(i) < 0) ok_so_far = .false. end do ok = ok_so_far end function