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

Erratic behavior from Fortran compiler ?

WSinc
New Contributor I
567 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
Honored Contributor III
567 Views

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

0 Kudos
jimdempseyatthecove
Honored Contributor III
567 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

0 Kudos
Steve_Lionel
Honored Contributor III
567 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?

0 Kudos
jimdempseyatthecove
Honored Contributor III
567 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

0 Kudos
Steve_Lionel
Honored Contributor III
567 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.

0 Kudos
Reply