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

Automatic line wrapping of standard out at 40 characters

gillesc
Beginner
1,364 Views
Hello, I tried to ask this to the Mac forums thinking it was a mac issue, but no one responded with explicit advice so I will try here.

I am using ifort (10.1.015) with MKL (10.0.1.014) on a Mac Pro Intel Quad Core with 4GB RAM (OS Mac OS X 10.5.4). I have a few lines in my code that write to the standard out with and without explicit format statements that all wrap the line at 40 characters. This wrapping is visual in the files when I open them or import them to something like excel, but if I just read them directly ifort sees it as one line.

Here is an example write line

write(21,*)(trans(l),l=1,3),(q(j,l),l=1,4),rcontact,dfopls_min,inn_ne,inn_tot,felec(1)

(I cut out the wrapping to the next line after 72 characters)

this gives an output of

-0.286923854398594 0.826408887787496 0.484482251442598
0.668091779538698 -0.257459132056355 0.333350458566333
-0.613388654286350 46.0506361399727 -8.70875510218642
6410863.42406656 5908206.35760950 0.127486011015066

when it should be one single line.

Anyone know if there is a fix for this. This doesn't happen when I use my powerbook with 10.4 or the linux at work.

Thanks

Chris
0 Kudos
2 Replies
cngilbreth
Beginner
1,364 Views
Try opening the file unit with a long record length. For instance,

open(unit=6,recl=4096)

for stdout.

Cheers,
Chris
0 Kudos
Steven_L_Intel1
Employee
1,364 Views
When you use list-directed formatting, you are leaving a lot of things to the choice of the implementation, including when to start a new record. By default, list-directed starts new records at column 80, but you can change this with RECL= as noted.

However, I don't think that's what's going on here. Rather, the Mac "Terminal" is somehow using a shorter length and is doing the wrapping for you. This is not under the control of Fortran.
0 Kudos
Reply