m_randrot.F90
605 Bytes
module m_randrot
contains
subroutine randrot(V,nrens)
implicit none
integer, intent(in) :: nrens
real, intent(out) :: V(nrens,nrens)
real, dimension(nrens,nrens) :: U, A, B
real sigma(nrens), work(10*nrens)
real, parameter :: pi=3.14159253589
integer ierr, iens
call random_number(B)
call random_number(A)
B = sqrt(-2.*log(A)) * cos(2.*pi*B)
!$OMP CRITICAL
call dgesvd('N', 'A', nrens, nrens, B, nrens, sigma, U, nrens, V, nrens, work, 10*nrens, ierr)
!$OMP END CRITICAL
if (ierr /= 0) print *, 'randrot: ierr',ierr
end subroutine randrot
end module m_randrot