Fortran输出自动换行 |
您所在的位置:网站首页 › print输出换行吗 › Fortran输出自动换行 |
对于一部分编译器(例如campaq fortran6.6,intel fortran 11.1)使用Fortran默认的格式输出时,如果一行的长度超过一定长度程序就会自动换行。这应该是从早期穿孔卡片时代留下来的问题吧! 解决该问题的方法是使用格式输出。例如下面的程序分别使用了默认格式与自定义的格式来输出一个数组,读者可以用campaq fortran或者intel fotran编译该程序,然后比较输出的文件out_auto_format.dat与out_selfdefined_format.dat的不同。 program main implicit none real(8) :: array(10,10) integer :: i,j array = 1d0 open(11,file='out_auto_format.dat') do i =1,10 write(11,*) (array(j,i),j=1,10) end do close(11) open(12,file='out_selfdefined_format.dat') do i =1,10 write(12,'(10F16.10)') (array(j,i),j=1,10) end do close(12) end program |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |