-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutate.f90
35 lines (35 loc) · 917 Bytes
/
mutate.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
subroutine mutate()
use numz
use ran_mod
use galapagos
use control
implicit none
integer i,j,ndo,k
real(b8) sigma,mu
real(b8)x1,x2
if(mute_rate .le. 0.0)return
if(do_one)then
do j = 1 , nstates
if(mute_rate > ran1())then
x1=ran1()
! i=nint((nstates-1)*ran1()+1)
i=nint((nstates-1)*x1 +1)
gene(i,j)=ncolor*ran1()
endif
enddo
else
mu=nstates*mute_rate
sigma=sqrt(mu*(1.0_b8-mute_rate))
do j = 1 , nstates
ndo=nint(normal(sigma,mu))
ndo=max(0,min(ndo,nstates))
do i=1,ndo
x1=ran1()
! k=nint((nstates-1)*ran1()+1)
k=nint((nstates-1)*x1 +1)
gene(k,j)=ncolor*ran1()
enddo
enddo
endif
return
end subroutine mutate