Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Anything not standard conforming in following code?

OP1
New Contributor III
890 Views

I am puzzled by a difference in behavior between the Intel compiler and the Cray compiler on the example below.

PROGRAM TEST_STRING_FUNCTION

IMPLICIT NONE

CHARACTER(LEN=:),ALLOCATABLE :: S
CALL SUB( __LINE__ ,S)
WRITE(*,*) __LINE__
WRITE(*,*) S

CONTAINS

SUBROUTINE SUB(I,O)
INTEGER,INTENT(IN) :: I
CHARACTER(LEN=:),ALLOCATABLE :: O
CHARACTER(LEN=15) :: S15_1
WRITE(S15_1,'(I15)') I
O = TRIM(ADJUSTL(S15_1))
END SUBROUTINE SUB

END PROGRAM TEST_STRING_FUNCTION

When (automatically preprocessed, due to the .F90 extension) and compiled with Intel, I get the expected output (7, then 6). With the Cray compiler, I only get the output from the first WRITE statement.

Am I overlooking something here? What could explain (besides a bug or omission in one of the compilers) the different behavior?

0 Kudos
6 Replies
Steven_L_Intel1
Employee
890 Views

I know that in the past, Cray, like us, required an option to get automatic reallocation on assignment. However, we always do the reallocation for deferred-length character, maybe Cray does not. I also know that Cray will change that default but don't know if it's in the version you're using. Look up what that Cray option is and turn it on, see what happens.

0 Kudos
OP1
New Contributor III
890 Views

Thanks Steve - your hint was spot on. This cured all the issues I had. Have a great weekend!

0 Kudos
Steven_L_Intel1
Employee
890 Views

I'll send the bill to Cray....

0 Kudos
OP1
New Contributor III
890 Views

Ha ha ha :-) ! Actually I just found that their compiler create an ICE with the following code:

PROGRAM TEST_ADJUSTL
IMPLICIT NONE
CHARACTER(LEN=:),ALLOCATABLE :: S
S = '    THIS IS A TEST   '
WRITE(*,*) S
WRITE(*,*) ADJUSTL(S)
END PROGRAM TEST_ADJUSTL

This is easy to work around, so I won't knock too hard on them for this... And let's not forget that they have a pretty solid F08 implementation ;-)

0 Kudos
Steven_L_Intel1
Employee
890 Views

In no way would I knock Cray's implementation - we respect and admire it. Be sure to report the ICE to Cray - I'm on good terms with my counterpart on their support team.

0 Kudos
Lorri_M_Intel
Employee
890 Views

I just want to clarify one tiny thing here ... Windows does not automatically preprocess based on the case of the extension, that's reserved for Linux and MacOS.

     Pedantically yours,

                  --Lorri

0 Kudos
Reply