传递指针的话,需要用 interface,而书写到 module 里,可以避免手动书写 interface
[Fortran] 纯文本查看 复制代码 module typedef
Implicit None
type tttt
integer:: num
character(len=15) :: name1
end type tttt
end module typedef
module mod_struct_mod
use typedef
Implicit None
contains
subroutine mod_struct(struct)
type(tttt),pointer:: struct
struct%name1="xie"
end subroutine mod_struct
end module mod_struct_mod
program hello
use mod_struct_mod
type(tttt),pointer::ps
type(tttt),target :: s
s%num=1
s%name1="wangwei"
ps=>s
call mod_struct(ps)
write(*,*) ps
end program hello |