[Fortran] 纯文本查看 复制代码
module mod_parasetting
integer,public::a
contains
subroutine parasetting()
implicit none
integer b
a=3
b=1
return
end subroutine parasetting
end module mod_parasetting
module mod_sum
contains
subroutine summarization(s)
use mod_parasetting,only:a
implicit none
integer s(a),d
integer,external::summ
d=2
s=summ(d)
return
end subroutine summarization
end module mod_sum
function summ(d) result(r)
use mod_parasetting,only:a
implicit none
integer d,c(a)
integer r(a)
integer i
c=1
do i=1,a
r(i)=c(i)+d
enddo
return
end function summ
program main
use mod_parasetting
use mod_sum
implicit none
integer,allocatable::s(:)
call parasetting()
allocate(s(a))
call summarization(s)
write(*,*) s
end program main
[Fortran] 纯文本查看 复制代码
module mod_sum
contains
subroutine summarization(s)
use mod_parasetting,only:a
implicit none
integer s(a),d
!integer summ
d=2
s=summ(d)
return
end subroutine summarization
function summ(d) result(r)
use mod_parasetting,only:a
implicit none
integer d,c(a)
integer r(a)
integer i
c=1
do i=1,a
r(i)=c(i)+d
enddo
return
end function summ
end module mod_sum