read_formatted Subroutine

private subroutine read_formatted(dtv, unit, iotype, v_list, iostat, iomsg)

Arguments

Type IntentOptional AttributesName
class(string), intent(inout) :: dtv

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in) :: iotype

Edit descriptor.

integer, intent(in) :: v_list(:)

Edit descriptor list.

integer, intent(out) :: iostat

IO status code.

character(len=*), intent(inout) :: iomsg

IO status message.

Description

Formatted input.

Calls

proc~~read_formatted~~CallsGraph proc~read_formatted read_formatted proc~get_next_non_blank_character_any_record get_next_non_blank_character_any_record proc~read_formatted->proc~get_next_non_blank_character_any_record proc~get_next_non_blank_character_this_record get_next_non_blank_character_this_record proc~get_next_non_blank_character_any_record->proc~get_next_non_blank_character_this_record
Help

Variables

TypeVisibility AttributesNameInitial
character(len=len(iomsg)), public :: local_iomsg

Local variant of iomsg, so it doesn't get inappropriately redefined.

character(kind=CK,len=1), public :: delim

String delimiter, if any.

character(kind=CK,len=100), public :: temporary

Temporary storage string.


Source Code

  subroutine read_formatted(dtv, unit, iotype, v_list, iostat, iomsg)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Formatted input.
  !<
  !< @bug Change temporary acks: find a more precise length of the input string and avoid the trimming!
  !---------------------------------------------------------------------------------------------------------------------------------
  class(string),             intent(inout) :: dtv         !< The string.
  integer,                   intent(in)    :: unit        !< Logical unit.
  character(len=*),          intent(in)    :: iotype      !< Edit descriptor.
  integer,                   intent(in)    :: v_list(:)   !< Edit descriptor list.
  integer,                   intent(out)   :: iostat      !< IO status code.
  character(len=*),          intent(inout) :: iomsg       !< IO status message.
  character(len=len(iomsg))                :: local_iomsg !< Local variant of iomsg, so it doesn't get inappropriately redefined.
  character(kind=CK, len=1)                :: delim       !< String delimiter, if any.
  character(kind=CK, len=100)              :: temporary   !< Temporary storage string.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  if (iotype == 'LISTDIRECTED') then
    call get_next_non_blank_character_any_record(unit=unit, ch=delim, iostat=iostat, iomsg=iomsg)
    if (iostat/=0) return
    if (delim=='"'.OR.delim=="'") then
      call dtv%read_delimited(unit=unit, delim=delim, iostat=iostat, iomsg=local_iomsg)
    else
      ! step back before the non-blank
      read(unit, "(TL1)", iostat=iostat, iomsg=iomsg)
      if (iostat /= 0) return
      call dtv%read_undelimited_listdirected(unit=unit, iostat=iostat, iomsg=local_iomsg)
    endif
    if (is_iostat_eor(iostat)) then
      ! suppress IOSTAT_EOR
      iostat = 0
    elseif (iostat /= 0) then
      iomsg = local_iomsg
    endif
    return
  else
    read(unit, "(A)", iostat=iostat, iomsg=iomsg)temporary
    dtv%raw = trim(temporary)
  endif
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine read_formatted