ranper(3f) - [M_datapac:RANDOM] generates a random permutation
Synopsis
Description
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
SUBROUTINE RANPER(N,Istart,X)
INTEGER,intent(in) :: N INTEGER,intent(inout) :: Istart REAL(kind=wp) :: X(:)
RANPER(3f) generates a random permutation of size N of the values 1.0, 2.0, 3.0, ..., N-1, N.
N The desired integer size of the random 1 to N permutation. ISTART An integer flag code which (if set to 0) will start the generator over and hence produce the same random permutation over and over again upon successive calls to this subroutine within a run; or (if set to some integer value not equal to 0, like, say, 1) will allow the generator to continue from where it stopped and hence produce different random permutations upon successive calls to this subroutine within a run.
X A vector (of dimension at least N) into which the generated random permutation will be placed of size N of the values 1.0, 2.0, 3.0, ..., n-1, n.
Sample program:
program demo_ranper use M_datapac, only : ranper implicit none integer,parameter :: n=10 integer :: istart real :: x(n) integer :: i do i=1,3 istart=i call RANPER(N,Istart,X) write(*,*)istart write(*,(*(g0.2,1x)))x enddo end program demo_ranper
The original DATAPAC library was written by James Filliben of the Statistical Engineering Division, National Institute of Standards and Technology.Algorithm suggested by Dan Lozier, National Bureau of Standards (205.01).
John Urban, 2022.05.31
CC0-1.0
Nemo Release 3.1 | ranper (3) | February 23, 2025 |