read_formatted Subroutine

private 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!

Bug

Read listdirected with and without delimiters does not work.

Type Bound

string

Arguments

Type IntentOptional Attributes Name
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.


Calls

proc~~read_formatted~~CallsGraph proc~read_formatted string%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~read_delimited string%read_delimited proc~read_formatted->proc~read_delimited proc~read_undelimited_listdirected string%read_undelimited_listdirected proc~read_formatted->proc~read_undelimited_listdirected 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 proc~get_decimal_mode get_decimal_mode proc~read_undelimited_listdirected->proc~get_decimal_mode proc~read_undelimited string%read_undelimited proc~read_undelimited_listdirected->proc~read_undelimited

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!
   !<
   !< @bug Read listdirected with and without delimiters does not work.
   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
   endsubroutine read_formatted