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

Allocatable Array arguments

Stephen_Sutcliffe
New Contributor II
873 Views

In an application that I put together recently I utilised the allocatable argument feature in a function call but forgot to create an explicit interface in the calling program unit. I initially used the debug configuration during the development stage and the program seemed to behave perfectly well however when I compiled the Release configuration it crashed in the function at the point where it called

if(allocated(files)) deallocate(files)  where files is the allocatable argument.

I cured the problem by putting the function in a module so that the interface is defined by the module. I am curious as to why it should work in Debug but not in Release and why the compiler can't detect such cases where allocatable arguments have no interfaces defined.

Thanks

0 Kudos
4 Replies
Steven_L_Intel1
Employee
873 Views

The compiler can detect this with the Generated Interface Checking feature, on by default in a new Debug configuration (as of 10.1). It does require that the called routine be compiled first (if in a separate source). If you have a small example that demonstrates this not working I'd like to see it.

Here's an example:

[fortran]
integer, allocatable :: x(:)
call sub (x)

print *, x
end

subroutine sub (y)
integer, allocatable :: y(:)
allocate (y(3))
y = 4
end
[/fortran]

[plain]
C:\Projects>ifort /warn:interface t.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 1
3.1.1.171 Build 20130313
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

t.f90(2): error #8055: The procedure has a dummy argument that has the ALLOCATABLE, ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source.  
call sub (x)
----------^
compilation aborted for t.f90 (code 1)
[/plain]

0 Kudos
Stephen_Sutcliffe
New Contributor II
873 Views

Hi Steve,

I've extracted the file (almost) and added a simple calling routine. The file compiles with no warnings or errors. Buildlog is attached.

PS the new forum file upload is much better than the old method

0 Kudos
Steven_L_Intel1
Employee
873 Views

How very odd.  My experiments show that subroutines get the message but functions don't. Thanks - we'll look into this. Issue ID is DPD200242997.

0 Kudos
Anonymous66
Valued Contributor I
873 Views

A fix has been found for this issue. We are planning to include it in the next major release which is currently scheduled for later this year.

0 Kudos
Reply