[Fortran] 纯文本查看 复制代码
Module Proc2
Implicit None
interface
Subroutine IF_PROC(x,y)
integer :: x , y
End Subroutine IF_PROC
end interface
contains
Subroutine f1(x,y)
integer :: x , y
write(*,*) x+y
End Subroutine f1
Subroutine f2(x,y)
integer :: x , y
write(*,*) x-y
End Subroutine f2
End Module Proc2
Program Proc_pointer
use Proc2
Implicit None
integer :: x , y , n
Procedure(IF_PROC) , pointer :: proc
read(*,*) n , x , y
if(n==1) then
proc => f1
else
proc => f2
end if
call proc(x,y)
End Program Proc_pointer