1 SUBROUTINE ga_initial(istart,npossum,ig2sum,filename,myid)
10 USE mpi_params,
ONLY: master
16 INTEGER :: istart, npossum, ig2sum, myid
17 INTEGER :: i, j, k, l, itemp, istat
18 CHARACTER(LEN=100) :: filename
19 CHARACTER(LEN=200) :: temp
25 pardel(i)=par_max(i)-par_min(i)
27 g1(i)=pardel(i)/(itemp-1)
39 nchrome=nchrome+ig2(i)
40 npossum=npossum+2**nposibl(i)
41 ig2sum=ig2sum+(2**ig2(i))
43 IF (nchrome.gt.nchrmax)
THEN
44 IF (myid .eq. master)
THEN
46 WRITE(iunit_ga_out,1800) nchrome
52 IF (npossum.lt.ig2sum .and. microga.ne.0
53 1 .and. myid.eq.master)
THEN
55 WRITE(iunit_ga_out,2100)
69 IF(rand.lt.0.5d0) iparent(j,i)=0
72 IF (npossum.lt.ig2sum)
CALL ga_possibl(parent,iparent,myid)
74 IF (unique_ind .gt. 0)
THEN
76 CALL ga_code(unique_ind, i, parent, iparent)
82 IF (myid .eq. master)
THEN
84 temp =
"../ga_restart." // filename
85 CALL safe_open(iunit_ga_restart, istat,
86 1 trim(temp),
'unknown',
'formatted')
87 READ (iunit_ga_restart,*) istart,npopsiz
89 READ(iunit_ga_restart,*) k,(iparent(l,j),l=1,nchrome)
91 CLOSE (iunit_ga_restart)
94 CALL mpi_bcast(istart, 1, mpi_integer, master,
95 1 mpi_comm_world, ierr)
96 CALL mpi_bcast(npopsiz, 1, mpi_integer, master,
97 1 mpi_comm_world, ierr)
99 IF (myid .eq. master) fitness = iparent(l,:)
100 CALL mpi_bcast(fitness, indmax, mpi_real8, master,
101 1 mpi_comm_world, ierr)
102 IF (myid .ne. master) iparent(l,:) = fitness
107 IF(irestrt.ne.0)
CALL ran3(idum-istart,rand)
109 1800
FORMAT(1x,
'ERROR: nchrome > nchrmax. Set nchrmax = ',i6)
110 2000
FORMAT(1x,
'ERROR: you have a parameter with a number of '/
111 + 1x,
' possibilities > 2**30! if you really desire this,'/
112 + 1x,
' change the do loop 7 statement and recompile.'//
113 + 1x,
' you may also need to alter the code to work with'/
114 + 1x,
' real numbers rather than integer numbers; fortran'/
115 + 1x,
' does not like to compute 2**j when j>30.')
116 2100
FORMAT(1x,
'WARNING: for some cases, a considerable performance'/
117 + 1x,
' reduction has been observed when running a non-'/
118 + 1x,
' optimal number of bits with the micro-GA.'/
119 + 1x,
' If possible, use values for nposibl of 2**n,'/
120 + 1x,
' e.g. 2, 4, 8, 16, 32, 64, etc. See ReadMe file.')
123 END SUBROUTINE ga_initial