gfortran需要格式宽度,而ifort不需要? [英] gfortran requires format widths while ifort doesn't?

查看:699
本文介绍了gfortran需要格式宽度,而ifort不需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将.FOR文件(用于实践目的)从ifort迁移到gfortran。此文件在我的英特尔Visual Fortran解决方案中编译时没有问题。然而,当我使用以下命令在gfortran中编译它时:

  gfortran -ffree-form -ffree-line-length-200  - Dinternal_debug -c MyFile.FOR -o MyFile.o 

我收到以下错误消息:

  MyFile.FOR:4561:22:

102格式(A,I)
1
错误:在(1)格式化字符串中需要的非负宽度

ifort不需要那里是一个格式宽度还是有额外的ifort选项可以放宽这个要求?如何在ifort中运行文件,但不在gfortran中运行?解决方案

您的观察结果是正确的,我以前遇到过这个问题。在Fortran中,英特尔Fortran不执行此要求。字段宽度实际上是Fortran标准所要求的。我不知道任何可以改变这种行为的编译器选项。我知道的唯一选择是修复代码,使其符合标准。



如何在错误:格式字符串(1)处需要非负宽度。请注意,您询问的 g0 不是接受 I 的编译器选项。这是一个不同的格式描述符,而不是 I


I am trying to migrate a .FOR file (for practice purposes) from ifort to gfortran. This file compiles in my Intel Visual Fortran solution with no issues. However when I compile it in gfortran using the following command:

gfortran -ffree-form -ffree-line-length-200 -Dinternal_debug -c MyFile.FOR -o MyFile.o

I get the following error message:

MyFile.FOR:4561:22:

   102     format(A, I)
                      1
Error: Nonnegative width required in format string at (1)

Does ifort simply not require there to be a format width or are there additional ifort options that enable relaxing this requirement? How come the file runs smoothly in ifort but not in gfortran?

解决方案

Your observation is correct, I have encountered this myself before. Intel Fortran does not enforce this requirement while gfortran does. The field width is actually required by the Fortran standard. I am not aware of any compiler option that could change this behaviour. The only option I am aware of is to fix the code to make it standard compliant.

How to do it can be found in Error: Nonnegative width required in format string at (1) . Note that the g0 that you asked about is not a compiler option to accept I. It is a different format descriptor to put into the code instead of I.

这篇关于gfortran需要格式宽度,而ifort不需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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