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

Error with variable length strings

Andrew_Smith
Valued Contributor I
573 Views
This code produces an unallocated result. I tried using /assume:realloc_lhs but it also failed.

[bash]pure function strFromReal(a) result(str)
   real, intent(in) :: a
   character(25) temp
   character(:), allocatable :: str
   write(temp, *) a
   str = trim(adjustl(temp))
end function[/bash]
0 Kudos
2 Replies
Andrew_Smith
Valued Contributor I
573 Views
I am using IVF 11.1.65 with VS 2008.

Actually I think it is Visual studio integration that is failing. When I watch variable str at the end of the function I get an Index out of bounds error.

However, if I assign str back to temp again I get a good result for temp.
0 Kudos
Steven_L_Intel1
Employee
573 Views
I think that we know about deferred-length character variables not displaying properly in the debugger. I tried your code with an internal build of our next major release and I could see the value once it was allocated and assigned. Your code should work in the 11.1.065 compiler.
0 Kudos
Reply