read_periodic_optional Subroutine

private subroutine read_periodic_optional(filename, m)

Reads periodic link data from periodic.dat if it exists.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
type(mesh_t), intent(inout) :: m

Calls

proc~~read_periodic_optional~~CallsGraph proc~read_periodic_optional mod_mesh_io::read_periodic_optional proc~fatal_error mod_kinds::fatal_error proc~read_periodic_optional->proc~fatal_error

Called by

proc~~read_periodic_optional~~CalledByGraph proc~read_periodic_optional mod_mesh_io::read_periodic_optional proc~read_native_mesh mod_mesh_io::read_native_mesh proc~read_native_mesh->proc~read_periodic_optional program~lowmach_react_hex lowmach_react_hex program~lowmach_react_hex->proc~read_native_mesh

Source Code

   subroutine read_periodic_optional(filename, m)
      character(len=*), intent(in) :: filename
      type(mesh_t), intent(inout) :: m

      integer :: unit_id, ios, nlinks, i
      integer :: face_id, pair_face_id, neighbor_cell

      open(newunit=unit_id, file=trim(filename), status='old', action='read', iostat=ios)
      if (ios /= 0) return

      read(unit_id, *, iostat=ios) nlinks
      if (ios /= 0 .or. nlinks < 0) call fatal_error('mesh_io', 'invalid periodic header')

      do i = 1, nlinks
         read(unit_id, *, iostat=ios) face_id, pair_face_id, neighbor_cell
         if (ios /= 0) call fatal_error('mesh_io', 'failed reading periodic link')
         if (face_id < 1 .or. face_id > m%nfaces) call fatal_error('mesh_io', 'periodic face id out of range')
         if (pair_face_id < 1 .or. pair_face_id > m%nfaces) call fatal_error('mesh_io', 'periodic pair face id out of range')
         if (neighbor_cell < 1 .or. neighbor_cell > m%ncells) call fatal_error('mesh_io', 'periodic neighbor cell out of range')
         m%faces(face_id)%periodic_face = pair_face_id
         m%faces(face_id)%periodic_neighbor = neighbor_cell
      end do

      close(unit_id)
   end subroutine read_periodic_optional