- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got error when the following program was compiled. But I can not figure what was wrong.
module work_arrayThe error
integer :: n
real, allocatable :: work (:)
end module work_array
program main
use work_array
call sub
print*, work
end program main
subroutine sub
use work_array
implicit none
n = 2
allocate (work(n))
work (1) = 1.0
work (2) = 2.0
return
end subroutine sub
Error 1 Error: A non-optional actual argument must be present when invoking a procedure with an explicit interface. C:ivf est est est.F90 8Thanks.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do a Build > Rebuild Solution or delete all _MOD.mod files and try again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What's the magic thing there? It works though I have figured another way to solve this issue. I put the subprogram into the module so that the interface became explicit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The magic thing is "generated interface checking". When the compiler sees a routine that is not a module or contained procedure, it generates a specially-named module containing an interface block for that routine. In version 10.x, the module is routinename_MOD and the file names are that name plus .f90 and .mod. (This will change in a future release to reduce the chance of a conflict with a user module.)
When the compiler sees a call to a routine for which no explicit interface is available, it looks to see if there is a generated module for it, and if so, uses the interface block to perform error checking. (Note that a generated interface is NOT a substitute for providing an explicit interface when the language requires one.)
The compiler tries to be smart about the case when the called routine is later in the same source in that if it does not find a generated module, it waits until the whole source has been processed before doing the checking. The problem occurs when you compile the source, edit it to change the called routine, say, removing an argument, and then recompile. This time the compiler sees that a generated interface is available, not noticing that it would be recreated later, so it uses a stale definition.
This is controlled by the options /gen-interface and /warn:interface. Both are on by default in newly-created VS projects.
When the compiler sees a call to a routine for which no explicit interface is available, it looks to see if there is a generated module for it, and if so, uses the interface block to perform error checking. (Note that a generated interface is NOT a substitute for providing an explicit interface when the language requires one.)
The compiler tries to be smart about the case when the called routine is later in the same source in that if it does not find a generated module, it waits until the whole source has been processed before doing the checking. The problem occurs when you compile the source, edit it to change the called routine, say, removing an argument, and then recompile. This time the compiler sees that a generated interface is available, not noticing that it would be recreated later, so it uses a stale definition.
This is controlled by the options /gen-interface and /warn:interface. Both are on by default in newly-created VS projects.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
where do I find options? tools>options? I don't see the /gen-interface. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Project > Properties > Fortran > Diagnostics. "Generate Interface Blocks" and "Check Routine Interfaces".
Tools > Options sets Visual Studio behavior, not Fortran compile behavior.
Tools > Options sets Visual Studio behavior, not Fortran compile behavior.
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