Is this legal?



Hi,
subject says all: is the attached code legal? two compilers accept it,
one does not.

Thanks
Salvatore
---------------------------------------- usemod2.f90
-------------------
module s_type_mod
type s_foo_type
real(kind(1.e0)), allocatable :: v(:)
end type s_foo_type
end module s_type_mod
module s_foo_mod
use s_type_mod
interface foobar
subroutine s_foobar(x)
use s_type_mod
type(s_foo_type), intent (inout) :: x
end subroutine s_foobar
end interface
end module s_foo_mod

module d_type_mod
type d_foo_type
real(kind(1.d0)), allocatable :: v(:)
end type d_foo_type
end module d_type_mod

module d_foo_mod
use d_type_mod

interface foobar
subroutine d_foobar(x)
use d_type_mod
type(d_foo_type), intent (inout) :: x
end subroutine d_foobar
end interface
end module d_foo_mod

module foo_mod
use s_foo_mod
use d_foo_mod
end module foo_mod

subroutine s_foobar(x)
use foo_mod, protect => s_foobar
type(s_foo_type), intent (inout) :: x

if (.not.allocated(x%v)) allocate(x%v(10))
end subroutine s_foobar

subroutine d_foobar(x)
use foo_mod, protect => d_foobar
type(d_foo_type), intent (inout) :: x

if (.not.allocated(x%v)) allocate(x%v(10))
end subroutine d_foobar


program test
use foo_mod
type(d_foo_type) :: z

call foobar(z)

end program test

.



Relevant Pages

  • Re: Control host association
    ... IMPLICIT NONE ... END SUBROUTINE do_something ... END PROGRAM test ... None of the compilers I have was able to spot the fact that a do-loop ...
    (comp.lang.fortran)
  • Re: Is this legal?
    ... versions of foobar ... all three compilers support ALLOCATABLEs in derived types as per ... end subroutine s_foobar ...
    (comp.lang.fortran)
  • Re: LEN() of unallocated array
    ... > Now, AFAIK, the above subroutine is legal Fortran; ... > end program test ... CVF compiles above ok, but has a runtime access error on execution. ... allocate ) ...
    (comp.lang.fortran)
  • Re: aliased intent(in out) arguments
    ... the code is not standard-conforming. ... What is non-conforming is for the subroutine in question to then modify ... One could also easily write a case where array elements were being ... Compilers *MAY* catch errors like this. ...
    (comp.lang.fortran)
  • Re: question about negative indices in fortran 77
    ... | I am working with an "inherited" program written in Fortran 77. ... | Intel compilers for linux), but now I'm doing some modifications and I ... | I'm checking for violations of array bounds because the program is doing ... | subroutine where it isn't touched. ...
    (comp.lang.fortran)