Fortran形成浮点数的输出 [英] Fortran formated output for floating point numbers
问题描述
有没有办法在Fortran中写入$ code> 17,3 而不是$ code> 17.3 的浮点数,更改点到一个逗号?
我有一些大型数据集通过一个子程序发送到.csv,我想做一些Excel。 Excel的德语版本使用。
作为浮点数的分隔符。我知道我可以使用导入功能来处理它,或者使用Nodepad ++来搜索和替换。
与,
。
但是我确实生成了大量的这些文件,子程序将被其他人使用,所以Excel就可以很好地使用。
如果你只是写一两行,你可以添加十进制编辑描述符 dc
到您的输出格式。这是一个简单的例子
write(*,'(dc,f12.3)')12.3
$生产 12,300 code
如果要写入文件,请添加子句
decimal ='comma'
打开
语句,例如:
open(6,decimal =逗号')
当然,我在(重新)打开stdout写逗号而不是分。
Is there a way in Fortran to write float numbers as 17,3
and not 17.3
, changing the dot to a comma?
I have some large data sets wirtten to a .csv by a subroutine, and i want to do some Excel on it. The german version of Excel uses .
as a seperator in floating point numbers. I know i can use the import feature to handle it, or use Nodepad++ to search and replace .
with ,
.
But i do generate lots of these files, and the subroutine will be used by others, so an Excel ready file would be nice.
解决方案 If you're just writing a line or two you can add the decimal edit descriptor dc
to your output format. Here's a simple example
write(*,'(dc,f12.3)') 12.3
which produces
12,300
If you want to write to a file, add the clause
decimal = 'comma'
to your open
statement, for example:
open(6,decimal='comma')
Of course, here I'm (re-)opening stdout to write commas rather than points.
这篇关于Fortran形成浮点数的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!