writeinfiles_test.F [SRC] [CPP] [JOB] [SCAN]
TOOLS / PREDATAS / INOUT



   1 | include(dom.inc)
   2 |       SUBROUTINE writeinfiles(path, ndirs, s, T, P, global_kabs)
   3 | 
   4 | !       ===============================================================!
   5 | !                                                                      !
   6 | !       writeinfiles.F : Writes out the data base of the geometry.     !
   7 | !                        Format: V2.04                                 !
   8 | !                                                                      !
   9 | !       in             : The complete Data Base                        !
  10 | !                                                                      !
  11 | !       author         : J. AMAYA (june 2007)                          !
  12 | !                                                                      !
  13 | !       ===============================================================!
  14 | 
  15 |         USE datas
  16 | 
  17 |         IMPLICIT NONE
  18 | 
  19 |         INCLUDE 'dom_constants.h'
  20 | 
  21 | !       IN
  22 |         CHARACTER*80     :: path
  23 |         DOM_INT          :: ndirs
  24 |         DOM_REAL :: s(4, ndirs)
  25 |         DOM_REAL :: T, P, global_kabs
  26 | 
  27 | !       OUT
  28 | 
  29 | !       LOCAL
  30 |         DOM_INT, allocatable, dimension(:)           :: fatnodelist
  31 |         DOM_INT, allocatable, dimension(:)           :: neighbour
  32 |         DOM_INT, allocatable, dimension(:)           :: pathway
  33 |         DOM_INT, allocatable, dimension(:)           :: added
  34 |         DOM_INT, allocatable, dimension(:)           :: knownf
  35 |         DOM_INT, allocatable, dimension(:)           :: ninfaces
  36 |         DOM_INT, allocatable, dimension(:)           :: bcfaces
  37 |         DOM_INT, allocatable, dimension(:)           :: cellnodes
  38 |         DOM_INT, allocatable, dimension(:)           :: cellfaces
  39 |         DOM_INT                :: i, j, i_fatnodes, parent2,parent
  40 |         DOM_INT                :: nb_faces, thiscell_id, nbdyfaces
  41 |         DOM_INT                :: ndim, nbnodes, thisnode_nb
  42 |         DOM_INT                :: thisface_id, k, neparent
  43 |         DOM_INT                :: cellcount, myneigh
  44 |         DOM_REAL       :: xc, yc, zc
  45 |         DOM_REAL       :: kabs_gray, k_scat, Dns
  46 |         DOM_REAL       :: nmin
  47 |         DOM_REAL, allocatable, dimension(:)  :: n1, n2, n3
  48 |         DOM_REAL, allocatable, dimension(:)  :: xfc, yfc, zfc
  49 |         DOM_REAL, allocatable, dimension(:)  :: area
  50 |         character*80           :: c2cfile, ccellsfile, cfacesfile
  51 |         character*80           :: normfile, volafile, gdatafile
  52 |         character*80           :: emisfile, kscafile, externfile 
  53 |         character*80           :: quadfile, clfacefile
  54 |         character*80           :: progfile, nodesfile, clnodefile
  55 |         character*80           :: c2facfile, facfile
  56 |         type(cell),    pointer :: pt_cell, auxcell_ptr
  57 |         type(face),    pointer :: pt_face
  58 |         type(fatnode), pointer :: pt_fatnode
  59 | 
  60 | !       --------------------------------------!
  61 | !       Set file names and open them to write !
  62 | !       --------------------------------------!
  63 | 
  64 |         nodesfile  = path(1:len_trim(path))//'/Nodelist.in'
  65 |         c2cfile    = path(1:len_trim(path))//'/Cell2cells.in'
  66 |         c2facfile  = path(1:len_trim(path))//'/Cell2faces.in'
  67 |         facfile    = path(1:len_trim(path))//'/Facelist.in'
  68 |         ccellsfile = path(1:len_trim(path))//'/Centercells.in'
  69 |         cfacesfile = path(1:len_trim(path))//'/Centerfaces.in'
  70 |         clnodefile = path(1:len_trim(path))//'/Cellnodes.in'
  71 |         normfile   = path(1:len_trim(path))//'/Normals.in'
  72 |         volafile   = path(1:len_trim(path))//'/Volumesareas.in'
  73 |         emisfile   = path(1:len_trim(path))//'/Emissivities.in'
  74 |         kscafile   = path(1:len_trim(path))//'/K_Scattering.in'
  75 |         externfile = path(1:len_trim(path))//'/Externaldata.in'
  76 | !       clpropfile = path(1:len_trim(path))//'/CLProperties.in'
  77 |         clfacefile = path(1:len_trim(path))//'/CLFaces.in'
  78 |         quadfile   = path(1:len_trim(path))//'/Quadrature.in'
  79 |         progfile   = path(1:len_trim(path))//'/Progress.in'
  80 |         gdatafile  = path(1:len_trim(path))//'/Global.in'
  81 | 
  82 |         OPEN(FILE_NODES, FILE=nodesfile , FORM='UNFORMATTED')
  83 |         OPEN(FILE_C2C  , FILE=c2cfile   , FORM='UNFORMATTED')
  84 |         OPEN(FILE_C2FAC, FILE=c2facfile , FORM='UNFORMATTED')
  85 |         OPEN(FILE_FAC  , FILE=facfile   , FORM='UNFORMATTED')
  86 |         OPEN(FILE_CCELL, FILE=ccellsfile, FORM='UNFORMATTED')
  87 |         OPEN(FILE_CFACE, FILE=cfacesfile, FORM='UNFORMATTED')
  88 |         OPEN(FILE_CLNOD, FILE=clnodefile, FORM='UNFORMATTED')
  89 |         OPEN(FILE_NORM , FILE=normfile  , FORM='UNFORMATTED')
  90 |         OPEN(FILE_VOLA , FILE=volafile  , FORM='UNFORMATTED')
  91 |         OPEN(FILE_EMIS , FILE=emisfile  , FORM='UNFORMATTED')
  92 |         OPEN(FILE_KSCA , FILE=kscafile  , FORM='UNFORMATTED')
  93 |         OPEN(FILE_EXTRN, FILE=externfile, FORM='UNFORMATTED')
  94 | !       OPEN(FILE_CLPRO, FILE=clpropfile, FORM='UNFORMATTED')
  95 |         OPEN(FILE_CLFAC, FILE=clfacefile, FORM='UNFORMATTED')
  96 |         OPEN(FILE_QUADR, FILE=quadfile  , FORM='UNFORMATTED')
  97 |         OPEN(FILE_PROG , FILE=progfile  , FORM='UNFORMATTED')
  98 |         OPEN(FILE_GDATA, FILE=gdatafile , FORM='UNFORMATTED')
  99 | 
 100 |         OPEN(UNIT=69,FILE=path(1:len_trim(path))//'Test.txt',           &
 101 |      &       FORM='FORMATTED')
 102 | 
 103 |         nbdyfaces = 0
 104 | 
 105 | !       ---------------------------!
 106 | !       Write 'Quadrature.in' file !
 107 | !       ---------------------------!
 108 | 
 109 |         WRITE(*,*) " Writing Quadrature.in"
 110 |         WRITE(69,*) " Writing Quadrature.in"
 111 |         DO i=1, ndirs
 112 |           WRITE(FILE_QUADR) (s(j,i),j=1,4)
 113 |           WRITE(69,*) (s(j,i),j=1,4)
 114 |         ENDDO
 115 | 
 116 |         CLOSE(FILE_QUADR)
 117 | 
 118 | !       -------------------------!
 119 | !       Write 'Progress.in' file !
 120 | !       -------------------------!
 121 | 
 122 |         WRITE(*,*) " Writing Progress.in"
 123 |         WRITE(69,*) " Writing Progress.in"
 124 | 
 125 |         IF (ALLOCATED(pathway))  DEALLOCATE(pathway)
 126 |         IF (ALLOCATED(added))    DEALLOCATE(added)
 127 |         IF (ALLOCATED(ninfaces)) DEALLOCATE(ninfaces)
 128 |         IF (ALLOCATED(bcfaces))  DEALLOCATE(bcfaces)
 129 |         IF (ALLOCATED(knownf))   DEALLOCATE(knownf)
 130 | 
 131 |         ALLOCATE( pathway(i_ncells))
 132 |         ALLOCATE(   added(i_ncells))
 133 |         ALLOCATE(  knownf(i_ncells))
 134 |         ALLOCATE(ninfaces(i_ncells))
 135 |         ALLOCATE( bcfaces(i_ncells))
 136 | 
 137 |         pathway = 0
 138 |         nmin = 1d-13
 139 | 
 140 | !       ------------------------------!
 141 | !       Do one register per direction !
 142 | !       ------------------------------!
 143 |         DO i=1, ndirs
 144 | 
 145 |           added     = 0
 146 |           cellcount = 0
 147 |           knownf    = 0
 148 |           ninfaces  = 0
 149 |           bcfaces   = 0
 150 | 
 151 |           WRITE(*,'(1x,A,1x,f6.4,1x,f6.4,1x,f6.4)') " dir: ", s(1:3,i)
 152 |           WRITE(69,'(1x,A,1x,f6.4,1x,f6.4,1x,f6.4)') " dir: ", s(1:3,i)
 153 | 
 154 | !         -------------------------------------------------------!
 155 | !         Detect 'in' and 'in'+boundary faces for this direction !
 156 | !         -------------------------------------------------------!
 157 |           pt_cell => cell_list
 158 |           DO WHILE (ASSOCIATED(pt_cell))
 159 | 
 160 |             j = pt_cell%cell_id
 161 |             DO k=1, pt_cell%i_nbfaces
 162 | 
 163 |               pt_face => pt_cell%cell_face(k)%face_ptr
 164 |               parent = 1
 165 |               IF (pt_face%parent_cell(1).ne.j) parent = 2
 166 | 
 167 | !             ---------------------------------------!
 168 | !             If face is in, normal*direction is < 0 !
 169 | !             ---------------------------------------!
 170 |               Dns = pt_face%face_normal(1,parent)*s(1,i) +              &
 171 |      &              pt_face%face_normal(2,parent)*s(2,i) +              &
 172 |      &              pt_face%face_normal(3,parent)*s(3,i)
 173 |               IF (Dns.lt.nmin) THEN
 174 |                 ninfaces(j) = ninfaces(j) + 1
 175 |                 IF (pt_face%emissivity.ne.-1.) THEN
 176 |                   bcfaces(j) = bcfaces(j) + 1
 177 |                 ENDIF
 178 |               ENDIF
 179 |               IF (ABS(Dns).lt.nmin) THEN
 180 |                 WRITE(*,*) " Warning: the point product of face normal"
 181 |                 WRITE(*,*) "          times the direction has found to"
 182 |                 WRITE(*,*) "          be very small. Your mesh and "
 183 |                 WRITE(*,*) "          quadrature method are not well"
 184 |                 WRITE(*,*) "          suited. Try changing one."
 185 |                 STOP
 186 |               ENDIF
 187 | 
 188 |             ENDDO
 189 | 
 190 |             pt_cell => pt_cell%next_cell
 191 |           ENDDO
 192 | 
 193 | !         ---------------------------------------!
 194 | !         Fill pathway vector in multiple cycles !
 195 | !         ---------------------------------------!
 196 |           DO WHILE(cellcount.lt.i_ncells)
 197 | 
 198 |             pt_cell => cell_list
 199 | !            print*, " Begin again: ", cellcount
 200 | !            READ(*,*)
 201 | 
 202 |             DO WHILE(ASSOCIATED(pt_cell))
 203 | 
 204 |               j = pt_cell%cell_id
 205 | !              print*, " Cell ",j,":",knownf(j),bcfaces(j),ninfaces(j)
 206 | 
 207 |               IF ( (added(j).eq.0).and.                                 &
 208 |      &             (knownf(j)+bcfaces(j).eq.ninfaces(j)) ) THEN
 209 | 
 210 |                 added(j)           = 1
 211 |                 cellcount          = cellcount + 1
 212 |                 pathway(cellcount) = j
 213 | 
 214 | !               -------------------------------------------------!
 215 | !               Tell neighbour cells that my out faces are known !
 216 | !               -------------------------------------------------!
 217 |                 DO k=1, pt_cell%i_nbfaces
 218 | 
 219 |                   pt_face => pt_cell%cell_face(k)%face_ptr
 220 |                   parent = 1
 221 |                   IF (pt_face%parent_cell(1).ne.j) parent = 2
 222 | 
 223 | !                 ---------------------------------------!
 224 | !                 If face is 'out', normal*direction > 0 !
 225 | !                 ---------------------------------------!
 226 |                   Dns = pt_face%face_normal(1,parent)*s(1,i) +          &
 227 |      &                  pt_face%face_normal(2,parent)*s(2,i) +          &
 228 |      &                  pt_face%face_normal(3,parent)*s(3,i)
 229 | 
 230 |                   IF ((Dns.gt.nmin).and.(pt_face%emissivity.eq.-1.))  &
 231 |      &            THEN
 232 |                     IF (pt_face%parent_cell(1).eq.j) THEN
 233 |                       myneigh = pt_face%parent2_ptr%cell_id
 234 |                     ELSE
 235 |                       myneigh = pt_face%parent1_ptr%cell_id
 236 |                     ENDIF
 237 |                     knownf(myneigh) = knownf(myneigh) + 1
 238 |                   ENDIF
 239 | 
 240 |                 ENDDO
 241 | 
 242 |               ENDIF
 243 | 
 244 |               pt_cell => pt_cell%next_cell
 245 | 
 246 |             ENDDO
 247 | 
 248 |           ENDDO
 249 | 
 250 |           WRITE(FILE_PROG) (pathway(j),j=1,i_ncells)
 251 |           WRITE(69,*) (pathway(j),j=1,i_ncells)
 252 | 
 253 |         ENDDO
 254 | 
 255 |         DEALLOCATE(pathway)
 256 |         DEALLOCATE(added)
 257 | 
 258 |         CLOSE(FILE_PROG)
 259 | 
 260 | !       -------------------------!
 261 | !       Write 'Facelist.in' file !
 262 | !       -------------------------!
 263 | 
 264 |         WRITE(69,*) "Facelist.in"
 265 |         pt_face => face_list
 266 |         DO i=1, i_nfaces
 267 | 
 268 |           IF (pt_face%i_nbparents.eq.2) THEN
 269 |             IF (pt_face%parent2_ptr%cell_id.eq.0) THEN
 270 |               WRITE(*,*) " Fatal error: face ", pt_face%face_id,        &
 271 |      &                   " has lost one parent"
 272 |             ENDIF
 273 |           ENDIF
 274 | 
 275 |           WRITE(FILE_FAC) pt_face%face_id, pt_face%i_nbnodes,           &
 276 |      &                    (pt_face%face_point(j,1),                     &
 277 |      &                    j=1,pt_face%i_nbnodes)
 278 |           WRITE(69,*) pt_face%face_id, pt_face%i_nbnodes,               &
 279 |      &                    (pt_face%face_point(j,1),                     &
 280 |      &                    j=1,pt_face%i_nbnodes)
 281 |           pt_face => pt_face%next_face
 282 |         ENDDO
 283 | 
 284 | !       -------------------------!
 285 | !       Write 'Nodelist.in' file !
 286 | !       -------------------------!
 287 | 
 288 |         WRITE(69,*) "Nodelist.in"
 289 |         DO i=1, i_nnodes
 290 |           WRITE(FILE_NODES) i, (node_list(j,i),j=1,3)
 291 |           WRITE(69,*) i, (node_list(j,i),j=1,3)
 292 |         ENDDO
 293 | 
 294 | !       -------------------------------------------!
 295 | !       Save global mesh and initial solution data !
 296 | !       -------------------------------------------!
 297 | 
 298 |         WRITE(69,*) "Global.in"
 299 |         WRITE(FILE_GDATA) i_ncells, i_nnodes, i_nfaces, i_nfacesmax
 300 |         WRITE(FILE_GDATA) T, P, global_kabs
 301 | 
 302 | !       --------------------!
 303 | !       Loop over all cells !
 304 | !       --------------------!
 305 | 
 306 |         IF (ALLOCATED(neighbour)) DEALLOCATE(neighbour)
 307 | 
 308 |         ALLOCATE(neighbour(1:2*i_nfacesmax))
 309 | 
 310 |         WRITE(*,*) " Looping over all the cells", i_ncells
 311 |         WRITE(69,*) " Looping over all the cells", i_ncells
 312 | 
 313 |         pt_cell => cell_list
 314 | 
 315 |         DO i=1, i_ncells
 316 | 
 317 |           thiscell_id = pt_cell%cell_id
 318 |           nb_faces    = pt_cell%i_nbfaces
 319 |           neighbour   = 0
 320 | !          print*, "C: ", thiscell_id, nb_faces
 321 | 
 322 | !         -------------------------!
 323 | !         Detect cell's properties !
 324 | !         -------------------------!
 325 | 
 326 |           SELECTCASE(pt_cell%celltype)
 327 |             CASE(EL_TRI)
 328 |               ndim = 2
 329 |               nbnodes = 3
 330 |             CASE(EL_QUAD)
 331 |               ndim = 2
 332 |               nbnodes = 4
 333 |             CASE(EL_TETRA)
 334 |               ndim = 3
 335 |               nbnodes = 4
 336 |             CASE(EL_HEXA)
 337 |               ndim = 3
 338 |               nbnodes = 8
 339 |             CASE DEFAULT
 340 |               WRITE(*,*) "Error: element type not recognised ",         &
 341 |      &                    pt_cell%celltype
 342 |               STOP
 343 |           ENDSELECT          
 344 | 
 345 | !         --------------------------------------------------------!
 346 | !         Detect the neighbour cells (0 if no neigh. at the face) !
 347 | !         --------------------------------------------------------!
 348 | 
 349 |           DO j=1, nb_faces
 350 | 
 351 |             pt_face => pt_cell%cell_face(j)%face_ptr
 352 |             thisface_id = pt_face%face_id
 353 | 
 354 |             IF (pt_face%i_nbparents.eq.2) THEN
 355 |               IF (pt_face%parent2_ptr%cell_id.eq.0) THEN
 356 |                 WRITE(*,*) " Face id: ", thisface_id
 357 |                 WRITE(*,*) " Fatal error: face  ",pt_face%face_id,      &
 358 |      &                     " has lost one parent"
 359 |               ENDIF
 360 |             ENDIF
 361 | 
 362 | 
 363 | !           -----------------------------------!
 364 | !           Detect the adjacent cell to face j !
 365 | !           -----------------------------------!
 366 |             IF (pt_face%i_nbparents.eq.2) THEN
 367 | 
 368 |               neparent = 1
 369 |               auxcell_ptr => pt_face%parent1_ptr
 370 | 
 371 |               IF (pt_face%parent_cell(1).eq.thiscell_id) THEN
 372 |                 neparent = 2
 373 |                 auxcell_ptr => pt_face%parent2_ptr
 374 |               ENDIF
 375 | 
 376 | !              print*, "      nparent=",pt_face%i_nbparents
 377 | 
 378 |                IF (auxcell_ptr%cell_id.eq.0) THEN
 379 |                  print*, "   F: ",thisface_id,"neparent: ", neparent
 380 |                  print*, "      neighid=",auxcell_ptr%cell_id
 381 |                  print*, "      parents:", pt_face%i_nbparents
 382 |                  print*, "      parent1:", pt_face%parent1_ptr%cell_id
 383 |                  print*, "      parent2:", pt_face%parent2_ptr%cell_id
 384 |                  WRITE(*,*) " Fatal error, face ",pt_face%face_id,      &
 385 |      &                      " points to no parent cell"
 386 |                  STOP
 387 |                ENDIF
 388 | 
 389 | !             ------------------------------------------------!
 390 | !             Set the face rank in the neighbour cell's array !
 391 | !             ------------------------------------------------!
 392 |               neighbour(2*j-1) = pt_face%parent_cell(neparent)
 393 |               DO k=1, nb_faces
 394 | !                print*, "      k=", k
 395 | !                print*, "      neighid=",auxcell_ptr%cell_id
 396 | !                print*, "id:",auxcell_ptr%cell_face(k)%face_ptr%face_id
 397 |                 IF (auxcell_ptr%cell_face(k)%face_ptr%                  &
 398 |      &                  face_id.eq.thisface_id) EXIT
 399 |               ENDDO
 400 |               neighbour(2*j) = k
 401 |             ELSE
 402 | !              print*, "         boundary face!"
 403 |               nbdyfaces = nbdyfaces + 1
 404 |               neighbour(2*j-1) = 0
 405 |               neighbour  (2*j) = 0
 406 |             ENDIF
 407 | 
 408 |           ENDDO
 409 | 
 410 | !         ---------------------------!
 411 | !         Write 'Cell2cells.in' file !
 412 | !         ---------------------------!
 413 | 
 414 | !          print*, "      Cell2cells.in"
 415 |           WRITE(FILE_C2C) thiscell_id,                                  &
 416 |      &                    nb_faces,                                     &
 417 |      &                    neighbour(1:2*nb_faces)
 418 |           WRITE(69,*) "Cell2cells.in:",thiscell_id,                     &
 419 |      &                    nb_faces,                                     &
 420 |      &                    neighbour(1:2*nb_faces)
 421 | 
 422 | !         --------------------------------------------------!
 423 | !         Fill cellnodes vector and calculate cell's center !
 424 | !         --------------------------------------------------!
 425 | 
 426 |           IF (ALLOCATED(cellnodes)) DEALLOCATE(cellnodes)
 427 |           ALLOCATE(cellnodes(nbnodes))
 428 | 
 429 |           xc = 0
 430 |           yc = 0
 431 |           zc = 0
 432 | 
 433 |           DO j=1, nbnodes
 434 |             thisnode_nb = pt_cell%cellnodes(j)
 435 |             cellnodes(j) = thisnode_nb
 436 |             xc = xc + node_list(1, thisnode_nb)
 437 |             yc = yc + node_list(2, thisnode_nb)
 438 |             zc = zc + node_list(3, thisnode_nb)
 439 |           ENDDO
 440 | 
 441 |           xc = xc / nbnodes
 442 |           yc = yc / nbnodes
 443 |           zc = zc / nbnodes
 444 | 
 445 | !         ------------------------------------------------!
 446 | !         Write 'Centercells.in' and 'Cellnodes.in' files !
 447 | !         ------------------------------------------------!
 448 | 
 449 |           WRITE(FILE_CCELL) thiscell_id, xc, yc, zc
 450 |           WRITE(69,*) "Centercells.in:",thiscell_id, xc, yc, zc
 451 |           WRITE(FILE_CLNOD) thiscell_id, nbnodes,                       &
 452 |      &                     (cellnodes(j),j=1,nbnodes)
 453 |           WRITE(69,*) "Cellnodes.in",thiscell_id, nbnodes,              &
 454 |      &                     (cellnodes(j),j=1,nbnodes)
 455 | 
 456 | !         --------------------!
 457 | !         Compute faces' data !
 458 | !         --------------------!
 459 | 
 460 |           IF (ALLOCATED(cellfaces))   DEALLOCATE(cellfaces)
 461 |           IF (ALLOCATED(xfc))         DEALLOCATE(xfc)
 462 |           IF (ALLOCATED(yfc))         DEALLOCATE(yfc)
 463 |           IF (ALLOCATED(zfc))         DEALLOCATE(zfc)
 464 |           IF (ALLOCATED(n1))          DEALLOCATE(n1)
 465 |           IF (ALLOCATED(n2))          DEALLOCATE(n2)
 466 |           IF (ALLOCATED(n3))          DEALLOCATE(n3)
 467 |           IF (ALLOCATED(area))        DEALLOCATE(area)
 468 | 
 469 |           ALLOCATE(cellfaces(nb_faces))
 470 |           ALLOCATE(xfc      (nb_faces))
 471 |           ALLOCATE(yfc      (nb_faces))
 472 |           ALLOCATE(zfc      (nb_faces))
 473 |           ALLOCATE(n1       (nb_faces))
 474 |           ALLOCATE(n2       (nb_faces))
 475 |           ALLOCATE(n3       (nb_faces))
 476 |           ALLOCATE(area     (nb_faces))
 477 | 
 478 |           DO j=1, nb_faces 
 479 | 
 480 | !           ----------------!
 481 | !           Get face center !
 482 | !           ----------------!
 483 |             pt_face => pt_cell%cell_face(j)%face_ptr
 484 |             xfc(j) = pt_face%x
 485 |             yfc(j) = pt_face%y
 486 |             zfc(j) = pt_face%z
 487 | 
 488 | !           ------------------------------------------!
 489 | !           Get face normal, area and B.C. properties !
 490 | !           ------------------------------------------!
 491 |             parent = 1
 492 |             IF (pt_face%parent_cell(1).ne.thiscell_id) parent = 2
 493 |             n1(j) = pt_face%face_normal(1,parent)
 494 |             n2(j) = pt_face%face_normal(2,parent)
 495 |             n3(j) = pt_face%face_normal(3,parent)
 496 | 
 497 |             area     (j) = pt_face%area
 498 |             cellfaces(j) = pt_face%face_id
 499 | 
 500 |           ENDDO
 501 | 
 502 | !         ------------------------------------------------!
 503 | !         Write 'Centerfaces.in' and 'Cell2faces.in' file !
 504 | !         ------------------------------------------------!
 505 | 
 506 |           WRITE(FILE_CFACE) thiscell_id, nb_faces,                      &
 507 |      &                      (xfc(j), yfc(j), zfc(j),                    &
 508 |      &                      j=1, nb_faces)
 509 |           WRITE(69,*) "Centerfaces.in:",thiscell_id, nb_faces,          &
 510 |      &                      (xfc(j), yfc(j), zfc(j),                    &
 511 |      &                      j=1, nb_faces)
 512 | 
 513 |           WRITE(FILE_C2FAC) thiscell_id, nb_faces,                      &
 514 |      &                      (cellfaces(j),j=1, nb_faces)
 515 |           WRITE(69,*) "Cell2faces.in:",thiscell_id, nb_faces,           &
 516 |      &                      (cellfaces(j),j=1, nb_faces)
 517 | 
 518 | !         -------------------!
 519 | !         Write 'Normals.in' !
 520 | !         -------------------!
 521 | 
 522 |           WRITE(FILE_NORM) thiscell_id, nb_faces,                       &
 523 |      &                     (n1(j), n2(j), n3(j),                        &
 524 |      &                     j=1, nb_faces)
 525 |           WRITE(69,*) "Normals.in:",thiscell_id, nb_faces,              &
 526 |      &                     (n1(j), n2(j), n3(j),                        &
 527 |      &                     j=1, nb_faces)
 528 | 
 529 | !         ------------------------!
 530 | !         Write 'Volumesareas.in' !
 531 | !         ------------------------!
 532 | 
 533 |           WRITE(FILE_VOLA) thiscell_id,nb_faces,pt_cell%volume,         &
 534 |      &                     (area(j),j=1, nb_faces)
 535 |           WRITE(69,*) "Volumesareas.in:",thiscell_id,nb_faces,          &
 536 |      &                pt_cell%volume,(area(j),j=1, nb_faces)
 537 | 
 538 | !-- CL in initbc
 539 | !         ------------------------!
 540 | !         Write 'Emissivities.in' !
 541 | !         ------------------------!
 542 | !
 543 | !          WRITE(FILE_EMIS) thiscell_id, nb_faces,                      &
 544 | !    &                      (epsil(j),j=1, nb_faces)
 545 | !           print*, thiscell_id, nb_faces, (epsil(j),j=1, nb_faces)
 546 | !
 547 | !         ------------------------!
 548 | !         Write 'CLProperties.in' !
 549 | !         ------------------------!
 550 | !         WRITE(FILE_CLPRO) thiscell_id, nb_faces,                      &
 551 | !    &                      (Tw(j),j=1, nb_faces)
 552 | !--
 553 | 
 554 | !         ------------------------!
 555 | !         Write 'K_Scattering.in' !
 556 | !         ------------------------!
 557 | !--- A coder le calcul de k_scat different de zero
 558 |            k_scat = 0.
 559 |            WRITE(FILE_KSCA) thiscell_id, k_scat
 560 | 
 561 | !         ------------------------!
 562 | !         Write 'Externaldata.in' !
 563 | !         ------------------------!
 564 |           kabs_gray = global_kabs
 565 |           WRITE(FILE_EXTRN) thiscell_id, kabs_gray
 566 | 
 567 | !         ----------------!
 568 | !         Go to next cell !
 569 | !         ----------------!
 570 | 
 571 |           pt_cell => pt_cell%next_cell
 572 | 
 573 |         ENDDO
 574 | 
 575 | !       -------------------!
 576 | !       Write 'CLFaces.in' !
 577 | !       -------------------!
 578 | 
 579 |         WRITE(FILE_CLFAC) nbdyfaces
 580 | 
 581 | !       ----------------!
 582 | !       Close all files !
 583 | !       ----------------!
 584 | 
 585 |         print*, " Closing files"
 586 | 
 587 |         CLOSE(FILE_NODES)
 588 |         CLOSE(FILE_C2C  )
 589 |         CLOSE(FILE_C2FAC)
 590 |         CLOSE(FILE_FAC  )
 591 |         CLOSE(FILE_CCELL)
 592 |         CLOSE(FILE_CFACE)
 593 |         CLOSE(FILE_CLNOD)
 594 |         CLOSE(FILE_NORM )
 595 |         CLOSE(FILE_VOLA )
 596 |         CLOSE(FILE_EMIS )
 597 |         CLOSE(FILE_KSCA )
 598 |         CLOSE(FILE_EXTRN)
 599 | !       CLOSE(FILE_CLPRO)
 600 |         CLOSE(FILE_CLFAC)
 601 |         CLOSE(FILE_GDATA)
 602 | 
 603 |         CLOSE(69)
 604 | 
 605 |       END SUBROUTINE writeinfiles