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

Assumed-size arguments in External procedures

David_Mccabe
Beginner
1,274 Views
I am currentlymoving a lot of code over to the intel fortran compiler.

In the existing code, there are a large number of calls to external procedures which use assumed-len or assumed-shape dummy arguments, but no interface is used. Here's an example:

program char_array

character(len=10),dimension(2) :: arg

arg(1)="hello"

arg(2)="world"

call test(arg)

end program char_array

subroutine test(arg)

character(len=*),dimension(:),intent(in) :: arg

write(*,*) arg(1)

write(*,*) arg(2)

read(*,*)

end subroutine test

I understand this is bad practice and an interface should be used, but adding interfaces orputting the procedures into moduleswould take too long.

My question is:
Is therea compiler option which wouldguarantee that the codewould compile and run without an error?

0 Kudos
2 Replies
TimP
Honored Contributor III
1,274 Views
Assumed shape requires interface specification. Without that, the compiler should reject it.
Assumed size will be checked by the -gen-interfaces compiler option. This option leaves automatically generated interface blocks in the build directory.
0 Kudos
Steven_L_Intel1
Employee
1,274 Views
As Tim suggests, /warn:interface will catch this (in most cases). This is on by default in a Debug configuration in a Visual Studio project. From the command line, add /warn:interface. Without the compiler being able to "see" the external routine, it has no idea that there is a problem.

C:\Projects>ifort /warn:interface t.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.1.1.258 Build 20111011
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

t.f90(11): warning #7978: Required interface for passing assumed shape array is
missing from original source [ARG]
call test(arg)
----------^
0 Kudos
Reply