str_a_I1P Function

private pure function str_a_I1P(n, no_sign, separator, delimiters) result(str)

Arguments

TypeIntentOptionalAttributesName
integer(kind=I1P), intent(in) :: n(:)
logical, intent(in), optional :: no_sign
character(len=1), intent(in), optional :: separator
character, intent(in), optional :: delimiters(1:2)

Return Value character(len=:),allocatable


Calls

proc~~str_a_i1p~2~~CallsGraph proc~str_a_i1p~2 str_a_I1P proc~str_i1p~2 str_I1P proc~str_a_i1p~2->proc~str_i1p~2

Called by

proc~~str_a_i1p~2~~CalledByGraph proc~str_a_i1p~2 str_a_I1P interface~str~2 str interface~str~2->proc~str_a_i1p~2 proc~bctoi_i8p~2 bctoi_I8P proc~bctoi_i8p~2->interface~str~2 proc~bctoi_i2p~2 bctoi_I2P proc~bctoi_i2p~2->interface~str~2 proc~bctoi_i1p~2 bctoi_I1P proc~bctoi_i1p~2->interface~str~2 proc~bctoi_i4p~2 bctoi_I4P proc~bctoi_i4p~2->interface~str~2 interface~bcton~2 bcton interface~bcton~2->proc~bctoi_i8p~2 interface~bcton~2->proc~bctoi_i2p~2 interface~bcton~2->proc~bctoi_i1p~2 interface~bcton~2->proc~bctoi_i4p~2

Contents

Source Code


Source Code

   pure function str_a_I1P(n, no_sign, separator, delimiters) result(str)
   !< Convert integer array to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1_I1P, -2_I1P])
   !<```
   !=> +1,-2 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1_I1P, 2_I1P], no_sign=.true.)
   !<```
   !=> 1,2 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1_I1P, -2_I1P], separator='|')
   !<```
   !=> +1|-2 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1_I1P, -2_I1P], delimiters=['(', ')'])
   !<```
   !=> (+1,-2) <<<
   integer(I1P), intent(in)           :: n(:)            !< Integer array to be converted.
   logical,      intent(in), optional :: no_sign         !< Flag for leaving out the sign.
   character(1), intent(in), optional :: separator       !< Eventual separator of array values.
   character(*), intent(in), optional :: delimiters(1:2) !< Eventual delimiters of array values.
   character(len=:), allocatable      :: str             !< Returned string containing input number.
   character(DI1P)                    :: strn            !< String containing of element of input array number.
   character(len=1)                   :: sep             !< Array values separator
   integer                            :: i               !< Counter.

   str = ''
   sep = ','
   if(present(separator)) sep = separator
   if (present(no_sign)) then
     do i=1,size(n)
       strn = str_I1P(no_sign=no_sign, n=n(i))
       str = str//sep//trim(strn)
     enddo
   else
     do i=1,size(n)
       strn = str_I1P(n=n(i))
       str = str//sep//trim(strn)
     enddo
   endif
   str = trim(str(2:))
   if (present(delimiters)) str = delimiters(1)//str//delimiters(2)
   endfunction str_a_I1P