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?
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.
...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.
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.
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...
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".
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.