PROGRAM SET4STAX3D0
C=======================================================================
C THREE DIMENSIONAL DATA GENERATING PROGRAM FOR EIGENLANCZOS_SOLID.FOR
C    PROJECT NAME: BEAM000
C    BOUNDARY CONDITIONS
C            LEFT END:  EITHER FIXED (COMPLETELY FIXED) OR FREE
C            RIGHT END: FREE
C            ALL OTHERS: NO NORMAL FOECE, NO SHEAR FORCE
C    DOMAIN: RECTANGULAR
C    ELEMENT: 8-NODED ISOPARAMETRIC HEXA 3D ELEMENT
C    DOMAIN DISCRETIZATION: ONE-SIZE ELEMENTS 
C     EIJI FUKUMORI JUNE 18, 2010
C=======================================================================
      IMPLICIT REAL*8 ( A-H , O-Z )
      PARAMETER ( ND=8, MXE=220000, MXN=230000, MXB=20000 )
      PARAMETER (YOUNG=205.D9,POISSON=0.3D0, DENSITY=7860.D0,
     * TLX = 100.D0    , TLY = 2.D0   , TLZ = 2.D0   ,   
     * NEX = 100      , NEY = 2      , NEZ = 3     , 
     * DX  = TLX/NEX  , DY  = TLY/NEY, DZ  = TLZ/NEZ, 
     * NDX = NEX+1    , NDY = NEY+1  , NDZ = NEZ+1       )
C=======================================================================
      DIMENSION NODEX(MXE,ND), 
     * XCOORD(MXN), YCOORD(MXN) ,ZCOORD(MXN),
     * IBNDFX(MXB), IBNDFY(MXB) ,IBNDFZ(MXB),
     * BVX(MXB)   , BVY(MXB)    ,BVZ(MXB)   ,
     * IBFORCEX(MXB), IBFORCEY(MXB), IBFORCEZ(MXB)
      CHARACTER INPFILE*13,EXFILE*3
      LOGICAL YES, RSTRAINT
C=======================================================================
      DATA INPFILE / 'EIGN3D08S.DAT' /
C=======================================================================
      F(X) = X 
      G(X) = X
C=======================================================================
C      NEZ: NEMBER OF VERTICAL   ELEMENTS (NUMBER OF NODES: NEZ+1)
C      NEY: NEMBER OF DEPTH      ELEMENTS (NUMBER OF NODES: NEY+1)
C      NEX: NEMBER OF HORIZONTAL ELEMENTS (NUMBER OF NODES: NEX+1)
C=======================================================================
C--------- EIGRNVALUE PARAMETER
C--------- DELTA = SHIFT PARAMETER THAT MUST BE > 0.
C--------- NEIGEN = NUMBER OF EIGRNVALUES TO BE EVALUATED
      DELTA    = 1.D-2
      NEIGEN   = 30
C---------------- RSTRAINT = .FALSE. MEANS LEFT END IS FREE
C---------------- RSTRAINT = .TRUE.  MEANS LEFT END IS FIXED
      RSTRAINT = .TRUE.
C=======================================================================
      WRITE (*,*)'DENSITY OF SOLID = ',DENSITY
      WRITE (*,*)'YOUNG MODULUS    = ',YOUNG
      WRITE (*,*)'POISSON RATIO    = ',POISSON
      WRITE (*,*)'DELTA    =', DELTA
      WRITE (*,*)'NEIGEN   =', NEIGEN
      WRITE (*,*)'RSTRAINT =', RSTRAINT
C=======================================================================
C                    ELEMENT CREATION
      NE = 0
      DO I = 1 , NEX
      DO J = 1 , NEY
      DO K = 1 , NEZ
      NE = NE + 1
      IF ( NE .GT. MXE ) STOP 'NE > MXE'
      NODEX(NE,1) = (I-1)*NDY*NDZ + (K-1)*NDY + J
      NODEX(NE,2) = NODEX(NE,1) + NDY*NDZ
      NODEX(NE,3) = NODEX(NE,2) + 1
      NODEX(NE,4) = NODEX(NE,1) + 1
      NODEX(NE,5) = NODEX(NE,1) + NDY
      NODEX(NE,6) = NODEX(NE,5) + NDY*NDZ
      NODEX(NE,7) = NODEX(NE,6) + 1
      NODEX(NE,8) = NODEX(NE,5) + 1
      END DO
      END DO
      END DO
      WRITE (*,*) 'NUMBER OF ELEMENTS =', NE
C=======================================================================
C--------0---------0---------0---------0---------0---------0---------0--
C                 NODAL COORDINATE CREATION
      NNODE = 0
      DO I = 1 , NDX
      DO K = 1 , NDZ
      DO J = 1 , NDY
      NNODE = NNODE + 1
      IF ( NNODE .GT. MXN ) STOP 'NNODE > MXN'
      XCOORD(NNODE) = (I-1)*DX
      YCOORD(NNODE) = (J-1)*DY
      ZCOORD(NNODE) = (K-1)*DZ
      END DO
      END DO
      END DO
      WRITE (*,*) 'NUMBER OF NODAL POINTS =', NNODE
C=======================================================================
C                    BOUNDARY CONDITIONS
C==== FIRST FIND
C--------- NAVIER EQUATIONS
C------- IF THERE ARE SOME DIRICHLET BOUNDARIES, RSTRAINT = .TRUE.
C------- IF NO NODE IS GROUNDED, RSTRAINT = .FALSE.
      NBFX = 0
      NBFY = 0
      NBFZ = 0
      IF ( RSTRAINT ) THEN
C-----------------------------------------------
C--------- X DIRECTION ON FACE -X
      DO K = 1 , NDZ
      DO J = 1 , NDY
      NBFX = NBFX + 1
      IBNDFX(NBFX) = J + (K-1)*NDY
      BVX(NBFX) = 0.D0
C
      NBFY = NBFY + 1
      IBNDFY(NBFY) = J + (K-1)*NDY
      BVX(NBFX) = 0.D0
C
      NBFZ = NBFZ + 1
      IBNDFZ(NBFZ) = J + (K-1)*NDY
      BVZ(NBFZ) = 0.D0
      END DO
      END DO
      END IF
C=======================================================================
C                      DATA FILE INQUIRY
      EXFILE = 'NEW'
      INQUIRE ( FILE = INPFILE, EXIST = YES )
      IF ( YES ) EXFILE='OLD'
C=======================================================================
C                     CREATING DATA FILES
C---------- PARAMETERS
      OPEN ( 1, FILE=INPFILE, STATUS = EXFILE )
      WRITE(1,*) DELTA, NEIGEN 
      WRITE(1,*) DENSITY, YOUNG, POISSON
C---------- ELEMENTS
      WRITE(1,*) NE
      DO I = 1 , NE
      WRITE (1,*) I, (NODEX(I,J), J = 1 , ND )
      END DO
C---------- COORDINATES OF NONAL POINTS
      WRITE(1,*) NNODE
      DO I = 1 , NNODE
      WRITE(1,*) I,XCOORD(I), YCOORD(I), ZCOORD(I)
      END DO
C---------- DIRICHLET TYPE BOUNDARY CONDITIONS
      WRITE(1,*) NBFX
       IF ( NBFX .GT. 0 ) THEN
         DO I = 1 , NBFX 
         WRITE (1,*) IBNDFX(I), BVX(I)
         END DO
       END IF
      WRITE(1,*) NBFY
       IF ( NBFY .GT. 0 ) THEN
         DO  I = 1 , NBFY 
         WRITE (1,*) IBNDFY(I), BVY(I)
         END DO
       END IF
      WRITE(1,*) NBFZ
       IF ( NBFZ .GT. 0 ) THEN
         DO  I = 1 , NBFZ 
         WRITE (1,*) IBNDFZ(I), BVZ(I)
         END DO
       END IF
C=======================================================================
C---------- FINAL
      CLOSE (1)
C=======================================================================
      CALL BANDWID ( ND, MXE, NE, NODEX , NBW  )
      INTEPT=2
C------ CREATION OF PARAMETER FILE TO BE USED IN INCLUDE STATEMENT
      OPEN ( 1, FILE='PARAM.DAT', STATUS='UNKNOWN' )
      WRITE (1,*) '      PARAMETER ( ND=',ND,' )'
      WRITE (1,*) '      PARAMETER ( INTEPT=',INTEPT,' )'
      WRITE (1,*) '      PARAMETER ( MXE=',NE,' )'
      WRITE (1,*) '      PARAMETER ( MXN=',NNODE,' )'
      WRITE (1,*) '      PARAMETER ( MXW=',NBW,' )'
      WRITE (1,*) '      PARAMETER ( MXENGN=',NEIGEN,' )'
      WRITE (1,*) '      PARAMETER ( MXB=',NBFX+NBFY+NBFZ,' )'
      CLOSE (1)
C=======================================================================
C---------- ELEMENT DRAWING
C      OPEN ( 1, FILE='ELEMENT.DAT', STATUS = 'UNKNOWN')
C      DO I = 1, NE
C      DO J = 1 , ND
C      WRITE (1,*) XCOORD(NODEX(I,J)), YCOORD(NODEX(I,J))
C      END DO
C      WRITE (1,*) XCOORD(NODEX(I,1)), YCOORD(NODEX(I,1))
C      WRITE (1,*)
C      END DO
C      CLOSE (1)
      STOP 'NORMAL TERMINATION'
      END
C
C
      SUBROUTINE BANDWID ( ND, MXE, NE, NODEX , NBW  )
      IMPLICIT REAL*8 ( A-H , O-Z )
      DIMENSION NODEX(MXE,ND)
      NBW = 0
      DO  I = 1 , NE
      DO  J = 1 , ND-1
      DO  K = J+1 , ND
      NBW = MAX0(NBW,IABS(NODEX(I,J)-NODEX(I,K)))
      END DO
      END DO
      END DO
      NBW = NBW + 1
      WRITE(*,*) 'HALF BANDWIDTH + 1 =', NBW
      RETURN
      END