* format

* format

There appears to be a line length limit with the * output format, which does not occur with some other compilers.
Often I will quickly write a variable dump to the screen or a file, that I will later import into excel for further analysis.
* is very quick and easy, as you don't have to think of the possible range of values that could occur, or the mixture of variable types.
However, with ifort, "write (*,*) x,y,z,a,b,c" can result in the output record being over two lines.
I think that also "write (98,*) x,y,z,a,b,c" might have this problem, but certainly redirecting screen output to a file has this problem.
Having to merge lines in excel defeats the purpose of a quick review !

Is there a way of removing this line length restriction ?


6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

At runtime, have you tried setting the FORT_FMT_RECL environment variable to some longer line length?

(For a file, perhaps specify the RECL explicitly in the OPEN for the file.)

You could also perhaps use an explicit format - something like "(*(G0,:,1X))".


Thanks for your advice. FORT_FMT_RECL appears to apply to files and defaults to 132. ( I have not yet noticed that limit with formatted output! I'd hope the format would only give a new record when I define a /)
write (* is for standard output, which "OPEN: RECL Specifier" reports that after 80 characters, the remaining characters will wrap to the next line.
I am appearing to get an 80 character limit in my redirected standard output. It does not appear to be 132 characters, so the environment variable might not apply.
Changing the record length for standard output does not appear to be covered by FORT_FMT_RECL , and certainly using OPEN (*... to change record length attributes from 80 looks messy.

With other compilers, I have not struck this case where writing 100 characters will produce two lines of output in a re-directed file.
I basically want to turn off the generation of a second line. I have not noticed write (* producing multiple lines of output before.
Excel terminating at 256 characters was (is?) also a significant annoyance for .prn files, which has required me to write a program to merge the 2 blocks. I can't recall if that has been fixed with 2010.


ps: I have just tested Excel 2010: .prn files are limited to 256, but .txt files truncate at 1024 characters, which will have to be adequate.

Some tests here show that FORT_FMT_RECL modifies the behaviour of list directed formatting to the the console.

If you use * you hand over a lot of control to the Fortran processor.  This explicitly includes it creating new records when it gets an inclination to do so. There was a recent discussion on c.l.f where someone pointed out that if it wanted to the Fortran processor could also use the r*nnn form of output for repeated items.

For simple output to Excel I prefer to use csv - a typical office installation associates the csv extension to Excel so by simply typing the name of the csv file at the command prompt Excel will fire up and open the file for you.  I think the format "(*(G0,:,','))" is all you need if you are just dealing with numbers and live somewhere that uses the period as a decimal separator.

Environment variable FORT_FMT_RECL not defined
>ifort /check:all /warn:all /standard-semantics lotto_numbers.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Ian's new 64 bit toy!  Version Build 20130607
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.
 3.9208680E-07 2.5480442E-02 0.3525161 0.6669145 0.9630555
 0.8382882 0.3353550 0.9153272 0.7958636 0.8326931
>set FORT_FMT_RECL=120
 3.9208680E-07 2.5480442E-02 0.3525161 0.6669145 0.9630555 0.8382882 0.3353550 0.9153272
 0.7958636 0.8326931
>set FORT_FMT_RECL=160
 3.9208680E-07 2.5480442E-02 0.3525161 0.6669145 0.9630555 0.8382882 0.3353550 0.9153272 0.7958636 0.8326931


Downloadapplication/octet-stream lotto-numbers.f90359 bytes

We've added the ability to "ignore" the right margin for list-directed output, in a release due out later this year.


I will also add that if you care about the format of the output, don't use list-directed, which leaves an awful lot to the discretion of the implementation.

But we do support a Fortran 2008 feature that is meant for situations such as yours. Instead of (*,*) use:

write (*,"*(G0,1X))" x, y, z, a, b, c

Try this and see if it does what you want. The only issue would be if you have character values, they would not be written with delimiters. (With list-directed, you could open the file with DELIM=:QUOTE" and get delimiters.)

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today