PROGRAM SETPOLAR
C======================================================================
C        DATA ASSEMBLY PROGRAM FOR APPLICATION: POLAR1D.FOR
C                   EIJI FUKUMORI  11-FEB-2022
C  X(I) = RADIUS OF POLAR COORDINATE
C  CHARGE(I) = CHARGE SUCH AS CURRENT INTO THE CENTER WIRE OF COAXIAL
C  IBTYPE(1) = BOUNDARY CONDITION AT R=0        2 FOR NEUMANN
C  IBTYPE(2) = BOUNDARY CONDITION AT R=RADIUSB  1 FOR DICHILET
C  BV(I) = BOUNDARY VALUES
C  NODEX(I,J) = REPRESENTS ELEMENT CONFIGURATION
C======================================================================
      IMPLICIT REAL*8 ( A-H , O-Z )
      PARAMETER ( MXND=3,MXE=20000, MXN=MXE+1, ND=2 )
      DIMENSION NODEX(MXE,MXND),CHARGE(MXE),X(MXN),IBTYPE(2),BV(2)
C---------- INFORMATION OF COAXIAL CABLE DIMENSION
C-------------------- RADIUSA: RADIUS OF THE CENTER CONDUCTOR
C-------------------- RADIUSB: RADIUS OF BRAIDED CONDUCTOR 
      RADIUSA = 0.7D0
      RADIUSB = 2.4D0
      WRITE (*,*) 'RADIUS A=', RADIUSA
      WRITE (*,*) 'RADIUS B=', RADIUSB
C---------- BOUNDARY CONDITIONS
      IBTYPE(1) = 2
      IBTYPE(2) = 1
      BV(1) = 0.D0
      BV(2) = 0.D0
C---------- VALUE OF CHARGE INTO THE CENTER CONDUCTOR
      PI = 4.D0*DATAN (1.D0)
      Q = 1.D0/(2.D0*PI*RADIUSA)
      WRITE (*,*) 'UNIFORM ELECTRICAL CHARGE(Q(R=0 TO A))=',Q
      WRITE (*,*) 'BOUNDARY CONDITION AT R=0 IS NEUMANN TYPE'
      WRITE (*,*) 'BOUNDARY VALUE IS ', BV(1)
      WRITE (*,*) 'BOUNDARY CONDITION AT R=B IS DIRICHLET TYPE'
      WRITE (*,*) 'BOUNDARY VALUE IS ', BV(2)
C----------------------------------------------------------
C--------- NE1 = NUMBER OF ELEMENTS WHERE CHARGE APPLIED
C--------- NE2 = NO CHARGE ZONE
      NE1 = 10
      NE2 = 30
      NE = NE1 + NE2
      WRITE (*,*) 'NUMBER OF ELEMENTS IN CHARGE ZONE NE1=', NE1
      WRITE (*,*) 'NUMBER OF ELEMENTS IN NO-CHARGE ZONE NE2=', NE2
C------- NODAL NUMBER ASSIGNMENT----------
C--------------- CHARGE ZONE
      DO I = 1 , NE1
      CHARGE(I) = Q
      DO J = 1 , ND
      NODE = I - 1 + J
      NODEX(I,J) = NODE
      END DO
      END DO
C--------------- NO CHARGE ZONE ----------
      DO I = 1+NE1 , NE1+NE2
      CHARGE(I) = 0.D0
      DO J = 1 , ND
      NODE = I - 1 + J
      NODEX(I,J) = NODE
      END DO
      END DO
C--------------NODAL COORDINATE--------------
C------------ CHARGE ZONE
      NNODE1 = NE1 + 1
      DX = RADIUSA / NE1
      NNODE = 0
      DO I = 1 , NNODE1
      NNODE = NNODE + 1
      X(NNODE) = ( I - 1 ) * DX
      END DO
C------------ NO CHARGE ZONE
      NNODE2 = NE2
      DX = ( RADIUSB - RADIUSA ) / NE2
      DO I = 1 , NNODE2
      NNODE = NNODE + 1
      X(NNODE) =  I*DX + RADIUSA
      END DO
C------- WRITING DATA INTO INPUT FILE
      OPEN ( 1,FILE='POLAR.DAT', STATUS="UNKNOWN")
      WRITE(1,*) NE
      DO I = 1 , NE
      WRITE(1,*) I, (NODEX(I,J),J=1,ND), CHARGE(I)
      END DO
      DO I = 1 , NNODE
      WRITE(1,*) I, X(I)
      END DO
      WRITE(1,*) IBTYPE(1), BV(1)
      WRITE(1,*) IBTYPE(2), BV(2)
      CLOSE (1)
      STOP
      END