str_I1P Function

private elemental function str_I1P(n, no_sign) result(str)

Convert integer to string.

 use penf
 print "(A)", str(n=-1_I1P)
 use penf
 print "(A)", str(n=-1_I1P, no_sign=.true.)

Arguments

TypeIntentOptionalAttributesName
integer(kind=I1P), intent(in) :: n

Integer to be converted.

logical, intent(in), optional :: no_sign

Flag for leaving out the sign.

Return Value character

Returned string containing input number plus padding zeros.


Called by

proc~~str_i1p~~CalledByGraph proc~str_i1p str_I1P proc~str_a_i1p str_a_I1P proc~str_a_i1p->proc~str_i1p interface~str str interface~str->proc~str_i1p interface~str->proc~str_a_i1p proc~printf printf proc~printf->interface~str proc~bctoi_i8p bctoi_I8P proc~bctoi_i8p->interface~str proc~printf~4 printf proc~printf~4->interface~str proc~printf~2 printf proc~printf~2->interface~str proc~bctoi_i2p bctoi_I2P proc~bctoi_i2p->interface~str program~volatile_doctest~33 volatile_doctest program~volatile_doctest~33->interface~str program~volatile_doctest~229 volatile_doctest program~volatile_doctest~229->interface~str program~volatile_doctest~369 volatile_doctest program~volatile_doctest~369->interface~str program~volatile_doctest~645 volatile_doctest program~volatile_doctest~645->interface~str proc~bctoi_i1p bctoi_I1P proc~bctoi_i1p->interface~str proc~printf~3 printf proc~printf~3->interface~str proc~bctoi_i4p bctoi_I4P proc~bctoi_i4p->interface~str program~volatile_doctest~30 volatile_doctest program~volatile_doctest~30->interface~str program~volatile_doctest~412 volatile_doctest program~volatile_doctest~412->interface~str program~volatile_doctest~512 volatile_doctest program~volatile_doctest~512->interface~str program~volatile_doctest~744 volatile_doctest program~volatile_doctest~744->interface~str interface~bcton bcton interface~bcton->proc~bctoi_i8p interface~bcton->proc~bctoi_i2p interface~bcton->proc~bctoi_i1p interface~bcton->proc~bctoi_i4p

Contents

Source Code


Source Code

   elemental function str_I1P(n, no_sign) result(str)
   !< Convert integer to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1_I1P)
   !<```
   !=> -1 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1_I1P, no_sign=.true.)
   !<```
   !=> 1 <<<
   integer(I1P), intent(in)           :: n       !< Integer to be converted.
   logical,      intent(in), optional :: no_sign !< Flag for leaving out the sign.
   character(DI1P)                    :: str     !< Returned string containing input number plus padding zeros.

   write(str, FI1P) n                ! Casting of n to string.
   str = adjustl(trim(str))          ! Removing white spaces.
   if (n>=0_I1P) str='+'//trim(str)  ! Prefixing plus if n>0.
   if (present(no_sign)) str=str(2:) ! Leaving out the sign.
   endfunction str_I1P