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

标签 module fortran fortran90 fortran95 formats

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

最佳答案

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


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/

相关文章:

objective-c - 为什么在 Swift 中继承自 NSObject 的类会变成 public?

module - 在 Fortran 90 中使用通用 block 和模块在内存方面是否存在差异

fortran - 随机数生成器(RNG/PRNG)返回种子的更新值

ruby - block 内的 def 函数能完成什么任务?

powershell - 'local' 是 PowerShell 模块中的函数参数

typescript - 为什么 Typescript 使用关键字 "export"来公开类和接口(interface)?

Fortran 运行时警告 : temporary array

python - 使用 F2PY 处理 Python 中的 Fortran 字符数组

arrays - 在 Fortran 90 中,是否必须事先声明数组维度?

fortran - 使用 fortran 覆盖文件