0
在試圖簡化我的代碼,我決定以下列方式創建中的另一個模塊:如何在主模塊中包含模塊?
module A
contains
module B
real*8, parameter ::pi=3.14159
end module B
end module A
program test
use A
write(*,*)pi
end
這沒有奏效。簡化模塊的一些策略是什麼?
這(爲你的編譯器會告訴你)是無效的。但是,你想要「包含」模塊做什麼?有_submodules_這樣的東西,但這可能不是你所追求的。如果您只想使用'A'並從'B'訪問事物,然後使用'module A;使用B;最終模塊A'很高興地工作。 – francescalus