Fortran Coder

标题: Fortran数据写出格式请教 [打印本页]

作者: geoyang    时间: 2016-2-16 16:38
标题: Fortran数据写出格式请教
各位大侠,小弟刚接触Fortran,对数据格式写出格式不太懂,想请教一下我这个数据该咋读和按要求的格式写出啊?
我有列数据如下:
4565
44566  
44567
44568
44565
44566
4565
44563
99999
44561
44563  
44564
...
想通过Fortran读完后按6F12.4这个格式写出
4565.000   44566.000   44567.000   44568.000   44565.000   44566.000
4565.000   44563.000   99999.000   44561.000   44563.000   44564.000

.....
即每行6个数据,每个数据占12个characters,并且带4个decimal places

请教各位大侠,这个程序该咋写呢?非常感谢



作者: fcode    时间: 2016-2-16 17:13
[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
Program www_fcode_cn
  Implicit None
  Integer :: k
  Real :: a(6)
  Open( 12 , File = '旧文件' )
  Open( 13 , File = '新文件' )
  Do
    Read( 12 , * , iostat = k ) a
    if ( k /= 0 ) exit
    write( 13 , '(6F12.4)' ) a
  End Do
End Program www_fcode_cn

作者: geoyang    时间: 2016-2-16 17:20
fcode 发表于 2016-2-16 17:13
[mw_shl_code=fortran,true]Program www_fcode_cn
  Implicit None
  Integer :: k

哈哈,多谢多谢了!




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2