gambit_read.F [SRC] [CPP] [JOB] [SCAN]
TOOLS / COMMON



   1 | include(dom.inc)
   2 | 
   3 |       MODULE gambit_read
   4 | 
   5 | !       ================================================================!
   6 | !                                                                       !
   7 | !       gambit_read.F : Reads GAMBIT mesh files                         !
   8 | !                                                                       !
   9 | !       author        : D. POITOU (march 2008)                          !
  10 | !                                                                       !
  11 | !       ================================================================!
  12 | 
  13 |         IMPLICIT NONE
  14 | 
  15 |         TYPE patch
  16 |           CHARACTER*32                         :: patch_name
  17 |           DOM_INT                              :: itype
  18 |           DOM_INT                              :: nentry
  19 |           DOM_INT, allocatable, dimension(:)   :: cl_node
  20 |           DOM_INT, allocatable, dimension(:)   :: cl_elem
  21 |           DOM_INT, allocatable, dimension(:)   :: cl_face 
  22 |         END TYPE patch
  23 | 
  24 |         DOM_INT, PARAMETER                     :: NDP_MAX = 10
  25 | 
  26 |         DOM_INT                                :: NUMNP,NELEM,NGRPS
  27 |         DOM_INT                                :: NBSETS,NDFCD
  28 |         DOM_INT                                :: NDFVL
  29 |         DOM_INT                                :: i,j,tmp, patchtype, n
  30 | 
  31 |         DOM_INT, allocatable, dimension(:,:)   :: facepatch
  32 |         DOM_INT, allocatable, dimension(:)     :: ND,NE,NTYPE,NDP
  33 |         DOM_INT, allocatable, dimension(:,:)   :: NODE
  34 | 
  35 |         DOM_REAL,allocatable, dimension(:,:)   :: X
  36 | 
  37 |         DOM_STR80                              :: gambit_meshfile
  38 |         DOM_STR80                              :: SECTION,END_SECTION
  39 | 
  40 |         TYPE(patch), allocatable,dimension(:)  :: list_patch
  41 |                
  42 |         CONTAINS
  43 | 
  44 | !       ================================================================
  45 | 
  46 |         SUBROUTINE readmsh
  47 |        
  48 |           IMPLICIT NONE
  49 | 
  50 |           include 'dom_constants.h'
  51 | 
  52 |           OPEN(FILE_MSH,FILE=gambit_meshfile, FORM='FORMATTED')
  53 | 
  54 | !         ----------------------!
  55 | !         Read Global mesh data !
  56 | !         ----------------------!
  57 | 
  58 |           WRITE(*,*)
  59 |           WRITE(*,*) 'Reading GAMBIT neutral file'
  60 | 
  61 |           READ(FILE_MSH,*)
  62 |           READ(FILE_MSH,*)
  63 |           READ(FILE_MSH,*)
  64 |           READ(FILE_MSH,*) SECTION
  65 |           READ(FILE_MSH,*)
  66 |           READ(FILE_MSH,*)
  67 |           READ(FILE_MSH,'(6(1X,I9))') NUMNP, NELEM, NGRPS,              &
  68 |      &                                NBSETS, NDFCD, NDFVL
  69 |           READ(FILE_MSH,*) END_SECTION
  70 | 
  71 | !         -----------------!
  72 | !         Allocate vectors !
  73 | !         -----------------!
  74 | 
  75 |           IF(ALLOCATED(ND))         DEALLOCATE(ND)
  76 |           IF(ALLOCATED(X))          DEALLOCATE(X)
  77 |           IF(ALLOCATED(NE))         DEALLOCATE(NE)
  78 |           IF(ALLOCATED(NTYPE))      DEALLOCATE(NTYPE)
  79 |           IF(ALLOCATED(NDP))        DEALLOCATE(NDP)
  80 |           IF(ALLOCATED(NODE))       DEALLOCATE(NODE)
  81 |           IF(ALLOCATED(list_patch)) DEALLOCATE(list_patch)
  82 |        
  83 |           ALLOCATE(ND         (NUMNP)) 
  84 |           ALLOCATE(X          (NDFCD,NUMNP))
  85 |           ALLOCATE(NE         (NELEM))
  86 |           ALLOCATE(NTYPE      (NELEM))
  87 |           ALLOCATE(NDP        (NELEM))
  88 |           ALLOCATE(NODE       (NDP_MAX,NELEM))
  89 |           ALLOCATE(list_patch (NBSETS))
  90 |           ALLOCATE(facepatch  (NDP_MAX,NELEM))
  91 | 
  92 | !         ----------------------!
  93 | !         Read nodal coordinate !
  94 | !         ----------------------!
  95 | 
  96 |           DO WHILE(SECTION.ne.'NODAL COORDINATES')
  97 |             READ(FILE_MSH,'(3X,A17)') SECTION
  98 |           ENDDO
  99 | 
 100 |           WRITE(*,*) ' >>>> Reading section ', SECTION
 101 | 
 102 |           DO i=1,NUMNP
 103 |             READ(FILE_MSH,'(I10,3E20.11)') ND(i),(X(j,i),j=1,NDFCD)   
 104 | !           print*, ND(i),(X(j,i),j=1,NDFCD) 
 105 |           ENDDO
 106 |        
 107 |           READ(FILE_MSH,'(A12)') END_SECTION
 108 | 
 109 |           IF (END_SECTION.eq.'ENDOFSECTION') THEN
 110 | !           WRITE(*,*)  END_SECTION
 111 |           ELSE
 112 |             WRITE(*,*) 'Error in :', SECTION
 113 |             STOP
 114 |           ENDIF
 115 |        
 116 | !         -----------------------------------!
 117 | !         Read the element/Cell connectivity !
 118 | !         -----------------------------------!
 119 | 
 120 |           DO WHILE(SECTION.ne.'ELEMENTS/CELLS')
 121 |             READ(FILE_MSH,'(6X,A14)') SECTION
 122 |           ENDDO
 123 | 
 124 |           WRITE(*,*) ' >>>> Reading section ', SECTION
 125 | 
 126 |           DO i=1,NELEM
 127 |             READ(FILE_MSH,'(I8,1X,I2,1X,I2,1X,7I8:/(15X,7I8:))')        &
 128 |      &                      NE(i),NTYPE(i),NDP(i),(NODE(j,i),j=1,NDP(i))
 129 | !           WRITE(*,*) NE(i),NTYPE(i),NDP(i),(NODE(j,i),j=1,NDP(i))
 130 |           ENDDO
 131 | 
 132 |           READ(FILE_MSH,'(A12)') END_SECTION
 133 |           IF (END_SECTION.eq.'ENDOFSECTION') THEN
 134 | !           WRITE(*,*) END_SECTION
 135 |           ELSE
 136 |             WRITE(*,*) 'Error in :',SECTION
 137 |             STOP
 138 |           ENDIF
 139 | 
 140 | !         -----------------------!
 141 | !         Read the element group !
 142 | !         -----------------------!
 143 | 
 144 |           WRITE(*,*) ' >>>> Unused section ELEMENT GROUP'
 145 |           DO WHILE(SECTION.ne.'ENDOFSECTION')
 146 |             READ(FILE_MSH,'(A12)') SECTION
 147 |           ENDDO
 148 | 
 149 | !         -----------------------------!
 150 | !         Read the boundary conditions !
 151 | !         -----------------------------!
 152 | 
 153 |           facepatch=0
 154 | 
 155 |           DO i=1,NBSETS
 156 | 
 157 |             READ(FILE_MSH,'(1X,A19)') SECTION
 158 |             IF(i.eq.1) THEN
 159 |               WRITE(*,*) ' >>>> Reading section ', SECTION
 160 |             ENDIF
 161 | 
 162 |             READ(FILE_MSH,'(A32,8I10)') list_patch(i)%patch_name,       &
 163 |      &              list_patch(i)%itype,list_patch(i)%nentry
 164 | !           print*, list_patch(i)%patch_name,list_patch(i)%itype,       &
 165 | !    &              list_patch(i)%nentry
 166 | 
 167 |             WRITE(*,*) '>> Patch:',i,'/',NBSETS,list_patch(i)%patch_name
 168 | 
 169 |             ALLOCATE(list_patch(i)%cl_node(list_patch(i)%nentry)) 
 170 |             ALLOCATE(list_patch(i)%cl_elem(list_patch(i)%nentry))
 171 |             ALLOCATE(list_patch(i)%cl_face(list_patch(i)%nentry))
 172 | 
 173 |             DO j=1,list_patch(i)%nentry
 174 | 
 175 |               patchtype = list_patch(i)%itype
 176 | 
 177 |               IF (patchtype.eq.0) THEN
 178 |                 READ(FILE_MSH,'(I10,4E20.12)') list_patch(i)%cl_node(j) 
 179 | !               print*, list_patch(i)%cl_node(j)
 180 |                 WRITE(*,*)  'Bad TYPE of Boundary condition'
 181 |                 WRITE(*,*)  'Should be defined usind elments not nodes'
 182 |                 STOP
 183 |               ELSEIF (patchtype.eq.1) THEN
 184 |                 READ(FILE_MSH,'(I10,2I5, (4E20.12))')                   &
 185 |      &          list_patch(i)%cl_elem(j),tmp,list_patch(i)%cl_face(j)
 186 |                 facepatch(list_patch(i)%cl_face(j),                     &
 187 |      &          list_patch(i)%cl_elem(j))=i
 188 |               ENDIF
 189 | 
 190 |             ENDDO
 191 | 
 192 |             READ(FILE_MSH,'(A12)') END_SECTION
 193 |             IF (END_SECTION.eq.'ENDOFSECTION') THEN
 194 | !             print*, END_SECTION
 195 |             ELSE
 196 |               WRITE(*,*) 'Error in :',SECTION
 197 |               STOP
 198 |             ENDIF
 199 | 
 200 |          ENDDO  
 201 | 
 202 |          WRITE(*,*) 'GAMBIT neutral file successfully read'
 203 |          WRITE(*,*)
 204 | 
 205 |          CLOSE(FILE_MSH)
 206 |       
 207 |         END SUBROUTINE readmsh 
 208 | 
 209 | !       ================================================================
 210 | 
 211 |       END MODULE gambit_read


gambit_read.F could be called by:
creategeometry_gambit.F [TOOLS/VISU/SRC] - 14
gambit2dom.F [TOOLS/PREDATAS/INOUT] - 16
Makefile [TOOLS/PREDATAS] - 98
Makefile [TOOLS/VISU] - 66