Allocatable Array arguments

Allocatable Array arguments

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.


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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:

integer, allocatable :: x(:)
call sub (x)
print *, x
subroutine sub (y)
integer, allocatable :: y(:)
allocate (y(3))
y = 4

C:Projects>ifort /warn:interface t.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 1 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.   [X]
call sub (x)
compilation aborted for t.f90 (code 1)

Retired 12/31/2016

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


Downloadapplication/octet-stream test.f903.02 KB
Downloadapplication/octet-stream utl-getfilesx-genmod.f90538 bytes
Downloadtext/plain buildlog.txt501 bytes

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.

Retired 12/31/2016

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today