I have a derived type:
module foo
type bar
integer, allocatable, dimension(:) :: data
end type bar
end module foo
Now I would like to allocate bar
's data within a subroutine without an explicit interface:
program main
use foo
type(bar) :: mybar
call alloc_my_bar(10,mybar)
print*, mybar
end program
subroutine alloc_my_bar(n,mybar)
use foo
type(bar) :: mybar
integer :: n
allocate(mybar%data(n))
mybar%data = 42
end subroutine alloc_my_bar
This seems to work just fine with ifort
, but I know that if mybar wasn't part of a user defined type, I would need an explicit interface ... Does putting the allocatable array into a user defined type remove the need for an explicit interface? What version of the fortran standard is this code compatible with (F90, F95, F2003 ... ) if any?