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

IFX vs IFORT on treatments on the string length when using a string type dummy parameter

GuoYJ
Beginner
375 Views

Got a lesson today: IFX and IFORT have different treatments on the string length when using a string type dummy parameter in calling a subroutine in which the string parameter is intent(out). Special attention shoud be paid especially when the string length defined in the subroutine is different than that defined in the caller. With IFORT, the length of the string will be truncated to the defined length in the caller when it is returned from the subroutine in case its length defined in the subroutine is longer. However, with IFX, the length will changed to the length defined in the subroutine thus if the length defined in the caller is smaller, the string will occupy the space of adjacent variables, which will lead to error!

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
318 Views

An incorrect program does not have predictable results. "If a present scalar dummy argument is of type character with default kind or C character kind, the length len of the dummy argument shall be less than or equal to the length of the actual argument." 

View solution in original post

2 Replies
Steve_Lionel
Honored Contributor III
319 Views

An incorrect program does not have predictable results. "If a present scalar dummy argument is of type character with default kind or C character kind, the length len of the dummy argument shall be less than or equal to the length of the actual argument." 

Steve_Lionel
Honored Contributor III
237 Views

I should also remark that, in my opinion, specifying a length other than (*) for a character dummy argument is a bad idea - it just leads to headaches such as this. 

0 Kudos
Reply