fortran - 同时写入控制台和文件的简洁方法?
问题描述
我正在尝试简化控制台程序文本的输出。目前,这些程序以两种不同的方式运行:
- 直接来自 CMD 或批处理脚本
- 远程或盲目,由另一个程序调用
因此,所有输出给用户的信息都需要去控制台和一个默认的错误文件。
目前,我只是在重复自己:
write(*,*) "That wasn't a number!"
write(199,*) "That wasn't a number!"
我想出的最好的方法是使用子程序:
subroutine werr(string)
implicit none
character*(*), intent(in) :: string
write(*,*) string
write(199,*) string
return
end subroutine
更好,但仍然需要call werr("Some text or another.")
有没有办法模仿写作的方式,我可以简单地拥有werr("Some text or another.")
?
解决方案
推荐阅读
- java - 将数字的数字相乘,直到得到一位数字
- php - 通过 php 中的 preg_replace 删除顶部和底部的多行 html 代码,而不是两个字符串 'hello' 的中间
- ubuntu - 使用 TinyCC 在 X86 Linux 上编译 STM32 程序
- react-native - 屏幕上的动态标题更改
- javascript - 是否还有理由将 htmlElement 引用设为空?
- python - Kivy raise FactoryException('Unknown class <%s>' % name) kivy.factory.FactoryException: Unknown class
- ios - iOS:未呈现 NSMutableAttributedString.AddAttributes。(Xamarin)
- kotlin - 在迭代期间更改 MutableList
- ios - 将应用程序提交到 Apple Store 时,IAP verifyReceipt url 应该是沙箱还是服务器上的购买 url?
- c - 如何在 C 中使用 wininet api 将文件上传到 anonfile?