Re: Allocatables in derived types and functions
- From: "Arno" <arnoinperu@xxxxxxxxxxx>
- Date: 13 Oct 2006 01:44:25 -0700
That compiler is from July. There have been at least two updates since
then. It would not astonish me if your larger example still failed, but
we have fixed bugs in this area over time, so please do send us the
full example if a current compiler doesn't fix it (or if you're unable
to get a current compiler in a timely fashion.)
The latest version of the compiler will be installed, but may take some
time. So, I will post the code, just to be sure.
The main program:
!---------------- main.f90 -----------------
program test
use my_class
type (my_obj) :: my_object
call init(my_object)
end program test
!---------------- main.f90 -----------------
And the module:
!---------------- my_class.f90 -----------------
module my_class
type my_obj
integer,dimension(2) :: i
end type my_obj
type dummy_obj
integer, dimension(:),allocatable :: x,y
end type dummy_obj
contains
!----------------------------------------------------------------------
function get_i(this) result(res)
type (my_obj),intent(in) :: this
integer,dimension(2) :: res
res = this%i
end function get_i
!----------------------------------------------------------------------
subroutine init(this)
type (my_obj), intent(inout) :: this
type (dummy_obj),dimension(:),allocatable :: dummy
this%i = [1,2]
call write_i(&
get_i(this),&
dummy)
end subroutine init
!----------------------------------------------------------------------
subroutine write_i(&
i,&
dummy)
integer,dimension(2),intent(in) :: i
type (dummy_obj),dimension(:),intent(out),allocatable :: dummy
write(*,*) i
end subroutine write_i
!----------------------------------------------------------------------
end module my_class
!---------------- my_class.f90 -----------------
This crashes at the write statement in subroutine write_i. Compiler is
ifort (20060706Z).
Note that this is the minimal code in order to make it crash. If I
change some things, it runs. Specifically one of the following changes
is sufficient to make it run:
* Change the content of dummy_obj from x,y to x.
* Change the content of dummy_obj from allocatable to fixed size arrays
* Change the content of my_obj from an integer array to an integer
* Change the variable dummy in procedures init and write_i from
allocatable array, to fixed size array
* Change the intent of the variable dummy from intent(out) to
intent(in)
I get, logically, a warning that the variable dummy is not set in
procedure write_i, but even if it is set, the program crashes at the
write statement.
One final note: the dummy object and variables have no functionality in
the code above, but of course it does have a meaning in my original
code, which is too big to post (10k lines).
I would be very thankful if someone has some comments.
Arno
.
- Follow-Ups:
- Re: Allocatables in derived types and functions
- From: Steve Lionel
- Re: Allocatables in derived types and functions
- References:
- Allocatables in derived types and functions
- From: Arno
- Re: Allocatables in derived types and functions
- From: Steve Lionel
- Re: Allocatables in derived types and functions
- From: Arno
- Re: Allocatables in derived types and functions
- From: Steve Lionel
- Allocatables in derived types and functions
- Prev by Date: Re: Standard query: Bounds of allocatable components from derived-type constructors?
- Next by Date: Disk from book
- Previous by thread: Re: Allocatables in derived types and functions
- Next by thread: Re: Allocatables in derived types and functions
- Index(es):
Relevant Pages
|