Hi, I have a problem with a code I'm working with. I'm a student in physics and I'm writing a code in Fortran 90 that should calculate the Polonium's half-life time. I have no data to work with so I generated them with the library random number and here is the problem, I have a 300 lines code with something like 5 subroutine but one of them is the one that is generating the data with which I'll work with and it is the one creating several segmentation faults. What I'd like to do, and I hope someone of you could help me, is to define an allocatable array, in which generate n times random numbers of which just r will satisfied some given conditions. So the fact is that i'm trying to allocate the array dimension after having create some of his component. Being more specific I'll write just the piece of code that generate those number because it is the same as the subroutine and is much shorter than the whole code. Code (Fortran): program polly implicit none REAL::dx,l,p,q,z,m INTEGER::i,n,r REAL,DIMENSION(:),allocatable::x,y n=100 dx=0.05 l=3.0 p=10.0 q=10.0 r=0 !allocate (x(n),y(n)) do i=1,n call random_number(x) call random_number(y) m=y(i)*q z=x(i)*p if ((exp(-l*(z+dx))) <= log(m) .AND. log(m) <= (exp(-l*(z-dx)))) then write(unit=1,fmt=*), x,y r=r+1 else x=0 y=0 END IF print*,"r",r,"x",x,"y",y end program polly So here the value of r after the do cycle should be the times which the condition is satisfied so it is the dimension I wish x and y had. I tried multiple times and multiple ways, even setting the dimension as n and giving the value 0 to all the n-r "holes" in the array. Then in the whole program I have those other subroutine that are based on the same x and y that are intent in, which are the two arrays that I calculate in the subroutine above. Moreover these subroutines calculate several mean value that need to be divided by the real number of component and not the whole n. Furthermore, I don't know where the accepted point will be in the array so that it is not sufficient to just allocate the vectors but I need also a procedures to select only the acceptable points ignoring all the others. I don't know if I made it clear to you or not, I tried. I hope you can help. Thanks anyway.