Re: Assumed-shape arrays and dummy procedures
- From: Tobias Burnus <burnus@xxxxxxxx>
- Date: Sun, 6 Apr 2008 15:02:06 -0700 (PDT)
On Apr 6, 3:56 am, "James Van Buskirk" <not_va...@xxxxxxxxxxx> wrote:
subroutine callthru(qsub, option)
implicit logical(q)
integer, intent(in) :: option
external qsub
if(option == 1) then
write(*,'(a)') 'Calling subroutine A'
call A(qsub, 2)
"A" takes a subroutine as argument.
else if(option == 2) then
write(*,'(a)') 'Calling subroutine B'
call B(qsub, 2)
While "B" takes a function as argument.
I believe the program is invalid. Quoting the Fortran 2003 standard:
"12.4.1.3 Actual arguments associated with dummy procedure entities"
[...]
"If the interface of the dummy argument is implicit and either the
name of the
dummy argument is explicitly typed or it is referenced as a function,
the dummy
argument shall not be referenced as a subroutine"
As you once reference "qsub" as function and once as subroutine (by
using them as actual argument), the program is invalid and the
compiler is free to reject it. Interestingly, most compiler accept a
reduced version which contains such calls. For the most reduced
version which uses implicit typing, of my compilers, only gfortran
rejects it. For the full program, most of my compilers reject it.
In conclusion, I think gfortran is right and your program is invalid.
subroutine A(sub, n)
integer, intent(in) :: n
interface
subroutine sub(x)
implicit none
real, intent(in) :: x(:)
end subroutine sub
end interface
subroutine B(sub, n)
integer, intent(in) :: n
interface
function sub(x)
implicit none
integer, intent(in) :: x
logical sub(x)
end function sub
end interface
Tobias
.
- Follow-Ups:
- Re: Assumed-shape arrays and dummy procedures
- From: James Van Buskirk
- Re: Assumed-shape arrays and dummy procedures
- From: glen herrmannsfeldt
- Re: Assumed-shape arrays and dummy procedures
- References:
- Assumed-shape arrays and dummy procedures
- From: bill
- Re: Assumed-shape arrays and dummy procedures
- From: James Van Buskirk
- Assumed-shape arrays and dummy procedures
- Prev by Date: Re: Any libraries for vector mask and vector population count?
- Next by Date: Re: Fortran 77 parser
- Previous by thread: Re: Assumed-shape arrays and dummy procedures
- Next by thread: Re: Assumed-shape arrays and dummy procedures
- Index(es):
Relevant Pages
|