- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following call produces the warning:
...no actual arg corresponding to dummy arg N...
any ideas?
call stopit('Hello')
...
subroutine Stopit(msg,n)
integer,optional ,intent(in):: n
character(111),intent(in):: msg
...no actual arg corresponding to dummy arg N...
any ideas?
call stopit('Hello')
...
subroutine Stopit(msg,n)
integer,optional ,intent(in):: n
character(111),intent(in):: msg
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need an explicit interface to call a routine with an optional argument.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding a comma immediately after 'Hello'.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But Steve, I have been happily using optional arguments without explicit interfaces by putting the subroutines with optional arguments into a module. I learnt this from you, after studying your very useful FortranWinPrint, which does not use an explicit interface.
Well, I was happy until recently when I have consistently been getting a warning message on compiling, which I have reduced to the simplistic case below:
Warning: In the call to UTILS_mp_CALLED, actual argument #4 has no corresponding dummy argument.
10 call Called(*10,'F')
Firstly there are only 3 arguments, and secondly it looks legal code to me. It does also link and run without any errors that I have been able to detect. I am using CVF6.6A, W2K SP3. Is it possible to get rid of this spurious warning?
Alan
Well, I was happy until recently when I have consistently been getting a warning message on compiling, which I have reduced to the simplistic case below:
Warning: In the call to UTILS_mp_CALLED, actual argument #4 has no corresponding dummy argument.
10 call Called(*10,'F')
Firstly there are only 3 arguments, and secondly it looks legal code to me. It does also link and run without any errors that I have been able to detect. I am using CVF6.6A, W2K SP3. Is it possible to get rid of this spurious warning?
MODULE UTILS Contains ! subroutine Calling 10 call Called(*10,'F') return end subroutine Calling ! subroutine Called( *, FileorDir, Quiet) ! * Return 1 on error ! character*1, intent(in), optional :: FileOrDir logical*1, intent(in), optional :: Quiet return end subroutine Called ! end module UTILS
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alan,
You are using an explicit interface - it's in the module. Your case is a bug - the alternate return (yuck!) is throwing off the compiler's argument checker. BTW, it says argument #4 because CHARACTER arguments count as two. Confusing, I know. We should really clean this up someday...
Steve
You are using an explicit interface - it's in the module. Your case is a bug - the alternate return (yuck!) is throwing off the compiler's argument checker. BTW, it says argument #4 because CHARACTER arguments count as two. Confusing, I know. We should really clean this up someday...
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thanks for that - but I have not found any reference in the User's Guide or the Language Reference Manual to the fact that putting subroutines with optional arguments into modules produces explicit interfaces. I suspect that I am not alone here.
I am also trying to find similar guidance for dynamically declaring arrays in subroutines - I know that the following works for arrays B & C, but again I can find nor reference (perhaps I am not very good at ferreting these things out).
Alan
Thanks for that - but I have not found any reference in the User's Guide or the Language Reference Manual to the fact that putting subroutines with optional arguments into modules produces explicit interfaces. I suspect that I am not alone here.
I am also trying to find similar guidance for dynamically declaring arrays in subroutines - I know that the following works for arrays B & C, but again I can find nor reference (perhaps I am not very good at ferreting these things out).
Subroutine ABCD(A,N) Integer*4, intent(in) :: N Real*8, intent(in) :: A(N) Real*8 B(N), C(N) return end
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alan,
See my article on the topic of explicit interfaces in the Visual Fortran newsletter. The Language Reference Manual isn't intended to teach the Fortran language, and the nuances of explicit interfaces are more a matter for a tutorial.
For your array question, see the LRM index under "Automatic arrays".
Steve
See my article on the topic of explicit interfaces in the Visual Fortran newsletter. The Language Reference Manual isn't intended to teach the Fortran language, and the nuances of explicit interfaces are more a matter for a tutorial.
For your array question, see the LRM index under "Automatic arrays".
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thanks for the references ? but I still maintain that something as important as modules providing explicit interfaces should be in the LRM. On dynamic sizing of arrays, I will add ?Automatic? to my list of words that mean something different in Fortran: the prime example is ?Parameter?.
You don?t seem to like alternate returns, which I use when it is even less elegant not to use them, but the Fortran File I/O intrinsic statements are effectively full of them in the form of eg ERR=label, END=label, etc. But I have not heard of their being deprecated!
Alan
Thanks for the references ? but I still maintain that something as important as modules providing explicit interfaces should be in the LRM. On dynamic sizing of arrays, I will add ?Automatic? to my list of words that mean something different in Fortran: the prime example is ?Parameter?.
You don?t seem to like alternate returns, which I use when it is even less elegant not to use them, but the Fortran File I/O intrinsic statements are effectively full of them in the form of eg ERR=label, END=label, etc. But I have not heard of their being deprecated!
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll suggest to our writers that they enhance the section of the manual discussing explicit interfaces.
Steve
Steve

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