Home > Archive > Fortran > February 2007 > uniform distribution with a random dimension usign IMSL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
uniform distribution with a random dimension usign IMSL
|
|
| fortee 2007-02-16, 7:06 pm |
| I tried to made a code with a poisson and a uniform distribution in
IMSL. There is no problem in compiling the following code in Intel
Fortran Complier. But when I try to execute the code, a error message
pops up.
I want to draw a vector x1 from a unifrom distribution[0,1] with a
random dimension (n) which is drawn from a poisson distribution(mean
5000). I mean
iter1 x1(4999 dimension)
iter2 x1(4988 dimension)
....
iter10 x1(4898 dimension)
Dimensions are random
Please help me. I am so frustrated now.
program brownian
INCLUDE 'link_f90_static.h'
use rnpoi_int
use rnset_int
use rnun_int
implicit none
integer, dimension(1)::len
integer:: i
real, parameter:: ns=5000
integer, dimension(1):: dummy
integer:: N
real, allocatable::x1(:)
real:: dum
integer, parameter:: r=10
real:: ks(r)
do i=1,r
call rnpoi(ns, len)
dummy(:)=len
N=dummy(1)
allocate(x1(N))
call rnun(x1)
ks(r)=sum(x1)
enddo
dum=sum(ks)/r
end program brownian
| |
| e p chandler 2007-02-17, 4:10 am |
| On Feb 16, 7:32 pm, "fortee" <hongch...@gmail.com> wrote:
> I tried to made a code with a poisson and a uniform distribution in
> IMSL. There is no problem in compiling the following code in Intel
> Fortran Complier. But when I try to execute the code, a error message
> pops up.
>
> I want to draw a vector x1 from a unifrom distribution[0,1] with a
> random dimension (n) which is drawn from a poisson distribution(mean
> 5000). I mean
>
> iter1 x1(4999 dimension)
> iter2 x1(4988 dimension)
> ...
> iter10 x1(4898 dimension)
>
> Dimensions are random
>
> Please help me. I am so frustrated now.
>
> program brownian
>
> INCLUDE 'link_f90_static.h'
>
> use rnpoi_int
> use rnset_int
> use rnun_int
>
> implicit none
>
> integer, dimension(1)::len
> integer:: i
> real, parameter:: ns=5000
> integer, dimension(1):: dummy
>
> integer:: N
> real, allocatable::x1(:)
>
> real:: dum
> integer, parameter:: r=10
>
> real:: ks(r)
>
> do i=1,r
> call rnpoi(ns, len)
> dummy(:)=len
> N=dummy(1)
>
> allocate(x1(N))
>
> call rnun(x1)
You are calling RNUN with an assumed shape array. Maybe it requires a
fixed size array or an assumed size array instead?
>
> ks(r)=sum(x1)
> enddo
>
> dum=sum(ks)/r
>
> end program brownian
| |
| Dave Seaman 2007-02-17, 4:10 am |
| On 16 Feb 2007 16:32:53 -0800, fortee wrote:
> I tried to made a code with a poisson and a uniform distribution in
> IMSL. There is no problem in compiling the following code in Intel
> Fortran Complier. But when I try to execute the code, a error message
> pops up.
> I want to draw a vector x1 from a unifrom distribution[0,1] with a
> random dimension (n) which is drawn from a poisson distribution(mean
> 5000). I mean
> iter1 x1(4999 dimension)
> iter2 x1(4988 dimension)
> ...
> iter10 x1(4898 dimension)
> Dimensions are random
> Please help me. I am so frustrated now.
> program brownian
> INCLUDE 'link_f90_static.h'
> use rnpoi_int
> use rnset_int
> use rnun_int
> implicit none
> integer, dimension(1)::len
> integer:: i
> real, parameter:: ns=5000
> integer, dimension(1):: dummy
> integer:: N
> real, allocatable::x1(:)
> real:: dum
> integer, parameter:: r=10
> real:: ks(r)
> do i=1,r
> call rnpoi(ns, len)
> dummy(:)=len
> N=dummy(1)
> allocate(x1(N))
> call rnun(x1)
> ks(r)=sum(x1)
> enddo
> dum=sum(ks)/r
> end program brownian
Your IMSL calls appear to be ok. The problem is that you have an
ALLOCATE statement inside a DO loop, but no DEALLOCATE anywhere. This
results in an error when you attempt to allocate the same array for the
second time.
--
Dave Seaman
U.S. Court of Appeals to review three issues
concerning case of Mumia Abu-Jamal.
<http://www.mumia2000.org/>
| |
| fortee 2007-02-20, 10:04 pm |
| On 2=BF=F916=C0=CF, =BF=C0=C8=C411=BD=C351=BA=D0, Dave Seaman <dsea...@no.s=
uch.host> wrote:
> On 16 Feb 2007 16:32:53 -0800, fortee wrote:
>
>
>
>
>
>
> Your IMSL calls appear to be ok. The problem is that you have an
> ALLOCATE statement inside a DO loop, but no DEALLOCATE anywhere. This
> results in an error when you attempt to allocate the same array for the
> second time.
>
> --
> Dave Seaman
> U.S. Court of Appeals to review three issues
> concerning case of Mumia Abu-Jamal.
> <http://www.mumia2000.org/>- =B5=FB=BF=C2 =C5=D8=BD=BA=C6=AE =BC=FB=B1=E2=
=B1=E2 -
>
> - =B5=FB=BF=C2 =C5=D8=BD=BA=C6=AE =BA=B8=B1=E2 -
Thanks. It works with deallocate.
|
|
|
|
|