read_char_record Subroutine

private subroutine read_char_record(unit, text, swapped, err)

Read a character scalar record into a deferred length string.

Characters are single bytes so swapped never changes the payload, but it is still needed to decode the record header itself.

Arguments

Type IntentOptional Attributes Name
integer(kind=default_int), intent(in) :: unit
character(len=:), intent(out), allocatable :: text
logical, intent(in) :: swapped
type(error_t), intent(inout) :: err

Calls

proc~~read_char_record~~CallsGraph proc~read_char_record read_char_record proc~check_io check_io proc~read_char_record->proc~check_io proc~error_get_code error_t%error_get_code proc~read_char_record->proc~error_get_code proc~error_wrap error_t%error_wrap proc~read_char_record->proc~error_wrap proc~read_record_header read_record_header proc~read_char_record->proc~read_record_header interface~to_char to_char proc~check_io->interface~to_char proc~error_set error_t%error_set proc~check_io->proc~error_set proc~clip_tail clip_tail proc~error_wrap->proc~clip_tail proc~error_has_error error_t%error_has_error proc~error_wrap->proc~error_has_error proc~read_record_header->proc~check_io proc~read_record_header->interface~to_char proc~bswap_int32 bswap_int32 proc~read_record_header->proc~bswap_int32 proc~bswap_int64 bswap_int64 proc~read_record_header->proc~bswap_int64 proc~element_bytes element_bytes proc~read_record_header->proc~element_bytes proc~read_record_header->proc~error_set proc~to_char_char to_char_char interface~to_char->proc~to_char_char proc~to_char_dp to_char_dp interface~to_char->proc~to_char_dp proc~to_char_int32 to_char_int32 interface~to_char->proc~to_char_int32 proc~to_char_int64 to_char_int64 interface~to_char->proc~to_char_int64 proc~to_char_logical to_char_logical interface~to_char->proc~to_char_logical proc~to_char_matrix_dp to_char_matrix_dp interface~to_char->proc~to_char_matrix_dp proc~to_char_matrix_int32 to_char_matrix_int32 interface~to_char->proc~to_char_matrix_int32 proc~to_char_matrix_int64 to_char_matrix_int64 interface~to_char->proc~to_char_matrix_int64 proc~to_char_matrix_sp to_char_matrix_sp interface~to_char->proc~to_char_matrix_sp proc~to_char_sp to_char_sp interface~to_char->proc~to_char_sp proc~to_char_vector_dp to_char_vector_dp interface~to_char->proc~to_char_vector_dp proc~to_char_vector_int32 to_char_vector_int32 interface~to_char->proc~to_char_vector_int32 proc~to_char_vector_int64 to_char_vector_int64 interface~to_char->proc~to_char_vector_int64 proc~to_char_vector_sp to_char_vector_sp interface~to_char->proc~to_char_vector_sp

Called by

proc~~read_char_record~~CalledByGraph proc~read_char_record read_char_record interface~read_array read_array interface~read_array->proc~read_char_record proc~soa_read_int32_field soa_read_int32_field proc~soa_read_int32_field->interface~read_array proc~soa_read_int64_field soa_read_int64_field proc~soa_read_int64_field->interface~read_array proc~soa_read_logical_field soa_read_logical_field proc~soa_read_logical_field->interface~read_array proc~soa_read_prologue soa_read_prologue proc~soa_read_prologue->interface~read_array proc~soa_read_real_dp_field soa_read_real_dp_field proc~soa_read_real_dp_field->interface~read_array proc~soa_read_real_sp_field soa_read_real_sp_field proc~soa_read_real_sp_field->interface~read_array interface~soa_read_field soa_read_field interface~soa_read_field->proc~soa_read_int32_field interface~soa_read_field->proc~soa_read_int64_field interface~soa_read_field->proc~soa_read_logical_field interface~soa_read_field->proc~soa_read_real_dp_field interface~soa_read_field->proc~soa_read_real_sp_field proc~particle_soa_deserialize particle_soa_t%particle_soa_deserialize proc~particle_soa_deserialize->proc~soa_read_prologue proc~particle_soa_deserialize->interface~soa_read_field

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: code
integer(kind=int64), private :: count
integer(kind=default_int), private :: ios
logical, private :: ok

Source Code

   subroutine read_char_record(unit, text, swapped, err)
      !! Read a character scalar record into a deferred length string.
      !!
      !! Characters are single bytes so `swapped` never changes the payload,
      !! but it is still needed to decode the record header itself.
      integer(default_int), intent(in) :: unit
      character(len=:), allocatable, intent(out) :: text
      logical, intent(in) :: swapped
      type(error_t), intent(inout) :: err

      integer(default_int) :: ios, code
      logical :: ok
      integer(int64) :: count

      call read_record_header(unit, PIC_TAG_CHAR, swapped, count, ok, err)
      if (.not. ok) then
         code = err%get_code()
         call err%wrap(code, "failed to read character record")
         text = ""
         return
      end if

      allocate (character(len=count) :: text)
      if (count > 0_int64) then
         read (unit, iostat=ios) text
         call check_io(ios, "short read on character payload", err)
      end if
   end subroutine read_char_record