- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page