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

writing vector to File - differences between Gfortran and Ifort

joao_n_
Beginner
873 Views

Hi All,

I have a code that I'm migrating from gfortran to ifort.

After a number of time steps I write a vector (~ 500 lines) to a file using:

WRITE (unit, *) Time_Steps, vector(:)

In gfortran this gives me the, output file:

Time_1, vector(1), vector(2), .... vector(end)

Time_2, vector(1), vector(2), .... vector(end)

Time_3, vector(1), vector(2), .... vector(end)

....

When running with ifort the output is messed up, with a line break every 5 columns.

Any idea what's happening ?

thanks, jp

p.s I already tried specifying the format but it didn't work...

0 Kudos
7 Replies
Izaak_Beekman
New Contributor II
873 Views

I think you most certainly need an edit descriptor if you want the format to have line breaks where you want them. (With an edit descriptor you can specify the number of entities per line by either typing an edit descriptor for each column or using repeat counts, or, if the number of columns is only known at runtime, you can dynamically build an edit descriptor.) The exact output of the default * edit descriptor is processor dependent (processor in the sense as defined by the fortran standard, to mean hardware, compiler etc.) and for ifort, it will put elements on a new line if the line length starts to become too long.

0 Kudos
Steven_L_Intel1
Employee
873 Views

It's an implementation difference in the default record length for list-directed output. Intel Fortran and its predecessors DEC/Compaq Fortran have used 80 columns for decades. Back in the 1970s this made sense, not so much today.

In compiler version 14 we added the option -wrap-margin- to allow indefinitely long record lengths for list-directed output. There is also an environment variable that can control this.

0 Kudos
joao_n_
Beginner
873 Views

Hi Steve,

Thanks for your comment but.... it didn't work.

I'm compiling with -fast -wrap-margin and the output is still exactly the same... Any other sugestions ?

thanks for that.

JP

0 Kudos
Steven_L_Intel1
Employee
873 Views

Show me a small example program that demonstrates the problem, along with the output you get from gfortran. Also, the option I mentioned is new in version 14. In older versions you can open the file with a larger RECL= value and it will use that as the margin.
 

0 Kudos
mecej4
Honored Contributor III
873 Views

joao n. wrote:

Thanks for your comment but.... it didn't work.

I'm compiling with -fast -wrap-margin and the output is still exactly the same... Any other sugestions ?

thanks for that.

JP

The option you wanted is -wrap-margin-, not -wrap-margin (note the '-' at the end; think -wrap-margin+).

As Steve said, this option is available with the Version 14 compiler. Older versions will complain that -wrap-margin- is not a recognized option.

 

0 Kudos
joao_n_
Beginner
873 Views

ops...

my mistake, now working perfectly. tks !
 

0 Kudos
Lorri_M_Intel
Employee
873 Views

On Linux, the correct spelling is -no-wrap-margin

The trailing hyphen is a Windows-ism, and was accidentally accepted by the Linux version of "ifort".

In other words, please update your makefile to use -no-wrap-margin instead.

            thanks!

                       --Lorri

0 Kudos
Reply