Different interfaces cause problem in 4.5, but not 4.4
Paul van Delst
Paul.Vandelst@noaa.gov
Thu Oct 14 21:06:00 GMT 2010
Hello,
Please consider the following code:
<-----begin----->
module esmf_mod
public :: esmf_gridcompsetservices
contains
subroutine esmf_gridcompsetservices (subroutinename)
implicit none
interface
subroutine subroutinename (rc)
implicit none
integer :: rc
end subroutine
end interface
end subroutine esmf_gridcompsetservices
end module esmf_mod
!----------------------------------------------------------------------
module nems
contains
subroutine nems_register(rc)
integer,intent(out) :: rc
rc = 0
end subroutine nems_register
end module nems
!----------------------------------------------------------------------
program intent_test
use esmf_mod
use nems, only: nems_register
call esmf_gridcompsetservices(nems_register)
print *, 'It works!'
end program intent_test
<-----end----->
When compiled with gfortran 4.4 the output is:
$ gfortran44 --version
GNU Fortran (GCC) 4.4.0 20090514 (Red Hat 4.4.0-6)
$ gfortran44 test_intent.f90
$ a.out
It works!
When compiled with gfortran 4.5 we get the following:
$ gfortran45 --version
GNU Fortran (GCC) 4.5.1
$ gfortran45 test_intent.f90
intent_test.f90:26.32:
call esmf_gridcompsetservices(nems_register)
1
Error: Interface mismatch in dummy procedure 'subroutinename' at (1): INTENT mismatch in argument 'rc'
My initial reaction when I was shown this code, and told gfortran 4.5 wouldn't compile it, was that the interfaces were
different so it shouldn't compile.
But then when I tried gfortran 4.4 it worked. And the test code compiles and runs as expected with g95, pgf95, ifort (on
linux) and xlf95 on AIX.
Since just about every other compiler I've been able to get results for compiles and runs the code in question, is
gfortran 4.5 just being overly strict? Or is gfortran 4.5 correct to reject this code? (And what changed between 4.4 and
4.5 to trip this error?)
Thanks for any insight.
cheers,
paulv
--
Paul van Delst
More information about the Fortran
mailing list