浮点数的 Fortran 格式输出 [英] Fortran formated output for floating point numbers
问题描述
在 Fortran 中有没有办法将浮点数写为 17,3
而不是 17.3
,将点改为逗号?
Is there a way in Fortran to write float numbers as 17,3
and not 17.3
, changing the dot to a comma?
我有一些大型数据集通过子程序写入 .csv,我想在上面做一些 Excel.德文版 Excel 使用 .
作为浮点数的分隔符.我知道我可以使用导入功能来处理它,或者使用 Nodepad++ 搜索并将 .
替换为 ,
.但是我确实生成了很多这些文件,并且子程序将被其他人使用,所以一个 Excel 就绪文件会很好.
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.
推荐答案
如果你只是写一两行,你可以将十进制编辑描述符 dc
添加到你的输出格式中.这是一个简单的例子
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
产生
12,300
如果要写入文件,请添加子句
If you want to write to a file, add the clause
decimal = 'comma'
到你的 open
语句,例如:
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屋!