get_delimiter_mode Subroutine

private subroutine get_delimiter_mode(unit, delim, iostat, iomsg)

Uses

  • proc~~get_delimiter_mode~2~~UsesGraph proc~get_delimiter_mode~2 get_delimiter_mode iso_fortran_env iso_fortran_env proc~get_delimiter_mode~2->iso_fortran_env

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: unit
character(kind=CK,len=1), intent(out) :: delim
integer, intent(out) :: iostat
character, intent(inout) :: iomsg

Contents

Source Code


Source Code

   subroutine get_delimiter_mode(unit, delim, iostat, iomsg)
   !< Get the DELIM changeable connection mode for the given unit.
   !<
   !< If the unit is connected to an internal file, then the default value of NONE is always returned.
   use, intrinsic :: iso_fortran_env, only : iostat_inquire_internal_unit
   integer,                   intent(in)    :: unit         !< The unit for the connection.
   character(len=1, kind=CK), intent(out)   :: delim        !< Represents the value of the DELIM mode.
   integer,                   intent(out)   :: iostat       !< IOSTAT error code, non-zero on error.
   character(*),              intent(inout) :: iomsg        !< IOMSG explanatory message - only defined if iostat is non-zero.
   character(10)                            :: delim_buffer !< Buffer for INQUIRE about DELIM, sized for APOSTROHPE.
   character(len(iomsg))                    :: local_iomsg  !< Local variant of iomsg, so it doesn't get inappropriately redefined.

   ! get the string representation of the changeable mode
   inquire(unit, delim=delim_buffer, iostat=iostat, iomsg=local_iomsg)
   if (iostat == iostat_inquire_internal_unit) then
      ! no way of determining the DELIM mode for an internal file
      iostat = 0
      delim = ''
      return
   elseif (iostat /= 0) then
      iomsg = local_iomsg
      return
   endif
   ! interpret the DELIM string
   if (delim_buffer == 'QUOTE') then
      delim = '"'
   elseif (delim_buffer == 'APOSTROPHE') then
      delim = ''''
   else
      delim = '"'
   endif
   endsubroutine get_delimiter_mode