gpt4 book ai didi

module - Fortran 模块中的格式化语句

转载 作者:行者123 更新时间:2023-12-02 05:58:56 24 4
gpt4 key购买 nike

我有一个包含许多子例程的模块,这些子例程都使用相同的输出格式集。现在,我必须在每个子例程中声明格式。有没有办法在模块中声明它们,以便所有子例程都可以访问它们?

最佳答案

您可以在模块级别将格式存储为字符。例如


module foo
implicit none
character(len=20), parameter :: form = "(1X,A)"
contains
subroutine bar
...
write(my_unit, form) "Hello, World"
end subroutine bar
end module foo

关于module - Fortran 模块中的格式化语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6665531/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com