我如何在主模块中包括模块

  • 本文关键字:模块 包括 fortran
  • 更新时间 :
  • 英文 :


为了简化我的代码,我决定以以下方式在另一个模块中创建一个模块:

   module A
    contains                                                                                                                         
        module B
        real*8, parameter ::pi=3.14159
        end module B
   end module A

   program test
   use A
   write(*,*)pi
   end

这无效。简化模块的哪些策略?

我认为您想要的是这样:

module B
    implicit none
    real, parameter :: pi = 3.14159
end module B
module A
    use B
    implicit none
end module A
program main
    use A
    implicit none
    print*, pi
end program main

最新更新