1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
module callback_03
contains
real function cb(f, a, b)
real, intent(in) :: a, b
interface
real function f(x)
implicit none
real, intent(in) :: x
end function
end interface
cb = (b-a) + f(a) + f(b)
end function
subroutine foo1(c, d)
real :: c, d
print *, cb(f, c, d)
contains
real function f(x)
real, intent(in) :: x
f = 2*x
end function f
end subroutine foo1
subroutine foo2(c, d)
real :: c, d
print *, cb(f, c, d)
contains
real function f(x)
real, intent(in) :: x
f = -2*x
end function f
end subroutine foo2
end module
program main
use callback_03
call foo1(1.5, 2.0)
call foo2(1.5, 2.0)
end program main
|