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.
29285 Discussions

Automatic function result doesn't automatically result?

IanH
Honored Contributor III
630 Views

With ifort 12.0.5 and this program:

[fortran]! ifort /check:all /warn:all /standard-semantics xxxx.f90 PROGRAM automatically_broken IMPLICIT NONE TYPE some_type INTEGER :: some_number END TYPE some_type TYPE(some_type) :: st_array(2) INTEGER :: fn_result(2) !**** st_array = [some_type(1), some_type(2)] fn_result = do_some_counting(st_array, 2) PRINT "('Out of the function the result is: ',99(I0,:,','))", fn_result CONTAINS FUNCTION do_some_counting(st_arg, idx) RESULT(res) TYPE(some_type), INTENT(IN) :: st_arg(:) INTEGER, INTENT(IN) :: idx INTEGER :: res(st_arg(idx)%some_number) !---- INTEGER :: i !**** res = [(i, i = 1, SIZE(res))] PRINT "('In the function st_arg(idx)%some_number is ',I0)", & st_arg(idx)%some_number PRINT "('In the function the result is: ',99(I0,:,','))", res END FUNCTION do_some_counting END PROGRAM automatically_broken [/fortran]
I got:

[fortran]In the function st_arg(idx)%some_number is 2 In the function the result is: 0,4635040 Out of the function the result is: 0,0[/fortran] which made me address the compiler with rather strong language earlier today.

0 Kudos
3 Replies
Steven_L_Intel1
Employee
630 Views
Understandable. At first glance it seems that res isn't being set up properly. We'll take a closer look.
0 Kudos
Steven_L_Intel1
Employee
630 Views
Curious thing - in 12.0.5 this fails on IA-32 but works on Intel 64. In the upcoming 12.0.6 it works when optimization is disabled on IA-32 but not with optimization. Escalated as DPD200172823.
0 Kudos
Steven_L_Intel1
Employee
630 Views

This was fixed in the 13.0 (Composer XE 2013 initial release) compiler, but I didn't find out about that until today.

0 Kudos
Reply