program smpl8 real x,t,v1,v2 integer, parameter :: n = 5 real, dimension(n) :: diff integer i 21 format(i4,' x=',f5.2,' tail=',f8.4) 22 format(2f12.6) do i = 1,n x = real(i) t = func(x) ! logistic tail probs diff(i) = 1. - t write(6,21) i,x,t end do ! loop on i call norms(diff,n,v1,v2) write(6,22) v1,v2 stop end program smpl8 real function func(z) ! note dummy name implicit none real, intent(in) :: z ! declares variable as input only func = 1. - 1./(1. + exp(-z) ) ! NOT a good way to do it return end function func subroutine norms(x,m,l1,l2) ! dummy names integer, intent(in) :: m ! input only real, intent(out) :: l1,l2 ! output only real, dimension(m) :: x ! variable dimension -- one way l1 = 0. l2 = 0. do i = 1,m l1 = l1 + abs(x(i)) l2 = l2 + x(i)*x(i) end do ! loop on i l2 = sqrt(l2) return end subroutine norms