Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

format width control not required in ifort?

awa5114
Beginner
869 Views

I am trying to migrate a .FOR file (for practice purposes) to gfortran. This file compiles in my Intel Visual Fortran solution with no issues. However when I compile it in gfortran 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?

0 Kudos
6 Replies
andrew_4619
Honored Contributor II
869 Views

compile with standards checking. There are lots of non-standard extensions to the language that different compilers will accept. If you aim for standards compliance such issue then disappear.

0 Kudos
andrew_4619
Honored Contributor II
869 Views

...after and initial world of pain that is.... In Ifort you can have standards checking and then on a per file or per project basis have some non-standard warning numbers that you can chose to let the compiler not report.

0 Kudos
mecej4
Honored Contributor III
869 Views

Fortran 2003 lets you use the I0 format to let the compiler/runtime choose the proper field width. Section 10.6.1.1 of that standard says this about the Iw.m format:

     When w is zero, the processor selects the field width.

0 Kudos
awa5114
Beginner
869 Views

@mecej4 

I also have format descriptors like '(A2, F)'. I want the processor to also select the number of decimal points after a floating point number in gfortran. Is there an equivalent way to do that also? specifying a format like '(F0.0)' gives a default width but brings the number of decimal places down to zero...

 

0 Kudos
mecej4
Honored Contributor III
869 Views

The best way to find answers to such questions is to consult the Fortran compiler (IFort, Gfortran, etc., as appropriate) documentation.

An output format specification of F0.d is allowed, and results in d digits after the decimal point, with the output field width chosen by the "processor".

0 Kudos
Steve_Lionel
Honored Contributor III
869 Views

As others have noted, I and F without widths are an extension. Intel Fortran supplies a default width based on the data type of the item being transferred. This is described in the Intel documentation.

0 Kudos
Reply