module funciones implicit none real, parameter :: PI = 4 * atan (1.) contains real function f(x) real, intent (in) :: x if (x <= -(PI/2)) then f = -1 if (x < PI/2) then f = cos (x) else f = 0 end if end function end module program Hito5integral use funciones implicit none real, allocatable :: x(:) , y(:) real :: a, b, dx integer :: N, i a = -2 * PI b = PI N = 10 dx = (b-a)/N x = [(a + i * dx , i = 0 , N)] do i = 0 , N y(i) = F (x(i)) end do write (*,*) 'Suma=' , dx * sum (y) end program