General string utilities
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 |
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
transform an int32 to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | i |
transform an int64 to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | i |
transform a real(sp) to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | r |
transform a real(dp) to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | r |
transform a character to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | c |
tranform a logical to a string either true or false
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in) | :: | l |
Obtain the current precision being used to print variables to strings
Usage: precision = get_precision()
returns a default_int result
Obtain the current precision being used to print variables to strings
Usage: precision = get_precision()
returns a default_int result
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)
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)
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
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
Get the current precision for real numbers
function to pad a string with a certain number of characters for nice printing
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s | |||
integer(kind=default_int), | intent(in) | :: | width |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str |
transform a character to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | c |
transform a real(dp) to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | r |
transform an int32 to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | i |
transform an int64 to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | i |
tranform a logical to a string either true or false
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in) | :: | l |
transform a real(sp) to a string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | r |
Set the precision for real numbers
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=default_int), | intent(in) | :: | precision |