V3FIT
ga_code.f
1  SUBROUTINE ga_code(j,k,array,iarray)
2 c#######################################################################
3 c
4 c
5 c This routine codes a PARAMETER into a binary string.
6 c
7  USE ga_mod
8  IMPLICIT NONE
9  INTEGER :: j, k, i, istart, iparam, m
10  REAL(rprec), DIMENSION(nparmax,indmax) :: array
11  INTEGER, DIMENSION(nchrmax,indmax) :: iarray
12 
13  SAVE
14 c
15 c First, establish the beginning location of the PARAMETER string of
16 c interest.
17  istart=1
18  DO 10 i=1,k-1
19  istart=istart+ig2(i)
20  10 CONTINUE
21 c
22 c Find the equivalent coded PARAMETER value, and back out the binary
23 c string by factors of two.
24  m=ig2(k)-1
25  IF (g1(k).eq.0.0_dp) RETURN
26  iparam=nint((array(k,j)-g0(k))/g1(k))
27  DO 20 i=istart,istart+ig2(k)-1
28  iarray(i,j)=0
29  IF ((iparam+1).gt.(2**m)) THEN
30  iarray(i,j)=1
31  iparam=iparam-2**m
32  END IF
33  m=m-1
34  20 CONTINUE
35 c WRITE(3,*)array(k,j),iparam,(iarray(i,j),i=istart,istart+ig2(k)-1)
36 c
37  END SUBROUTINE ga_code