C     COSTRUZIONE RETICOLO A TELA DI RAGNO
      INTEGER*2 NOD(3,2000)
      REAL*8 X(1000)/1000*0.D0/,Y(1000)/1000*0.D0/
      REAL*8 RI,RE,RAP,ALFA,TETA,R
      open (5,file='retrag.dat')
      open (8,file='retrag.out')
      open (6,file='retrag.ris')
10    CONTINUE
      READ(5,*) RI,RE,RAP,NUM
      I=2
      ALFA=3.14159265D0/NUM
      TETA=ALFA
      R=RI
2     DO 1 K=1,NUM
      X(I)=R*DSIN(TETA)
      Y(I)=R*DCOS(TETA)
      I=I+1
1     TETA=TETA+2.D0*ALFA
      IF(R.EQ.RE) GO TO 3
      TETA=TETA-ALFA
      R=R*RAP
      IF(R.GT.RE) RE=R
      GO TO 2
3     I=I-1
ccc      WRITE(6,102)(K,X(K),Y(K),K=1,I)
      K=1
      DO 4 J=1,NUM
      NOD(1,K)=1
      NOD(2,K)=K+2
      IF(K+2.EQ.NUM+2) NOD(2,K)=NOD(2,K)-NUM
      NOD(3,K)=K+1
4     K=K+1
      N=2
      L=2
6     DO 5 J=1,NUM
      NOD(1,K)=L
      NOD(1,K+1)=L
      NOD(2,K)=L+NUM+1
      NOD(2,K+1)=L+1
      NOD(3,K)=L+NUM
      IF(NOD(2,K).EQ.N*NUM+2) NOD(2,K)=NOD(2,K)-NUM
      NOD(3,K+1)=NOD(2,K)
      IF(NOD(2,K+1).EQ.(N-1)*NUM+2) NOD(2,K+1)=NOD(2,K+1)-NUM
      L=L+1
5     K=K+2
      N=N+1
      IF(L.LT.I-NUM) GO TO 6
      K=K-1
ccc      WRITE(6,103)(J,(NOD(L,J),L=1,3),J=1,K)
      L=1
cccc      WRITE(8,104) I,K,L,L,L,I,I
cccc      WRITE(8,104)((NOD(L,J),L=1,3),J=1,K)
cccc      WRITE(8,101)(X(M),Y(M),M=1,I)
c*******
      write(6,*) ' numero nodi=',i,'  numero elementi=',k
      write(8,*) i,k,'     N  NTRI'
      do j=1,k
         write(8,104) (NOD(L,J),L=1,3),1
      end do
      do m=1,i
         WRITE(8,111) X(m),Y(M)
      end do
c**********
      L=1
      R=1.
cccc      WRITE(6,108) L,K,R
      L1=100
cccc      WRITE(6,104) L1
cccc      WRITE(6,109) L,K,R
cccc      WRITE(6,105)
      N=1
      K=1
      R=-1.D0*2.D0/(3*NUM)
      R=-1000.D0*2.D0/(3*NUM)
      RAP=R*NUM/2.D0
cccc      WRITE(6,106) K,RAP,N
      M=NUM+1
cccc      DO 7 K=2,M
cccc7     WRITE(6,106) K,R,N
cccc      WRITE(6,105)
      R=0.01
cccc      WRITE(6,100)R
cccc      WRITE(6,105)
C     GO TO 10
       STOP
100   FORMAT(3F16.8,1X,I2)
101   FORMAT(6F13.5)
102   FORMAT(3(3X,I4,1X,2F13.7))
103   FORMAT(6(1X,I4,1X,3I4,3X))
104   FORMAT(16I5)
105   FORMAT(80X)
106   FORMAT(I4,E16.8,9X,I1)
107   FORMAT(I3)
108   FORMAT(2I4,F16.8)
109   FORMAT(2I4,F5.1)
110   FORMAT(3I3)
111   FORMAT(6F13.5)
C0.1             1000.             2.1           10SCHEDA DATI
      END
