pic_string_utils Module

General string utilities


Uses

  • module~~pic_string_utils~~UsesGraph module~pic_string_utils pic_string_utils module~pic_types pic_types module~pic_string_utils->module~pic_types iso_fortran_env iso_fortran_env module~pic_types->iso_fortran_env

Used by

  • module~~pic_string_utils~~UsedByGraph module~pic_string_utils pic_string_utils module~pic_debugging_tools pic_debugging_tools module~pic_debugging_tools->module~pic_string_utils module~pic_matrix_printer pic_matrix_printer module~pic_debugging_tools->module~pic_matrix_printer module~pic_flop_rate pic_flop_rate module~pic_flop_rate->module~pic_string_utils module~pic_timer pic_timer module~pic_flop_rate->module~pic_timer module~pic_matrix_printer->module~pic_string_utils module~pic_matrix_printer_v2 pic_matrix_printer_v2 module~pic_matrix_printer_v2->module~pic_string_utils module~pic_timer->module~pic_string_utils

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private, parameter :: default_dp_precision = 12
integer(kind=default_int), private :: dp_precision = default_dp_precision

Interfaces

public interface to_string

converts a variable of type (int32, int64, sp, dp, char, logical) to a “string” which is just a collecting of chars.

Usage result = to_string(variable)

Note

the functions here are not elemental so they won’t work for arrays. Please use pic_print_array_v2 module for this

  • private function to_string_int32(i) result(trimmed_str)

    transform an int32 to a string

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: i

    Return Value character(len=:), allocatable

  • private function to_string_int64(i) result(trimmed_str)

    transform an int64 to a string

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: i

    Return Value character(len=:), allocatable

  • private function to_string_sp(r) result(trimmed_str)

    transform a real(sp) to a string

    Arguments

    Type IntentOptional Attributes Name
    real(kind=sp), intent(in) :: r

    Return Value character(len=:), allocatable

  • private function to_string_dp(r) result(trimmed_str)

    transform a real(dp) to a string

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: r

    Return Value character(len=:), allocatable

  • private function to_string_char(c) result(trimmed_str)

    transform a character to a string

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: c

    Return Value character(len=:), allocatable

  • private function to_string_logical(l) result(trimmed_str)

    tranform a logical to a string either true or false

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(in) :: l

    Return Value character(len=:), allocatable

private interface get_precision

Obtain the current precision being used to print variables to strings

Usage: precision = get_precision()

returns a default_int result

  • private interface get_precision()

    Obtain the current precision being used to print variables to strings

    Usage: precision = get_precision()

    returns a default_int result

    Arguments

    None

private interface pad

adds a number X of spaces to the left of a “string” whcih is just a collection of characters. Mostly used for nice printing

Usage: var = pad(“hello”, n_spaces)

  • private interface pad()

    adds a number X of spaces to the left of a “string” whcih is just a collection of characters. Mostly used for nice printing

    Usage: var = pad(“hello”, n_spaces)

    Arguments

    None

private interface set_precision

This routine overrides the default dp precision used for printing strings in the to_string function, the default is : integer(default_int), parameter :: default_dp_precision = 12

Usage: call set_precision(variable) where variable is default_int

  • private interface set_precision()

    This routine overrides the default dp precision used for printing strings in the to_string function, the default is : integer(default_int), parameter :: default_dp_precision = 12

    Usage: call set_precision(variable) where variable is default_int

    Arguments

    None

private interface to_upper

takes a character variable and transforms it to uppercase

usage var = to_upper(“hello”)

  • private interface to_upper()

    takes a character variable and transforms it to uppercase

    usage var = to_upper(“hello”)

    Arguments

    None

Functions

public function get_precision() result(precision)

Get the current precision for real numbers

Arguments

None

Return Value integer(kind=default_int)

public function pad(s, width) result(padded)

function to pad a string with a certain number of characters for nice printing

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: s
integer(kind=default_int), intent(in) :: width

Return Value character(len=:), allocatable

public function to_upper(str) result(upper_str)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

Return Value character(len=len)

private function to_string_char(c) result(trimmed_str)

transform a character to a string

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: c

Return Value character(len=:), allocatable

private function to_string_dp(r) result(trimmed_str)

transform a real(dp) to a string

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: r

Return Value character(len=:), allocatable

private function to_string_int32(i) result(trimmed_str)

transform an int32 to a string

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: i

Return Value character(len=:), allocatable

private function to_string_int64(i) result(trimmed_str)

transform an int64 to a string

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: i

Return Value character(len=:), allocatable

private function to_string_logical(l) result(trimmed_str)

tranform a logical to a string either true or false

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: l

Return Value character(len=:), allocatable

private function to_string_sp(r) result(trimmed_str)

transform a real(sp) to a string

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: r

Return Value character(len=:), allocatable


Subroutines

public subroutine set_precision(precision)

Set the precision for real numbers

Arguments

Type IntentOptional Attributes Name
integer(kind=default_int), intent(in) :: precision