!****************************************************
program Electric_Fields
!****************************************************
 implicit none
 integer,parameter:: P=20      !max number of charges
 real,dimension(P):: X,Y,Q
 integer          :: N
 integer          :: i,j,nd
 real             :: x0,y0,theta
 real,parameter   :: PI= 3.14159265359
!-------------  SET CHARGE DISTRIBUTION ----
 print *, '# Enter number of charges:'
 read  *, N
 print *, '# N= ',N
 do i=1,N
  print *,'# Charge: ',i
  print *,'# Position and charge: (X,Y,Q):'
  read  *,  X(i),Y(i),Q(i)
  print *,'# (X,Y)= ', X(i),Y(i), ' Q= ',Q(i)
 enddo
!-------------  DRAWING LINES  -------------
!We draw 2*nd field lines around each charge
 nd    = 6
 do  i = 1,N
  do j = 1,(2*nd)
   theta = (PI/nd)*j
   x0    = X(i) + 0.1 * cos(theta)
   y0    = Y(i) + 0.1 * sin(theta)
   call  eline(x0,y0,X,Y,Q,N)
  enddo
 enddo
end program Electric_Fields
