- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
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?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Assumed size will be checked by the -gen-interfaces compiler option. This option leaves automatically generated interface blocks in the build directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
----------^
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)
----------^

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page