V3FIT
ga_newgen.f
1  SUBROUTINE ga_newgen(npossum,ig2sum,myid)
2 c#######################################################################
3 c
4 c Write child array back into parent array for new generation. Check
5 c to see IF the best parent was replicated; IF not, and IF ielite=1,
6 c THEN reproduce the best parent into a random slot.
7 c
8  USE ga_mod
9  USE mpi_params, ONLY: master
10  IMPLICIT NONE
11  INTEGER :: npossum, ig2sum, kelite, jelite
12  INTEGER :: irand, j, n, myid
13  REAL(rprec) :: rand
14  SAVE
15 c
16  IF (npossum.lt.ig2sum) CALL ga_possibl(child,ichild,myid)
17  kelite=0
18  DO 94 j=1,npopsiz
19  jelite=0
20  DO 95 n=1,nchrome
21  iparent(n,j)=ichild(n,j)
22  IF (iparent(n,j).eq.ibest(n)) jelite=jelite+1
23  IF (jelite.eq.nchrome) kelite=1
24  95 CONTINUE
25  94 CONTINUE
26  IF (ielite.ne.0 .and. kelite.eq.0) THEN
27  CALL ran3(1,rand)
28  irand=1+int(npopsiz*rand)
29  iparent(1:nchrome,irand)=ibest(1:nchrome)
30  IF (myid .eq. master) WRITE(iunit_ga_out,1260) irand
31  END IF
32 c
33  1260 FORMAT(' Elitist Reproduction on Individual ',i4)
34 c
35  END SUBROUTINE ga_newgen