Re: Is this legal?



Before someone asks, the error is about the renaming of the specific
versions of foobar
as in
use foo_mod, protect => s_foobar

all three compilers support ALLOCATABLEs in derived types as per
tr15581
Thanks


On 29 Mag, 16:03, Salvatore <sfilipp...@xxxxxxxxxxx> wrote:
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: Is Fortran faster than C?
    ... So I think F2003 has the benefits of a language with garbage ... So you can use allocatables to set up ... compiler from implementing GC for pointer variables, ... subroutine add_node ...
    (comp.lang.fortran)
  • Re: ALLOCATABLE arrays
    ... > temporary work arrays: ... > subroutine sub1 ... > On the contrast, frequent allocation/deallocation of allocatables ... I often use use allocatable arrays instead of automatic arrays as a ...
    (comp.lang.fortran)
  • Re: Is Fortran faster than C?
    ... type, pointer:: next ... subroutine add_node ... The idea being to use pointers to implement aliasing, and allocatables ... extended types and finalizers have nothing to do with the issue at ...
    (comp.lang.fortran)
  • Re: Is Fortran faster than C?
    ... type, pointer:: next ... subroutine add_node ... The idea being to use pointers to implement aliasing, and allocatables ... extended types and finalizers have nothing to do with the issue at ...
    (comp.lang.fortran)
  • Is this legal?
    ... two compilers accept it, ... end subroutine s_foobar ... end program test ...
    (comp.lang.fortran)