1! { dg-do compile } 2! 3! PR fortran/48800 4! 5! Contributed by Daniel Carrera 6! 7 pure function runge_kutta_step(t, r_, dr, h) result(res) 8 real, intent(in) :: t, r_(:), h 9 real, dimension(:), allocatable :: k1, k2, k3, k4, res 10 integer :: N 11 12 interface 13 pure function dr(t, r_) ! { dg-error "cannot have a deferred shape" } 14 real, intent(in) :: t, r_(:) 15 real :: dr(:) 16 end function 17 end interface 18 19 N = size(r_) 20 allocate(k1(N),k2(N),k3(N),k4(N),res(N)) 21 22 k1 = dr(t, r_) 23 k2 = dr(t + h/2, r_ + k1*h/2) 24 k3 = dr(t + h/2, r_ + k2*h/2) 25 k4 = dr(t + h , r_ + k3*h) 26 27 res = r_ + (k1 + 2*k2 + 2*k3 + k4) * h/6 28 end function 29