module OW_rndseed

use OW_exec_time
use OW_parms_areal

implicit none

contains

!---------------------------------------------
SUBROUTINE init_random_seed(isp,iwn,rand1,iw)

   integer,optional			:: iw
   real 				:: rnd,rand1(iwn)
   integer, dimension(2) 		:: seed, seed_old
   integer 			:: L,i,n,seed_1,seed_2,iwn,isp

   if (present(iw)) then
      call owexec_time (rnd)
      seed(1)=int(rnd*(isp*iw))+rndcte
      call owexec_time (rnd)
      seed(2)=int(rnd/(iw*isp))+rndcte
      call random_seed(put=seed)
   else
      call owexec_time (rnd)
      seed(1)=int(rnd*(isp))+rndcte
      call owexec_time (rnd)
      seed(2)=int(rnd/isp)+rndcte
      call random_seed(put=seed)
   end if
   do i=1,iwn
      call random_number(rand1(i))
   end do

   rand1=(rand1-0.5)*2.

END SUBROUTINE
end module
