Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26756 Discussions

Erratic behavior from Fortran compiler ?

WSinc
New Contributor I
102 Views

Regarding formatted I/O, I don't get the same behavior from these two source code examples:

 

write(1,* )  (a(ira,kk),kk=1,nca)

  

 

write(1,*)     a(ira,1:nca)

The first one does it right, but the second one gives different results.

A is a 2-dimensional array, could be REAL, D.P. or integer.

The row number IRA is specified ahead of time.

 

Is there any reason why the compiler would give different behaviors ?

 

I can generate a simple test program if needed.

0 Kudos
5 Replies
Steve_Lionel
Black Belt Retired Employee
102 Views

A simple test program as well as a description or example of the "different behaviors" would be useful.

jimdempseyatthecove
Black Belt
102 Views

I recall there was(is) a different thread on the Windows or Linux forum that discusses the same issue. It may have a tracking number.

Jim Dempsey

Steve_Lionel
Black Belt Retired Employee
102 Views

I don't remember an issue like this. Could it be that you are thinking of one related to use of a zero width in an explicit format causing a side-effect of a later WRITE?

jimdempseyatthecove
Black Belt
102 Views

As I remember, the thread related to a statement like:

   some2Darray = other2DarrayFirstDimGT1(idx, 1:N)

Where the compiler produced/interpreted the shape of the rhs as being a 1D array

This problem may potentially suffer part of this confusion.

A simple test to confirm this would be to try encapsulating the array slice in ()'s

write(1,*) (a(ira,1:nca))

Jim Dempsey

Steve_Lionel
Black Belt Retired Employee
102 Views

For list-directed output, the shape of the array would not have any effect. It's just a sequence of elements.

Bill hasn't told us what the different results are. At this point I suggest we wait for a test case and sample output, along with the exact compiler version being used, before speculating further.

Reply