NAFPack_io_utils.f90 Source File


This file depends on

sourcefile~~nafpack_io_utils.f90~~EfferentGraph sourcefile~nafpack_io_utils.f90 NAFPack_io_utils.f90 sourcefile~nafpack_kinds.f90 NAFPack_kinds.f90 sourcefile~nafpack_io_utils.f90->sourcefile~nafpack_kinds.f90

Files dependent on this one

sourcefile~~nafpack_io_utils.f90~~AfferentGraph sourcefile~nafpack_io_utils.f90 NAFPack_io_utils.f90 sourcefile~nafpack_ansi.f90 NAFPack_ANSI.f90 sourcefile~nafpack_ansi.f90->sourcefile~nafpack_io_utils.f90 sourcefile~nafpack_ansi_ascii.f90 NAFPack_ANSI_ASCII.f90 sourcefile~nafpack_ansi_ascii.f90->sourcefile~nafpack_ansi.f90 sourcefile~nafpack_ansi_ucs4.f90 NAFPack_ANSI_ucs4.f90 sourcefile~nafpack_ansi_ucs4.f90->sourcefile~nafpack_ansi.f90 sourcefile~nafpack_logger_mod.f90 NAFPack_Logger_mod.f90 sourcefile~nafpack_logger_mod.f90->sourcefile~nafpack_ansi.f90 sourcefile~nafpack_terminal.f90 NAFPack_terminal.f90 sourcefile~nafpack_logger_mod.f90->sourcefile~nafpack_terminal.f90 sourcefile~nafpack_terminal.f90->sourcefile~nafpack_ansi.f90 sourcefile~nafpack_iterative_methods.f90 NAFPack_Iterative_methods.f90 sourcefile~nafpack_iterative_methods.f90->sourcefile~nafpack_logger_mod.f90 sourcefile~nafpack_linalg.f90 NAFPack_linalg.f90 sourcefile~nafpack_linalg.f90->sourcefile~nafpack_iterative_methods.f90

Source Code

module NAFPack_io_utils

    use NAFPack_kinds, only: ascii, ucs4, &
                             sp, dp, qp, &
                             i8, i16, isp, idp

    implicit none(type, external)

    private

    public :: to_str_ascii, to_str_ucs4

    interface to_str_ascii
        module procedure int8_to_str_ascii
        module procedure int16_to_str_ascii
    end interface to_str_ascii

    interface to_str_ucs4
        module procedure int8_to_str_ucs4
        module procedure int16_to_str_ucs4
    end interface to_str_ucs4

contains

    pure function int8_to_str_ascii(value) result(str)
        integer(i8), intent(in) :: value
        character(len=:, kind=ascii), allocatable :: str
        character(len=64, kind=ascii) :: buffer
        integer :: nlen

        write (buffer, '(I0)') value

        nlen = len_trim(buffer)

        allocate (character(len=nlen, kind=ascii) :: str)

        str = buffer(1:nlen)
    end function int8_to_str_ascii

    pure function int16_to_str_ascii(value) result(str)
        integer(i16), intent(in) :: value
        character(len=:, kind=ascii), allocatable :: str
        character(len=64, kind=ascii) :: buffer
        integer :: nlen

        write (buffer, '(I0)') value

        nlen = len_trim(buffer)

        allocate (character(len=nlen, kind=ascii) :: str)

        str = buffer(1:nlen)
    end function int16_to_str_ascii

    pure function int8_to_str_ucs4(value) result(str)
        integer(i8), intent(in) :: value
        character(len=:, kind=ucs4), allocatable :: str
        character(len=64, kind=ucs4) :: buffer
        integer :: nlen

        write (buffer, '(I0)') value

        nlen = len_trim(buffer)

        allocate (character(len=nlen, kind=ucs4) :: str)

        str = buffer(1:nlen)
    end function int8_to_str_ucs4

    pure function int16_to_str_ucs4(value) result(str)
        integer(i16), intent(in) :: value
        character(len=:, kind=ucs4), allocatable :: str
        character(len=64, kind=ucs4) :: buffer
        integer :: nlen

        write (buffer, '(I0)') value

        nlen = len_trim(buffer)

        allocate (character(len=nlen, kind=ucs4) :: str)

        str = buffer(1:nlen)
    end function int16_to_str_ucs4

end module NAFPack_io_utils