- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I am using the following code for random permutations:
subroutine rperm(nsim, IPERM1)
integer, intent(in) :: nsim
integer, dimension(:), intent(out) :: IPERM1
integer :: mynumber, i, j, k
real, dimension(nsim) :: rand2
call random_number(rand2)
IPERM1= 0
do i=1,nsim
print*, 'HEREHEREHERE: i=', i
mynumber=1
do j=1,nsim
if (rand2(i) > rand2(j)) then
mynumber = mynumber+1
end if
end do
if (i>1) then
do k=1,i-1
if (rand2(i) <= rand2(k) .and. rand2(i) >= rand2(k)) then
mynumber = mynumber+1
end if
end do
c
end if
print*, 'RPERM WORKS HERE'
IPERM1(i) = mynumber
end do
return
end subroutine rperm
However, it is getting stuck at the line: IPERM1(i) = mynumber and exits the subroutine.
Why is this happening?
- Etiquetas:
- Intel® Fortran Compiler
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
How are you calling the procedure? Does it have an explicit interface?
(Is the argument nsim redundant given the size of the IPERM1 argument is available inside the procedure?)
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I'm guessing you don't have an explicit interface, and so iperm1(:) must be assumed size. Otherwise, as Ian hinted, size(iperm1) would be defined, and nsim > size(iperm1) could be checked to detect an obvious problem. In any case, violating that condition would make behavior unpredictable.
If iperm1 is meant to have dimension(nsize), writing it that way and invoking ifort interface checking would give you an automatic indication of the violation.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Got it. I needed to declare it's size. Thanks
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla