Re: jagged parameter arrays
- From: "David Frank" <dave_frank@xxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 13:07:23 GMT
"Ron Shepard" <ron-shepard@xxxxxxxxxxxxxxxxxx> wrote in message
news:ron-shepard-2BBB8E.01343929082005@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> I am doing this now with allocate statements for the arrays and
> runtime assignments for both the "n" and j(1:n) values. This
> somehow seems inelegant, as ultimately I have to store the
> information twice in order to get it into the desired derived type
> form. Is it possible to do this kind of jagged array initialization
> at compile time? Is it possible to, in some roundabout way, achieve
> the effect of parameters?
>
Below at least has no runtime initializations or size assumptions
! ------------------
module test_1
integer,parameter :: sja(2) = [2,4]
type xxx
integer :: j(100) ! max array size
end type xxx
type (xxx) :: arr(size(sja))
data arr(1)%j(1:2)/1,2/
data arr(2)%j(1:4)/1,2,3,4/
end module test_1
! -----------------
program test
use test_1
integer :: n,i
do n = 1,size(sja)
write (*,*) (arr(n)%j(i),i=1,sja(n))
end do
end program
.
- References:
- jagged parameter arrays
- From: Ron Shepard
- jagged parameter arrays
- Prev by Date: [CHALLENGE] finding rightmost zero bit
- Next by Date: Re: little isprime challenge
- Previous by thread: jagged parameter arrays
- Next by thread: [CHALLENGE] finding rightmost zero bit
- Index(es):