program ex1
implicit none
integer::a
a=10
call sub()
write(*,*)a
end
subroutine sub()
implicit none
integer::a
a=20
write(*,*)a
return
end
返回值为
20
10
但是用module写
[Fortran] 纯文本查看复制代码
module global
implicit none
integer::a
end module
program ex
use global
implicit none
a=10
call sub()
write(*,*)a
end
subroutine sub()
use global
implicit none
a=20
write(*,*)a
return
end