你这个代码里也没有多态呀。
要避免把本程序单元contains下的过程传递给本程序单元之外的过程使用。
[Fortran] 纯文本查看 复制代码 Module testMod
implicit none
integer :: iorder = 1
contains
real(8) function fun(xy)
real(8) :: xy(2)
if(iorder<1.or.iorder>size(xy)) then
write(*,*) 'error in iorder!' , iorder
stop
end if
fun= xy(iorder)
end function
real(8) function GaussInteg_Tri( fun,xv1 )
real(8) :: xv1(2)
real(8) ,external :: fun
GaussInteg_Tri = fun(xv1)
write(*,*) GaussInteg_Tri
end function
End Module testMod
program Test
use testMod
implicit none
real(8)::xv1(2)=[11.0_8,22.0_8]
write(*,*) GaussInteg_Tri( fun , xv1 )
end program Test |