Skip to content

Derived type IO #312

@awvwgk

Description

@awvwgk

With types like the bitset_type it might be a really useful feature to use them in normal IO (read and write data transfer). The bitset_type for example implements a write_bitset interface, but could as well define the very same function as derived type IO:

An interface to a formatted write usually looks like

subroutine write_formatted(self, unit, iotype, v_list, iostat, iomsg) !> Instance of the object to write. class(*), intent(inout) :: self !> Formatted unit for output. integer, intent(in) :: unit !> Type of formatted data transfer, has the value "LISTDIRECTED" for fmt=*, "NAMELIST" for namelist output or starts with "DT" for derived type output. character(len=*), intent(in) :: iotype !> Rank one array of default integer type containing the edit descriptors for derived type output. integer, intent(in) :: v_list(:) !> Status identifier to indicate success of output operation. integer, intent(out) :: iostat !> Buffer to return error message in case of failing output operation. character(len=*), intent(inout) :: iomsg end subroutine write_formatted

While an interface to an unformatted write is given here for short reference

subroutine write_unformatted(self, unit, iostat, iomsg) !> Instance of the object to write. class(*), intent(inout) :: self !> Formatted unit for output. integer, intent(in) :: unit !> Status identifier to indicate success of output operation. integer, intent(out) :: iostat !> Buffer to return error message in case of failing output operation. character(len=*), intent(inout) :: iomsg end subroutine write_unformatted

This would allow to easily write a bitset with

use stdlib_bitset, only : bitset_type type(bitset_type) :: bitset ! ... print*, bitset end

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIDiscussion on a specific API for a proposal (exploratory)implementationImplementation in experimental and submission of a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions