ifort的no-wrap-margin只能部分工作 [英] ifort's no-wrap-margin works only partially

查看:175
本文介绍了ifort的no-wrap-margin只能部分工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于一些不幸的原因,我必须使用ifort,问题是ifport截断长(> 80个字符)默认情况下写(*,*)行(这在gfortran中不会发生)。有一个叫no-wrap-margin的选项可以恢复gfortran的行为,即只要我想在一行中写行就行。但是,这仅适用于少于8184个字符的行。比这更长的一行,比如用

 程序主
隐式无
整数::
write(*,*)(i,i = 1,683)
end program main

产生输出第二行中的最后一个数字。有没有办法在没有在写入语句中指定格式的情况下获得我想要的行为?我误解了-no-wrap-margin选项吗?

解决方案

-no-wrap-margin 选项将禁用英特尔Fortran中的默认检查,以检查输出记录的长度,这是

作为一个好处,英特尔已经实施了无限格式项目。应用到您的示例代码中,它可能如下所示:

 程序主
隐含无
整数: :
write(*,'(*(I0,X))')(i,i = 1,683)
end program main
pre>

for some unfortunate reasons I have to use ifort, the "problem" is that ifort truncates long (>80 characters) write(*,*) lines by default (this doesn't happen in gfortran). There's an option called -no-wrap-margin that supposedly recovers the gfortran behavior, which is to write lines as long as I want in a single line. However this only works for lines with less than 8184 characters. A line longer than that, as for example the one obtained with

program main
    implicit none
    integer :: i
    write(*,*) (i, i=1, 683)
end program main

results in the last number in the second line of the output. Is there a way to get the behavior I want without specifying a format in the write statement? Have I misunderstood the -no-wrap-margin option?

解决方案

The -no-wrap-margin option disables the default check in Intel Fortran for the length of output records, which is a remnant from older times.

Unfortunately, however, the Intel implementation seems to impose a limit of around 2^15 (= 32768) bytes of output, or 8192 default (4 byte) integers, forcing the excess to a new line, which gfortran does not, as you observed.

As an upside, Intel has implemented the unlimited format item. Applied to your example code, it could look as follows:

program main
    implicit none
    integer :: i
    write(*,'(*(I0,X))') (i, i=1, 683)
end program main

这篇关于ifort的no-wrap-margin只能部分工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆