[Fortran] 纯文本查看 复制代码
! ****************************************************************************************** !
Module random_choice_FYS
use prec
IMPLICIT NONE
Integer,allocatable,Target :: pos_tmp(:)
Integer,Pointer :: posp(:)
contains
!-------------------------------------------------------------------
!-------------------------------------------------------------------
Subroutine choice_FYS(NL,N,L,num,p,i,j)
Integer,intent(IN) :: NL,N,L,num
Integer,intent(INOUT) :: p
Integer,intent(OUT) :: i,j
Integer :: pp,tmp
Real(kq) :: KK
!------------------------------------------------------------------
call random_number(KK); pp=Int(KK*(NL-p-1) +1)
if ((p < num)) Then
p=p+1
i = int(pp/L)
j = mod(pp,L)
tmp = posp(NL-p+1)
posp(NL-p+1) = posp(pp)
posp(pp) = tmp
else
return
endif
!---------------------------
Return
End subroutine choice_FYS
!-------------------------------------------------------------------
!-------------------------------------------------------------------
End Module random_choice_FYS
!***************************************************************************