hi,
I have been asking myself this question for a long time, and there's
nobody around me at work who knows anything about programming, so
there it is.
I very much like derived types. I use them all the time. In the
derived type ptcl I have three unallocated arrays x,y and z. In the
main I create the variable ptcles of type ptcl. I would like to pass
ptcles as argument to a routine called gnagna that would allocate the
arrays ptcles%x, ptcles%y, and ptcles%z.
Here is the code. When I compile it with the PGI compiler on a Cray,
it works. I first get F F F , then T T T.
Beyond the practical aspect, I would like to know whether I am lucky,
or whether all F90 compilers on all machines will accept it.
--------------------------------------------------------------------------------------------
module opla
type ptcl
double precision, dimension(:), pointer :: x,y,z
end type
end module
!==============================
program essai
use opla
implicit none
type(ptcl) ptcles
print *,allocated(ptcles%x), allocated(ptcles%y), allocated(ptcles%z)
call gnagna(ptcles)
print *,allocated(ptcles%x), allocated(ptcles%y), allocated(ptcles%z)
end program
!===============================
subroutine gnagna(ptcles)
use opla
implicit none
type(ptcl) ptcles
allocate(ptcles%x(100))
allocate(ptcles%y(100))
allocate(ptcles%z(100))
end subroutine


|